Reorganized source code and directory tree.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1375 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
BIN
src/.DS_Store
vendored
Normal file
BIN
src/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
src/English.lproj/InfoPlist.strings
Normal file
BIN
src/English.lproj/InfoPlist.strings
Normal file
Binary file not shown.
754
src/Grafx2.xcodeproj/project.pbxproj
Normal file
754
src/Grafx2.xcodeproj/project.pbxproj
Normal file
@@ -0,0 +1,754 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 42;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
002F39FA09D0881F10EBEB88 /* SDL_image.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F39F909D0881F10EBEB88 /* SDL_image.framework */; };
|
||||
002F3A2E09D0888800EBEB88 /* SDLMain.m in Sources */ = {isa = PBXBuildFile; fileRef = 002F3A2C09D0888800EBEB88 /* SDLMain.m */; };
|
||||
002F3A3F09D088BA00EBEB88 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 002F3A3E09D088BA00EBEB88 /* main.c */; };
|
||||
40D82CA110ECAF13005D27B5 /* miscfileformats.c in Sources */ = {isa = PBXBuildFile; fileRef = 40D82CA010ECAF13005D27B5 /* miscfileformats.c */; };
|
||||
40D82CA610ECAF58005D27B5 /* brush_ops.c in Sources */ = {isa = PBXBuildFile; fileRef = 40D82CA510ECAF58005D27B5 /* brush_ops.c */; };
|
||||
40D82CAA10ECAFC5005D27B5 /* buttons_effects.c in Sources */ = {isa = PBXBuildFile; fileRef = 40D82CA910ECAFC5005D27B5 /* buttons_effects.c */; };
|
||||
40D82CAE10ECAFDC005D27B5 /* layers.c in Sources */ = {isa = PBXBuildFile; fileRef = 40D82CAD10ECAFDC005D27B5 /* layers.c */; };
|
||||
40D82CB210ECB02B005D27B5 /* fileformats.c in Sources */ = {isa = PBXBuildFile; fileRef = 40D82CB110ECB02B005D27B5 /* fileformats.c */; };
|
||||
40D82CBF10ECB089005D27B5 /* libraw2crtc.c in Sources */ = {isa = PBXBuildFile; fileRef = 40D82CBE10ECB089005D27B5 /* libraw2crtc.c */; };
|
||||
40D82D3A10ECC4CA005D27B5 /* SDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F39F909D0881F00EBEB88 /* SDL.framework */; };
|
||||
40D82D4310ECC536005D27B5 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 40D82D4110ECC536005D27B5 /* Info.plist */; };
|
||||
40D82D4410ECC536005D27B5 /* SDLMain.nib in Resources */ = {isa = PBXBuildFile; fileRef = 40D82D4210ECC536005D27B5 /* SDLMain.nib */; };
|
||||
40D82D5010ECC609005D27B5 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 40D82D4E10ECC609005D27B5 /* Info.plist */; };
|
||||
40D82D5110ECC609005D27B5 /* SDLMain.nib in Resources */ = {isa = PBXBuildFile; fileRef = 40D82D4F10ECC609005D27B5 /* SDLMain.nib */; };
|
||||
40D82D5710ECC67A005D27B5 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 40D82D5510ECC67A005D27B5 /* Info.plist */; };
|
||||
40D82D5810ECC67A005D27B5 /* SDLMain.nib in Resources */ = {isa = PBXBuildFile; fileRef = 40D82D5610ECC67A005D27B5 /* SDLMain.nib */; };
|
||||
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
|
||||
F5142653101F6CC5006CF3C4 /* font_Classic.png in Copy skins */ = {isa = PBXBuildFile; fileRef = F514264D101F6CB8006CF3C4 /* font_Classic.png */; };
|
||||
F5142654101F6CC5006CF3C4 /* font_Fairlight.png in Copy skins */ = {isa = PBXBuildFile; fileRef = F514264E101F6CB8006CF3C4 /* font_Fairlight.png */; };
|
||||
F5142655101F6CC5006CF3C4 /* font_Fun.png in Copy skins */ = {isa = PBXBuildFile; fileRef = F514264F101F6CB9006CF3C4 /* font_Fun.png */; };
|
||||
F5142656101F6CC5006CF3C4 /* font_Melon.png in Copy skins */ = {isa = PBXBuildFile; fileRef = F5142650101F6CB9006CF3C4 /* font_Melon.png */; };
|
||||
F5142657101F6CC5006CF3C4 /* skin_classic.png in Copy skins */ = {isa = PBXBuildFile; fileRef = F5142651101F6CB9006CF3C4 /* skin_classic.png */; };
|
||||
F5142658101F6CC5006CF3C4 /* skin_modern.png in Copy skins */ = {isa = PBXBuildFile; fileRef = F5142652101F6CB9006CF3C4 /* skin_modern.png */; };
|
||||
F51CBD2E0EC8A3E1005C06AC /* 5pxtinyfont.png in Copy fonts */ = {isa = PBXBuildFile; fileRef = F51CBD2B0EC8A3E1005C06AC /* 5pxtinyfont.png */; };
|
||||
F51CBD2F0EC8A3E1005C06AC /* colorfont.pcx in Copy fonts */ = {isa = PBXBuildFile; fileRef = F51CBD2C0EC8A3E1005C06AC /* colorfont.pcx */; };
|
||||
F51CBD300EC8A3E1005C06AC /* Tuffy.ttf in Copy fonts */ = {isa = PBXBuildFile; fileRef = F51CBD2D0EC8A3E1005C06AC /* Tuffy.ttf */; };
|
||||
F539315E0FE171C3003CB103 /* pversion.c in Sources */ = {isa = PBXBuildFile; fileRef = F539315D0FE171C3003CB103 /* pversion.c */; };
|
||||
F5A33E6A0EC893F800F8052D /* 8pxfont.png in Copy fonts */ = {isa = PBXBuildFile; fileRef = F5A33E690EC893F800F8052D /* 8pxfont.png */; };
|
||||
F5AA405F0FBC406D00B7577C /* pxquad.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AA405A0FBC406D00B7577C /* pxquad.c */; };
|
||||
F5AA40600FBC406D00B7577C /* pxtall2.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AA405B0FBC406D00B7577C /* pxtall2.c */; };
|
||||
F5AA40610FBC406D00B7577C /* pxtriple.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AA405C0FBC406D00B7577C /* pxtriple.c */; };
|
||||
F5AA40620FBC406D00B7577C /* pxwide2.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AA405D0FBC406D00B7577C /* pxwide2.c */; };
|
||||
F5AA40630FBC406D00B7577C /* transform.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AA405E0FBC406D00B7577C /* transform.c */; };
|
||||
F5AC28BC0F4873C700455509 /* hotkeys.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AC28B90F4873C700455509 /* hotkeys.c */; };
|
||||
F5AC28BD0F4873C700455509 /* input.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AC28BA0F4873C700455509 /* input.c */; };
|
||||
F5AC28BE0F4873C700455509 /* realpath.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AC28BB0F4873C700455509 /* realpath.c */; };
|
||||
F5AD4B1F0EA8CCF0009CCAC4 /* version.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AD4B1E0EA8CCF0009CCAC4 /* version.c */; };
|
||||
F5AE6F990EDA119D000CE0EF /* GrafX2_Classic.gif in Copy fonts */ = {isa = PBXBuildFile; fileRef = F5AE6F980EDA119D000CE0EF /* GrafX2_Classic.gif */; };
|
||||
F5AE83FD0ECF8FD300200704 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5AE83FC0ECF8FD300200704 /* ApplicationServices.framework */; };
|
||||
F5AED03E0F1989E00090A93F /* mountlist.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AED03C0F1989E00090A93F /* mountlist.c */; };
|
||||
F5AFA00D0EFAC7D300663B43 /* brush.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AFA0070EFAC7D300663B43 /* brush.c */; };
|
||||
F5AFA00E0EFAC7D300663B43 /* pxsimple.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AFA0080EFAC7D300663B43 /* pxsimple.c */; };
|
||||
F5AFA00F0EFAC7D300663B43 /* pxtall.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AFA0090EFAC7D300663B43 /* pxtall.c */; };
|
||||
F5AFA0100EFAC7D300663B43 /* pxwide.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AFA00A0EFAC7D300663B43 /* pxwide.c */; };
|
||||
F5AFA0110EFAC7D300663B43 /* setup.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AFA00B0EFAC7D300663B43 /* setup.c */; };
|
||||
F5AFA0120EFAC7D300663B43 /* windows.c in Sources */ = {isa = PBXBuildFile; fileRef = F5AFA00C0EFAC7D300663B43 /* windows.c */; };
|
||||
F5B138C30EB71D28000B83CC /* SDL_ttf in Frameworks */ = {isa = PBXBuildFile; fileRef = F5B138C20EB71D28000B83CC /* SDL_ttf */; };
|
||||
F5B19B930EA4BE3E003F4BA4 /* graph.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B7B0EA4BE3E003F4BA4 /* graph.c */; };
|
||||
F5B19B940EA4BE3E003F4BA4 /* init.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B7C0EA4BE3E003F4BA4 /* init.c */; };
|
||||
F5B19B950EA4BE3E003F4BA4 /* io.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B7D0EA4BE3E003F4BA4 /* io.c */; };
|
||||
F5B19B970EA4BE3E003F4BA4 /* loadsave.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B7F0EA4BE3E003F4BA4 /* loadsave.c */; };
|
||||
F5B19B9A0EA4BE3E003F4BA4 /* op_c.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B820EA4BE3E003F4BA4 /* op_c.c */; };
|
||||
F5B19B9B0EA4BE3E003F4BA4 /* operatio.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B830EA4BE3E003F4BA4 /* operatio.c */; };
|
||||
F5B19B9C0EA4BE3E003F4BA4 /* pages.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B840EA4BE3E003F4BA4 /* pages.c */; };
|
||||
F5B19B9D0EA4BE3E003F4BA4 /* palette.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B850EA4BE3E003F4BA4 /* palette.c */; };
|
||||
F5B19B9E0EA4BE3E003F4BA4 /* readini.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B860EA4BE3E003F4BA4 /* readini.c */; };
|
||||
F5B19B9F0EA4BE3E003F4BA4 /* readline.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B870EA4BE3E003F4BA4 /* readline.c */; };
|
||||
F5B19BA00EA4BE3E003F4BA4 /* saveini.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B880EA4BE3E003F4BA4 /* saveini.c */; };
|
||||
F5B19BA10EA4BE3E003F4BA4 /* sdlscreen.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B890EA4BE3E003F4BA4 /* sdlscreen.c */; };
|
||||
F5B19BA20EA4BE3E003F4BA4 /* SFont.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B8A0EA4BE3E003F4BA4 /* SFont.c */; };
|
||||
F5B19BA30EA4BE3E003F4BA4 /* shade.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B8B0EA4BE3E003F4BA4 /* shade.c */; };
|
||||
F5B19BA40EA4BE3E003F4BA4 /* special.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B8C0EA4BE3E003F4BA4 /* special.c */; };
|
||||
F5B19C1D0EA4D71C003F4BA4 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5B19C1C0EA4D71C003F4BA4 /* CoreFoundation.framework */; };
|
||||
F5B19C3D0EA4DC91003F4BA4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F5B19C3B0EA4DC91003F4BA4 /* InfoPlist.strings */; };
|
||||
F5B1EE850EAD0F4E00B087B5 /* gfx2def.ini in Resources */ = {isa = PBXBuildFile; fileRef = F5B1EE840EAD0F4E00B087B5 /* gfx2def.ini */; };
|
||||
F5B310B40F949A9C008197E2 /* buttons.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B310AD0F949A9C008197E2 /* buttons.c */; };
|
||||
F5B310B50F949A9C008197E2 /* engine.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B310AE0F949A9C008197E2 /* engine.c */; };
|
||||
F5B310B60F949A9C008197E2 /* filesel.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B310AF0F949A9C008197E2 /* filesel.c */; };
|
||||
F5B310B70F949A9C008197E2 /* help.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B310B00F949A9C008197E2 /* help.c */; };
|
||||
F5B310B80F949A9C008197E2 /* keyboard.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B310B10F949A9C008197E2 /* keyboard.c */; };
|
||||
F5B310B90F949A9C008197E2 /* misc.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B310B20F949A9C008197E2 /* misc.c */; };
|
||||
F5B310BA0F949A9C008197E2 /* text.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B310B30F949A9C008197E2 /* text.c */; };
|
||||
F5CDCE320F6EA6D600B31F63 /* pxdouble.c in Sources */ = {isa = PBXBuildFile; fileRef = F5CDCE310F6EA6D600B31F63 /* pxdouble.c */; };
|
||||
F5DCE2BC0EA5116A0065B0EF /* SDL_ttf in Copy Frameworks into .app bundle */ = {isa = PBXBuildFile; fileRef = F5DCE2BE0EA5118F0065B0EF /* SDL_ttf */; };
|
||||
F5DCE2BC0EA5116B0065B0EF /* SDL_image in Copy Frameworks into .app bundle */ = {isa = PBXBuildFile; fileRef = F5DCE2BB0EA5116B0065B0EF /* SDL_image */; };
|
||||
F5DCE2BE0EA5118E0065B0EF /* SDL in Copy Frameworks into .app bundle */ = {isa = PBXBuildFile; fileRef = F5DCE2BD0EA5118E0065B0EF /* SDL */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
002F39FD09D0883400EBEB88 /* Copy Frameworks into .app bundle */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = SDL_image.framework/Versions/A;
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
F5DCE2BC0EA5116B0065B0EF /* SDL_image in Copy Frameworks into .app bundle */,
|
||||
);
|
||||
name = "Copy Frameworks into .app bundle";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
002F39FD09D0883400EBEB89 /* Copy Frameworks into .app bundle */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = SDL.framework/Versions/A;
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
F5DCE2BE0EA5118E0065B0EF /* SDL in Copy Frameworks into .app bundle */,
|
||||
);
|
||||
name = "Copy Frameworks into .app bundle";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
002F39FD09D0883400EBEB8A /* Copy Frameworks into .app bundle */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = SDL_ttf.framework/Versions/A;
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
F5DCE2BC0EA5116A0065B0EF /* SDL_ttf in Copy Frameworks into .app bundle */,
|
||||
);
|
||||
name = "Copy Frameworks into .app bundle";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
40D82D4C10ECC5A4005D27B5 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = Library/Frameworks/SDL.framework/Resources;
|
||||
dstSubfolderSpec = 7;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
40D82D5310ECC659005D27B5 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 7;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
F514264B101F6C5B006CF3C4 /* Copy skins */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = skins;
|
||||
dstSubfolderSpec = 7;
|
||||
files = (
|
||||
F5142653101F6CC5006CF3C4 /* font_Classic.png in Copy skins */,
|
||||
F5142654101F6CC5006CF3C4 /* font_Fairlight.png in Copy skins */,
|
||||
F5142655101F6CC5006CF3C4 /* font_Fun.png in Copy skins */,
|
||||
F5142656101F6CC5006CF3C4 /* font_Melon.png in Copy skins */,
|
||||
F5142657101F6CC5006CF3C4 /* skin_classic.png in Copy skins */,
|
||||
F5142658101F6CC5006CF3C4 /* skin_modern.png in Copy skins */,
|
||||
);
|
||||
name = "Copy skins";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
F5A33F1D0EC8A26C00F8052D /* Copy fonts */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = fonts;
|
||||
dstSubfolderSpec = 7;
|
||||
files = (
|
||||
F5AE6F990EDA119D000CE0EF /* GrafX2_Classic.gif in Copy fonts */,
|
||||
F51CBD300EC8A3E1005C06AC /* Tuffy.ttf in Copy fonts */,
|
||||
F51CBD2F0EC8A3E1005C06AC /* colorfont.pcx in Copy fonts */,
|
||||
F51CBD2E0EC8A3E1005C06AC /* 5pxtinyfont.png in Copy fonts */,
|
||||
F5A33E6A0EC893F800F8052D /* 8pxfont.png in Copy fonts */,
|
||||
);
|
||||
name = "Copy fonts";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
002F39F909D0881F00EBEB88 /* SDL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL.framework; path = /Library/Frameworks/SDL.framework; sourceTree = "<absolute>"; };
|
||||
002F39F909D0881F10EBEB88 /* SDL_image.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL_image.framework; path = /Library/Frameworks/SDL_image.framework; sourceTree = "<absolute>"; };
|
||||
002F3A2B09D0888800EBEB88 /* SDLMain.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SDLMain.h; sourceTree = SOURCE_ROOT; };
|
||||
002F3A2C09D0888800EBEB88 /* SDLMain.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SDLMain.m; sourceTree = SOURCE_ROOT; };
|
||||
002F3A3E09D088BA00EBEB88 /* main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = SOURCE_ROOT; };
|
||||
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
||||
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
|
||||
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
|
||||
32CA4F630368D1EE00C91783 /* Grafx2_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Grafx2_Prefix.pch; sourceTree = "<group>"; };
|
||||
40D82CA010ECAF13005D27B5 /* miscfileformats.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = miscfileformats.c; sourceTree = "<group>"; };
|
||||
40D82CA510ECAF58005D27B5 /* brush_ops.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = brush_ops.c; sourceTree = "<group>"; };
|
||||
40D82CA910ECAFC5005D27B5 /* buttons_effects.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = buttons_effects.c; sourceTree = "<group>"; };
|
||||
40D82CAD10ECAFDC005D27B5 /* layers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = layers.c; sourceTree = "<group>"; };
|
||||
40D82CB110ECB02B005D27B5 /* fileformats.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fileformats.c; sourceTree = "<group>"; };
|
||||
40D82CBE10ECB089005D27B5 /* libraw2crtc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = libraw2crtc.c; sourceTree = "<group>"; };
|
||||
40D82D4110ECC536005D27B5 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = /Library/Frameworks/SDL.framework/Resources/Info.plist; sourceTree = "<absolute>"; };
|
||||
40D82D4210ECC536005D27B5 /* SDLMain.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = SDLMain.nib; path = /Library/Frameworks/SDL.framework/Resources/SDLMain.nib; sourceTree = "<absolute>"; };
|
||||
40D82D4E10ECC609005D27B5 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = /Library/Frameworks/SDL.framework/Versions/A/Resources/Info.plist; sourceTree = "<absolute>"; };
|
||||
40D82D4F10ECC609005D27B5 /* SDLMain.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = SDLMain.nib; path = /Library/Frameworks/SDL.framework/Versions/A/Resources/SDLMain.nib; sourceTree = "<absolute>"; };
|
||||
40D82D5510ECC67A005D27B5 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = /Library/Frameworks/SDL.framework/Versions/A/Resources/Info.plist; sourceTree = "<absolute>"; };
|
||||
40D82D5610ECC67A005D27B5 /* SDLMain.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = SDLMain.nib; path = /Library/Frameworks/SDL.framework/Versions/A/Resources/SDLMain.nib; sourceTree = "<absolute>"; };
|
||||
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
|
||||
8D1107320486CEB800E47090 /* Grafx2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Grafx2.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
F514264D101F6CB8006CF3C4 /* font_Classic.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = font_Classic.png; path = skins/font_Classic.png; sourceTree = "<group>"; };
|
||||
F514264E101F6CB8006CF3C4 /* font_Fairlight.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = font_Fairlight.png; path = skins/font_Fairlight.png; sourceTree = "<group>"; };
|
||||
F514264F101F6CB9006CF3C4 /* font_Fun.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = font_Fun.png; path = skins/font_Fun.png; sourceTree = "<group>"; };
|
||||
F5142650101F6CB9006CF3C4 /* font_Melon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = font_Melon.png; path = skins/font_Melon.png; sourceTree = "<group>"; };
|
||||
F5142651101F6CB9006CF3C4 /* skin_classic.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = skin_classic.png; path = skins/skin_classic.png; sourceTree = "<group>"; };
|
||||
F5142652101F6CB9006CF3C4 /* skin_modern.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = skin_modern.png; path = skins/skin_modern.png; sourceTree = "<group>"; };
|
||||
F51CBD2B0EC8A3E1005C06AC /* 5pxtinyfont.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = 5pxtinyfont.png; path = fonts/5pxtinyfont.png; sourceTree = "<group>"; };
|
||||
F51CBD2C0EC8A3E1005C06AC /* colorfont.pcx */ = {isa = PBXFileReference; lastKnownFileType = file; name = colorfont.pcx; path = fonts/colorfont.pcx; sourceTree = "<group>"; };
|
||||
F51CBD2D0EC8A3E1005C06AC /* Tuffy.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = Tuffy.ttf; path = fonts/Tuffy.ttf; sourceTree = "<group>"; };
|
||||
F539315D0FE171C3003CB103 /* pversion.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = pversion.c; sourceTree = "<group>"; };
|
||||
F5A33E690EC893F800F8052D /* 8pxfont.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = 8pxfont.png; path = fonts/8pxfont.png; sourceTree = "<group>"; };
|
||||
F5AA405A0FBC406D00B7577C /* pxquad.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = pxquad.c; sourceTree = "<group>"; };
|
||||
F5AA405B0FBC406D00B7577C /* pxtall2.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = pxtall2.c; sourceTree = "<group>"; };
|
||||
F5AA405C0FBC406D00B7577C /* pxtriple.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = pxtriple.c; sourceTree = "<group>"; };
|
||||
F5AA405D0FBC406D00B7577C /* pxwide2.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = pxwide2.c; sourceTree = "<group>"; };
|
||||
F5AA405E0FBC406D00B7577C /* transform.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = transform.c; sourceTree = "<group>"; };
|
||||
F5AC28B90F4873C700455509 /* hotkeys.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = hotkeys.c; sourceTree = "<group>"; };
|
||||
F5AC28BA0F4873C700455509 /* input.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = input.c; sourceTree = "<group>"; };
|
||||
F5AC28BB0F4873C700455509 /* realpath.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = realpath.c; sourceTree = "<group>"; };
|
||||
F5AD4B1E0EA8CCF0009CCAC4 /* version.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = version.c; sourceTree = "<group>"; };
|
||||
F5AE6F980EDA119D000CE0EF /* GrafX2_Classic.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = GrafX2_Classic.gif; path = fonts/GrafX2_Classic.gif; sourceTree = "<group>"; };
|
||||
F5AE83FC0ECF8FD300200704 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
|
||||
F5AED03C0F1989E00090A93F /* mountlist.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = mountlist.c; sourceTree = "<group>"; };
|
||||
F5AFA0070EFAC7D300663B43 /* brush.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = brush.c; sourceTree = "<group>"; };
|
||||
F5AFA0080EFAC7D300663B43 /* pxsimple.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = pxsimple.c; sourceTree = "<group>"; };
|
||||
F5AFA0090EFAC7D300663B43 /* pxtall.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = pxtall.c; sourceTree = "<group>"; };
|
||||
F5AFA00A0EFAC7D300663B43 /* pxwide.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = pxwide.c; sourceTree = "<group>"; };
|
||||
F5AFA00B0EFAC7D300663B43 /* setup.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = setup.c; sourceTree = "<group>"; };
|
||||
F5AFA00C0EFAC7D300663B43 /* windows.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = windows.c; sourceTree = "<group>"; };
|
||||
F5B138C20EB71D28000B83CC /* SDL_ttf */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = SDL_ttf; path = /Library/Frameworks/SDL_ttf.framework/SDL_ttf; sourceTree = "<absolute>"; };
|
||||
F5B19B6C0EA4BDA8003F4BA4 /* SDL_image.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL_image.framework; path = /Library/Frameworks/SDL_image.framework; sourceTree = "<absolute>"; };
|
||||
F5B19B7B0EA4BE3E003F4BA4 /* graph.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = graph.c; sourceTree = "<group>"; };
|
||||
F5B19B7C0EA4BE3E003F4BA4 /* init.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = init.c; sourceTree = "<group>"; };
|
||||
F5B19B7D0EA4BE3E003F4BA4 /* io.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = io.c; sourceTree = "<group>"; };
|
||||
F5B19B7F0EA4BE3E003F4BA4 /* loadsave.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = loadsave.c; sourceTree = "<group>"; };
|
||||
F5B19B820EA4BE3E003F4BA4 /* op_c.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = op_c.c; sourceTree = "<group>"; };
|
||||
F5B19B830EA4BE3E003F4BA4 /* operatio.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = operatio.c; sourceTree = "<group>"; };
|
||||
F5B19B840EA4BE3E003F4BA4 /* pages.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = pages.c; sourceTree = "<group>"; };
|
||||
F5B19B850EA4BE3E003F4BA4 /* palette.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = palette.c; sourceTree = "<group>"; };
|
||||
F5B19B860EA4BE3E003F4BA4 /* readini.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = readini.c; sourceTree = "<group>"; };
|
||||
F5B19B870EA4BE3E003F4BA4 /* readline.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = readline.c; sourceTree = "<group>"; };
|
||||
F5B19B880EA4BE3E003F4BA4 /* saveini.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = saveini.c; sourceTree = "<group>"; };
|
||||
F5B19B890EA4BE3E003F4BA4 /* sdlscreen.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = sdlscreen.c; sourceTree = "<group>"; };
|
||||
F5B19B8A0EA4BE3E003F4BA4 /* SFont.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SFont.c; sourceTree = "<group>"; };
|
||||
F5B19B8B0EA4BE3E003F4BA4 /* shade.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = shade.c; sourceTree = "<group>"; };
|
||||
F5B19B8C0EA4BE3E003F4BA4 /* special.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = special.c; sourceTree = "<group>"; };
|
||||
F5B19C1C0EA4D71C003F4BA4 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
|
||||
F5B19C3C0EA4DC91003F4BA4 /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
F5B1EE840EAD0F4E00B087B5 /* gfx2def.ini */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = gfx2def.ini; sourceTree = "<group>"; };
|
||||
F5B310AD0F949A9C008197E2 /* buttons.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = buttons.c; sourceTree = "<group>"; };
|
||||
F5B310AE0F949A9C008197E2 /* engine.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = engine.c; sourceTree = "<group>"; };
|
||||
F5B310AF0F949A9C008197E2 /* filesel.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = filesel.c; sourceTree = "<group>"; };
|
||||
F5B310B00F949A9C008197E2 /* help.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = help.c; sourceTree = "<group>"; };
|
||||
F5B310B10F949A9C008197E2 /* keyboard.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = keyboard.c; sourceTree = "<group>"; };
|
||||
F5B310B20F949A9C008197E2 /* misc.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = misc.c; sourceTree = "<group>"; };
|
||||
F5B310B30F949A9C008197E2 /* text.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = text.c; sourceTree = "<group>"; };
|
||||
F5CDCE310F6EA6D600B31F63 /* pxdouble.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = pxdouble.c; sourceTree = "<group>"; };
|
||||
F5DCE2BB0EA5116B0065B0EF /* SDL_image */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = SDL_image; path = /Library/Frameworks/SDL_image.framework/Versions/A/SDL_image; sourceTree = "<absolute>"; };
|
||||
F5DCE2BD0EA5118E0065B0EF /* SDL */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = SDL; path = /Library/Frameworks/SDL.framework/Versions/A/SDL; sourceTree = "<absolute>"; };
|
||||
F5DCE2BE0EA5118F0065B0EF /* SDL_ttf */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = SDL_ttf; path = /Library/Frameworks/SDL_ttf.framework/Versions/A/SDL_ttf; sourceTree = "<absolute>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
8D11072E0486CEB800E47090 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
002F39FA09D0881F10EBEB88 /* SDL_image.framework in Frameworks */,
|
||||
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
|
||||
F5B19C1D0EA4D71C003F4BA4 /* CoreFoundation.framework in Frameworks */,
|
||||
F5B138C30EB71D28000B83CC /* SDL_ttf in Frameworks */,
|
||||
F5AE83FD0ECF8FD300200704 /* ApplicationServices.framework in Frameworks */,
|
||||
40D82D3A10ECC4CA005D27B5 /* SDL.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
080E96DDFE201D6D7F000001 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
002F3A2B09D0888800EBEB88 /* SDLMain.h */,
|
||||
002F3A2C09D0888800EBEB88 /* SDLMain.m */,
|
||||
);
|
||||
name = Classes;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
002F39F909D0881F00EBEB88 /* SDL.framework */,
|
||||
002F39F909D0881F10EBEB88 /* SDL_image.framework */,
|
||||
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
|
||||
);
|
||||
name = "Linked Frameworks";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
29B97324FDCFA39411CA2CEA /* AppKit.framework */,
|
||||
29B97325FDCFA39411CA2CEA /* Foundation.framework */,
|
||||
);
|
||||
name = "Other Frameworks";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
19C28FACFE9D520D11CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8D1107320486CEB800E47090 /* Grafx2.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97314FDCFA39411CA2CEA /* Grafx2 */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
40D82D5410ECC67A005D27B5 /* Resources */,
|
||||
40D82D4D10ECC609005D27B5 /* Resources */,
|
||||
40D82D4010ECC536005D27B5 /* Resources */,
|
||||
40D82CBE10ECB089005D27B5 /* libraw2crtc.c */,
|
||||
40D82CB110ECB02B005D27B5 /* fileformats.c */,
|
||||
40D82CAD10ECAFDC005D27B5 /* layers.c */,
|
||||
40D82CA910ECAFC5005D27B5 /* buttons_effects.c */,
|
||||
40D82CA510ECAF58005D27B5 /* brush_ops.c */,
|
||||
40D82CA010ECAF13005D27B5 /* miscfileformats.c */,
|
||||
F514264D101F6CB8006CF3C4 /* font_Classic.png */,
|
||||
F514264E101F6CB8006CF3C4 /* font_Fairlight.png */,
|
||||
F514264F101F6CB9006CF3C4 /* font_Fun.png */,
|
||||
F5142650101F6CB9006CF3C4 /* font_Melon.png */,
|
||||
F5142651101F6CB9006CF3C4 /* skin_classic.png */,
|
||||
F5142652101F6CB9006CF3C4 /* skin_modern.png */,
|
||||
F539315D0FE171C3003CB103 /* pversion.c */,
|
||||
F5CDCE310F6EA6D600B31F63 /* pxdouble.c */,
|
||||
F5AC28B90F4873C700455509 /* hotkeys.c */,
|
||||
F5AC28BA0F4873C700455509 /* input.c */,
|
||||
F5AC28BB0F4873C700455509 /* realpath.c */,
|
||||
F5AED03C0F1989E00090A93F /* mountlist.c */,
|
||||
F5AFA0070EFAC7D300663B43 /* brush.c */,
|
||||
F5AFA0080EFAC7D300663B43 /* pxsimple.c */,
|
||||
F5AFA0090EFAC7D300663B43 /* pxtall.c */,
|
||||
F5AFA00A0EFAC7D300663B43 /* pxwide.c */,
|
||||
F5AFA00B0EFAC7D300663B43 /* setup.c */,
|
||||
F5AFA00C0EFAC7D300663B43 /* windows.c */,
|
||||
F5AE6F980EDA119D000CE0EF /* GrafX2_Classic.gif */,
|
||||
F5AE83FC0ECF8FD300200704 /* ApplicationServices.framework */,
|
||||
F51CBD2B0EC8A3E1005C06AC /* 5pxtinyfont.png */,
|
||||
F51CBD2C0EC8A3E1005C06AC /* colorfont.pcx */,
|
||||
F51CBD2D0EC8A3E1005C06AC /* Tuffy.ttf */,
|
||||
F5A33E690EC893F800F8052D /* 8pxfont.png */,
|
||||
F5B138C20EB71D28000B83CC /* SDL_ttf */,
|
||||
F5B1EE840EAD0F4E00B087B5 /* gfx2def.ini */,
|
||||
F5B310AD0F949A9C008197E2 /* buttons.c */,
|
||||
F5B310AE0F949A9C008197E2 /* engine.c */,
|
||||
F5B310AF0F949A9C008197E2 /* filesel.c */,
|
||||
F5B310B00F949A9C008197E2 /* help.c */,
|
||||
F5B310B10F949A9C008197E2 /* keyboard.c */,
|
||||
F5B310B20F949A9C008197E2 /* misc.c */,
|
||||
F5B310B30F949A9C008197E2 /* text.c */,
|
||||
F5AD4B1E0EA8CCF0009CCAC4 /* version.c */,
|
||||
F5DCE2BD0EA5118E0065B0EF /* SDL */,
|
||||
F5DCE2BB0EA5116B0065B0EF /* SDL_image */,
|
||||
F5DCE2BE0EA5118F0065B0EF /* SDL_ttf */,
|
||||
F5B19C3B0EA4DC91003F4BA4 /* InfoPlist.strings */,
|
||||
F5B19C1C0EA4D71C003F4BA4 /* CoreFoundation.framework */,
|
||||
F5B19B7B0EA4BE3E003F4BA4 /* graph.c */,
|
||||
F5B19B7C0EA4BE3E003F4BA4 /* init.c */,
|
||||
F5B19B7D0EA4BE3E003F4BA4 /* io.c */,
|
||||
F5B19B7F0EA4BE3E003F4BA4 /* loadsave.c */,
|
||||
F5B19B820EA4BE3E003F4BA4 /* op_c.c */,
|
||||
F5B19B830EA4BE3E003F4BA4 /* operatio.c */,
|
||||
F5B19B840EA4BE3E003F4BA4 /* pages.c */,
|
||||
F5B19B850EA4BE3E003F4BA4 /* palette.c */,
|
||||
F5B19B860EA4BE3E003F4BA4 /* readini.c */,
|
||||
F5B19B870EA4BE3E003F4BA4 /* readline.c */,
|
||||
F5B19B880EA4BE3E003F4BA4 /* saveini.c */,
|
||||
F5B19B890EA4BE3E003F4BA4 /* sdlscreen.c */,
|
||||
F5B19B8A0EA4BE3E003F4BA4 /* SFont.c */,
|
||||
F5B19B8B0EA4BE3E003F4BA4 /* shade.c */,
|
||||
F5B19B8C0EA4BE3E003F4BA4 /* special.c */,
|
||||
F5B19B6C0EA4BDA8003F4BA4 /* SDL_image.framework */,
|
||||
080E96DDFE201D6D7F000001 /* Classes */,
|
||||
29B97315FDCFA39411CA2CEA /* Other Sources */,
|
||||
29B97317FDCFA39411CA2CEA /* Resources */,
|
||||
29B97323FDCFA39411CA2CEA /* Frameworks */,
|
||||
19C28FACFE9D520D11CA2CBB /* Products */,
|
||||
);
|
||||
name = Grafx2;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
32CA4F630368D1EE00C91783 /* Grafx2_Prefix.pch */,
|
||||
002F3A3E09D088BA00EBEB88 /* main.c */,
|
||||
F5AA405A0FBC406D00B7577C /* pxquad.c */,
|
||||
F5AA405B0FBC406D00B7577C /* pxtall2.c */,
|
||||
F5AA405C0FBC406D00B7577C /* pxtriple.c */,
|
||||
F5AA405D0FBC406D00B7577C /* pxwide2.c */,
|
||||
F5AA405E0FBC406D00B7577C /* transform.c */,
|
||||
);
|
||||
name = "Other Sources";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97317FDCFA39411CA2CEA /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8D1107310486CEB800E47090 /* Info.plist */,
|
||||
);
|
||||
name = Resources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
|
||||
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
40D82D4010ECC536005D27B5 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
40D82D4110ECC536005D27B5 /* Info.plist */,
|
||||
40D82D4210ECC536005D27B5 /* SDLMain.nib */,
|
||||
);
|
||||
name = Resources;
|
||||
path = /Library/Frameworks/SDL.framework/Resources;
|
||||
sourceTree = "<absolute>";
|
||||
};
|
||||
40D82D4D10ECC609005D27B5 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
40D82D4E10ECC609005D27B5 /* Info.plist */,
|
||||
40D82D4F10ECC609005D27B5 /* SDLMain.nib */,
|
||||
);
|
||||
name = Resources;
|
||||
path = /Library/Frameworks/SDL.framework/Versions/A/Resources;
|
||||
sourceTree = "<absolute>";
|
||||
};
|
||||
40D82D5410ECC67A005D27B5 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
40D82D5510ECC67A005D27B5 /* Info.plist */,
|
||||
40D82D5610ECC67A005D27B5 /* SDLMain.nib */,
|
||||
);
|
||||
name = Resources;
|
||||
path = /Library/Frameworks/SDL.framework/Versions/A/Resources;
|
||||
sourceTree = "<absolute>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
8D1107260486CEB800E47090 /* Grafx2 */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "Grafx2" */;
|
||||
buildPhases = (
|
||||
8D1107290486CEB800E47090 /* Resources */,
|
||||
8D11072C0486CEB800E47090 /* Sources */,
|
||||
8D11072E0486CEB800E47090 /* Frameworks */,
|
||||
002F39FD09D0883400EBEB88 /* Copy Frameworks into .app bundle */,
|
||||
002F39FD09D0883400EBEB89 /* Copy Frameworks into .app bundle */,
|
||||
002F39FD09D0883400EBEB8A /* Copy Frameworks into .app bundle */,
|
||||
F5A33F1D0EC8A26C00F8052D /* Copy fonts */,
|
||||
F514264B101F6C5B006CF3C4 /* Copy skins */,
|
||||
40D82D4C10ECC5A4005D27B5 /* CopyFiles */,
|
||||
40D82D5310ECC659005D27B5 /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = Grafx2;
|
||||
productInstallPath = "$(HOME)/Applications";
|
||||
productName = Grafx2;
|
||||
productReference = 8D1107320486CEB800E47090 /* Grafx2.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Grafx2" */;
|
||||
compatibilityVersion = "Xcode 2.4";
|
||||
hasScannedForEncodings = 1;
|
||||
mainGroup = 29B97314FDCFA39411CA2CEA /* Grafx2 */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
8D1107260486CEB800E47090 /* Grafx2 */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
8D1107290486CEB800E47090 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F5B19C3D0EA4DC91003F4BA4 /* InfoPlist.strings in Resources */,
|
||||
F5B1EE850EAD0F4E00B087B5 /* gfx2def.ini in Resources */,
|
||||
40D82D4310ECC536005D27B5 /* Info.plist in Resources */,
|
||||
40D82D4410ECC536005D27B5 /* SDLMain.nib in Resources */,
|
||||
40D82D5010ECC609005D27B5 /* Info.plist in Resources */,
|
||||
40D82D5110ECC609005D27B5 /* SDLMain.nib in Resources */,
|
||||
40D82D5710ECC67A005D27B5 /* Info.plist in Resources */,
|
||||
40D82D5810ECC67A005D27B5 /* SDLMain.nib in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
8D11072C0486CEB800E47090 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
002F3A2E09D0888800EBEB88 /* SDLMain.m in Sources */,
|
||||
002F3A3F09D088BA00EBEB88 /* main.c in Sources */,
|
||||
F5B19B930EA4BE3E003F4BA4 /* graph.c in Sources */,
|
||||
F5B19B940EA4BE3E003F4BA4 /* init.c in Sources */,
|
||||
F5B19B950EA4BE3E003F4BA4 /* io.c in Sources */,
|
||||
F5B19B970EA4BE3E003F4BA4 /* loadsave.c in Sources */,
|
||||
F5B19B9A0EA4BE3E003F4BA4 /* op_c.c in Sources */,
|
||||
F5B19B9B0EA4BE3E003F4BA4 /* operatio.c in Sources */,
|
||||
F5B19B9C0EA4BE3E003F4BA4 /* pages.c in Sources */,
|
||||
F5B19B9D0EA4BE3E003F4BA4 /* palette.c in Sources */,
|
||||
F5B19B9E0EA4BE3E003F4BA4 /* readini.c in Sources */,
|
||||
F5B19B9F0EA4BE3E003F4BA4 /* readline.c in Sources */,
|
||||
F5B19BA00EA4BE3E003F4BA4 /* saveini.c in Sources */,
|
||||
F5B19BA10EA4BE3E003F4BA4 /* sdlscreen.c in Sources */,
|
||||
F5B19BA20EA4BE3E003F4BA4 /* SFont.c in Sources */,
|
||||
F5B19BA30EA4BE3E003F4BA4 /* shade.c in Sources */,
|
||||
F5B19BA40EA4BE3E003F4BA4 /* special.c in Sources */,
|
||||
F5AD4B1F0EA8CCF0009CCAC4 /* version.c in Sources */,
|
||||
F5AFA00D0EFAC7D300663B43 /* brush.c in Sources */,
|
||||
F5AFA00E0EFAC7D300663B43 /* pxsimple.c in Sources */,
|
||||
F5AFA00F0EFAC7D300663B43 /* pxtall.c in Sources */,
|
||||
F5AFA0100EFAC7D300663B43 /* pxwide.c in Sources */,
|
||||
F5AFA0110EFAC7D300663B43 /* setup.c in Sources */,
|
||||
F5AFA0120EFAC7D300663B43 /* windows.c in Sources */,
|
||||
F5AED03E0F1989E00090A93F /* mountlist.c in Sources */,
|
||||
F5AC28BC0F4873C700455509 /* hotkeys.c in Sources */,
|
||||
F5AC28BD0F4873C700455509 /* input.c in Sources */,
|
||||
F5AC28BE0F4873C700455509 /* realpath.c in Sources */,
|
||||
F5CDCE320F6EA6D600B31F63 /* pxdouble.c in Sources */,
|
||||
F5B310B40F949A9C008197E2 /* buttons.c in Sources */,
|
||||
F5B310B50F949A9C008197E2 /* engine.c in Sources */,
|
||||
F5B310B60F949A9C008197E2 /* filesel.c in Sources */,
|
||||
F5B310B70F949A9C008197E2 /* help.c in Sources */,
|
||||
F5B310B80F949A9C008197E2 /* keyboard.c in Sources */,
|
||||
F5B310B90F949A9C008197E2 /* misc.c in Sources */,
|
||||
F5B310BA0F949A9C008197E2 /* text.c in Sources */,
|
||||
F5AA405F0FBC406D00B7577C /* pxquad.c in Sources */,
|
||||
F5AA40600FBC406D00B7577C /* pxtall2.c in Sources */,
|
||||
F5AA40610FBC406D00B7577C /* pxtriple.c in Sources */,
|
||||
F5AA40620FBC406D00B7577C /* pxwide2.c in Sources */,
|
||||
F5AA40630FBC406D00B7577C /* transform.c in Sources */,
|
||||
F539315E0FE171C3003CB103 /* pversion.c in Sources */,
|
||||
40D82CA110ECAF13005D27B5 /* miscfileformats.c in Sources */,
|
||||
40D82CA610ECAF58005D27B5 /* brush_ops.c in Sources */,
|
||||
40D82CAA10ECAFC5005D27B5 /* buttons_effects.c in Sources */,
|
||||
40D82CAE10ECAFDC005D27B5 /* layers.c in Sources */,
|
||||
40D82CB210ECB02B005D27B5 /* fileformats.c in Sources */,
|
||||
40D82CBF10ECB089005D27B5 /* libraw2crtc.c in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
F5B19C3B0EA4DC91003F4BA4 /* InfoPlist.strings */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
F5B19C3C0EA4DC91003F4BA4 /* English */,
|
||||
);
|
||||
name = InfoPlist.strings;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
C01FCF4B08A954540054247B /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
|
||||
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)",
|
||||
);
|
||||
FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(DEVELOPER_DIR)/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks\"";
|
||||
FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Versions/A/Frameworks\"";
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
__macosx__,
|
||||
__linux__,
|
||||
);
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = "$(HOME)/Applications";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
|
||||
"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2)",
|
||||
"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_3)",
|
||||
"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_4)",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL_image.framework\"";
|
||||
LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL.framework\"";
|
||||
LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_3 = "\"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL_ttf.framework\"";
|
||||
LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_4 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework\"";
|
||||
PRODUCT_NAME = Grafx2;
|
||||
REZ_SEARCH_PATHS = "";
|
||||
WRAPPER_EXTENSION = app;
|
||||
ZERO_LINK = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C01FCF4C08A954540054247B /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = (
|
||||
ppc,
|
||||
i386,
|
||||
);
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
|
||||
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)",
|
||||
);
|
||||
FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(DEVELOPER_DIR)/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks\"";
|
||||
FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Versions/A/Frameworks\"";
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
__macosx__,
|
||||
__linux__,
|
||||
);
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = "$(HOME)/Applications";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
|
||||
"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2)",
|
||||
"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_3)",
|
||||
"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_4)",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL_image.framework\"";
|
||||
LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL.framework\"";
|
||||
LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_3 = "\"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL_ttf.framework\"";
|
||||
LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_4 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework\"";
|
||||
PRODUCT_NAME = Grafx2;
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
C01FCF4F08A954540054247B /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
/Library/Frameworks,
|
||||
"$(FRAMEWORK_SEARCH_PATHS)",
|
||||
);
|
||||
GCC_OPTIMIZATION_LEVEL = 3;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
__macosx__,
|
||||
__linux__,
|
||||
);
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
/usr/X11/include,
|
||||
/Library/Frameworks/SDL_image.framework/Headers,
|
||||
"$(HOME)/Library/Frameworks/SDL.framework/Headers",
|
||||
/Library/Frameworks/SDL.framework/Headers,
|
||||
/Library/SDL_ttf.framework/Headers,
|
||||
/usr/local/include,
|
||||
"$(HEADER_SEARCH_PATHS)",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
/usr/X11/lib,
|
||||
/usr/local/lib,
|
||||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-lpng",
|
||||
"-lz",
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRELINK_LIBS = SDL_Image;
|
||||
SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
|
||||
STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static;
|
||||
ZERO_LINK = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C01FCF5008A954540054247B /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
/Library/Frameworks,
|
||||
"$(FRAMEWORK_SEARCH_PATHS)",
|
||||
);
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
__macosx__,
|
||||
__linux__,
|
||||
);
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(HOME)/Library/Frameworks/SDL.framework/Headers",
|
||||
/Library/Frameworks/SDL.framework/Headers,
|
||||
/usr/local/include,
|
||||
"$(HEADER_SEARCH_PATHS)",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = /usr/local/lib;
|
||||
OTHER_LDFLAGS = (
|
||||
"-lpng",
|
||||
"-lz",
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRELINK_LIBS = SDL_Image;
|
||||
SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
|
||||
STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "Grafx2" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C01FCF4B08A954540054247B /* Debug */,
|
||||
C01FCF4C08A954540054247B /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Grafx2" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C01FCF4F08A954540054247B /* Debug */,
|
||||
C01FCF5008A954540054247B /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
|
||||
}
|
||||
319
src/Grafx2.xcodeproj/xx.pbxuser
Normal file
319
src/Grafx2.xcodeproj/xx.pbxuser
Normal file
@@ -0,0 +1,319 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
002F3A2B09D0888800EBEB88 /* SDLMain.h */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {867, 536}}";
|
||||
sepNavSelRange = "{302, 0}";
|
||||
sepNavVisRect = "{{0, 0}, {867, 536}}";
|
||||
sepNavWindowFrame = "{{15, 76}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
002F3A2C09D0888800EBEB88 /* SDLMain.m */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1084, 7296}}";
|
||||
sepNavSelRange = "{1567, 12}";
|
||||
sepNavVisRect = "{{0, 718}, {867, 536}}";
|
||||
sepNavWindowFrame = "{{38, 55}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
002F3A3E09D088BA00EBEB88 /* main.c */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1044, 15086}}";
|
||||
sepNavSelRange = "{19535, 0}";
|
||||
sepNavVisRect = "{{0, 10961}, {867, 536}}";
|
||||
sepNavWindowFrame = "{{14, 76}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||
activeBuildConfigurationName = Release;
|
||||
activeExecutable = F5B19B5D0EA4BD57003F4BA4 /* Grafx2 */;
|
||||
activeTarget = 8D1107260486CEB800E47090 /* Grafx2 */;
|
||||
addToTargets = (
|
||||
);
|
||||
breakpointsGroup = F5B19B700EA4BDA9003F4BA4 /* XCBreakpointsBucket */;
|
||||
codeSenseManager = F5B19B6A0EA4BD79003F4BA4 /* Code sense */;
|
||||
executables = (
|
||||
F5B19B5D0EA4BD57003F4BA4 /* Grafx2 */,
|
||||
);
|
||||
perUserDictionary = {
|
||||
PBXConfiguration.PBXFileTableDataSource3.PBXErrorsWarningsDataSource = {
|
||||
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
|
||||
PBXFileTableDataSourceColumnSortingKey = PBXErrorsWarningsDataSource_LocationID;
|
||||
PBXFileTableDataSourceColumnWidthsKey = (
|
||||
20,
|
||||
453,
|
||||
58,
|
||||
);
|
||||
PBXFileTableDataSourceColumnsKey = (
|
||||
PBXErrorsWarningsDataSource_TypeID,
|
||||
PBXErrorsWarningsDataSource_MessageID,
|
||||
PBXErrorsWarningsDataSource_LocationID,
|
||||
);
|
||||
};
|
||||
PBXConfiguration.PBXFileTableDataSource3.PBXExecutablesDataSource = {
|
||||
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
|
||||
PBXFileTableDataSourceColumnSortingKey = PBXExecutablesDataSource_NameID;
|
||||
PBXFileTableDataSourceColumnWidthsKey = (
|
||||
22,
|
||||
300,
|
||||
209,
|
||||
);
|
||||
PBXFileTableDataSourceColumnsKey = (
|
||||
PBXExecutablesDataSource_ActiveFlagID,
|
||||
PBXExecutablesDataSource_NameID,
|
||||
PBXExecutablesDataSource_CommentsID,
|
||||
);
|
||||
};
|
||||
PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = {
|
||||
PBXFileTableDataSourceColumnSortingDirectionKey = 1;
|
||||
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Built_ColumnID;
|
||||
PBXFileTableDataSourceColumnWidthsKey = (
|
||||
20,
|
||||
99,
|
||||
20,
|
||||
48,
|
||||
43,
|
||||
43,
|
||||
20,
|
||||
264,
|
||||
10,
|
||||
20,
|
||||
);
|
||||
PBXFileTableDataSourceColumnsKey = (
|
||||
PBXFileDataSource_FiletypeID,
|
||||
PBXFileDataSource_Filename_ColumnID,
|
||||
PBXFileDataSource_Built_ColumnID,
|
||||
PBXFileDataSource_ObjectSize_ColumnID,
|
||||
PBXFileDataSource_Errors_ColumnID,
|
||||
PBXFileDataSource_Warnings_ColumnID,
|
||||
PBXFileDataSource_Target_ColumnID,
|
||||
PBXFileDataSource_Path_ColumnID,
|
||||
PBXFileDataSource_Comments_ColumnID,
|
||||
PBXFileDataSource_SCM_ColumnID,
|
||||
);
|
||||
};
|
||||
PBXConfiguration.PBXFileTableDataSource3.PBXFindDataSource = {
|
||||
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
|
||||
PBXFileTableDataSourceColumnSortingKey = PBXFindDataSource_LocationID;
|
||||
PBXFileTableDataSourceColumnWidthsKey = (
|
||||
200,
|
||||
413.2085,
|
||||
);
|
||||
PBXFileTableDataSourceColumnsKey = (
|
||||
PBXFindDataSource_MessageID,
|
||||
PBXFindDataSource_LocationID,
|
||||
);
|
||||
};
|
||||
PBXConfiguration.PBXFileTableDataSource3.PBXSymbolsDataSource = {
|
||||
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
|
||||
PBXFileTableDataSourceColumnSortingKey = PBXSymbolsDataSource_SymbolNameID;
|
||||
PBXFileTableDataSourceColumnWidthsKey = (
|
||||
16,
|
||||
200,
|
||||
50,
|
||||
325.2085,
|
||||
);
|
||||
PBXFileTableDataSourceColumnsKey = (
|
||||
PBXSymbolsDataSource_SymbolTypeIconID,
|
||||
PBXSymbolsDataSource_SymbolNameID,
|
||||
PBXSymbolsDataSource_SymbolTypeID,
|
||||
PBXSymbolsDataSource_ReferenceNameID,
|
||||
);
|
||||
};
|
||||
PBXConfiguration.PBXFileTableDataSource3.XCSCMDataSource = {
|
||||
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
|
||||
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
|
||||
PBXFileTableDataSourceColumnWidthsKey = (
|
||||
20,
|
||||
20,
|
||||
262,
|
||||
20,
|
||||
48.1626,
|
||||
43,
|
||||
43,
|
||||
20,
|
||||
);
|
||||
PBXFileTableDataSourceColumnsKey = (
|
||||
PBXFileDataSource_SCM_ColumnID,
|
||||
PBXFileDataSource_FiletypeID,
|
||||
PBXFileDataSource_Filename_ColumnID,
|
||||
PBXFileDataSource_Built_ColumnID,
|
||||
PBXFileDataSource_ObjectSize_ColumnID,
|
||||
PBXFileDataSource_Errors_ColumnID,
|
||||
PBXFileDataSource_Warnings_ColumnID,
|
||||
PBXFileDataSource_Target_ColumnID,
|
||||
);
|
||||
};
|
||||
PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = {
|
||||
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
|
||||
PBXFileTableDataSourceColumnSortingKey = PBXTargetDataSource_PrimaryAttribute;
|
||||
PBXFileTableDataSourceColumnWidthsKey = (
|
||||
20,
|
||||
200,
|
||||
106,
|
||||
20,
|
||||
48,
|
||||
43,
|
||||
43,
|
||||
);
|
||||
PBXFileTableDataSourceColumnsKey = (
|
||||
PBXFileDataSource_FiletypeID,
|
||||
PBXFileDataSource_Filename_ColumnID,
|
||||
PBXTargetDataSource_PrimaryAttribute,
|
||||
PBXFileDataSource_Built_ColumnID,
|
||||
PBXFileDataSource_ObjectSize_ColumnID,
|
||||
PBXFileDataSource_Errors_ColumnID,
|
||||
PBXFileDataSource_Warnings_ColumnID,
|
||||
);
|
||||
};
|
||||
PBXPerProjectTemplateStateSaveDate = 270495112;
|
||||
PBXWorkspaceStateSaveDate = 270495112;
|
||||
};
|
||||
sourceControlManager = F5B19B690EA4BD79003F4BA4 /* Source Control */;
|
||||
userBuildSettings = {
|
||||
OBJROOT = "$(SYMROOT)";
|
||||
};
|
||||
};
|
||||
32CA4F630368D1EE00C91783 /* Grafx2_Prefix.pch */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {932, 587}}";
|
||||
sepNavSelRange = "{0, 0}";
|
||||
sepNavVisRect = "{{0, 0}, {932, 587}}";
|
||||
sepNavWindowFrame = "{{15, 25}, {971, 716}}";
|
||||
};
|
||||
};
|
||||
8D1107260486CEB800E47090 /* Grafx2 */ = {
|
||||
activeExec = 0;
|
||||
executables = (
|
||||
F5B19B5D0EA4BD57003F4BA4 /* Grafx2 */,
|
||||
);
|
||||
};
|
||||
F51CBD2B0EC8A3E1005C06AC /* 5pxtinyfont.png */ = {
|
||||
uiCtxt = {
|
||||
sepNavWindowFrame = "{{15, 25}, {971, 716}}";
|
||||
};
|
||||
};
|
||||
F5A33E690EC893F800F8052D /* 8pxfont.png */ = {
|
||||
uiCtxt = {
|
||||
sepNavWindowFrame = "{{15, 76}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
F5AD4B1E0EA8CCF0009CCAC4 /* version.c */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {932, 587}}";
|
||||
sepNavSelRange = "{26, 0}";
|
||||
sepNavVisRect = "{{0, 0}, {932, 587}}";
|
||||
sepNavWindowFrame = "{{7, 5}, {971, 716}}";
|
||||
};
|
||||
};
|
||||
F5AED03C0F1989E00090A93F /* mountlist.c */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {867, 17252}}";
|
||||
sepNavSelRange = "{4702, 50}";
|
||||
sepNavVisRect = "{{0, 2973}, {867, 536}}";
|
||||
sepNavWindowFrame = "{{15, 76}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
F5B19B5D0EA4BD57003F4BA4 /* Grafx2 */ = {
|
||||
isa = PBXExecutable;
|
||||
activeArgIndex = 2147483647;
|
||||
activeArgIndices = (
|
||||
);
|
||||
argumentStrings = (
|
||||
);
|
||||
autoAttachOnCrash = 1;
|
||||
configStateDict = {
|
||||
};
|
||||
customDataFormattersEnabled = 1;
|
||||
debuggerPlugin = GDBDebugging;
|
||||
disassemblyDisplayState = 0;
|
||||
dylibVariantSuffix = "";
|
||||
enableDebugStr = 1;
|
||||
environmentEntries = (
|
||||
);
|
||||
executableSystemSymbolLevel = 0;
|
||||
executableUserSymbolLevel = 0;
|
||||
libgmallocEnabled = 0;
|
||||
name = Grafx2;
|
||||
savedGlobals = {
|
||||
};
|
||||
sourceDirectories = (
|
||||
);
|
||||
variableFormatDictionary = {
|
||||
};
|
||||
};
|
||||
F5B19B690EA4BD79003F4BA4 /* Source Control */ = {
|
||||
isa = PBXSourceControlManager;
|
||||
fallbackIsa = XCSourceControlManager;
|
||||
isSCMEnabled = 0;
|
||||
scmConfiguration = {
|
||||
};
|
||||
scmType = scm.subversion;
|
||||
};
|
||||
F5B19B6A0EA4BD79003F4BA4 /* Code sense */ = {
|
||||
isa = PBXCodeSenseManager;
|
||||
indexTemplatePath = "";
|
||||
};
|
||||
F5B19B700EA4BDA9003F4BA4 /* XCBreakpointsBucket */ = {
|
||||
isa = XCBreakpointsBucket;
|
||||
name = "Project Breakpoints";
|
||||
objects = (
|
||||
);
|
||||
};
|
||||
F5B19B7B0EA4BE3E003F4BA4 /* graph.c */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1140, 52782}}";
|
||||
sepNavSelRange = "{6769, 0}";
|
||||
sepNavVisRect = "{{0, 0}, {867, 536}}";
|
||||
sepNavWindowFrame = "{{14, 76}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
F5B19B7C0EA4BE3E003F4BA4 /* init.c */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1660, 46018}}";
|
||||
sepNavSelRange = "{81112, 1}";
|
||||
sepNavVisRect = "{{0, 44925}, {867, 536}}";
|
||||
sepNavWindowFrame = "{{12, 46}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
F5B19B7F0EA4BE3E003F4BA4 /* loadsave.c */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1700, 112651}}";
|
||||
sepNavSelRange = "{1098, 24}";
|
||||
sepNavVisRect = "{{0, 331}, {867, 536}}";
|
||||
sepNavWindowFrame = "{{15, 76}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
F5B19B850EA4BE3E003F4BA4 /* palette.c */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1268, 37031}}";
|
||||
sepNavSelRange = "{75128, 0}";
|
||||
sepNavVisRect = "{{0, 0}, {0, 0}}";
|
||||
sepNavWindowFrame = "{{15, 76}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
F5B19B880EA4BE3E003F4BA4 /* saveini.c */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1156, 12084}}";
|
||||
sepNavSelRange = "{19568, 0}";
|
||||
sepNavVisRect = "{{0, 0}, {0, 0}}";
|
||||
sepNavWindowFrame = "{{15, 76}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
F5B19B890EA4BE3E003F4BA4 /* sdlscreen.c */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1396, 4351}}";
|
||||
sepNavSelRange = "{2375, 0}";
|
||||
sepNavVisRect = "{{0, 1072}, {867, 536}}";
|
||||
sepNavWindowFrame = "{{35, 15}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
F5B19C3C0EA4DC91003F4BA4 /* English */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1692, 536}}";
|
||||
sepNavSelRange = "{0, 0}";
|
||||
sepNavVisRect = "{{825, 0}, {867, 536}}";
|
||||
sepNavWindowFrame = "{{15, 76}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
}
|
||||
1403
src/Grafx2.xcodeproj/xx.perspective
Normal file
1403
src/Grafx2.xcodeproj/xx.perspective
Normal file
File diff suppressed because it is too large
Load Diff
9
src/Grafx2_Prefix.pch
Normal file
9
src/Grafx2_Prefix.pch
Normal file
@@ -0,0 +1,9 @@
|
||||
//
|
||||
// Prefix header for all source files of the 'Grafx2' target in the 'Grafx2' project
|
||||
//
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
453
src/Makefile
Normal file
453
src/Makefile
Normal file
@@ -0,0 +1,453 @@
|
||||
# Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
#
|
||||
# Copyright 2009 Per Olofsson
|
||||
# Copyright 2008 Peter Gordon
|
||||
# Copyright 2008 Yves Rizoud
|
||||
# Copyright 2007 Adrien Destugues
|
||||
# Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
#
|
||||
# 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/>
|
||||
|
||||
# Overridable defaults
|
||||
prefix = /usr/local
|
||||
exec_prefix = $(prefix)
|
||||
bindir = $(exec_prefix)/bin
|
||||
datarootdir = $(prefix)/share
|
||||
datadir = $(datarootdir)
|
||||
|
||||
# Compile with OPTIM=0 to disable gcc optimizations, to enable debug.
|
||||
STRIP = strip
|
||||
|
||||
|
||||
### PLATFORM DETECTION AND CONFIGURATION ###
|
||||
|
||||
PLATFORMOBJ =
|
||||
|
||||
# There is no uname under windows, but we can guess we are there with the COMSPEC env.var
|
||||
# Windows specific
|
||||
ifdef COMSPEC
|
||||
DELCOMMAND = rm -f
|
||||
MKDIR = mkdir -p
|
||||
RMDIR = rmdir
|
||||
CP = cp
|
||||
BIN = ../bin/grafx2.exe
|
||||
COPT = -W -Wall -Wdeclaration-after-statement -O$(OPTIM) -g -ggdb `sdl-config --cflags` $(TTFCOPT) $(JOYCOPT) $(LUACOPT) $(LAYERCOPT)
|
||||
LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) -lpng $(LUALOPT)
|
||||
LUALOPT = -llua
|
||||
CC = gcc
|
||||
OBJDIR = ../obj/win32
|
||||
# Resources (icon)
|
||||
WINDRES = windres.exe
|
||||
PLATFORMOBJ = $(OBJDIR)/winres.o
|
||||
PLATFORM = win32
|
||||
#some misc files we have to add to the release archive under windows.
|
||||
PLATFORMFILES = bin/SDL.dll bin/SDL_image.dll bin/libpng13.dll bin/zlib1.dll $(TTFLIBS)
|
||||
ZIP = zip
|
||||
else
|
||||
|
||||
#For all other platforms, we can rely on uname
|
||||
PLATFORM = $(shell uname)
|
||||
|
||||
#AmigaOS4 specific
|
||||
ifeq ($(PLATFORM),AmigaOS) # 1
|
||||
DELCOMMAND = rm -rf
|
||||
MKDIR = mkdir -p
|
||||
RMDIR = rmdir
|
||||
CP = cp
|
||||
BIN = ../bin/grafx2
|
||||
COPT = -Wall -c -gstabs -mcrt=newlib `sdl-config --cflags` -I/SDK/Local/common/include/SDL -D__USE_INLINE__ $(TTFCOPT)
|
||||
LOPT = `sdl-config --libs` -lSDL_image -lpng -ljpeg -lz $(TTFLOPT) -lft2
|
||||
CC = gcc
|
||||
OBJDIR = ../obj/amiga
|
||||
ZIP = lha
|
||||
ZIPOPT = a
|
||||
|
||||
else
|
||||
ifeq ($(PLATFORM),Darwin) # 2
|
||||
#Mac OS X specific
|
||||
DELCOMMAND = rm -rf
|
||||
MKDIR = mkdir -p
|
||||
RMDIR = rmdir
|
||||
CP = cp
|
||||
ZIP = zip
|
||||
PLATFORMFILES = gfx2.png
|
||||
BIN = ../bin/grafx2
|
||||
# Where the SDL frameworks are located
|
||||
FWDIR = /Library/Frameworks
|
||||
SDLCOPT = -arch i386 -I$(FWDIR)/SDL.framework/Headers -I$(FWDIR)/SDL_image.framework/Headers -I$(FWDIR)/SDL_ttf.framework/Headers -D_THREAD_SAFE
|
||||
SDLLOPT = -arch i386 -L/usr/lib -framework SDL -framework SDL_image -framework SDL_ttf -framework Cocoa -framework Carbon -framework OpenGL
|
||||
COPT = -D__macosx__ -D__linux__ -W -Wall -Wdeclaration-after-statement -O$(OPTIM) -std=c99 -c -g $(SDLCOPT) $(TTFCOPT) -I/usr/X11/include
|
||||
LOPT = $(SDLLOPT) -L/usr/X11/lib -R/usr/X11/lib -lpng
|
||||
# Use gcc for compiling. Use ncc to build a callgraph and analyze the code.
|
||||
CC = gcc
|
||||
#CC = nccgen -ncgcc -ncld -ncfabs
|
||||
OBJDIR = ../obj/macosx
|
||||
PLATFORMOBJ = $(OBJDIR)/SDLMain.o
|
||||
X11LOPT =
|
||||
MACAPPEXE = Grafx2.app/Contents/MacOS/Grafx2
|
||||
|
||||
else
|
||||
ifeq ($(PLATFORM),AROS) # 3
|
||||
#AROS specific
|
||||
DELCOMMAND = rm -rf
|
||||
MKDIR = mkdir -p
|
||||
RMDIR = rmdir
|
||||
CP = cp
|
||||
BIN = ../bin/grafx2
|
||||
COPT = -Wall -g `sdl-config --cflags` $(TTFCOPT)
|
||||
LOPT = -lSDL_image `sdl-config --libs` -lpng -ljpeg -lz $(TTFLOPT) -lfreetype2shared
|
||||
CC = gcc
|
||||
OBJDIR = ../obj/aros
|
||||
STRIP = strip --strip-unneeded --remove-section .comment
|
||||
ZIP = lha
|
||||
ZIPOPT = a
|
||||
|
||||
else
|
||||
ifeq ($(PLATFORM),MorphOS) # 4
|
||||
#MorphOS specific
|
||||
DELCOMMAND = rm -rf
|
||||
MKDIR = mkdir -p
|
||||
RMDIR = rmdir
|
||||
CP = cp
|
||||
BIN = ../bin/grafx2
|
||||
COPT = -Wall -gstabs -c `sdl-config --cflags` $(TTFCOPT)
|
||||
LOPT = -lSDL_image `sdl-config --libs` -lpng -ljpeg -lz $(TTFLOPT)
|
||||
CC = gcc
|
||||
OBJDIR = ../obj/morphos
|
||||
ZIP = lha
|
||||
ZIPOPT = a
|
||||
PLATFORMFILES = ../misc/grafx2.info
|
||||
|
||||
else
|
||||
ifeq ($(PLATFORM),AMIGA) # 5
|
||||
# AmigaOS 3.x specific (building with gcc)
|
||||
DELCOMMAND = rm -rf
|
||||
MKDIR = mkdir -p
|
||||
RMDIR = rmdir
|
||||
CP = cp
|
||||
BIN = ../bin/grafx2
|
||||
COPT = -Wall -gstabs -c `sdl-config --cflags` $(TTFCOPT)
|
||||
LOPT = -lSDL_image `sdl-config --libs` -lpng -ljpeg -lz $(TTFLOPT) -lfreetype
|
||||
CC = gcc
|
||||
OBJDIR = ../obj/amiga
|
||||
ZIP = lha
|
||||
ZIPOPT = a
|
||||
|
||||
else
|
||||
ifeq ($(PLATFORM),BeOS) # 6
|
||||
#BeOS specific
|
||||
DELCOMMAND = rm -rf
|
||||
MKDIR = mkdir -p
|
||||
RMDIR = rmdir
|
||||
CP = cp
|
||||
BIN = ../bin/grafx2
|
||||
COPT = -W -Wall -c -g `sdl-config --cflags` $(TTFCOPT) -I/boot/home/config/include
|
||||
LOPT = `sdl-config --libs` -lSDL_image -lpng -ljpeg -lz $(TTFLOPT)
|
||||
CC = gcc
|
||||
OBJDIR = ../obj/beos
|
||||
ZIP = zip
|
||||
|
||||
else
|
||||
ifeq ($(PLATFORM),Haiku) # 7
|
||||
#Haiku specific
|
||||
DELCOMMAND = rm -rf
|
||||
MKDIR = mkdir -p
|
||||
RMDIR = rmdir
|
||||
CP = cp
|
||||
BIN = ../bin/grafx2
|
||||
COPT = -W -Wall -c -g `sdl-config --cflags` $(TTFCOPT) -I/boot/common/include
|
||||
LOPT = `sdl-config --libs` -lSDL_image -lpng -ljpeg -lz $(TTFLOPT)
|
||||
CC = gcc
|
||||
OBJDIR = ../obj/haiku
|
||||
ZIP = zip
|
||||
|
||||
else
|
||||
ifeq ($(PLATFORM),skyos) # 8
|
||||
#SkyOS specific
|
||||
DELCOMMAND = rm -rf
|
||||
MKDIR = mkdir -p
|
||||
RMDIR = rmdir
|
||||
CP = cp
|
||||
BIN = ../bin/grafx2
|
||||
COPT = -W -Wall -Wdeclaration-after-statement -c -g `sdl-config --cflags` $(TTFCOPT)
|
||||
LOPT = `sdl-config --libs` -lSDL_image -lpng -ljpeg -lz $(TTFLOPT)
|
||||
CC = gcc
|
||||
OBJDIR = ../obj/skyos
|
||||
ZIP = zip
|
||||
|
||||
else
|
||||
ifeq ($(PLATFORM),OSF1) #9
|
||||
#OSF1 / tru64 alpha
|
||||
DELCOMMAND = rm -rf
|
||||
MKDIR = mkdir -p
|
||||
RMDIR = rmdir
|
||||
CP = cp
|
||||
ZIP = zip
|
||||
PLATFORMFILES = gfx2.png
|
||||
BIN = ../bin/grafx2
|
||||
COPT = -W -Wall -std=c99 -c -g -gstabs -D__TRU64__ `sdl-config --cflags` $(TTFCOPT) $(LUACOPT)
|
||||
LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) -lpng $(LUALOPT) -lm
|
||||
OBJDIR = ../obj/unix
|
||||
X11LOPT = -lX11
|
||||
CC = gcc
|
||||
|
||||
else
|
||||
ifeq ($(findstring Kickstart,$(shell version)),Kickstart) # 9
|
||||
# Classic amiga without gcc. Use vbcc.
|
||||
PLATFORM = amiga-vbcc
|
||||
DELCOMMAND = delete
|
||||
MKDIR = makedir
|
||||
RMDIR= delete
|
||||
CP = copy
|
||||
BIN = ../bin/grafx2
|
||||
COPT = -c99 -Ivbcc:PosixLib/include -D__amigaos__ $(TTFCOPT)
|
||||
CC = vc
|
||||
OBJDIR = ../obj/amiga-vbcc
|
||||
ZIP = lha
|
||||
ZIPOPT = a
|
||||
|
||||
NOTTF = 1
|
||||
|
||||
else
|
||||
|
||||
# Finally, the default rules that work fine for most unix/gcc systems, linux and freebsd are tested.
|
||||
# Linux and FreeBSD specific (default rules)
|
||||
DELCOMMAND = rm -rf
|
||||
MKDIR = mkdir -p
|
||||
RMDIR = rmdir
|
||||
CP = cp
|
||||
ZIP = zip
|
||||
PLATFORMFILES = gfx2.png
|
||||
LUACOPT = `pkg-config lua5.1 --cflags`
|
||||
LUALOPT = `pkg-config lua5.1 --libs`
|
||||
|
||||
# These can only be used under linux and maybe freebsd. They allow to compile for the gp2x or to create a windows binary
|
||||
ifdef WIN32CROSS
|
||||
#cross compile a Win32 executable
|
||||
CC = i586-mingw32msvc-gcc
|
||||
BIN = ../bin/grafx2.exe
|
||||
COPT = -W -Wall -Wdeclaration-after-statement -O$(OPTIM) -g -ggdb -Dmain=SDL_main `/usr/local/cross-tools/i386-mingw32/bin/sdl-config --cflags` $(TTFCOPT)
|
||||
LOPT = -mwindows -lmingw32 -lSDLmain -lSDL -lshlwapi `/usr/local/cross-tools/i386-mingw32/bin/sdl-config --libs` -lSDL_image $(TTFLOPT)
|
||||
OBJDIR = ../obj/win32
|
||||
PLATFORM = win32
|
||||
else
|
||||
ifdef GP2XCROSS
|
||||
|
||||
#cross compile an exec for the gp2x
|
||||
CC = /opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/bin/arm-open2x-linux-gcc
|
||||
BIN = ../grafx2.gpe
|
||||
COPT = -W -Wall -Wdeclaration-after-statement -pedantic -std=c99 -static -g -O3 -I/opt/open2x/gcc-4.1.1-glibc-2.3.6/include `/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/sdl-config --cflags` $(TTFCOPT) -D__GP2X__
|
||||
LOPT = -static -lSDL_image `/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/sdl-config --static-libs` -ljpeg -lpng -lz -lm $(TTFLOPT)
|
||||
OBJDIR = ../obj/gp2x
|
||||
NOTTF = 1
|
||||
PLATFORM = gp2x
|
||||
STRIP = /opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/bin/arm-open2x-linux-strip
|
||||
JOYCOPT = -DUSE_JOYSTICK
|
||||
else
|
||||
|
||||
# Compiles a regular linux executable for the native platform
|
||||
BIN = ../bin/grafx2
|
||||
COPT = -W -Wall -Wdeclaration-after-statement -std=c99 -c -g `sdl-config --cflags` $(TTFCOPT) $(LUACOPT)
|
||||
LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) -lpng $(LUALOPT) -lm
|
||||
# Use gcc for compiling. Use ncc to build a callgraph and analyze the code.
|
||||
CC = gcc
|
||||
#CC = nccgen -ncgcc -ncld -ncfabs
|
||||
OBJDIR = ../obj/unix
|
||||
X11LOPT = -lX11
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
### BUILD SETTINGS are set according to vars set in the platform selection, the "overridable defaults", and environment variables set before launching make
|
||||
|
||||
#TrueType is optional: make NOTTF=1 to disable support and dependencies.
|
||||
ifeq ($(NOTTF),1)
|
||||
TTFCOPT = -DNOTTF=1
|
||||
TTFLOPT =
|
||||
TTFLIBS =
|
||||
TTFLABEL = -nottf
|
||||
else
|
||||
TTFCOPT =
|
||||
TTFLOPT = -L/usr/local/lib -lSDL_ttf $(X11LOPT)
|
||||
TTFLIBS = bin/libfreetype-6.dll bin/SDL_ttf.dll
|
||||
TTFLABEL =
|
||||
endif
|
||||
|
||||
#Lua scripting is optional too
|
||||
ifeq ($(NOLUA),1)
|
||||
LUACOPT =
|
||||
LUALOPT =
|
||||
LUALABEL = -nolua
|
||||
else
|
||||
LUACOPT += -D__ENABLE_LUA__
|
||||
LUALABEL =
|
||||
endif
|
||||
|
||||
#To enable Joystick emulation of cursor, make USE_JOYSTICK=1 (for input.o)
|
||||
#This can be necessary to test cursor code on a PC, but by default for all
|
||||
#non-console platforms the joystick is disabled, to avoid reporting
|
||||
#'restless' movements when an analog joystick or a poorly-calibrated joypad
|
||||
#is plugged in.
|
||||
ifeq ($(USE_JOYSTICK),1)
|
||||
JOYCOPT = -DUSE_JOYSTICK
|
||||
endif
|
||||
|
||||
#To speed up rendering, can disable the layered editing
|
||||
# with NOLAYERS=1
|
||||
ifeq ($(NOLAYERS),1)
|
||||
LAYERCOPT = -DNOLAYERS
|
||||
else
|
||||
LAYERCOPT =
|
||||
endif
|
||||
|
||||
### And now for the real build rules ###
|
||||
|
||||
.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.
|
||||
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 $(OBJDIR)/libraw2crtc.o $(OBJDIR)/brush_ops.o $(OBJDIR)/buttons_effects.o $(OBJDIR)/layers.o
|
||||
|
||||
SKIN_FILES = ../share/grafx2/skins/skin_classic.png ../share/grafx2/skins/skin_modern.png ../share/grafx2/skins/font_Classic.png ../share/grafx2/skins/font_Fun.png
|
||||
|
||||
ifeq ($(PLATFORM),Darwin)
|
||||
all : $(MACAPPEXE)
|
||||
$(MACAPPEXE) : $(BIN)
|
||||
rm -rf Grafx2.app
|
||||
mkdir -p Grafx2.app Grafx2.app/Contents Grafx2.app/Contents/Frameworks Grafx2.app/Contents/MacOS Grafx2.app/Contents/Resources
|
||||
echo 'APPL????' > Grafx2.app/Contents/PkgInfo
|
||||
cp Info.plist Grafx2.app/Contents
|
||||
cp -r English.lproj Grafx2.app/Contents/Resources
|
||||
cp -r fonts Grafx2.app/Contents/Resources
|
||||
cp -r skins Grafx2.app/Contents/Resources
|
||||
cp -r gfx2def.ini Grafx2.app/Contents/Resources
|
||||
cp -Rp $(FWDIR)/SDL.framework Grafx2.app/Contents/Frameworks
|
||||
cp -Rp $(FWDIR)/SDL_image.framework Grafx2.app/Contents/Frameworks
|
||||
cp -Rp $(FWDIR)/SDL_ttf.framework Grafx2.app/Contents/Frameworks
|
||||
cp $(BIN) $(MACAPPEXE)
|
||||
else
|
||||
all : $(BIN)
|
||||
endif
|
||||
|
||||
|
||||
debug : $(BIN)
|
||||
|
||||
# Make release will strip the executable to make it smaller but non-debugable
|
||||
release : version $(BIN)
|
||||
$(STRIP) $(BIN)
|
||||
|
||||
# Create a zip archive ready for upload to the website, including binaries and sourcecode
|
||||
ziprelease: version $(BIN) release
|
||||
echo `sed "s/.*=\"\(.*\)\";/\1/" pversion.c`.`svnversion` | tr " :" "_-" | sed -e "s/\(wip\)\\./\1/I" > $(OBJDIR)/versiontag
|
||||
|
||||
tar cvzf "../src-`cat $(OBJDIR)/versiontag`.tgz" --strip=1 ../src/*.c ../src/*.h ../src/Makefile ../src/Makefile.dep ../src/gfx2.ico
|
||||
cd .. && $(ZIP) $(ZIPOPT) "grafx2-`cat $(OBJDIR:../%=%)/versiontag`$(TTFLABEL)-$(PLATFORM).$(ZIP)" $(BIN:../%=%) share/grafx2/gfx2def.ini share/grafx2/scripts/bru_*.lua share/grafx2/scripts/pal_*.lua share/grafx2/scripts/pic_*.lua share/grafx2/scripts/scn_*.lua $(SKIN_FILES:../%=%) share/grafx2/gfx2.gif doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt share/grafx2/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 share/grafx2/fonts/Tuffy.ttf src-`cat $(OBJDIR:../%=%)/versiontag`.tgz $(PLATFORMFILES:../%=%)
|
||||
$(DELCOMMAND) "../src-`cat $(OBJDIR)/versiontag`.tgz"
|
||||
tar cvzf "../grafx2-`cat $(OBJDIR)/versiontag`$(TTFLABEL)-src.tgz" --strip=1 --transform 's,^,grafx2/,g' ../src/*.c ../src/*.h ../src/Makefile ../src/Makefile.dep ../share/grafx2/gfx2def.ini ../share/grafx2/scripts/bru_*.lua ../share/grafx2/scripts/pal_*.lua ../share/grafx2/scripts/pic_*.lua ../share/grafx2/scripts/scn_*.lua $(SKIN_FILES) ../src/gfx2.ico ../share/grafx2/gfx2.gif ../doc/README.txt ../doc/COMPILING.txt ../doc/gpl-2.0.txt ../misc/unix/grafx2.1 ../misc/unix/grafx2.xpm ../misc/unix/grafx2.desktop ../share/grafx2/fonts/8pxfont.png ../share/grafx2/fonts/Tuffy.ttf
|
||||
$(DELCOMMAND) "$(OBJDIR)/versiontag"
|
||||
|
||||
testsed :
|
||||
|
||||
$(BIN) : $(OBJ)
|
||||
test -d ../bin || $(MKDIR) ../bin
|
||||
$(CC) $(OBJ) -o $(BIN) $(LOPT) $(LFLAGS)
|
||||
|
||||
# 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
|
||||
$(if $(wildcard $(OBJDIR)),,$(MKDIR) $(OBJDIR))
|
||||
$(CC) $(COPT) $(CFLAGS) -c $*.c -o $(OBJDIR)/$*.o
|
||||
|
||||
$(OBJDIR)/%.o : %.m
|
||||
$(if $(wildcard $(OBJDIR)),,$(MKDIR) $(OBJDIR))
|
||||
$(CC) $(COPT) -c $*.m -o $(OBJDIR)/$*.o
|
||||
|
||||
depend :
|
||||
$(CC) -MM *.c | sed 's:^[^ ]:$$(OBJDIR)/&:' > Makefile.dep
|
||||
|
||||
# Link the icons to the program under windows
|
||||
$(OBJDIR)/winres.o : gfx2.ico
|
||||
echo "1 ICON \"gfx2.ico\"" | $(WINDRES) -o $(OBJDIR)/winres.o
|
||||
|
||||
clean :
|
||||
$(DELCOMMAND) $(OBJ)
|
||||
$(DELCOMMAND) $(BIN)
|
||||
|
||||
ifneq ($(PLATFORM),amiga-vbcc)
|
||||
# Linux installation of the program
|
||||
install : $(BIN)
|
||||
# Create dirs
|
||||
test -d $(DESTDIR)$(bindir) || $(MKDIR) $(DESTDIR)$(bindir)
|
||||
test -d $(DESTDIR)$(datadir)/grafx2 || $(MKDIR) $(DESTDIR)$(datadir)/grafx2
|
||||
test -d $(DESTDIR)$(datadir)/grafx2/fonts || $(MKDIR) $(DESTDIR)$(datadir)/grafx2/fonts
|
||||
test -d $(DESTDIR)$(datadir)/grafx2/skins || $(MKDIR) $(DESTDIR)$(datadir)/grafx2/skins
|
||||
test -d $(DESTDIR)$(datadir)/applications || $(MKDIR) $(DESTDIR)$(datadir)/applications
|
||||
test -d $(DESTDIR)$(datadir)/icons || $(MKDIR) $(DESTDIR)$(datadir)/icons
|
||||
# Copy files
|
||||
$(CP) $(BIN) $(DESTDIR)$(bindir)
|
||||
$(CP) ../share/grafx2/gfx2def.ini $(DESTDIR)$(datadir)/grafx2/
|
||||
$(CP) ../share/grafx2/gfx2.gif $(DESTDIR)$(datadir)/grafx2/
|
||||
$(CP) ../share/grafx2/fonts/* $(DESTDIR)$(datadir)/grafx2/fonts/
|
||||
$(CP) $(SKIN_FILES) $(DESTDIR)$(datadir)/grafx2/skins/
|
||||
# Icon and desktop file for debian
|
||||
$(CP) ../misc/unix/grafx2.desktop $(DESTDIR)$(datadir)/applications/
|
||||
$(CP) ../misc/unix/grafx2.xpm $(DESTDIR)$(datadir)/icons/
|
||||
@echo Install complete
|
||||
|
||||
# Linux uninstallation of the program
|
||||
uninstall :
|
||||
$(DELCOMMAND) $(DESTDIR)$(bindir)/grafx2
|
||||
$(DELCOMMAND) $(DESTDIR)$(datadir)/grafx2/gfx2def.ini
|
||||
$(DELCOMMAND) $(DESTDIR)$(datadir)/grafx2/gfx2.gif
|
||||
$(DELCOMMAND) $(DESTDIR)$(datadir)/grafx2/fonts/*
|
||||
$(if $(wildcard $(DESTDIR)$(datadir)/grafx2/fonts),,$(RMDIR) $(DESTDIR)$(datadir)/grafx2/fonts)
|
||||
cd $(DESTDIR)$(datadir) && $(DELCOMMAND) $(SKIN_FILES)
|
||||
$(if $(wildcard $(DESTDIR)$(datadir)/grafx2/skins),,$(RMDIR) $(DESTDIR)$(datadir)/grafx2/skins)
|
||||
$(if $(wildcard $(DESTDIR)$(datadir)/grafx2),,$(RMDIR) $(DESTDIR)$(datadir)/grafx2)
|
||||
# Icon and desktop file for debian
|
||||
$(DELCOMMAND) $(DESTDIR)$(datadir)/applications/grafx2.desktop
|
||||
$(DELCOMMAND) $(DESTDIR)$(datadir)/icons/grafx2.xpm
|
||||
@echo Uninstall complete
|
||||
|
||||
endif
|
||||
|
||||
-include Makefile.dep
|
||||
|
||||
97
src/Makefile.dep
Normal file
97
src/Makefile.dep
Normal file
@@ -0,0 +1,97 @@
|
||||
$(OBJDIR)/SFont.o: SFont.c SFont.h
|
||||
$(OBJDIR)/brush.o: brush.c global.h struct.h const.h graph.h misc.h errors.h \
|
||||
windows.h sdlscreen.h brush.h
|
||||
$(OBJDIR)/brush_ops.o: brush_ops.c brush.h struct.h const.h buttons.h engine.h \
|
||||
global.h graph.h misc.h operatio.h pages.h sdlscreen.h windows.h
|
||||
$(OBJDIR)/buttons.o: buttons.c const.h struct.h global.h misc.h graph.h engine.h \
|
||||
readline.h filesel.h loadsave.h init.h buttons.h operatio.h pages.h \
|
||||
palette.h errors.h readini.h saveini.h shade.h io.h help.h text.h \
|
||||
sdlscreen.h windows.h brush.h input.h special.h
|
||||
$(OBJDIR)/buttons_effects.o: buttons_effects.c buttons.h struct.h const.h engine.h \
|
||||
global.h graph.h help.h input.h misc.h readline.h sdlscreen.h windows.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 \
|
||||
input.h engine.h pages.h layers.h
|
||||
$(OBJDIR)/factory.o: factory.c brush.h struct.h const.h buttons.h engine.h errors.h \
|
||||
filesel.h loadsave.h global.h graph.h io.h misc.h pages.h readline.h \
|
||||
sdlscreen.h windows.h palette.h input.h help.h
|
||||
$(OBJDIR)/fileformats.o: fileformats.c errors.h global.h struct.h const.h \
|
||||
loadsave.h misc.h io.h windows.h pages.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 \
|
||||
input.h help.h filesel.h
|
||||
$(OBJDIR)/graph.o: graph.c global.h struct.h const.h engine.h buttons.h pages.h \
|
||||
errors.h sdlscreen.h graph.h misc.h pxsimple.h pxtall.h pxwide.h \
|
||||
pxdouble.h pxtriple.h pxwide2.h pxtall2.h pxquad.h windows.h input.h
|
||||
$(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 \
|
||||
errors.h pages.h
|
||||
$(OBJDIR)/hotkeys.o: hotkeys.c struct.h const.h global.h hotkeys.h
|
||||
$(OBJDIR)/init.o: init.c buttons.h struct.h const.h errors.h global.h graph.h \
|
||||
init.h io.h factory.h help.h hotkeys.h keyboard.h loadsave.h misc.h \
|
||||
mountlist.h operatio.h palette.h sdlscreen.h setup.h transform.h \
|
||||
windows.h layers.h
|
||||
$(OBJDIR)/input.o: input.c global.h struct.h const.h keyboard.h sdlscreen.h \
|
||||
windows.h errors.h misc.h input.h
|
||||
$(OBJDIR)/io.o: io.c struct.h const.h io.h realpath.h
|
||||
$(OBJDIR)/keyboard.o: keyboard.c global.h struct.h const.h keyboard.h
|
||||
$(OBJDIR)/layers.o: layers.c const.h struct.h global.h windows.h engine.h pages.h \
|
||||
sdlscreen.h input.h help.h misc.h
|
||||
$(OBJDIR)/libraw2crtc.o: libraw2crtc.c const.h global.h struct.h loadsave.h
|
||||
$(OBJDIR)/loadsave.o: loadsave.c buttons.h struct.h const.h errors.h global.h io.h \
|
||||
loadsave.h misc.h graph.h op_c.h pages.h palette.h sdlscreen.h \
|
||||
windows.h engine.h
|
||||
$(OBJDIR)/main.o: main.c const.h struct.h global.h graph.h misc.h init.h buttons.h \
|
||||
engine.h pages.h loadsave.h sdlscreen.h errors.h readini.h saveini.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 \
|
||||
engine.h misc.h keyboard.h windows.h palette.h input.h graph.h pages.h
|
||||
$(OBJDIR)/miscfileformats.o: miscfileformats.c engine.h struct.h const.h errors.h \
|
||||
global.h io.h libraw2crtc.h loadsave.h misc.h sdlscreen.h windows.h
|
||||
$(OBJDIR)/mountlist.o: mountlist.c
|
||||
$(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 \
|
||||
operatio.h buttons.h pages.h errors.h sdlscreen.h brush.h windows.h
|
||||
$(OBJDIR)/pages.o: pages.c global.h struct.h const.h pages.h errors.h loadsave.h \
|
||||
misc.h windows.h
|
||||
$(OBJDIR)/palette.o: palette.c const.h struct.h global.h misc.h engine.h readline.h \
|
||||
buttons.h pages.h help.h sdlscreen.h errors.h op_c.h windows.h input.h \
|
||||
palette.h shade.h
|
||||
$(OBJDIR)/pversion.o: pversion.c
|
||||
$(OBJDIR)/pxdouble.o: pxdouble.c global.h struct.h const.h sdlscreen.h misc.h \
|
||||
graph.h pxdouble.h pxwide.h
|
||||
$(OBJDIR)/pxquad.o: pxquad.c global.h struct.h const.h sdlscreen.h misc.h graph.h \
|
||||
pxquad.h
|
||||
$(OBJDIR)/pxsimple.o: pxsimple.c global.h struct.h const.h sdlscreen.h misc.h \
|
||||
graph.h pxsimple.h
|
||||
$(OBJDIR)/pxtall.o: pxtall.c global.h struct.h const.h sdlscreen.h misc.h graph.h \
|
||||
pxtall.h pxsimple.h
|
||||
$(OBJDIR)/pxtall2.o: pxtall2.c global.h struct.h const.h sdlscreen.h misc.h graph.h \
|
||||
pxtall2.h
|
||||
$(OBJDIR)/pxtriple.o: pxtriple.c global.h struct.h const.h sdlscreen.h misc.h \
|
||||
graph.h pxtriple.h
|
||||
$(OBJDIR)/pxwide.o: pxwide.c global.h struct.h const.h sdlscreen.h misc.h graph.h \
|
||||
pxwide.h
|
||||
$(OBJDIR)/pxwide2.o: pxwide2.c global.h struct.h const.h sdlscreen.h misc.h graph.h \
|
||||
pxwide2.h
|
||||
$(OBJDIR)/readini.o: readini.c const.h errors.h global.h struct.h misc.h readini.h
|
||||
$(OBJDIR)/readline.o: readline.c const.h struct.h global.h misc.h errors.h \
|
||||
sdlscreen.h readline.h windows.h input.h
|
||||
$(OBJDIR)/realpath.o: realpath.c
|
||||
$(OBJDIR)/saveini.o: saveini.c const.h global.h struct.h readini.h io.h errors.h \
|
||||
misc.h saveini.h
|
||||
$(OBJDIR)/sdlscreen.o: sdlscreen.c global.h struct.h const.h sdlscreen.h errors.h \
|
||||
misc.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 errors.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 \
|
||||
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 \
|
||||
errors.h
|
||||
$(OBJDIR)/transform.o: transform.c global.h struct.h const.h transform.h engine.h \
|
||||
sdlscreen.h windows.h input.h help.h misc.h readline.h buttons.h \
|
||||
pages.h
|
||||
$(OBJDIR)/version.o: version.c
|
||||
$(OBJDIR)/windows.o: windows.c windows.h struct.h const.h engine.h errors.h \
|
||||
global.h graph.h input.h misc.h readline.h sdlscreen.h
|
||||
11
src/SDLMain.h
Normal file
11
src/SDLMain.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
|
||||
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
|
||||
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
|
||||
|
||||
Feel free to customize this file to suit your needs
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface SDLMain : NSObject
|
||||
@end
|
||||
399
src/SDLMain.m
Normal file
399
src/SDLMain.m
Normal file
@@ -0,0 +1,399 @@
|
||||
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
|
||||
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
|
||||
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
|
||||
|
||||
Feel free to customize this file to suit your needs
|
||||
*/
|
||||
|
||||
#import "SDL.h"
|
||||
#import "SDLMain.h"
|
||||
#import <sys/param.h> /* for MAXPATHLEN */
|
||||
#import <unistd.h>
|
||||
|
||||
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
|
||||
but the method still is there and works. To avoid warnings, we declare
|
||||
it ourselves here. */
|
||||
@interface NSApplication(SDL_Missing_Methods)
|
||||
- (void)setAppleMenu:(NSMenu *)menu;
|
||||
@end
|
||||
|
||||
/* Use this flag to determine whether we use SDLMain.nib or not */
|
||||
#define SDL_USE_NIB_FILE 0
|
||||
|
||||
/* Use this flag to determine whether we use CPS (docking) or not */
|
||||
#define SDL_USE_CPS 1
|
||||
#ifdef SDL_USE_CPS
|
||||
/* Portions of CPS.h */
|
||||
typedef struct CPSProcessSerNum
|
||||
{
|
||||
UInt32 lo;
|
||||
UInt32 hi;
|
||||
} CPSProcessSerNum;
|
||||
|
||||
extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
|
||||
extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
|
||||
extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
|
||||
|
||||
#endif /* SDL_USE_CPS */
|
||||
|
||||
static int gArgc;
|
||||
static char **gArgv;
|
||||
static BOOL gFinderLaunch;
|
||||
static BOOL gCalledAppMainline = FALSE;
|
||||
|
||||
static NSString *getApplicationName(void)
|
||||
{
|
||||
NSDictionary *dict;
|
||||
NSString *appName = 0;
|
||||
|
||||
/* Determine the application name */
|
||||
dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
|
||||
if (dict)
|
||||
appName = [dict objectForKey: @"CFBundleName"];
|
||||
|
||||
if (![appName length])
|
||||
appName = [[NSProcessInfo processInfo] processName];
|
||||
|
||||
return appName;
|
||||
}
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
/* A helper category for NSString */
|
||||
@interface NSString (ReplaceSubString)
|
||||
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@interface SDLApplication : NSApplication
|
||||
@end
|
||||
|
||||
@implementation SDLApplication
|
||||
/* Invoked from the Quit menu item */
|
||||
- (void)terminate:(id)sender
|
||||
{
|
||||
/* Post a SDL_QUIT event */
|
||||
SDL_Event event;
|
||||
event.type = SDL_QUIT;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
/* override NSApplication:sendEvent, to keep Cocoa from beeping on
|
||||
non-command keystrokes */
|
||||
- (void)sendEvent:(NSEvent *)anEvent {
|
||||
if (NSKeyDown == [anEvent type] || NSKeyUp == [anEvent type]) {
|
||||
if ([anEvent modifierFlags] & NSCommandKeyMask)
|
||||
{
|
||||
SDL_SetModState(SDL_GetModState() | KMOD_META);
|
||||
[super sendEvent: anEvent];
|
||||
}
|
||||
} else
|
||||
{
|
||||
[super sendEvent: anEvent];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
/* The main class of the application, the application's delegate */
|
||||
@implementation SDLMain
|
||||
|
||||
/* Set the working directory to the .app's parent directory */
|
||||
- (void) setupWorkingDirectory:(BOOL)shouldChdir
|
||||
{
|
||||
if (shouldChdir)
|
||||
{
|
||||
char parentdir[MAXPATHLEN];
|
||||
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||
CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
|
||||
if (CFURLGetFileSystemRepresentation(url2, true, (UInt8 *)parentdir, MAXPATHLEN)) {
|
||||
assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
|
||||
}
|
||||
CFRelease(url);
|
||||
CFRelease(url2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
|
||||
/* Fix menu to contain the real app name instead of "SDL App" */
|
||||
- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName
|
||||
{
|
||||
NSRange aRange;
|
||||
NSEnumerator *enumerator;
|
||||
NSMenuItem *menuItem;
|
||||
|
||||
aRange = [[aMenu title] rangeOfString:@"SDL App"];
|
||||
if (aRange.length != 0)
|
||||
[aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
|
||||
|
||||
enumerator = [[aMenu itemArray] objectEnumerator];
|
||||
while ((menuItem = [enumerator nextObject]))
|
||||
{
|
||||
aRange = [[menuItem title] rangeOfString:@"SDL App"];
|
||||
if (aRange.length != 0)
|
||||
[menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]];
|
||||
if ([menuItem hasSubmenu])
|
||||
[self fixMenu:[menuItem submenu] withAppName:appName];
|
||||
}
|
||||
[ aMenu sizeToFit ];
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void setApplicationMenu(void)
|
||||
{
|
||||
/* warning: this code is very odd */
|
||||
NSMenu *appleMenu;
|
||||
NSMenuItem *menuItem;
|
||||
NSString *title;
|
||||
NSString *appName;
|
||||
|
||||
appName = getApplicationName();
|
||||
appleMenu = [[NSMenu alloc] initWithTitle:@""];
|
||||
|
||||
/* Add menu items */
|
||||
title = [@"About " stringByAppendingString:appName];
|
||||
[appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
|
||||
|
||||
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
title = [@"Hide " stringByAppendingString:appName];
|
||||
[appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
|
||||
|
||||
menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
|
||||
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
|
||||
|
||||
[appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
|
||||
|
||||
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
title = [@"Quit " stringByAppendingString:appName];
|
||||
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
|
||||
|
||||
|
||||
/* Put menu into the menubar */
|
||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
|
||||
[menuItem setSubmenu:appleMenu];
|
||||
[[NSApp mainMenu] addItem:menuItem];
|
||||
|
||||
/* Tell the application object that this is now the application menu */
|
||||
[NSApp setAppleMenu:appleMenu];
|
||||
|
||||
/* Finally give up our references to the objects */
|
||||
[appleMenu release];
|
||||
[menuItem release];
|
||||
}
|
||||
|
||||
/* Create a window menu */
|
||||
static void setupWindowMenu(void)
|
||||
{
|
||||
NSMenu *windowMenu;
|
||||
NSMenuItem *windowMenuItem;
|
||||
NSMenuItem *menuItem;
|
||||
|
||||
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
|
||||
|
||||
/* "Minimize" item */
|
||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
|
||||
[windowMenu addItem:menuItem];
|
||||
[menuItem release];
|
||||
|
||||
/* Put menu into the menubar */
|
||||
windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
||||
[windowMenuItem setSubmenu:windowMenu];
|
||||
[[NSApp mainMenu] addItem:windowMenuItem];
|
||||
|
||||
/* Tell the application object that this is now the window menu */
|
||||
[NSApp setWindowsMenu:windowMenu];
|
||||
|
||||
/* Finally give up our references to the objects */
|
||||
[windowMenu release];
|
||||
[windowMenuItem release];
|
||||
}
|
||||
|
||||
/* Replacement for NSApplicationMain */
|
||||
static void CustomApplicationMain (int argc, char **argv)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
SDLMain *sdlMain;
|
||||
|
||||
/* Ensure the application object is initialised */
|
||||
[SDLApplication sharedApplication];
|
||||
|
||||
#ifdef SDL_USE_CPS
|
||||
{
|
||||
CPSProcessSerNum PSN;
|
||||
/* Tell the dock about us */
|
||||
if (!CPSGetCurrentProcess(&PSN))
|
||||
if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
|
||||
if (!CPSSetFrontProcess(&PSN))
|
||||
[SDLApplication sharedApplication];
|
||||
}
|
||||
#endif /* SDL_USE_CPS */
|
||||
|
||||
/* Set up the menubar */
|
||||
[NSApp setMainMenu:[[NSMenu alloc] init]];
|
||||
setApplicationMenu();
|
||||
setupWindowMenu();
|
||||
|
||||
/* Create SDLMain and make it the app delegate */
|
||||
sdlMain = [[SDLMain alloc] init];
|
||||
[NSApp setDelegate:sdlMain];
|
||||
|
||||
/* Start the main event loop */
|
||||
[NSApp run];
|
||||
|
||||
[sdlMain release];
|
||||
[pool release];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Catch document open requests...this lets us notice files when the app
|
||||
* was launched by double-clicking a document, or when a document was
|
||||
* dragged/dropped on the app's icon. You need to have a
|
||||
* CFBundleDocumentsType section in your Info.plist to get this message,
|
||||
* apparently.
|
||||
*
|
||||
* Files are added to gArgv, so to the app, they'll look like command line
|
||||
* arguments. Previously, apps launched from the finder had nothing but
|
||||
* an argv[0].
|
||||
*
|
||||
* This message may be received multiple times to open several docs on launch.
|
||||
*
|
||||
* This message is ignored once the app's mainline has been called.
|
||||
*/
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
const char *temparg;
|
||||
size_t arglen;
|
||||
char *arg;
|
||||
char **newargv;
|
||||
|
||||
if (!gFinderLaunch) /* MacOS is passing command line args. */
|
||||
return FALSE;
|
||||
|
||||
if (gCalledAppMainline) /* app has started, ignore this document. */
|
||||
return FALSE;
|
||||
|
||||
temparg = [filename UTF8String];
|
||||
arglen = SDL_strlen(temparg) + 1;
|
||||
arg = (char *) SDL_malloc(arglen);
|
||||
if (arg == NULL)
|
||||
return FALSE;
|
||||
|
||||
newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
|
||||
if (newargv == NULL)
|
||||
{
|
||||
SDL_free(arg);
|
||||
return FALSE;
|
||||
}
|
||||
gArgv = newargv;
|
||||
|
||||
SDL_strlcpy(arg, temparg, arglen);
|
||||
gArgv[gArgc++] = arg;
|
||||
gArgv[gArgc] = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Called when the internal event loop has just started running */
|
||||
- (void) applicationDidFinishLaunching: (NSNotification *) note
|
||||
{
|
||||
int status;
|
||||
|
||||
/* Set the working directory to the .app's parent directory */
|
||||
[self setupWorkingDirectory:gFinderLaunch];
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
/* Set the main menu to contain the real app name instead of "SDL App" */
|
||||
[self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
|
||||
#endif
|
||||
|
||||
setenv("SDL_ENABLEAPPEVENTS", "1", 1);
|
||||
|
||||
/* Hand off to main application code */
|
||||
gCalledAppMainline = TRUE;
|
||||
status = SDL_main (gArgc, gArgv);
|
||||
|
||||
/* We're done, thank you for playing */
|
||||
exit(status);
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSString (ReplaceSubString)
|
||||
|
||||
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
|
||||
{
|
||||
unsigned int bufferSize;
|
||||
unsigned int selfLen = [self length];
|
||||
unsigned int aStringLen = [aString length];
|
||||
unichar *buffer;
|
||||
NSRange localRange;
|
||||
NSString *result;
|
||||
|
||||
bufferSize = selfLen + aStringLen - aRange.length;
|
||||
buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar));
|
||||
|
||||
/* Get first part into buffer */
|
||||
localRange.location = 0;
|
||||
localRange.length = aRange.location;
|
||||
[self getCharacters:buffer range:localRange];
|
||||
|
||||
/* Get middle part into buffer */
|
||||
localRange.location = 0;
|
||||
localRange.length = aStringLen;
|
||||
[aString getCharacters:(buffer+aRange.location) range:localRange];
|
||||
|
||||
/* Get last part into buffer */
|
||||
localRange.location = aRange.location + aRange.length;
|
||||
localRange.length = selfLen - localRange.location;
|
||||
[self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
|
||||
|
||||
/* Build output string */
|
||||
result = [NSString stringWithCharacters:buffer length:bufferSize];
|
||||
|
||||
NSDeallocateMemoryPages(buffer, bufferSize);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#ifdef main
|
||||
# undef main
|
||||
#endif
|
||||
|
||||
|
||||
/* Main entry point to executable - should *not* be SDL_main! */
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* Copy the arguments into a global variable */
|
||||
/* This is passed if we are launched by double-clicking */
|
||||
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
|
||||
gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
|
||||
gArgv[0] = argv[0];
|
||||
gArgv[1] = NULL;
|
||||
gArgc = 1;
|
||||
gFinderLaunch = YES;
|
||||
} else {
|
||||
int i;
|
||||
gArgc = argc;
|
||||
gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
|
||||
for (i = 0; i <= argc; i++)
|
||||
gArgv[i] = argv[i];
|
||||
gFinderLaunch = NO;
|
||||
}
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
[SDLApplication poseAsClass:[NSApplication class]];
|
||||
NSApplicationMain (argc, argv);
|
||||
#else
|
||||
CustomApplicationMain (argc, argv);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
178
src/SFont.c
Normal file
178
src/SFont.c
Normal file
@@ -0,0 +1,178 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* SFont: a simple font-library that uses special .pngs as fonts
|
||||
Copyright (C) 2003 Karl Bartel
|
||||
|
||||
License: GPL or LGPL (at your choice)
|
||||
WWW: http://www.linux-games.com/sfont/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Karl Bartel
|
||||
Cecilienstr. 14
|
||||
12307 Berlin
|
||||
GERMANY
|
||||
karlb@gmx.net
|
||||
*/
|
||||
#include <SDL.h>
|
||||
#include <SDL_video.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include "SFont.h"
|
||||
|
||||
static Uint32 GetPixel(SDL_Surface *Surface, Sint32 X, Sint32 Y)
|
||||
{
|
||||
Uint8 *bits;
|
||||
Uint32 Bpp;
|
||||
|
||||
assert(X>=0);
|
||||
assert(X<Surface->w);
|
||||
|
||||
Bpp = Surface->format->BytesPerPixel;
|
||||
bits = ((Uint8 *)Surface->pixels)+Y*Surface->pitch+X*Bpp;
|
||||
|
||||
// Get the pixel
|
||||
switch(Bpp) {
|
||||
case 1:
|
||||
return *((Uint8 *)Surface->pixels + Y * Surface->pitch + X);
|
||||
break;
|
||||
case 2:
|
||||
return *((Uint16 *)Surface->pixels + Y * Surface->pitch/2 + X);
|
||||
break;
|
||||
case 3: { // Format/endian independent
|
||||
Uint8 r, g, b;
|
||||
r = *((bits)+Surface->format->Rshift/8);
|
||||
g = *((bits)+Surface->format->Gshift/8);
|
||||
b = *((bits)+Surface->format->Bshift/8);
|
||||
return SDL_MapRGB(Surface->format, r, g, b);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
return *((Uint32 *)Surface->pixels + Y * Surface->pitch/4 + X);
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
SFont_Font* SFont_InitFont(SDL_Surface* Surface)
|
||||
{
|
||||
int x = 0, i = 0;
|
||||
Uint32 pixel;
|
||||
SFont_Font* Font;
|
||||
Uint32 pink;
|
||||
|
||||
if (Surface == NULL)
|
||||
return NULL;
|
||||
|
||||
Font = (SFont_Font *) malloc(sizeof(SFont_Font));
|
||||
Font->Surface = Surface;
|
||||
|
||||
SDL_LockSurface(Surface);
|
||||
|
||||
pink = SDL_MapRGB(Surface->format, 255, 0, 255);
|
||||
while (x < Surface->w) {
|
||||
if (GetPixel(Surface, x, 0) == pink) {
|
||||
Font->CharPos[i++]=x;
|
||||
while((x < Surface->w) && (GetPixel(Surface, x, 0)== pink))
|
||||
x++;
|
||||
Font->CharPos[i++]=x;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
Font->MaxPos = x-1;
|
||||
|
||||
pixel = GetPixel(Surface, 0, Surface->h-1);
|
||||
SDL_UnlockSurface(Surface);
|
||||
SDL_SetColorKey(Surface, SDL_SRCCOLORKEY, pixel);
|
||||
|
||||
return Font;
|
||||
}
|
||||
|
||||
void SFont_FreeFont(SFont_Font* FontInfo)
|
||||
{
|
||||
SDL_FreeSurface(FontInfo->Surface);
|
||||
free(FontInfo);
|
||||
}
|
||||
|
||||
void SFont_Write(SDL_Surface *Surface, const SFont_Font *Font,
|
||||
int x, int y, const char *text)
|
||||
{
|
||||
const char* c;
|
||||
int charoffset;
|
||||
SDL_Rect srcrect, dstrect;
|
||||
|
||||
if(text == NULL)
|
||||
return;
|
||||
|
||||
// these values won't change in the loop
|
||||
srcrect.y = 1;
|
||||
dstrect.y = y;
|
||||
srcrect.h = dstrect.h = Font->Surface->h - 1;
|
||||
|
||||
for(c = text; *c != '\0' && x <= Surface->w ; c++) {
|
||||
charoffset = ((int) (*c - 33)) * 2 + 1;
|
||||
// skip spaces and nonprintable characters
|
||||
if (*c == ' ' || charoffset < 0 || charoffset > Font->MaxPos) {
|
||||
x += Font->CharPos[2]-Font->CharPos[1];
|
||||
continue;
|
||||
}
|
||||
|
||||
srcrect.w = Font->CharPos[charoffset+2] - Font->CharPos[charoffset];
|
||||
dstrect.w = srcrect.w;
|
||||
srcrect.x = Font->CharPos[charoffset];
|
||||
dstrect.x = x;
|
||||
|
||||
SDL_BlitSurface(Font->Surface, &srcrect, Surface, &dstrect);
|
||||
|
||||
x += Font->CharPos[charoffset+1] - Font->CharPos[charoffset];
|
||||
}
|
||||
}
|
||||
|
||||
int SFont_TextWidth(const SFont_Font *Font, const char *text)
|
||||
{
|
||||
const char* c;
|
||||
int charoffset=0;
|
||||
int width = 0;
|
||||
|
||||
if(text == NULL)
|
||||
return 0;
|
||||
|
||||
for(c = text; *c != '\0'; c++) {
|
||||
charoffset = ((int) *c - 33) * 2 + 1;
|
||||
// skip spaces and nonprintable characters
|
||||
if (*c == ' ' || charoffset < 0 || charoffset > Font->MaxPos) {
|
||||
width += Font->CharPos[2]-Font->CharPos[1];
|
||||
continue;
|
||||
}
|
||||
|
||||
width += Font->CharPos[charoffset+1] - Font->CharPos[charoffset];
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
int SFont_TextHeight(const SFont_Font* Font)
|
||||
{
|
||||
return Font->Surface->h - 1;
|
||||
}
|
||||
|
||||
void SFont_WriteCenter(SDL_Surface *Surface, const SFont_Font *Font,
|
||||
int y, const char *text)
|
||||
{
|
||||
SFont_Write(Surface, Font, Surface->w/2 - SFont_TextWidth(Font, text)/2,
|
||||
y, text);
|
||||
}
|
||||
|
||||
98
src/SFont.h
Normal file
98
src/SFont.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* SFont: a simple font-library that uses special bitmaps as fonts
|
||||
Copyright (C) 2003 Karl Bartel
|
||||
|
||||
License: GPL or LGPL (at your choice)
|
||||
WWW: http://www.linux-games.com/sfont/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Karl Bartel
|
||||
Cecilienstr. 14
|
||||
12307 Berlin
|
||||
GERMANY
|
||||
karlb@gmx.net
|
||||
*/
|
||||
|
||||
/************************************************************************
|
||||
* SFONT - SDL Font Library by Karl Bartel <karlb@gmx.net> *
|
||||
* *
|
||||
* All functions are explained below. For further information, take a *
|
||||
* look at the example files, the links at the SFont web site, or *
|
||||
* contact me, if you problem isn' addressed anywhere. *
|
||||
* *
|
||||
************************************************************************/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///@file SFont.h
|
||||
/// Text rendering system, that uses bitmaps as fonts.
|
||||
/// Not specific to Grafx2, it writes to SDL_Surface.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef _SFONT_H_
|
||||
#define _SFONT_H_
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Declare one variable of this type for each font you are using.
|
||||
/// To load the fonts, load the font image into YourFont->Surface
|
||||
/// and call InitFont( YourFont );
|
||||
typedef struct {
|
||||
SDL_Surface *Surface;
|
||||
int CharPos[512];
|
||||
int MaxPos;
|
||||
} SFont_Font;
|
||||
|
||||
///
|
||||
/// Initializes the font.
|
||||
/// @param Font this contains the suface with the font.
|
||||
/// The Surface must be loaded before calling this function
|
||||
SFont_Font* SFont_InitFont (SDL_Surface *Font);
|
||||
|
||||
///
|
||||
/// Frees the font.
|
||||
/// @param Font The font to free
|
||||
/// The font must be loaded before using this function.
|
||||
void SFont_FreeFont(SFont_Font* Font);
|
||||
|
||||
///
|
||||
/// Blits a string to a surface.
|
||||
/// @param Surface The surface you want to blit to.
|
||||
/// @param Font The font to use.
|
||||
/// @param text A string containing the text you want to blit.
|
||||
/// @param x Coordinates to start drawing.
|
||||
/// @param y Coordinates to start drawing.
|
||||
void SFont_Write(SDL_Surface *Surface, const SFont_Font *Font, int x, int y,
|
||||
const char *text);
|
||||
|
||||
/// Returns the width of "text" in pixels
|
||||
int SFont_TextWidth(const SFont_Font* Font, const char *text);
|
||||
/// Returns the height of "text" in pixels (which is always equal to Font->Surface->h)
|
||||
int SFont_TextHeight(const SFont_Font* Font);
|
||||
|
||||
/// Blits a string to Surface with centered x position
|
||||
void SFont_WriteCenter(SDL_Surface *Surface, const SFont_Font* Font, int y,
|
||||
const char *text);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SFONT_H */
|
||||
1985
src/brush.c
Normal file
1985
src/brush.c
Normal file
File diff suppressed because it is too large
Load Diff
120
src/brush.h
Normal file
120
src/brush.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007-2008 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 brush.h
|
||||
/// Actions on the brush.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __BRUSH_H_
|
||||
#define __BRUSH_H_
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
/*!
|
||||
Gets the brush from the picture.
|
||||
@param start_x left edge coordinate in the picture
|
||||
@param start_y upper edge coordinate in the picture
|
||||
@param end_x right edge coordinate in the picture
|
||||
@param end_y bottom edge coordinate in the picture
|
||||
@param clear If 1, the area is also cleared from the picture.
|
||||
*/
|
||||
void Capture_brush(short start_x,short start_y,short end_x,short end_y,short clear);
|
||||
|
||||
/*!
|
||||
Rotates the brush to the right.
|
||||
*/
|
||||
void Rotate_90_deg(void);
|
||||
|
||||
/*!
|
||||
Stretch the brush to fit the given rectangle.
|
||||
*/
|
||||
void Stretch_brush(short x1, short y1, short x2, short y2);
|
||||
|
||||
/*!
|
||||
Stretch the brush to fit the given rectangle.
|
||||
Uses fast approximation for the preview while drawing the rectangle on screen.
|
||||
*/
|
||||
void Stretch_brush_preview(short x1, short y1, short x2, short y2);
|
||||
|
||||
/*!
|
||||
Rotates the brush to the right from the given angle.
|
||||
*/
|
||||
void Rotate_brush(float angle);
|
||||
|
||||
/*!
|
||||
Stretch the brush to fit the given rectangle.
|
||||
Uses fast approximation for the preview while changing the angle.
|
||||
*/
|
||||
void Rotate_brush_preview(float angle);
|
||||
|
||||
/*!
|
||||
Remap the brush palette to the nearest color in the picture one.
|
||||
Used when switching to the spare page.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Distort the brush on the screen.
|
||||
*/
|
||||
void Distort_brush_preview(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4);
|
||||
|
||||
/*!
|
||||
Replace the brush by a distorted version of itself.
|
||||
*/
|
||||
void Distort_brush(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4);
|
||||
|
||||
|
||||
void Remap_brush(void);
|
||||
|
||||
/*!
|
||||
Get color indexes used by the brush.
|
||||
*/
|
||||
void Get_colors_from_brush(void);
|
||||
|
||||
/*!
|
||||
Outline the brush, add 1 foreground-colored pixel on the edges.
|
||||
Edges are detected considering the backcolor as transparent.
|
||||
*/
|
||||
void Outline_brush(void);
|
||||
|
||||
/*!
|
||||
Nibble the brush, remove 1 pixel on the edges and make it transparent (ie filled with back color).
|
||||
Edges are detected considering the backcolor as transparent.
|
||||
*/
|
||||
void Nibble_brush(void);
|
||||
|
||||
/*!
|
||||
Get brush from picture according to a freehand form.
|
||||
@param vertices number of points in the freehand form
|
||||
@param points array of points coordinates
|
||||
@param clear If set to 1, the captured area is also cleared from the picture.
|
||||
*/
|
||||
void Capture_brush_with_lasso(int vertices, short * points,short clear);
|
||||
|
||||
|
||||
///
|
||||
/// Changes the Brush size, discarding its previous content.
|
||||
/// @return 0 OK, 1 Failed
|
||||
byte Realloc_brush(word new_brush_width, word new_brush_height);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
1293
src/brush_ops.c
Normal file
1293
src/brush_ops.c
Normal file
File diff suppressed because it is too large
Load Diff
4806
src/buttons.c
Normal file
4806
src/buttons.c
Normal file
File diff suppressed because it is too large
Load Diff
674
src/buttons.h
Normal file
674
src/buttons.h
Normal file
@@ -0,0 +1,674 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 buttons.h
|
||||
/// Almost all the editor actions that are called by the menu are here.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __BOUTONS_H_
|
||||
#define __BOUTONS_H_
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
void Stencil_update_color(byte color);
|
||||
void Stencil_tag_color(byte color, byte tag_color);
|
||||
|
||||
/*!
|
||||
Displays an error message when there is no more memory for the requested
|
||||
operation.
|
||||
*/
|
||||
void Message_out_of_memory(void);
|
||||
|
||||
/*!
|
||||
Displays the splash screen at program startup.
|
||||
*/
|
||||
void Button_Message_initial(void);
|
||||
|
||||
/*!
|
||||
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.
|
||||
These functions don't need (and will not work with) a custom brush.
|
||||
*/
|
||||
void Change_paintbrush_shape(byte shape);
|
||||
|
||||
// Boutons relatifs aux couleurs
|
||||
|
||||
|
||||
/*!
|
||||
Callback for the palette scroller buttons left click.
|
||||
Scrolls the menubar palette one column to the left.
|
||||
*/
|
||||
void Button_Pal_left(void);
|
||||
|
||||
/*!
|
||||
Callback for the palette scroller buttons right click.
|
||||
Scrolls the menubar palette faster to the left.
|
||||
*/
|
||||
void Button_Pal_left_fast(void);
|
||||
|
||||
/*!
|
||||
Callback for the palette scroller buttons left click.
|
||||
Scrolls the menubar palette one column to the right.
|
||||
*/
|
||||
void Button_Pal_right(void);
|
||||
|
||||
/*!
|
||||
Callback for the palette scroller buttons right click.
|
||||
Scrolls the menubar palette faster to the right.
|
||||
*/
|
||||
void Button_Pal_right_fast(void);
|
||||
|
||||
/*!
|
||||
Callback for the palette color buttons left click.
|
||||
Selects the foreground drawing color when clicking on the menubar palette.
|
||||
*/
|
||||
void Button_Select_forecolor(void);
|
||||
|
||||
/*!
|
||||
Callback for the palette color buttons right click.
|
||||
Selects the background drawing color when clicking on the menubar palette.
|
||||
*/
|
||||
void Button_Select_backcolor(void);
|
||||
|
||||
// Boutons relatifs au pinceaux
|
||||
|
||||
/*!
|
||||
Callback for the brush button left click.
|
||||
Selects the monochrome brush mode when right clicking on the brush button.
|
||||
*/
|
||||
void Button_Brush_monochrome(void);
|
||||
|
||||
/*!
|
||||
Callback for the brush button right click.
|
||||
Displays the "Paintbrush menu".
|
||||
*/
|
||||
void Button_Paintbrush_menu(void);
|
||||
|
||||
// Boutons relatifs au mode de dessin à main levée
|
||||
|
||||
/*!
|
||||
Callback for the freehand draw button left click.
|
||||
Selects freehand drawing mode, depending on the current state of the freehand button.
|
||||
*/
|
||||
void Button_Draw(void);
|
||||
|
||||
/*!
|
||||
Callback for the freehand draw button right click.
|
||||
Cycles the drawing modes for the freehand tool.
|
||||
*/
|
||||
void Button_Draw_switch_mode(void);
|
||||
|
||||
// Dessin par ligne
|
||||
|
||||
/*!
|
||||
Callback for the lines button left click.
|
||||
Selects lines drawing mode, depending on the current state of the lines button.
|
||||
*/
|
||||
void Button_Lines(void);
|
||||
|
||||
/*!
|
||||
Callback for the lines button right click.
|
||||
Cycles the drawing modes for the lines tool.
|
||||
*/
|
||||
void Button_Lines_switch_mode(void);
|
||||
|
||||
// Button relatif au remplissage
|
||||
|
||||
/*!
|
||||
Callback for the fill button left click.
|
||||
Start the filling operation.
|
||||
*/
|
||||
void Button_Fill(void);
|
||||
|
||||
/*!
|
||||
Callback for the fill button right click.
|
||||
Start the color replace operation.
|
||||
*/
|
||||
void Button_Replace(void);
|
||||
|
||||
/*!
|
||||
Disable and release the fill button.
|
||||
Restores the cursor (custom brushes are disabled for the fill operation).
|
||||
Cleans the status bar if the color replacement tool put a preview color inside it.
|
||||
*/
|
||||
void Button_Unselect_fill(void);
|
||||
|
||||
// Spray
|
||||
|
||||
/*!
|
||||
Callback for the spray button left click.
|
||||
Start the spray operation.
|
||||
*/
|
||||
void Button_Airbrush(void);
|
||||
|
||||
/*!
|
||||
Callback for the spray button right click.
|
||||
Opens the spray's setup menu.
|
||||
*/
|
||||
void Button_Airbrush_menu(void);
|
||||
|
||||
// Courbes de Bézier
|
||||
|
||||
/*!
|
||||
Callback for the curves button left click.
|
||||
Start curve operation according to the selected mode.
|
||||
*/
|
||||
void Button_Curves(void);
|
||||
|
||||
/*!
|
||||
Callback for the curves button right click.
|
||||
Select the curve mode (1-point, 2-point)
|
||||
*/
|
||||
void Button_Curves_switch_mode(void);
|
||||
|
||||
// Boutons relatifs aux rectangles pleins et vides
|
||||
|
||||
/*!
|
||||
Callback for the empty rectangle button.
|
||||
Start the rectangle operation.
|
||||
*/
|
||||
void Button_Empty_rectangle(void);
|
||||
|
||||
/*!
|
||||
Callback for the filled rectangle button.
|
||||
Start the filled rectangle operation.
|
||||
*/
|
||||
void Button_Filled_rectangle(void);
|
||||
|
||||
// Boutons relatifs au texte
|
||||
|
||||
/*!
|
||||
Callback for the text button.
|
||||
Opens the text setup window.
|
||||
*/
|
||||
void Button_Text(void);
|
||||
|
||||
// Boutons relatifs aux dégradés
|
||||
|
||||
/*!
|
||||
Callback for the gradation button.
|
||||
Opens the "Gradation menu".
|
||||
*/
|
||||
void Button_Gradients(void);
|
||||
|
||||
/*!
|
||||
Gets the informations from the gradations table and set the global vars for the current gradation.
|
||||
@param index index of the selected gradation
|
||||
*/
|
||||
void Load_gradient_data(int index);
|
||||
|
||||
// Boutons relatifs aux cercles (ellipses) dégradé(e)s
|
||||
|
||||
/*!
|
||||
Callback for the gradation circle button left click.
|
||||
Starts drawing a gradation circle.
|
||||
*/
|
||||
void Button_Grad_circle(void);
|
||||
|
||||
/*!
|
||||
Callback for the gradation circle right click.
|
||||
Starts drawing a gradation ellipsis.
|
||||
*/
|
||||
void Button_Grad_ellipse(void);
|
||||
|
||||
/*!
|
||||
Callback for the gradation rectangle button.
|
||||
Starts the gradation rectangle drawing operation.
|
||||
*/
|
||||
void Button_Grad_rectangle(void);
|
||||
|
||||
// Boutons relatifs aux cercles (ellipses) plein(e)s et vides
|
||||
|
||||
/*!
|
||||
Callback for the circle button left click.
|
||||
Starts drawing an empty circle
|
||||
*/
|
||||
void Button_Empty_circle(void);
|
||||
|
||||
/*!
|
||||
Callback for the circle button left click.
|
||||
Starts drawing an empty ellipsis
|
||||
*/
|
||||
void Button_Empty_ellipse(void);
|
||||
|
||||
/*!
|
||||
Callback for the filled circle button ledt click.
|
||||
Starts drawing a filled circle.
|
||||
*/
|
||||
void Button_Filled_circle(void);
|
||||
|
||||
/*!
|
||||
Callback for the filled circle right click.
|
||||
Starts drawing a filled ellipsis.
|
||||
*/
|
||||
void Button_Filled_ellipse(void);
|
||||
|
||||
// Boutons relatifs aux polygones vides et pleins
|
||||
|
||||
/*!
|
||||
Callback for the polyline button left click.
|
||||
Starts drawing a polygon.
|
||||
*/
|
||||
void Button_polygon(void);
|
||||
|
||||
/*!
|
||||
Callback for the polyline right click.
|
||||
Starts drawing a polyform.
|
||||
*/
|
||||
void Button_Polyform(void);
|
||||
|
||||
/*!
|
||||
Callback for the polyfill button left click.
|
||||
Starts drawing a filled polygon.
|
||||
*/
|
||||
void Button_Polyfill(void);
|
||||
|
||||
/*!
|
||||
Callback for the polyfill button right click.
|
||||
Starts drawing a filled polyform.
|
||||
*/
|
||||
void Button_Filled_polyform(void);
|
||||
|
||||
// Boutons d'ajustement de l'image
|
||||
|
||||
/*!
|
||||
Callback for the adjust picture button.
|
||||
Start the adjust picture operation.
|
||||
*/
|
||||
void Button_Adjust(void);
|
||||
|
||||
// Gestion du mode Shade
|
||||
|
||||
/*!
|
||||
Callback for the shade button (in the FX window).
|
||||
Toogle the shade mode.
|
||||
*/
|
||||
void Button_Shade_mode(void);
|
||||
|
||||
/*!
|
||||
Callback for the QSHade button (in the FX window).
|
||||
Toogle the Quick Shade effect.
|
||||
*/
|
||||
void Button_Quick_shade_mode(void);
|
||||
|
||||
/*!
|
||||
Callback for the Shade button (in the FX window) right click.
|
||||
Displays the shade setup menu.
|
||||
*/
|
||||
void Button_Shade_menu(void);
|
||||
|
||||
// Gestion du Stencil
|
||||
|
||||
/*!
|
||||
Callback for the Stencil button (in the FX window) left click.
|
||||
Toogle stencil mode.
|
||||
*/
|
||||
void Button_Stencil_mode(void);
|
||||
|
||||
/*!
|
||||
Callback for the Stencil button (in the FX window) right click.
|
||||
Displays the stencil setup menu.
|
||||
*/
|
||||
void Button_Stencil_menu(void);
|
||||
|
||||
// Gestion du Masque
|
||||
|
||||
/*!
|
||||
Callback for the Mask button (in the FX window) left click.
|
||||
Toogles the mask mode/
|
||||
*/
|
||||
void Button_Mask_mode(void);
|
||||
|
||||
/*!
|
||||
Callback for the Mask button (in the FX window) right click.
|
||||
Displays the mask setup menu.
|
||||
*/
|
||||
void Button_Mask_menu(void);
|
||||
|
||||
// Mode grille (Snap)
|
||||
|
||||
/*!
|
||||
Callback for the Grid button (in the FX window) left click.
|
||||
Toogle the grid.
|
||||
*/
|
||||
|
||||
void Button_Snap_mode(void);
|
||||
|
||||
/*!
|
||||
Callback for the Grid button (in the FX window) right click.
|
||||
Displays the grid setup menu.
|
||||
*/
|
||||
void Button_Grid_menu(void);
|
||||
|
||||
/*!
|
||||
Callback to toggle the grid visible in the magnified view.
|
||||
*/
|
||||
void Button_Show_grid(void);
|
||||
|
||||
// Mode trame (Sieve)
|
||||
|
||||
/*!
|
||||
In the sieve window, copy one of the presets patterns to the current one.
|
||||
@param index Index of the pattern to copy
|
||||
*/
|
||||
void Copy_preset_sieve(byte index);
|
||||
|
||||
/*!
|
||||
In the sieve window, swaps black and white in the current pattern.
|
||||
*/
|
||||
void Invert_trame(void);
|
||||
|
||||
/*!
|
||||
Callback for the Sieve button (in the FX window) left click.
|
||||
Toogle sieve mode.
|
||||
*/
|
||||
void Button_Sieve_mode(void);
|
||||
|
||||
/*!
|
||||
Callback for the Sieve button (in the FX window) right click.
|
||||
Displays the sieve setup menu.
|
||||
*/
|
||||
void Button_Sieve_menu(void);
|
||||
|
||||
// Mode Smooth
|
||||
|
||||
/*!
|
||||
Callback for the smooth button (in the FX window) left click.
|
||||
Toogles smooth mode.
|
||||
*/
|
||||
void Button_Smooth_mode(void);
|
||||
|
||||
/*!
|
||||
Callback for the Smooth button (in the FX window) right click.
|
||||
Displays the smooth setup menu.
|
||||
*/
|
||||
void Button_Smooth_mode(void);
|
||||
|
||||
// Boutons relatifs au mode Colorize
|
||||
|
||||
/*!
|
||||
Computes the tables used by the transparency/colorize mode.
|
||||
These tables are used to match the drawing color*picture color to the color that is painted on screen.
|
||||
*/
|
||||
void Compute_colorize_table(void);
|
||||
|
||||
/*!
|
||||
Callback for the Tranparency button (in the FX window) left click.
|
||||
Toogles transparent drawing mode.
|
||||
*/
|
||||
void Button_Colorize_mode(void);
|
||||
|
||||
/*!
|
||||
Callback for the Transparency button (in the FX window) right click.
|
||||
Displays the tranparency setup menu.
|
||||
*/
|
||||
void Button_Colorize_menu(void);
|
||||
|
||||
// Boutons relatifs au mode Tiling
|
||||
|
||||
/*!
|
||||
Callback for the Tiling button (in the FX window) left click.
|
||||
Toogles tiling mode.
|
||||
*/
|
||||
void Button_Tiling_mode(void);
|
||||
|
||||
/*!
|
||||
Callback for the Tiling button (in the FX window) right click.
|
||||
Displays the tiling setup menu.
|
||||
*/
|
||||
void Button_Tiling_menu(void);
|
||||
|
||||
/*!
|
||||
Callback for the command that turns off all drawaing effects.
|
||||
*/
|
||||
void Effects_off(void);
|
||||
|
||||
// Menu des effets
|
||||
|
||||
/*!
|
||||
Callback for the effects button click.
|
||||
Displays the effect selection menu.
|
||||
*/
|
||||
void Button_Effects(void);
|
||||
|
||||
// Prise de brosse
|
||||
|
||||
/*!
|
||||
Callback for the brush button left click.
|
||||
Start the brush picking operation.
|
||||
*/
|
||||
void Button_Brush(void);
|
||||
|
||||
/*!
|
||||
Callback for the brush button right click.
|
||||
Activates the last captured custom brush.
|
||||
*/
|
||||
void Button_Restore_brush(void);
|
||||
|
||||
/*!
|
||||
Disables the custom brush and set back a regular one.
|
||||
*/
|
||||
void Button_Unselect_brush(void);
|
||||
// Prise de brosse au lasso
|
||||
|
||||
/*!
|
||||
Callback for the freehand brush pick button left click.
|
||||
Starts freehand brush picking operation.
|
||||
*/
|
||||
void Button_Lasso(void);
|
||||
|
||||
/*!
|
||||
Disables the custom freehand brush and set back a regular one.
|
||||
*/
|
||||
void Button_Unselect_lasso(void);
|
||||
|
||||
// Button relatifs à la pipette
|
||||
|
||||
/*!
|
||||
Starts the color picking operation.
|
||||
*/
|
||||
void Button_Colorpicker(void);
|
||||
|
||||
/*!
|
||||
Disables the color picker button and get back to the previously selected drawing mode.
|
||||
*/
|
||||
void Button_Unselect_colorpicker(void);
|
||||
|
||||
/*!
|
||||
Swap fore- and background colors.
|
||||
*/
|
||||
void Button_Invert_foreback(void);
|
||||
|
||||
// Mode loupe
|
||||
|
||||
/*!
|
||||
Enters magnify mode.
|
||||
*/
|
||||
void Button_Magnify(void);
|
||||
|
||||
/*!
|
||||
Displays magnify menu.
|
||||
*/
|
||||
void Button_Magnify_menu(void);
|
||||
|
||||
/*!
|
||||
Exit magnify mode.
|
||||
*/
|
||||
void Button_Unselect_magnifier(void);
|
||||
|
||||
// Les différents effets sur la brosse
|
||||
|
||||
/*!
|
||||
Display the Brush effects window.
|
||||
*/
|
||||
void Button_Brush_FX(void);
|
||||
|
||||
// Boutons relatifs aux différentes pages
|
||||
|
||||
/*!
|
||||
Swap main and spare drawing pages.
|
||||
*/
|
||||
void Button_Page(void);
|
||||
|
||||
/*!
|
||||
Copy main page to spare page.
|
||||
*/
|
||||
void Button_Copy_page(void);
|
||||
|
||||
/*!
|
||||
Copy only pixel data from main page to spare page (no palette copy).
|
||||
*/
|
||||
void Copy_image_only(void);
|
||||
|
||||
/*!
|
||||
Kill (free from memory) the current page.
|
||||
*/
|
||||
void Button_Kill(void);
|
||||
|
||||
// Boutons relatifs aux changements de résolution et de taille d'image
|
||||
|
||||
/*!
|
||||
Display the screenmode menu.
|
||||
*/
|
||||
void Button_Resolution(void);
|
||||
|
||||
/*!
|
||||
Set the screen to the "safe resolution" (320x200 pixel window).
|
||||
*/
|
||||
void Button_Safety_resolution(void);
|
||||
|
||||
// Boutons relatifs aux chargements et sauvegardes
|
||||
|
||||
/*!
|
||||
Opens the load file dialog.
|
||||
*/
|
||||
void Button_Load(void);
|
||||
|
||||
/*!
|
||||
Reload current picture from disk.
|
||||
*/
|
||||
void Button_Reload(void);
|
||||
|
||||
/*!
|
||||
Open the save file dialog.
|
||||
*/
|
||||
void Button_Save(void);
|
||||
|
||||
/*!
|
||||
Saves the current file without asking for a new name.
|
||||
*/
|
||||
void Button_Autosave(void);
|
||||
|
||||
// Réglage des paramètres de l'utilisateur
|
||||
|
||||
/*!
|
||||
Display the setting menu.
|
||||
*/
|
||||
void Button_Settings(void);
|
||||
|
||||
/*!
|
||||
Display the skin selector window.
|
||||
*/
|
||||
void Button_Skins(void);
|
||||
|
||||
// Annulation de la dernière modification
|
||||
|
||||
/*!
|
||||
Undo the last modification to the picture.
|
||||
*/
|
||||
void Button_Undo(void);
|
||||
|
||||
/*!
|
||||
Redo an operation that has been undone.
|
||||
*/
|
||||
void Button_Redo(void);
|
||||
|
||||
// Boutons relatifs aux effacements d'images
|
||||
|
||||
/*!
|
||||
Clear the whole screen with black (color index 0).
|
||||
*/
|
||||
void Button_Clear(void);
|
||||
|
||||
/*!
|
||||
Clear the screen with the selected backcolor.
|
||||
*/
|
||||
void Button_Clear_with_backcolor(void);
|
||||
|
||||
// Quitter le programme
|
||||
|
||||
/*!
|
||||
Quits the program. Display a requester to save the changes to the picture before exiting if the pic was modified since last save.
|
||||
*/
|
||||
void Button_Quit(void);
|
||||
|
||||
// Cacher le menu
|
||||
|
||||
/*!
|
||||
Hides the menubar.
|
||||
*/
|
||||
void Button_Hide_menu(void);
|
||||
|
||||
/*!
|
||||
Shows a dropdown panel where you can choose which toolbars are visible
|
||||
*/
|
||||
void Button_Toggle_toolbar(void);
|
||||
|
||||
/*!
|
||||
Hides all toolbars (except status) or shows them again
|
||||
*/
|
||||
void Button_Toggle_all_toolbars(void);
|
||||
|
||||
|
||||
/*!
|
||||
Load picture from file.
|
||||
*/
|
||||
void Load_picture(byte image);
|
||||
|
||||
/*!
|
||||
Save picture to file.
|
||||
*/
|
||||
void Save_picture(byte image);
|
||||
|
||||
|
||||
/*!
|
||||
Generic color tagging menu, for various effects.
|
||||
*/
|
||||
void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_cancel, const char *help_section, word close_shortcut );
|
||||
|
||||
|
||||
/*!
|
||||
Display the menu for the smooth effect.
|
||||
*/
|
||||
void Button_Smooth_menu(void);
|
||||
|
||||
|
||||
/*!
|
||||
Toogles the smear mode.
|
||||
*/
|
||||
void Button_Smear_mode(void);
|
||||
|
||||
void Button_Brush_container(void);
|
||||
|
||||
#endif
|
||||
|
||||
1241
src/buttons_effects.c
Normal file
1241
src/buttons_effects.c
Normal file
File diff suppressed because it is too large
Load Diff
479
src/const.h
Normal file
479
src/const.h
Normal file
@@ -0,0 +1,479 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 const.h
|
||||
/// Constants (preprocessor defines) and enumerations used anywhere.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _CONST_H_
|
||||
#define _CONST_H_
|
||||
|
||||
#ifndef M_2PI
|
||||
#define M_2PI 6.28318530717958647692528676656 ///< Hmm, pie...
|
||||
#endif
|
||||
|
||||
#define VERSION1 2 ///< Version number for gfx2.cfg (1/4)
|
||||
#define VERSION2 0 ///< Version number for gfx2.cfg (2/4)
|
||||
#define BETA1 98 ///< Version number for gfx2.cfg (3/4)
|
||||
#define BETA2 0 ///< Version number for gfx2.cfg (4/4)
|
||||
#define MAX_VIDEO_MODES 100 ///< Maximum number of video modes Grafx2 can propose.
|
||||
#define NB_SHORTCUTS 181 ///< Number of actions that can have a key combination associated to it.
|
||||
#define NB_ZOOM_FACTORS 15 ///< Number of zoom levels available in the magnifier.
|
||||
#define MENU_WIDTH 254 ///< Width of the menu (not counting the palette)
|
||||
#define MENU_HEIGHT 44 ///< Height of the menu.
|
||||
#define NB_CURSOR_SPRITES 8 ///< Number of available mouse cursor sprites.
|
||||
#define CURSOR_SPRITE_WIDTH 15 ///< Width of a mouse cursor sprite.
|
||||
#define CURSOR_SPRITE_HEIGHT 15 ///< Height of a mouse cursor sprite.
|
||||
#define NB_EFFECTS_SPRITES 9 ///< Number of effect sprites.
|
||||
#define NB_MENU_SPRITES 20 ///< Number of menu sprites.
|
||||
#define MENU_SPRITE_WIDTH 14 ///< Width of a menu sprite in pixels
|
||||
#define MENU_SPRITE_HEIGHT 14 ///< Height of a menu sprite in pixels
|
||||
#define LAYER_SPRITE_WIDTH 14 ///< Width of a layer button in pixels
|
||||
#define LAYER_SPRITE_HEIGHT 10 ///< Height of a layer button in pixels
|
||||
#define PAINTBRUSH_WIDTH 16 ///< Width of a preset paintbrush sprite
|
||||
#define PAINTBRUSH_HEIGHT 16 ///< Height of a preset paintbrush sprite
|
||||
#define MAX_PAINTBRUSH_SIZE 127 ///< Max size for a resizable paintbrush
|
||||
#define ICON_SPRITE_WIDTH 8 ///< Width of an icon in pixels
|
||||
#define ICON_SPRITE_HEIGHT 8 ///< Height of an icon in pixels
|
||||
#define NB_PAINTBRUSH_SPRITES 48 ///< Number of preset paintbrushes
|
||||
#define NB_PRESET_SIEVE 12 ///< Number of preset sieve patterns
|
||||
#define OPERATION_STACK_SIZE 16 ///< Max number of parameters in the operation stack.
|
||||
#define MAX_DISPLAYABLE_PATH 37 ///< Max number of characters to display directory name, in Save/Load screens.
|
||||
#define COMMENT_SIZE 32 ///< Max number of characters for a comment in PKM or PNG file.
|
||||
#define NB_MAX_PAGES_UNDO 99 ///< Max number of undo pages
|
||||
#define DEFAULT_ZOOM_FACTOR 4 ///< Initial zoom factor for the magnifier.
|
||||
#define MAX_PATH_CHARACTERS 260 ///< Number of characters for a file+complete path. Adapt to your OS...
|
||||
#define NB_BOOKMARKS 4 ///< Number of bookmark buttons in Save/Load screen.
|
||||
// Character to show a right arrow, used when editing long strings. It's present in ::Gfx->System_font
|
||||
#define RIGHT_TRIANGLE_CHARACTER 16
|
||||
// Character to show a left arrow, used when editing long strings. It's present in ::Gfx->System_font
|
||||
#define LEFT_TRIANGLE_CHARACTER 17
|
||||
/// Character to display in menus for an ellipsis.
|
||||
#define ELLIPSIS_CHARACTER '…'
|
||||
#define NB_LAYERS 1 ///< Initial number of layers for a new image
|
||||
#define MAX_NB_LAYERS 16 ///< Maximum number of layers that can be used in grafx2. Note that 32 is upper limit because of a few bit fields.
|
||||
#define BRUSH_CONTAINER_PREVIEW_WIDTH 16 ///< Size for preview of a brush in Brush container
|
||||
#define BRUSH_CONTAINER_PREVIEW_HEIGHT 16 ///< Size for preview of a brush in Brush container
|
||||
#define BRUSH_CONTAINER_COLUMNS 4 ///< Number of columns in the Brush container
|
||||
#define BRUSH_CONTAINER_ROWS 3 ///< Number of rows in the Brush container
|
||||
|
||||
///
|
||||
/// We force the dynamic backup page allocation to leave a minimum of
|
||||
/// 256Kb of free memory, to allow the rest of the program to work safely.
|
||||
/// Note: This is a remainder of the DOS version. This system might not work
|
||||
/// so well on other OSes, where the "available memory" changes due to external
|
||||
/// factors.
|
||||
#define MINIMAL_MEMORY_TO_RESERVE (256*1024)
|
||||
|
||||
#define LEFT_SIDE 1 ///< Indicates a left side or left-click
|
||||
#define RIGHT_SIDE 2 ///< Indicates a right side or right-click
|
||||
|
||||
#define SEPARATOR_WIDTH 6 ///< Width of the separator between the normal and the zoomed view
|
||||
#define INITIAL_SEPARATOR_PROPORTION 0.3 ///< Proportion of the normal view width, relative to the whole screen width.
|
||||
#define NB_ZOOMED_PIXELS_MIN 4 ///< Minimal number of pixel shown (in width) by the zoomed view. (Note: below 4, you can't scroll!)
|
||||
|
||||
#if defined(__MORPHOS__) || defined(__amigaos4__) || defined(__amigaos__)
|
||||
#define PARENT_DIR "/"
|
||||
#else
|
||||
/// Filename that means "parent directory" for your operating system.
|
||||
#define PARENT_DIR ".."
|
||||
#endif
|
||||
|
||||
/// List of file formats recognized by grafx2
|
||||
enum FILE_FORMATS
|
||||
{
|
||||
FORMAT_ALL_IMAGES=0, ///< This is not really a file format, it's reserverd for a compilation of all file extensions
|
||||
FORMAT_ALL_FILES=1, ///< This is not really a file format, it's reserverd for the "*.*" filter option.
|
||||
FORMAT_PNG,
|
||||
FORMAT_GIF,
|
||||
FORMAT_BMP,
|
||||
FORMAT_PCX,
|
||||
FORMAT_PKM,
|
||||
FORMAT_LBM,
|
||||
FORMAT_IMG,
|
||||
FORMAT_SCx,
|
||||
FORMAT_PI1,
|
||||
FORMAT_PC1,
|
||||
FORMAT_CEL,
|
||||
FORMAT_NEO,
|
||||
FORMAT_C64,
|
||||
FORMAT_KCF,
|
||||
FORMAT_PAL,
|
||||
FORMAT_SCR,
|
||||
FORMAT_MISC, ///< Must be last of enum: others formats recognized by SDL_image
|
||||
};
|
||||
|
||||
/// Default format for 'save as'
|
||||
#define DEFAULT_FILEFORMAT FORMAT_GIF
|
||||
|
||||
/// Error codes for ::Error()
|
||||
enum ERROR_CODES
|
||||
{
|
||||
ERROR_WARNING=0, ///< Red flash on screen, non-fatal error
|
||||
ERROR_GUI_MISSING, ///< The graphics file is missing
|
||||
ERROR_GUI_CORRUPTED, ///< The graphics file cannot be parsed for GUI elements
|
||||
ERROR_INI_MISSING, ///< File gfx2def.ini is missing
|
||||
ERROR_CFG_MISSING, ///< File gfx2.cfg is missing (non-fatal)
|
||||
ERROR_CFG_CORRUPTED, ///< File gfx2.cfg couldn't be parsed (non-fatal)
|
||||
ERROR_CFG_OLD, ///< Unknown version of gfx2.cfg : either VERY old or wrong file (non-fatal)
|
||||
ERROR_MEMORY, ///< Out of memory
|
||||
ERROR_COMMAND_LINE, ///< Error in command-line arguments (syntax, or couldn't find the file to open)
|
||||
ERROR_FORBIDDEN_MODE, ///< Graphics mode requested is not supported
|
||||
ERROR_SAVING_CFG, ///< Error while writing gfx2.cfg
|
||||
ERROR_MISSING_DIRECTORY, ///< Unable to return to the original "current directory" on program exit
|
||||
ERROR_INI_CORRUPTED, ///< File gfx2.ini couldn't be parsed
|
||||
ERROR_SAVING_INI, ///< Error while writing gfx2.ini
|
||||
ERROR_SORRY_SORRY_SORRY ///< (Page allocation error that shouldn't ever happen, now)
|
||||
};
|
||||
|
||||
/// Available pixel scalers
|
||||
enum PIXEL_RATIO
|
||||
{
|
||||
PIXEL_SIMPLE=0, ///< Use real pixels
|
||||
PIXEL_WIDE, ///< Use wide pixels (2x1) like on Amstrad CPC mode 0
|
||||
PIXEL_TALL, ///< Use tall pixels (1x2) like on Amstrad CPC mode 2
|
||||
PIXEL_DOUBLE, ///< Use big pixels (2x2) if your LCD screen can't do lowres by itself
|
||||
PIXEL_TRIPLE, ///< Use really big pixels (3x3)
|
||||
PIXEL_WIDE2, ///< Use big wide pixels (4x2)
|
||||
PIXEL_TALL2, ///< Use big tall pixels (2x4)
|
||||
PIXEL_QUAD, ///< Use really giant pixels (4x4). You need to have a screen resolution at least 1280x800 to use this one
|
||||
PIXEL_MAX ///< Number of elements in enum
|
||||
};
|
||||
|
||||
/// Different kinds of menu button behavior.
|
||||
enum FAMILY_OF_BUTTONS
|
||||
{
|
||||
FAMILY_TOOL=1, ///< Drawing tools (example : Freehand draw)
|
||||
FAMILY_INTERRUPTION, ///< Temporary operation (example : choosing paintbrush) > Interrupts the current operation to do something, then come back.
|
||||
FAMILY_INSTANT, ///< Single-click action (example : choose a color in palette) > It will be over as soon as we exit the called function.
|
||||
FAMILY_TOOLBAR, ///< Hide/show the menu
|
||||
FAMILY_EFFECTS ///< Effects
|
||||
};
|
||||
|
||||
/// The different kinds of buttons in menus or windows.
|
||||
enum BUTTON_SHAPES
|
||||
{
|
||||
BUTTON_SHAPE_NO_FRAME, ///< Ex: the palette
|
||||
BUTTON_SHAPE_RECTANGLE, ///< Ex: Most buttons.
|
||||
BUTTON_SHAPE_TRIANGLE_TOP_LEFT, ///< Ex: Empty rectangles.
|
||||
BUTTON_SHAPE_TRIANGLE_BOTTOM_RIGHT ///< Ex: Filled rectangles.
|
||||
};
|
||||
|
||||
/// The different "mouse cursor" shapes
|
||||
enum CURSOR_SHAPES
|
||||
{
|
||||
CURSOR_SHAPE_ARROW,
|
||||
CURSOR_SHAPE_TARGET, ///< This one uses the paintbrush
|
||||
CURSOR_SHAPE_COLORPICKER, ///< This one uses the paintbrush
|
||||
CURSOR_SHAPE_HOURGLASS,
|
||||
CURSOR_SHAPE_MULTIDIRECTIONAL,
|
||||
CURSOR_SHAPE_HORIZONTAL,
|
||||
CURSOR_SHAPE_THIN_TARGET, ///< This one uses the paintbrush
|
||||
CURSOR_SHAPE_THIN_COLORPICKER, ///< This one uses the paintbrush
|
||||
CURSOR_SHAPE_XOR_TARGET,
|
||||
CURSOR_SHAPE_XOR_RECTANGLE,
|
||||
CURSOR_SHAPE_XOR_ROTATION
|
||||
};
|
||||
|
||||
/// The different shapes that can be used as a paintbrush (paintbrush types go in the beginning)
|
||||
enum PAINTBRUSH_SHAPES
|
||||
{
|
||||
PAINTBRUSH_SHAPE_ROUND,
|
||||
PAINTBRUSH_SHAPE_SQUARE,
|
||||
PAINTBRUSH_SHAPE_HORIZONTAL_BAR,
|
||||
PAINTBRUSH_SHAPE_VERTICAL_BAR,
|
||||
PAINTBRUSH_SHAPE_SLASH,
|
||||
PAINTBRUSH_SHAPE_ANTISLASH,
|
||||
PAINTBRUSH_SHAPE_RANDOM, ///< Random pixels in a circle shape, like an airbrush.
|
||||
PAINTBRUSH_SHAPE_CROSS,
|
||||
PAINTBRUSH_SHAPE_PLUS,
|
||||
PAINTBRUSH_SHAPE_DIAMOND,
|
||||
PAINTBRUSH_SHAPE_SIEVE_ROUND,
|
||||
PAINTBRUSH_SHAPE_SIEVE_SQUARE,
|
||||
PAINTBRUSH_SHAPE_MISC, ///< A raw monochrome bitmap, can't be resized. This must be the last of the preset paintbrush types.
|
||||
PAINTBRUSH_SHAPE_POINT, ///< Used to reduce the paintbrush to a single pixel, during operations like colorpicker.
|
||||
PAINTBRUSH_SHAPE_COLOR_BRUSH, ///< User's brush, in color mode
|
||||
PAINTBRUSH_SHAPE_MONO_BRUSH, ///< User's brush, in mono mode
|
||||
PAINTBRUSH_SHAPE_MAX ///< Upper limit.
|
||||
};
|
||||
|
||||
/// Normal resting state for a menu button.
|
||||
#define BUTTON_RELEASED 0
|
||||
/// State of a menu button that is being pressed.
|
||||
#define BUTTON_PRESSED 1
|
||||
|
||||
/// The different modes of the Shade
|
||||
enum SHADE_MODES
|
||||
{
|
||||
SHADE_MODE_NORMAL,
|
||||
SHADE_MODE_LOOP,
|
||||
SHADE_MODE_NOSAT
|
||||
};
|
||||
|
||||
/// Identifiers for the chunks (data blocks) of gfx2.cfg
|
||||
enum CHUNKS_CFG
|
||||
{
|
||||
CHUNK_KEYS = 0, ///< Shortcut keys definitions
|
||||
CHUNK_VIDEO_MODES = 1, ///< List of video modes
|
||||
CHUNK_SHADE = 2, ///< Shade settings
|
||||
CHUNK_MASK = 3, ///< Mask settings
|
||||
CHUNK_STENCIL = 4, ///< Stencil settings
|
||||
CHUNK_GRADIENTS = 5, ///< Gradients
|
||||
CHUNK_SMOOTH = 6, ///< Smooth effect settings
|
||||
CHUNK_EXCLUDE_COLORS = 7, ///< List of excluded colors
|
||||
CHUNK_QUICK_SHADE = 8, ///< QShade effect settings
|
||||
CHUNK_GRID = 9,
|
||||
CHUNK_MAX
|
||||
};
|
||||
|
||||
/// Identifiers for the 8x8 icons of ::Gfx->Icon_sprite (most are unused now)
|
||||
enum ICON_TYPES
|
||||
{
|
||||
ICON_FLOPPY_3_5=0, ///< 3.5 Floppy disk
|
||||
ICON_FLOPPY_5_25, ///< 5.25 Floppy disk
|
||||
ICON_HDD, ///< Hard disk drive
|
||||
ICON_CDROM, ///< CD-ROM
|
||||
ICON_NETWORK, ///< "Network" drive
|
||||
ICON_STAR, ///< Star (favorite)
|
||||
ICON_DROPDOWN, ///< Dropdown arrow
|
||||
NB_ICON_SPRITES ///< Number of 8x8 icons
|
||||
};
|
||||
|
||||
/// Identifiers for the buttons in the menu.
|
||||
enum BUTTON_NUMBERS
|
||||
{
|
||||
// Status bar
|
||||
BUTTON_HIDE = 0,
|
||||
|
||||
// Layer bar
|
||||
BUTTON_LAYER_MENU,
|
||||
BUTTON_LAYER_COLOR,
|
||||
BUTTON_LAYER_MERGE,
|
||||
BUTTON_LAYER_ADD,
|
||||
BUTTON_LAYER_REMOVE,
|
||||
BUTTON_LAYER_UP,
|
||||
BUTTON_LAYER_DOWN,
|
||||
BUTTON_LAYER_SELECT,
|
||||
|
||||
// Main menu
|
||||
BUTTON_PAINTBRUSHES,
|
||||
BUTTON_ADJUST,
|
||||
BUTTON_DRAW,
|
||||
BUTTON_CURVES,
|
||||
BUTTON_LINES,
|
||||
BUTTON_AIRBRUSH,
|
||||
BUTTON_FLOODFILL,
|
||||
BUTTON_POLYGONS,
|
||||
BUTTON_POLYFILL,
|
||||
BUTTON_RECTANGLES,
|
||||
BUTTON_FILLRECT,
|
||||
BUTTON_CIRCLES,
|
||||
BUTTON_FILLCIRC,
|
||||
BUTTON_GRADRECT,
|
||||
BUTTON_SPHERES,
|
||||
BUTTON_BRUSH,
|
||||
BUTTON_POLYBRUSH,
|
||||
BUTTON_BRUSH_EFFECTS,
|
||||
BUTTON_EFFECTS,
|
||||
BUTTON_TEXT,
|
||||
BUTTON_MAGNIFIER,
|
||||
BUTTON_COLORPICKER,
|
||||
BUTTON_RESOL,
|
||||
BUTTON_PAGE,
|
||||
BUTTON_SAVE,
|
||||
BUTTON_LOAD,
|
||||
BUTTON_SETTINGS,
|
||||
BUTTON_CLEAR,
|
||||
BUTTON_HELP,
|
||||
BUTTON_UNDO,
|
||||
BUTTON_KILL,
|
||||
BUTTON_QUIT,
|
||||
BUTTON_PALETTE,
|
||||
BUTTON_PAL_LEFT,
|
||||
BUTTON_PAL_RIGHT,
|
||||
BUTTON_CHOOSE_COL,
|
||||
NB_BUTTONS ///< Number of buttons in the menu bar.
|
||||
};
|
||||
|
||||
///
|
||||
/// Identifiers of special actions that can have a keyboard shortcut.
|
||||
/// They are special in the sense that there's no button in the menu for them,
|
||||
/// so it requires a specific handling.
|
||||
enum SPECIAL_ACTIONS
|
||||
{
|
||||
SPECIAL_MOUSE_UP=0,
|
||||
SPECIAL_MOUSE_DOWN,
|
||||
SPECIAL_MOUSE_LEFT,
|
||||
SPECIAL_MOUSE_RIGHT,
|
||||
SPECIAL_CLICK_LEFT,
|
||||
SPECIAL_CLICK_RIGHT,
|
||||
SPECIAL_NEXT_FORECOLOR,
|
||||
SPECIAL_PREVIOUS_FORECOLOR,
|
||||
SPECIAL_NEXT_BACKCOLOR,
|
||||
SPECIAL_PREVIOUS_BACKCOLOR,
|
||||
SPECIAL_SMALLER_PAINTBRUSH,
|
||||
SPECIAL_BIGGER_PAINTBRUSH,
|
||||
SPECIAL_NEXT_USER_FORECOLOR,
|
||||
SPECIAL_PREVIOUS_USER_FORECOLOR,
|
||||
SPECIAL_NEXT_USER_BACKCOLOR,
|
||||
SPECIAL_PREVIOUS_USER_BACKCOLOR,
|
||||
SPECIAL_SCROLL_UP,
|
||||
SPECIAL_SCROLL_DOWN,
|
||||
SPECIAL_SCROLL_LEFT,
|
||||
SPECIAL_SCROLL_RIGHT,
|
||||
SPECIAL_SCROLL_UP_FAST,
|
||||
SPECIAL_SCROLL_DOWN_FAST,
|
||||
SPECIAL_SCROLL_LEFT_FAST,
|
||||
SPECIAL_SCROLL_RIGHT_FAST,
|
||||
SPECIAL_SCROLL_UP_SLOW,
|
||||
SPECIAL_SCROLL_DOWN_SLOW,
|
||||
SPECIAL_SCROLL_LEFT_SLOW,
|
||||
SPECIAL_SCROLL_RIGHT_SLOW,
|
||||
SPECIAL_SHOW_HIDE_CURSOR,
|
||||
SPECIAL_DOT_PAINTBRUSH,
|
||||
SPECIAL_CONTINUOUS_DRAW,
|
||||
SPECIAL_FLIP_X,
|
||||
SPECIAL_FLIP_Y,
|
||||
SPECIAL_ROTATE_90,
|
||||
SPECIAL_ROTATE_180,
|
||||
SPECIAL_STRETCH,
|
||||
SPECIAL_DISTORT,
|
||||
SPECIAL_OUTLINE,
|
||||
SPECIAL_NIBBLE,
|
||||
SPECIAL_GET_BRUSH_COLORS,
|
||||
SPECIAL_RECOLORIZE_BRUSH,
|
||||
SPECIAL_ROTATE_ANY_ANGLE,
|
||||
SPECIAL_LOAD_BRUSH,
|
||||
SPECIAL_SAVE_BRUSH,
|
||||
SPECIAL_INVERT_SIEVE,
|
||||
SPECIAL_ZOOM_IN,
|
||||
SPECIAL_ZOOM_OUT,
|
||||
SPECIAL_CENTER_ATTACHMENT,
|
||||
SPECIAL_TOP_LEFT_ATTACHMENT,
|
||||
SPECIAL_TOP_RIGHT_ATTACHMENT,
|
||||
SPECIAL_BOTTOM_LEFT_ATTACHMENT,
|
||||
SPECIAL_BOTTOM_RIGHT_ATTACHMENT,
|
||||
SPECIAL_EXCLUDE_COLORS_MENU,
|
||||
SPECIAL_SHADE_MODE,
|
||||
SPECIAL_SHADE_MENU,
|
||||
SPECIAL_QUICK_SHADE_MODE, ///< This must be the first of the "effects" family
|
||||
SPECIAL_QUICK_SHADE_MENU,
|
||||
SPECIAL_STENCIL_MODE,
|
||||
SPECIAL_STENCIL_MENU,
|
||||
SPECIAL_MASK_MODE,
|
||||
SPECIAL_MASK_MENU,
|
||||
SPECIAL_GRID_MODE,
|
||||
SPECIAL_GRID_MENU,
|
||||
SPECIAL_SIEVE_MODE,
|
||||
SPECIAL_SIEVE_MENU,
|
||||
SPECIAL_COLORIZE_MODE,
|
||||
SPECIAL_COLORIZE_MENU,
|
||||
SPECIAL_SMOOTH_MODE,
|
||||
SPECIAL_SMOOTH_MENU,
|
||||
SPECIAL_SMEAR_MODE,
|
||||
SPECIAL_EFFECTS_OFF,
|
||||
SPECIAL_TILING_MODE,
|
||||
SPECIAL_TRANSPARENCY_1,
|
||||
SPECIAL_TRANSPARENCY_2,
|
||||
SPECIAL_TRANSPARENCY_3,
|
||||
SPECIAL_TRANSPARENCY_4,
|
||||
SPECIAL_TRANSPARENCY_5,
|
||||
SPECIAL_TRANSPARENCY_6,
|
||||
SPECIAL_TRANSPARENCY_7,
|
||||
SPECIAL_TRANSPARENCY_8,
|
||||
SPECIAL_TRANSPARENCY_9,
|
||||
SPECIAL_TRANSPARENCY_0,
|
||||
SPECIAL_TILING_MENU, ///< This must be the last of the "effects" family
|
||||
SPECIAL_ZOOM_1,
|
||||
SPECIAL_ZOOM_2,
|
||||
SPECIAL_ZOOM_3,
|
||||
SPECIAL_ZOOM_4,
|
||||
SPECIAL_ZOOM_5,
|
||||
SPECIAL_ZOOM_6,
|
||||
SPECIAL_ZOOM_8,
|
||||
SPECIAL_ZOOM_10,
|
||||
SPECIAL_ZOOM_12,
|
||||
SPECIAL_ZOOM_14,
|
||||
SPECIAL_ZOOM_16,
|
||||
SPECIAL_ZOOM_18,
|
||||
SPECIAL_ZOOM_20,
|
||||
SPECIAL_SHOW_GRID,
|
||||
SPECIAL_LAYER1_SELECT,
|
||||
SPECIAL_LAYER1_TOGGLE,
|
||||
SPECIAL_LAYER2_SELECT,
|
||||
SPECIAL_LAYER2_TOGGLE,
|
||||
SPECIAL_LAYER3_SELECT,
|
||||
SPECIAL_LAYER3_TOGGLE,
|
||||
SPECIAL_LAYER4_SELECT,
|
||||
SPECIAL_LAYER4_TOGGLE,
|
||||
SPECIAL_LAYER5_SELECT,
|
||||
SPECIAL_LAYER5_TOGGLE,
|
||||
SPECIAL_LAYER6_SELECT,
|
||||
SPECIAL_LAYER6_TOGGLE,
|
||||
SPECIAL_LAYER7_SELECT,
|
||||
SPECIAL_LAYER7_TOGGLE,
|
||||
SPECIAL_LAYER8_SELECT,
|
||||
SPECIAL_LAYER8_TOGGLE,
|
||||
NB_SPECIAL_SHORTCUTS ///< Number of special shortcuts
|
||||
};
|
||||
|
||||
/// Identifiers of the operations, ie tools you use on the image.
|
||||
enum OPERATIONS
|
||||
{
|
||||
OPERATION_CONTINUOUS_DRAW=0, ///< Freehand continuous draw
|
||||
OPERATION_DISCONTINUOUS_DRAW,///< Freehand discontinuous draw
|
||||
OPERATION_POINT_DRAW, ///< Freehand point-by-point draw
|
||||
OPERATION_FILLED_CONTOUR, ///< Filled contour
|
||||
OPERATION_LINE, ///< Lines
|
||||
OPERATION_K_LIGNE, ///< Linked lines
|
||||
OPERATION_CENTERED_LINES, ///< Centered lines
|
||||
OPERATION_EMPTY_RECTANGLE, ///< Empty rectangle
|
||||
OPERATION_FILLED_RECTANGLE, ///< Filled rectangle
|
||||
OPERATION_EMPTY_CIRCLE, ///< Empty circle
|
||||
OPERATION_FILLED_CIRCLE, ///< Filled circle
|
||||
OPERATION_EMPTY_ELLIPSE, ///< Empty ellipse
|
||||
OPERATION_FILLED_ELLIPSE, ///< Filled ellipse
|
||||
OPERATION_FILL, ///< Fill
|
||||
OPERATION_REPLACE, ///< Color replacer
|
||||
OPERATION_GRAB_BRUSH, ///< Rectangular brush grabbing
|
||||
OPERATION_POLYBRUSH, ///< Polygonal brush grabbing
|
||||
OPERATION_COLORPICK, ///< Colorpicker
|
||||
OPERATION_MAGNIFY, ///< Position the magnify window
|
||||
OPERATION_3_POINTS_CURVE, ///< Curve with 3 control points
|
||||
OPERATION_4_POINTS_CURVE, ///< Curve with 4 control points
|
||||
OPERATION_AIRBRUSH, ///< Airbrush
|
||||
OPERATION_POLYGON, ///< Polygon
|
||||
OPERATION_POLYFORM, ///< Polyform
|
||||
OPERATION_POLYFILL, ///< Filled polygon
|
||||
OPERATION_FILLED_POLYFORM, ///< Filled polyform
|
||||
OPERATION_SCROLL, ///< Scroll (pan)
|
||||
OPERATION_GRAD_CIRCLE, ///< Gradient-filled circle
|
||||
OPERATION_GRAD_ELLIPSE, ///< Gradient-filled ellipse
|
||||
OPERATION_ROTATE_BRUSH, ///< Rotate brush
|
||||
OPERATION_STRETCH_BRUSH, ///< Stretch brush
|
||||
OPERATION_DISTORT_BRUSH, ///< Distort brush
|
||||
OPERATION_GRAD_RECTANGLE, ///< Gradient-filled rectangle
|
||||
NB_OPERATIONS ///< Number of operations handled by the engine
|
||||
};
|
||||
|
||||
#endif
|
||||
3089
src/engine.c
Normal file
3089
src/engine.c
Normal file
File diff suppressed because it is too large
Load Diff
110
src/engine.h
Normal file
110
src/engine.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 engine.h
|
||||
/// Utility functions for the menu and all windows.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __ENGINE_H__
|
||||
#define __ENGINE_H__
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
void Main_handler (void);
|
||||
void Draw_menu_button_frame(byte btn_number,byte pressed);
|
||||
void Unselect_button (int btn_number);
|
||||
void Select_button (int btn_number,byte click);
|
||||
void Open_window (word width,word height, const char * title);
|
||||
void Close_window (void);
|
||||
|
||||
void Open_popup (word x_pos, word y_pos, word width, word height);
|
||||
void Close_popup (void);
|
||||
|
||||
void Window_draw_normal_bouton(word x_pos,word y_pos,word width,word height,
|
||||
char * title,byte undersc_letter,byte clickable);
|
||||
void Window_select_normal_button(word x_pos,word y_pos,word width,word height);
|
||||
void Window_unselect_normal_button(word x_pos,word y_pos,word width,word height);
|
||||
void Window_draw_palette_bouton(word x_pos,word y_pos);
|
||||
|
||||
void Compute_slider_cursor_height(T_Scroller_button * button);
|
||||
void Window_draw_slider(T_Scroller_button * button);
|
||||
void Window_draw_scroller_bouton(T_Scroller_button * button);
|
||||
|
||||
void Window_input_content(T_Special_button * button, char * content);
|
||||
void Window_clear_input_button(T_Special_button * button);
|
||||
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,
|
||||
word width, word height, char * title, byte undersc_letter,
|
||||
byte clickable, word shortcut);
|
||||
|
||||
T_Normal_button * Window_set_repeatable_button(word x_pos, word y_pos,
|
||||
word width, word height, char * title, byte undersc_letter,
|
||||
byte clickable, word shortcut);
|
||||
|
||||
T_Palette_button * Window_set_palette_button(word x_pos, word y_pos);
|
||||
void Window_clear_tags(void);
|
||||
void Tag_color_range(byte start, byte end);
|
||||
|
||||
T_Scroller_button * Window_set_scroller_button(word x_pos, word y_pos,
|
||||
word height, word nb_elements, word nb_elements_visible,
|
||||
word initial_position);
|
||||
|
||||
T_Special_button * Window_set_special_button(word x_pos, word y_pos, word width,
|
||||
word height);
|
||||
|
||||
T_Special_button * Window_set_input_button(word x_pos, word y_pos,
|
||||
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, byte display_centered, byte display_arrow,
|
||||
byte active_button,byte bottom_up);
|
||||
|
||||
/// Adds an item to a dropdown menu
|
||||
void Window_dropdown_add_item(T_Dropdown_button * dropdown, word btn_number,
|
||||
const char *label);
|
||||
|
||||
void Window_dropdown_clear_items(T_Dropdown_button * dropdown);
|
||||
|
||||
///
|
||||
/// Displays a dropped-down menu and handles the UI logic until the user
|
||||
/// releases a mouse button.
|
||||
/// This function then clears the dropdown and returns the selected item,
|
||||
/// or NULL if the user wasn't highlighting an item when he closed.
|
||||
T_Dropdown_choice * Dropdown_activate(T_Dropdown_button *button, short off_x, short off_y);
|
||||
|
||||
T_List_button * Window_set_list_button(T_Special_button * entry_button,
|
||||
T_Scroller_button * scroller, Func_draw_list_item draw_list_item);
|
||||
void Window_redraw_list(T_List_button * list);
|
||||
byte Window_click_in_rectangle(short start_x, short start_y, short end_x,
|
||||
short end_y);
|
||||
short Wait_click_in_palette(T_Palette_button * button);
|
||||
void Get_color_behind_window(byte * color, byte * click);
|
||||
|
||||
short Window_clicked_button(void);
|
||||
int Button_under_mouse(void);
|
||||
short Window_get_clicked_button(void);
|
||||
void Remap_window_backgrounds(byte * conversion_table, int Min_Y, int Max_Y);
|
||||
void Pixel_background(int x_pos, int y_pos, byte color);
|
||||
|
||||
#endif
|
||||
54
src/errors.h
Normal file
54
src/errors.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 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 errors.h
|
||||
/// Functions and macros for tracing and error reporting.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __VBCC__
|
||||
#define __func__ "stupid compiler !"
|
||||
#endif
|
||||
|
||||
/// Prints the source filename, line number, function name, a string and an integer.
|
||||
#define DEBUG(y,z) printf("%s %d %s | %s : %d###\n",__FILE__,__LINE__,__func__,y,(unsigned int)z)
|
||||
|
||||
/// Same as ::DEBUG but in hexadecimal
|
||||
#define DEBUGX(y,z) printf("%s %d %s | %s : %X###\n",__FILE__,__LINE__,__func__,y,(unsigned int)z)
|
||||
|
||||
/// Helper function used by the macro ::Error
|
||||
void Error_function(int error_code, const char *filename, int line_number, const char *function_name);
|
||||
|
||||
///
|
||||
/// Report a run-time error: It will print to standard output some information
|
||||
/// about the calling function, and then:
|
||||
/// - If the error code is 0, just do a red screen flash and resume.
|
||||
/// - If the error code is non-zero, abort the program.
|
||||
#define Error(n) Error_function(n, __FILE__,__LINE__,__func__)
|
||||
|
||||
/// Helper function used by the macro ::Warning
|
||||
void Warning_function(const char *message, const char *filename, int line_number, const char *function_name);
|
||||
|
||||
///
|
||||
/// Report a run-time abnormal condition : It will print to standard output
|
||||
/// some information about the calling function, and then resume silently.
|
||||
/// This is most useful in debugger so you can put a breakpoint on
|
||||
/// ::Warning_function and examine the stack trace.
|
||||
#define Warning(msg) Warning_function(msg, __FILE__,__LINE__,__func__)
|
||||
1076
src/factory.c
Normal file
1076
src/factory.c
Normal file
File diff suppressed because it is too large
Load Diff
3
src/factory.h
Normal file
3
src/factory.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
void Button_Brush_Factory(void);
|
||||
3654
src/fileformats.c
Normal file
3654
src/fileformats.c
Normal file
File diff suppressed because it is too large
Load Diff
1764
src/filesel.c
Normal file
1764
src/filesel.c
Normal file
File diff suppressed because it is too large
Load Diff
51
src/filesel.h
Normal file
51
src/filesel.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 filesel.h
|
||||
/// Fileselector window, used for loading and saving images and brushes.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __FILESEL_H__
|
||||
#define __FILESEL_H__
|
||||
|
||||
#include "struct.h"
|
||||
#include "loadsave.h"
|
||||
|
||||
byte Button_Load_or_Save(byte load, T_IO_Context *context);
|
||||
|
||||
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).
|
||||
/// The returned value is a pointer to a single static buffer of 19 characters
|
||||
/// including the '\\0'.
|
||||
char * Format_filename(const char * fname, int type);
|
||||
|
||||
void Free_fileselector_list(T_Fileselector *list);
|
||||
|
||||
void Sort_list_of_files(T_Fileselector *list);
|
||||
|
||||
void Recount_files(T_Fileselector *list);
|
||||
|
||||
T_Fileselector_item * Get_item_by_index(T_Fileselector *list, short index);
|
||||
|
||||
short Find_file_in_fileselector(T_Fileselector *list, const char * fname);
|
||||
|
||||
#endif
|
||||
BIN
src/gfx2.ico
Normal file
BIN
src/gfx2.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
984
src/global.h
Normal file
984
src/global.h
Normal file
@@ -0,0 +1,984 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2009 Franck Charlet
|
||||
Copyright 2009 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 global.h
|
||||
/// This file contains all global variables.
|
||||
/// They are prefixed by ::GFX2_GLOBAL so they are extern when needed.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef _GLOBAL_H_
|
||||
#define _GLOBAL_H_
|
||||
|
||||
#include <SDL.h>
|
||||
#include "struct.h"
|
||||
|
||||
// MAIN declares the variables,
|
||||
// other files only have an extern definition.
|
||||
#ifdef GLOBAL_VARIABLES
|
||||
/// Magic prefix to make all declarations extern, except when included by main.c.
|
||||
#define GFX2_GLOBAL
|
||||
#else
|
||||
#define GFX2_GLOBAL extern
|
||||
#endif
|
||||
|
||||
// -- CONFIGURATION variables
|
||||
|
||||
/// Current configuration.
|
||||
GFX2_GLOBAL T_Config Config;
|
||||
|
||||
/// Array of special keys.
|
||||
GFX2_GLOBAL word Config_Key[NB_SPECIAL_SHORTCUTS][2];
|
||||
|
||||
/// A video mode (resolution) usable by Grafx2.
|
||||
typedef struct
|
||||
{
|
||||
short Width; ///< Screen width
|
||||
short Height; ///< Screen height
|
||||
byte Mode; ///< Unused (used to be Mode-X, SVGA, etc)
|
||||
word Fullscreen; ///< 0 for window, 1 for fullscreen
|
||||
byte State; ///< How good is the mode supported. 0:Good (white) 1:OK (light) 2:So-so (dark) 4:User-disabled (black); +128 => System doesn't support it at all.
|
||||
} T_Video_mode;
|
||||
|
||||
/// Array of all video modes supported by your platform. Actually filled up to ::Nb_video_modes, excluded.
|
||||
GFX2_GLOBAL T_Video_mode Video_mode[MAX_VIDEO_MODES];
|
||||
|
||||
/// Actual number of video modes in ::Video_mode.
|
||||
GFX2_GLOBAL int Nb_video_modes;
|
||||
|
||||
// -- Menu colors
|
||||
|
||||
GFX2_GLOBAL byte MC_Black; ///< Index of color to use as "black" in the GUI menus.
|
||||
GFX2_GLOBAL byte MC_Dark; ///< Index of color to use as "dark grey" in the GUI menus.
|
||||
GFX2_GLOBAL byte MC_Light; ///< Index of color to use as "light grey" 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.
|
||||
|
||||
// Input state
|
||||
GFX2_GLOBAL word Mouse_X; ///< Current mouse cursor position.
|
||||
GFX2_GLOBAL word Mouse_Y; ///< Current mouse cursor position.
|
||||
GFX2_GLOBAL byte Mouse_K; ///< Current mouse buttons state. Bitfield: 1 for RMB, 2 for LMB.
|
||||
GFX2_GLOBAL byte Keyboard_click_allowed; ///< Set to 0 when you edit a textfield so you can use space without exiting it
|
||||
|
||||
/// Helper macro to take only one button when both are pressed (LMB has priority)
|
||||
#define Mouse_K_unique (Mouse_K==0?0:(Mouse_K&1?1:(Mouse_K&2?2:0)))
|
||||
|
||||
/// Last key pressed, 0 if none. Set by the latest call to ::Get_input()
|
||||
GFX2_GLOBAL dword Key;
|
||||
|
||||
///
|
||||
/// Last character typed, converted to ANSI character set (Windows-1252).
|
||||
/// This is mostly used when the user enters text (filename, etc).
|
||||
GFX2_GLOBAL dword Key_ANSI;
|
||||
|
||||
// Keyboard modifiers
|
||||
// (Name conflict with windows.h)
|
||||
#ifdef MOD_SHIFT
|
||||
#undef MOD_SHIFT
|
||||
#endif
|
||||
#ifdef MOD_CTRL
|
||||
#undef MOD_CTRL
|
||||
#endif
|
||||
#ifdef MOD_ALT
|
||||
#undef MOD_ALT
|
||||
#endif
|
||||
|
||||
/// Key modifier for SHIFT key. Used as mask in ::Key, for example.
|
||||
#define MOD_SHIFT 0x1000
|
||||
/// Key modifier for CONTROL key. Used as mask in ::Key, for example.
|
||||
#define MOD_CTRL 0x2000
|
||||
/// Key modifier for ALT key. Used as mask in ::Key, for example.
|
||||
#define MOD_ALT 0x4000
|
||||
/// Key modifier for META key. Used as mask in ::Key, for example.
|
||||
#define MOD_META 0x8000
|
||||
|
||||
/// Boolean set to true when the OS/window manager requests the application to close. ie: [X] button
|
||||
GFX2_GLOBAL byte Quit_is_required;
|
||||
|
||||
///
|
||||
/// This boolean is true when the current operation allows changing the
|
||||
/// foreground or background color.
|
||||
GFX2_GLOBAL byte Allow_color_change_during_operation;
|
||||
|
||||
// -- Mouse cursor data
|
||||
|
||||
/// Current mouse cursor. Value is in enum ::CURSOR_SHAPES
|
||||
GFX2_GLOBAL byte Cursor_shape;
|
||||
/// Backup of ::Cursor_shape, used while a window is open (and needs a different cursor)
|
||||
GFX2_GLOBAL byte Cursor_shape_before_window;
|
||||
/// Boolean, means the cursor should not be drawn. It's togglable by the user.
|
||||
GFX2_GLOBAL byte Cursor_hidden;
|
||||
/// Boolean, means the cursor is currently hovering over a menu GUI element.
|
||||
GFX2_GLOBAL byte Cursor_in_menu;
|
||||
/// Boolean, means the cursor was hovering over a menu GUI element.
|
||||
GFX2_GLOBAL byte Cursor_in_menu_previous;
|
||||
/// Storage for the graphics under the mouse cursor. Used by ::Hide_cursor and ::Display_cursor
|
||||
GFX2_GLOBAL byte Cursor_background[CURSOR_SPRITE_HEIGHT][CURSOR_SPRITE_WIDTH];
|
||||
|
||||
// -- Paintbrush data
|
||||
|
||||
/// Active paintbrush. It's an index in enum ::PAINTBRUSH_SHAPES
|
||||
GFX2_GLOBAL byte Paintbrush_shape;
|
||||
/// Backup of ::Paintbrush_shape, before fill operation
|
||||
GFX2_GLOBAL byte Paintbrush_shape_before_fill;
|
||||
/// Backup of ::Paintbrush_shape, before color picker operation
|
||||
GFX2_GLOBAL byte Paintbrush_shape_before_colorpicker;
|
||||
/// Backup of ::Paintbrush_shaper, before lasso operation
|
||||
GFX2_GLOBAL byte Paintbrush_shape_before_lasso;
|
||||
/// Boolean, true when the preview paintbrush shouldn't be drawn.
|
||||
GFX2_GLOBAL byte Paintbrush_hidden;
|
||||
/// Cordinate of the preview paintbrush in image space.
|
||||
GFX2_GLOBAL short Paintbrush_X;
|
||||
/// Cordinate of the preview paintbrush in image space.
|
||||
GFX2_GLOBAL short Paintbrush_Y;
|
||||
/// Pixel data of the current brush
|
||||
GFX2_GLOBAL byte * Paintbrush_sprite;
|
||||
/// Current paintbrush's width
|
||||
GFX2_GLOBAL short Paintbrush_width;
|
||||
/// Current paintbrush's height
|
||||
GFX2_GLOBAL short Paintbrush_height;
|
||||
/// Position of current paintbrush's handle
|
||||
GFX2_GLOBAL short Paintbrush_offset_X;
|
||||
/// Position of current paintbrush's handle
|
||||
GFX2_GLOBAL short Paintbrush_offset_Y;
|
||||
|
||||
// -- Graphic commands
|
||||
|
||||
/// On the screen, draw a point.
|
||||
GFX2_GLOBAL Func_pixel Pixel;
|
||||
/// Test a pixel color from screen.
|
||||
GFX2_GLOBAL Func_read Read_pixel;
|
||||
/// Redraw all screen, without overwriting the menu.
|
||||
GFX2_GLOBAL Func_display Display_screen;
|
||||
/// Draw a rectangle on screen.
|
||||
GFX2_GLOBAL Func_block Block;
|
||||
/// Draw a point from the image to screen (no zoom).
|
||||
GFX2_GLOBAL Func_pixel Pixel_preview_normal;
|
||||
/// Draw a point from the image to screen (magnified part).
|
||||
GFX2_GLOBAL Func_pixel Pixel_preview_magnifier;
|
||||
/// Draw a point from the image to screen (zoomed if needed).
|
||||
GFX2_GLOBAL Func_pixel Pixel_preview;
|
||||
/// Draw a horizontal XOR line on screen.
|
||||
GFX2_GLOBAL Func_line_XOR Horizontal_XOR_line;
|
||||
/// Draw a vertical XOR line on screen.
|
||||
GFX2_GLOBAL Func_line_XOR Vertical_XOR_line;
|
||||
/// Display part of the brush on screen, color mode.
|
||||
GFX2_GLOBAL Func_display_brush_color Display_brush_color;
|
||||
/// Display part of the brush on screen, monochrome mode.
|
||||
GFX2_GLOBAL Func_display_brush_mono Display_brush_mono;
|
||||
/// Clear the brush currently displayed on screen, redrawing the image instead.
|
||||
GFX2_GLOBAL Func_display_brush_color Clear_brush;
|
||||
/// Remap part of the screen after the menu colors have changed.
|
||||
GFX2_GLOBAL Func_remap Remap_screen;
|
||||
/// Draw a line on screen.
|
||||
GFX2_GLOBAL Func_procsline Display_line;
|
||||
/// Draw a line on screen, without doubling it if using wide pixels. (to be used when the line is already doubled in the input buffer)
|
||||
GFX2_GLOBAL Func_procsline Display_line_fast;
|
||||
/// Read a line of pixels from screen.
|
||||
GFX2_GLOBAL Func_procsline Read_line;
|
||||
/// Redraw all magnified part on screen, without overwriting the menu.
|
||||
GFX2_GLOBAL Func_display_zoom Display_zoomed_screen;
|
||||
/// Display part of the brush on the magnified part of screen, color mode.
|
||||
GFX2_GLOBAL Func_display_brush_color_zoom Display_brush_color_zoom;
|
||||
/// Display part of the brush on the magnified part of screen, monochrome mode.
|
||||
GFX2_GLOBAL Func_display_brush_mono_zoom Display_brush_mono_zoom;
|
||||
/// Clear the brush currently displayed on the magnified part of screen, redrawing the image instead.
|
||||
GFX2_GLOBAL Func_display_brush_color_zoom Clear_brush_scaled;
|
||||
/// Draw an arbitrary brush on screen (not the current brush)
|
||||
GFX2_GLOBAL Func_draw_brush Display_brush;
|
||||
|
||||
// -- Screen data
|
||||
|
||||
/// Requested window width. This is set when the user resizes the window.
|
||||
GFX2_GLOBAL int Resize_width;
|
||||
/// Requested window height. This is set when the user resizes the window.
|
||||
GFX2_GLOBAL int Resize_height;
|
||||
/// Current video mode. Index in ::Video_mode
|
||||
GFX2_GLOBAL int Current_resolution;
|
||||
/// After loading an image, this holds the "original screen width", if the file format supported it.
|
||||
GFX2_GLOBAL short Original_screen_X;
|
||||
/// After loading an image, this holds the "original screen height", if the file format supported it.
|
||||
GFX2_GLOBAL short Original_screen_Y;
|
||||
///
|
||||
/// Current screen (or window) width, in pixels.
|
||||
/// Note that this takes ::Pixel_ratio into account.
|
||||
GFX2_GLOBAL short Screen_width;
|
||||
///
|
||||
/// Current screen (or window) height, in pixels.
|
||||
/// Note that this takes ::Pixel_ratio into account.
|
||||
GFX2_GLOBAL short Screen_height;
|
||||
/// Coordinate (in image space) of the topmost visible pixel.
|
||||
GFX2_GLOBAL short Limit_top;
|
||||
///
|
||||
/// Coordinate (in image space) of the lowest visible pixel.
|
||||
/// This can be larger than the image height, if the screen is bigger than image.
|
||||
GFX2_GLOBAL short Limit_bottom;
|
||||
/// Coordinate (in image space) of the leftmost visible pixel.
|
||||
GFX2_GLOBAL short Limit_left;
|
||||
///
|
||||
/// Coordinate (in image space) of the rightmost visible pixel.
|
||||
/// This can be larger than the image width, if the screen is bigger than image.
|
||||
GFX2_GLOBAL short Limit_right;
|
||||
///
|
||||
/// Coordinate (in image space) of the lowest visible pixel, limited by the
|
||||
/// image height. Compare with ::Limit_bottom, which is not clipped.
|
||||
GFX2_GLOBAL short Limit_visible_bottom;
|
||||
///
|
||||
/// Coordinate (in image space) of the rightmost visible pixel, limited by the
|
||||
/// image width. Compare with ::Limit_right, which is not clipped.
|
||||
GFX2_GLOBAL short Limit_visible_right;
|
||||
|
||||
/// Coordinate (in image space) of the pixel at the top of the magnified view.
|
||||
GFX2_GLOBAL short Limit_top_zoom;
|
||||
///
|
||||
/// Coordinate (in image space) of the pixel at the bottom of the magnified view.
|
||||
/// This can be larger than the image height, if the screen is bigger than image.
|
||||
GFX2_GLOBAL short Limit_bottom_zoom;
|
||||
/// Coordinate (in image space) of the pixel at the left of the magnified view.
|
||||
GFX2_GLOBAL short Limit_left_zoom;
|
||||
///
|
||||
/// Coordinate (in image space) of the pixel at the right of the magnified view.
|
||||
/// This can be larger than the image width, if the screen is bigger than image.
|
||||
GFX2_GLOBAL short Limit_right_zoom;
|
||||
///
|
||||
/// Coordinate (in image space) of the lowest visible pixel, limited by the
|
||||
/// image height. Compare with ::Limit_bottom, which is not clipped.
|
||||
GFX2_GLOBAL short Limit_visible_bottom_zoom;
|
||||
/// Coordinate (in image space) of the rightmost visible pixel.
|
||||
/// This can be larger than the image width, if the screen is bigger than image.
|
||||
GFX2_GLOBAL short Limit_visible_right_zoom;
|
||||
|
||||
/// Buffer of pixels, used when drawing something to screen.
|
||||
GFX2_GLOBAL byte * Horizontal_line_buffer;
|
||||
|
||||
/// Current pixel ratio. Index in enum ::PIXEL_RATIO
|
||||
GFX2_GLOBAL int Pixel_ratio;
|
||||
/// Current width of pixels, according to ::Pixel_ratio
|
||||
GFX2_GLOBAL int Pixel_width;
|
||||
/// Current height of pixels, according to ::Pixel_ratio
|
||||
GFX2_GLOBAL int Pixel_height;
|
||||
|
||||
|
||||
// -- Current image data
|
||||
|
||||
/// Pointer to the pixel data of the main image
|
||||
GFX2_GLOBAL byte * Main_screen;
|
||||
/// Palette of the main image
|
||||
GFX2_GLOBAL T_Palette Main_palette;
|
||||
/// Boolean, means the image has been modified since last save.
|
||||
GFX2_GLOBAL byte Main_image_is_modified;
|
||||
/// Width in pixels of the main image.
|
||||
GFX2_GLOBAL short Main_image_width;
|
||||
/// Height in pixels of the main image.
|
||||
GFX2_GLOBAL short Main_image_height;
|
||||
/// X position (in image space) of the pixel to display in the top left corner of screen.
|
||||
GFX2_GLOBAL short Main_offset_X;
|
||||
/// Y position (in image space) of the pixel to display in the top left corner of screen.
|
||||
GFX2_GLOBAL short Main_offset_Y;
|
||||
/// Backup of ::Main_offset_X, used to store it while the magnifier is open.
|
||||
GFX2_GLOBAL short Old_main_offset_X;
|
||||
/// Backup of ::Main_offset_Y, used to store it while the magnifier is open.
|
||||
GFX2_GLOBAL short Old_main_offset_Y;
|
||||
/// Name of the directory that holds the image currently edited.
|
||||
GFX2_GLOBAL char Main_file_directory[1024];
|
||||
/// Filename (without directory) of the image currently edited.
|
||||
GFX2_GLOBAL char Main_filename[256];
|
||||
/// File format of the image currently edited. It's a value of enum ::FILE_FORMATS
|
||||
GFX2_GLOBAL byte Main_fileformat;
|
||||
///
|
||||
/// Fileselector "filter" format, for the current image.
|
||||
/// (The spare page has its own separate settings)
|
||||
/// It's 0 for "*.*", or a value of enum ::FILE_FORMATS
|
||||
GFX2_GLOBAL byte Main_format;
|
||||
/// Index of the first file/entry to display in the fileselector.
|
||||
GFX2_GLOBAL short Main_fileselector_position;
|
||||
///
|
||||
/// Position of the "highlight" bar in the fileselector. 10 Files can be visible,
|
||||
/// So it's a number in the [0-9] range.
|
||||
GFX2_GLOBAL short Main_fileselector_offset;
|
||||
/// Current directory for the fileselector.
|
||||
GFX2_GLOBAL char Main_current_directory[1024];
|
||||
/// Main image's file comment (some image formats support text strings).
|
||||
GFX2_GLOBAL char Main_comment[COMMENT_SIZE+1];
|
||||
/// X position (in screen coordinates) of the separator between normal and magnified views.
|
||||
GFX2_GLOBAL short Main_separator_position;
|
||||
/// X position (in screen coordinates) of the first pixel of the magnified view.
|
||||
GFX2_GLOBAL short Main_X_zoom;
|
||||
/// Proportion of the non-magnified part of the screen.
|
||||
GFX2_GLOBAL float Main_separator_proportion;
|
||||
/// Boolean, true if the main image has the magnifier active.
|
||||
GFX2_GLOBAL byte Main_magnifier_mode;
|
||||
/// Zoom factor used in the magnifier (main image).
|
||||
GFX2_GLOBAL word Main_magnifier_factor;
|
||||
/// Height of the magnified view for the main image.
|
||||
GFX2_GLOBAL word Main_magnifier_height;
|
||||
/// Width of the magnified view for the main image.
|
||||
GFX2_GLOBAL word Main_magnifier_width;
|
||||
/// X position (in image space) of the pixel to display in the top left corner of the magnified view.
|
||||
GFX2_GLOBAL short Main_magnifier_offset_X;
|
||||
/// Y position (in image space) of the pixel to display in the top left corner of the magnified view.
|
||||
GFX2_GLOBAL short Main_magnifier_offset_Y;
|
||||
/// Index of layer currently being edited
|
||||
GFX2_GLOBAL byte Main_current_layer;
|
||||
/// Bitfield that records which layers are visible. 2^0 for 0, 2^1 for 1, 2^2 for 2, etc.
|
||||
GFX2_GLOBAL dword Main_layers_visible;
|
||||
/// Index to use next time, when creating incremental backups, to make unique filename.
|
||||
GFX2_GLOBAL long Main_safety_number;
|
||||
/// Number of edit actions since the last safety backup
|
||||
GFX2_GLOBAL long Main_edits_since_safety_backup;
|
||||
/// SDL Time of the previous safety backup
|
||||
GFX2_GLOBAL Uint32 Main_time_of_safety_backup;
|
||||
/// Letter prefix for the filenames of safety backups. a or b
|
||||
GFX2_GLOBAL byte Main_safety_backup_prefix;
|
||||
|
||||
// -- Spare page data
|
||||
|
||||
/// Palette of the spare page
|
||||
GFX2_GLOBAL T_Palette Spare_palette;
|
||||
/// Boolean, means the spare page has been modified since last save.
|
||||
GFX2_GLOBAL byte Spare_image_is_modified;
|
||||
/// Width in pixels of the spare image.
|
||||
GFX2_GLOBAL short Spare_image_width;
|
||||
/// Height in pixels of the spare image.
|
||||
GFX2_GLOBAL short Spare_image_height;
|
||||
/// X position (in image space) of the pixel to display in the top left corner of screen.
|
||||
GFX2_GLOBAL short Spare_offset_X;
|
||||
/// Y position (in image space) of the pixel to display in the top left corner of screen.
|
||||
GFX2_GLOBAL short Spare_offset_Y;
|
||||
/// Backup of ::Main_offset_X, used to store it while the magnifier is open.
|
||||
GFX2_GLOBAL short Old_spare_offset_X;
|
||||
/// Backup of ::Main_offset_Y, used to store it while the magnifier is open.
|
||||
GFX2_GLOBAL short Old_spare_offset_Y;
|
||||
/// Name of the directory that holds the image currently edited as spare page.
|
||||
GFX2_GLOBAL char Spare_file_directory[MAX_PATH_CHARACTERS];
|
||||
/// Filename (without directory) of the image currently edited as spare page.
|
||||
GFX2_GLOBAL char Spare_filename[MAX_PATH_CHARACTERS];
|
||||
/// File format of the image currently edited as spare page. It's a value of enum ::FILE_FORMATS
|
||||
GFX2_GLOBAL byte Spare_fileformat;
|
||||
///
|
||||
/// Fileselector "filter" format, for the spare page.
|
||||
/// (The main image has its own separate settings)
|
||||
/// It's 0 for "*.*", or a value of enum ::FILE_FORMAT
|
||||
GFX2_GLOBAL byte Spare_format;
|
||||
/// Index of the first file/entry to display in the fileselector.
|
||||
GFX2_GLOBAL short Spare_fileselector_position;
|
||||
///
|
||||
/// Position of the "highlight" bar in the fileselector. 10 Files can be visible,
|
||||
/// So it's a number in the [0-9] range.
|
||||
GFX2_GLOBAL short Spare_fileselector_offset;
|
||||
/// Current directory for the fileselector.
|
||||
GFX2_GLOBAL char Spare_current_directory[MAX_PATH_CHARACTERS];
|
||||
/// Spare page's file comment (some image formats support text strings).
|
||||
GFX2_GLOBAL char Spare_comment[COMMENT_SIZE+1];
|
||||
/// X position (in screen coordinates) of the separator between normal and magnified views.
|
||||
GFX2_GLOBAL short Spare_separator_position;
|
||||
/// X position (in screen coordinates) of the first pixel of the magnified view.
|
||||
GFX2_GLOBAL short Spare_X_zoom;
|
||||
/// Proportion of the non-magnified part of the screen.
|
||||
GFX2_GLOBAL float Spare_separator_proportion;
|
||||
/// Boolean, true if the main image has the magnifier active.
|
||||
GFX2_GLOBAL byte Spare_magnifier_mode;
|
||||
/// Zoom factor used in the magnifier (spare page).
|
||||
GFX2_GLOBAL word Spare_magnifier_factor;
|
||||
/// Width of the magnified view for the spare page.
|
||||
GFX2_GLOBAL word Spare_magnifier_height;
|
||||
/// Height of the magnified view for the spare page.
|
||||
GFX2_GLOBAL word Spare_magnifier_width;
|
||||
/// X position (in image space) of the pixel to display in the top left corner of the magnified view.
|
||||
GFX2_GLOBAL short Spare_magnifier_offset_X;
|
||||
/// Y position (in image space) of the pixel to display in the top left corner of the magnified view.
|
||||
GFX2_GLOBAL short Spare_magnifier_offset_Y;
|
||||
/// Index of layer currently being edited
|
||||
GFX2_GLOBAL byte Spare_current_layer;
|
||||
/// Bitfield that records which layers are visible. 2^0 for 0, 2^1 for 1, 2^2 for 2, etc.
|
||||
GFX2_GLOBAL dword Spare_layers_visible;
|
||||
/// Index to use next time, when creating incremental backups, to make unique filename.
|
||||
GFX2_GLOBAL long Spare_safety_number;
|
||||
/// Number of edit actions since the last safety backup
|
||||
GFX2_GLOBAL long Spare_edits_since_safety_backup;
|
||||
/// SDL Time of the previous safety backup
|
||||
GFX2_GLOBAL Uint32 Spare_time_of_safety_backup;
|
||||
/// Letter prefix for the filenames of safety backups. a or b
|
||||
GFX2_GLOBAL byte Spare_safety_backup_prefix;
|
||||
|
||||
// -- Image backups
|
||||
|
||||
/// Backup of the current screen, used during drawing when FX feedback is OFF.
|
||||
GFX2_GLOBAL byte * Screen_backup;
|
||||
/// List of backup pages for the main image.
|
||||
GFX2_GLOBAL T_List_of_pages * Main_backups;
|
||||
/// List of backup pages for the spare page.
|
||||
GFX2_GLOBAL T_List_of_pages * Spare_backups;
|
||||
|
||||
|
||||
// -- Brush data
|
||||
|
||||
/// Pixel data of the current brush.
|
||||
GFX2_GLOBAL byte * Brush;
|
||||
/// X coordinate of the brush's "hot spot". It is < ::Brush_width
|
||||
GFX2_GLOBAL word Brush_offset_X;
|
||||
/// Y coordinate of the brush's "hot spot". It is < ::Brush_height
|
||||
GFX2_GLOBAL word Brush_offset_Y;
|
||||
/// Width of the current brush.
|
||||
GFX2_GLOBAL word Brush_width;
|
||||
/// Height of the current brush.
|
||||
GFX2_GLOBAL word Brush_height;
|
||||
/// Name of the directory that holds the brush fil (after loading or saving it).
|
||||
GFX2_GLOBAL char Brush_file_directory[MAX_PATH_CHARACTERS];
|
||||
/// Filename (without directory) of the brush (after loading or saving it).
|
||||
GFX2_GLOBAL char Brush_filename[MAX_PATH_CHARACTERS];
|
||||
/// File format of the brush. It's a value of enum ::FILE_FORMATS
|
||||
GFX2_GLOBAL byte Brush_fileformat;
|
||||
///
|
||||
/// Fileselector "filter" format, for the brush.
|
||||
/// It's 0 for "*.*", or a value of enum ::FILE_FORMATS
|
||||
GFX2_GLOBAL byte Brush_format;
|
||||
/// Index of the first file/entry to display in the brush's fileselector.
|
||||
GFX2_GLOBAL short Brush_fileselector_position;
|
||||
///
|
||||
/// Position of the "highlight" bar in the brush's fileselector. 10 Files can
|
||||
/// be visible, so it's a number in the [0-9] range.
|
||||
GFX2_GLOBAL short Brush_fileselector_offset;
|
||||
/// Current directory for the brush's fileselector.
|
||||
GFX2_GLOBAL char Brush_current_directory[256];
|
||||
/// File comment in the brush's fileselector (some image formats support text strings).
|
||||
GFX2_GLOBAL char Brush_comment[COMMENT_SIZE+1];
|
||||
/// Indicator used for the "Rotate brush" operation.
|
||||
GFX2_GLOBAL byte Brush_rotation_center_is_defined;
|
||||
/// Position of the brush's rotation center, in screen coordinates.
|
||||
GFX2_GLOBAL short Brush_rotation_center_X;
|
||||
/// Position of the brush's rotation center, in screen coordinates.
|
||||
GFX2_GLOBAL short Brush_rotation_center_Y;
|
||||
|
||||
// -- Menu data (toolbox)
|
||||
|
||||
/// Boolean, true if the menu has to be displayed.
|
||||
GFX2_GLOBAL byte Menu_is_visible;
|
||||
/// Height of the menu, when it's displayed
|
||||
GFX2_GLOBAL word Menu_height;
|
||||
///
|
||||
/// Y position (in screen coordinates) where the menu begins.
|
||||
/// This is always either ::Screen_height (when menu is hidden) or (::Screen_height - ::Menu_height)
|
||||
/// As a result, the drawing algoritm always draws the image from 0 to ::Menu_Y-1
|
||||
GFX2_GLOBAL word Menu_Y;
|
||||
/// Y position of the status bar (in screen coordinates)
|
||||
GFX2_GLOBAL word Menu_status_Y;
|
||||
/// Scaling factor for the menu and all GUI elements
|
||||
GFX2_GLOBAL byte Menu_factor_X;
|
||||
/// Scaling factor for the menu and all GUI elements
|
||||
GFX2_GLOBAL byte Menu_factor_Y;
|
||||
/// Size of a color cell in the menu's palette.
|
||||
GFX2_GLOBAL word Menu_palette_cell_width;
|
||||
|
||||
GFX2_GLOBAL T_Menu_Bar Menu_bars[MENUBAR_COUNT]
|
||||
#ifdef GLOBAL_VARIABLES
|
||||
=
|
||||
{{MENU_WIDTH, 9, 1, 45, NULL, 20, BUTTON_HIDE }, // Status
|
||||
{MENU_WIDTH, 10, 1, 35, NULL, 144, BUTTON_LAYER_SELECT }, // Layers
|
||||
{MENU_WIDTH, 35, 1, 0, NULL, 254, BUTTON_CHOOSE_COL }} // Main
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
// -- Window data
|
||||
|
||||
/// Number of stacked windows currently displayed. 0 when no window is present.
|
||||
GFX2_GLOBAL byte Windows_open;
|
||||
/// Backup of ::Menu_is_visible, used to store it while a window is open.
|
||||
GFX2_GLOBAL byte Menu_is_visible_before_window;
|
||||
/// Backup of ::Menu_Y, used to store it while a window is open.
|
||||
GFX2_GLOBAL word Menu_Y_before_window;
|
||||
/// Backup of ::Paintbrush_hidden, used to store it while a window is open.
|
||||
GFX2_GLOBAL byte Paintbrush_hidden_before_window;
|
||||
|
||||
GFX2_GLOBAL word Window_stack_pos_X[8];
|
||||
/// Position of the left border of the topmost window (in screen coordinates)
|
||||
#define Window_pos_X Window_stack_pos_X[Windows_open-1]
|
||||
|
||||
GFX2_GLOBAL word Window_stack_pos_Y[8];
|
||||
/// Position of the top border of the topmost window (in screen coordinates)
|
||||
#define Window_pos_Y Window_stack_pos_Y[Windows_open-1]
|
||||
|
||||
GFX2_GLOBAL word Window_stack_width[8];
|
||||
///
|
||||
/// Width of the topmost window, in "window pixels"
|
||||
/// (multiply by ::Menu_factor_X to get screen pixels)
|
||||
#define Window_width Window_stack_width[Windows_open-1]
|
||||
|
||||
GFX2_GLOBAL word Window_stack_height[8];
|
||||
///
|
||||
/// Height of the topmost window, in "window pixels"
|
||||
/// (multiply by ::Menu_factor_Y to get screen pixels)
|
||||
#define Window_height Window_stack_height[Windows_open-1]
|
||||
|
||||
GFX2_GLOBAL word Window_stack_nb_buttons[8];
|
||||
/// Total number of buttons/controls in the topmost window.
|
||||
#define Window_nb_buttons Window_stack_nb_buttons[Windows_open-1]
|
||||
|
||||
GFX2_GLOBAL T_Normal_button * Window_stack_normal_button_list[8];
|
||||
/// List of normal buttons in the topmost window.
|
||||
#define Window_normal_button_list Window_stack_normal_button_list[Windows_open-1]
|
||||
|
||||
GFX2_GLOBAL T_Palette_button * Window_stack_palette_button_list[8];
|
||||
/// List of "palette" buttons in the topmost window.
|
||||
#define Window_palette_button_list Window_stack_palette_button_list[Windows_open-1]
|
||||
|
||||
GFX2_GLOBAL T_Scroller_button * Window_stack_scroller_button_list[8];
|
||||
/// List of sliders (scrollers) in the topmost window.
|
||||
#define Window_scroller_button_list Window_stack_scroller_button_list[Windows_open-1]
|
||||
|
||||
GFX2_GLOBAL T_Special_button * Window_stack_special_button_list[8];
|
||||
/// List of special buttons in the topmost window.
|
||||
#define Window_special_button_list Window_stack_special_button_list[Windows_open-1]
|
||||
|
||||
GFX2_GLOBAL T_Dropdown_button * Window_stack_dropdown_button_list[8];
|
||||
/// List of dropdown buttons in the topmost window.
|
||||
#define Window_dropdown_button_list Window_stack_dropdown_button_list[Windows_open-1]
|
||||
|
||||
GFX2_GLOBAL T_List_button * Window_stack_list_button_list[8];
|
||||
/// List of list buttons in the topmost window.
|
||||
#define Window_list_button_list Window_stack_list_button_list[Windows_open-1]
|
||||
|
||||
|
||||
|
||||
GFX2_GLOBAL int Window_stack_attribute1[8];
|
||||
///
|
||||
/// The function ::Window_clicked_button() set this to ::LEFT_SIDE or ::RIGHT_SIDE
|
||||
/// after a button is activated through left or right mouse click.
|
||||
#define Window_attribute1 Window_stack_attribute1[Windows_open-1]
|
||||
|
||||
GFX2_GLOBAL int Window_stack_attribute2[8];
|
||||
///
|
||||
/// The function ::Window_clicked_button() set this to return extra information:
|
||||
/// - When a scroller was clicked: the scroller position (0-n)
|
||||
/// - When a palette was clicked: the color index (0-255)
|
||||
/// - When a dropdown was used: the selected item's number T_Dropdown_choice::Number
|
||||
#define Window_attribute2 Window_stack_attribute2[Windows_open-1]
|
||||
|
||||
|
||||
|
||||
|
||||
/// Definition of the menu (toolbox)
|
||||
GFX2_GLOBAL struct
|
||||
{
|
||||
// Button aspect
|
||||
word X_offset; ///< Position relative to menu's left
|
||||
word Y_offset; ///< Position relative to menu's top
|
||||
word Width; ///< Button's active width
|
||||
word Height; ///< Button's active heigth
|
||||
byte Pressed; ///< Button is currently pressed
|
||||
byte Shape; ///< Shape, listed in enum ::BUTTON_SHAPES
|
||||
|
||||
// Triggers on mouse/keyboard
|
||||
Func_action Left_action; ///< Action triggered by a left mouseclick on the button
|
||||
Func_action Right_action; ///< Action triggered by a right mouseclick on the button
|
||||
word Left_shortcut[2]; ///< Keyboard shortcut for a left mouseclick
|
||||
word Right_shortcut[2];///< Keyboard shortcut for a right mouseclick
|
||||
byte Left_instant; ///< Will not wait for mouse release before triggering action
|
||||
byte Right_instant; ///< Will not wait for mouse release before triggering action
|
||||
|
||||
// Data used when the button is unselected
|
||||
Func_action Unselect_action; ///< Action triggered by unselecting the button
|
||||
byte Family; ///< enum ::FAMILY_OF_BUTTONS.
|
||||
|
||||
} Buttons_Pool[NB_BUTTONS];
|
||||
|
||||
|
||||
|
||||
// -- Information about the different drawing modes (effects)
|
||||
|
||||
/// Current effecting function. When no effect is selected this is ::No_effect()
|
||||
GFX2_GLOBAL Func_effect Effect_function;
|
||||
|
||||
///
|
||||
/// Array of booleans, indicates which colors should never be picked by
|
||||
/// ::Best_color()
|
||||
GFX2_GLOBAL byte Exclude_color[256];
|
||||
|
||||
// -- Smear mode
|
||||
|
||||
/// Smear mode is activated
|
||||
GFX2_GLOBAL byte Smear_mode;
|
||||
/// Boolean, indicates that a smear is in progress.
|
||||
GFX2_GLOBAL byte Smear_start;
|
||||
/// Pointer to the sprite to use for smear; it contains pixels from the image.
|
||||
GFX2_GLOBAL byte * Smear_brush;
|
||||
/// Width of the ::Smear_brush
|
||||
GFX2_GLOBAL word Smear_brush_width;
|
||||
/// Height of the ::Smear_brush
|
||||
GFX2_GLOBAL word Smear_brush_height;
|
||||
/// Limits of the smear.
|
||||
GFX2_GLOBAL short Smear_min_X;
|
||||
/// Limits of the smear.
|
||||
GFX2_GLOBAL short Smear_max_X;
|
||||
/// Limits of the smear.
|
||||
GFX2_GLOBAL short Smear_min_Y;
|
||||
/// Limits of the smear.
|
||||
GFX2_GLOBAL short Smear_max_Y;
|
||||
|
||||
// -- Shade mode
|
||||
/// List of the shade tables
|
||||
GFX2_GLOBAL T_Shade Shade_list[8];
|
||||
/// Shade currently selected (index in ::Shade_list)
|
||||
GFX2_GLOBAL byte Shade_current;
|
||||
/// Conversion table in use
|
||||
GFX2_GLOBAL byte * Shade_table;
|
||||
/// Conversion table for a left click
|
||||
GFX2_GLOBAL byte Shade_table_left[256];
|
||||
/// Conversion table for a right click
|
||||
GFX2_GLOBAL byte Shade_table_right[256];
|
||||
/// Boolean, true when the shade mode is active.
|
||||
GFX2_GLOBAL byte Shade_mode;
|
||||
|
||||
/// Boolean, true when the quick-shade mode is active.
|
||||
GFX2_GLOBAL byte Quick_shade_mode;
|
||||
/// Size of the step, in Quick-shade mode. It's the number of colors to "jump".
|
||||
GFX2_GLOBAL byte Quick_shade_step;
|
||||
/// Determines how colors should loop in Quick-shade more. Value in enum ::SHADE_MODES
|
||||
GFX2_GLOBAL byte Quick_shade_loop;
|
||||
|
||||
// -- Stencil mode
|
||||
|
||||
/// Boolean, true when stencil mode is active.
|
||||
GFX2_GLOBAL byte Stencil_mode;
|
||||
/// Array of the protected colors by Stencil mode.
|
||||
GFX2_GLOBAL byte Stencil[256];
|
||||
|
||||
// -- Grid mode
|
||||
|
||||
/// Boolean, true when the Grid mode is active.
|
||||
GFX2_GLOBAL byte Snap_mode;
|
||||
/// Boolean, true when the Grid is displayed in zoomed view.
|
||||
GFX2_GLOBAL byte Show_grid;
|
||||
/// Width of the grid in Grid mode.
|
||||
GFX2_GLOBAL word Snap_width;
|
||||
/// Height of the grid in Grid mode.
|
||||
GFX2_GLOBAL word Snap_height;
|
||||
/// Position of the starting pixel, in Grid mode.
|
||||
GFX2_GLOBAL word Snap_offset_X;
|
||||
/// Position of the starting pixel, in Grid mode.
|
||||
GFX2_GLOBAL word Snap_offset_Y;
|
||||
|
||||
// -- Sieve mode
|
||||
|
||||
/// Boolean, true when the Sieve mode is active
|
||||
GFX2_GLOBAL byte Sieve_mode;
|
||||
/// Sprite of the sieve pattern. It's actually an array of booleans.
|
||||
GFX2_GLOBAL byte Sieve[16][16];
|
||||
/// Width of the sieve pattern, in Sieve mode.
|
||||
GFX2_GLOBAL short Sieve_width;
|
||||
/// Height of the sieve pattern, in Sieve mode.
|
||||
GFX2_GLOBAL short Sieve_height;
|
||||
|
||||
// -- Colorize mode
|
||||
|
||||
/// Boolean, true when the Colorize mode is active.
|
||||
GFX2_GLOBAL byte Colorize_mode;
|
||||
/// % of opacity of Colorize mode (for translucency)
|
||||
GFX2_GLOBAL byte Colorize_opacity;
|
||||
/// Sets the colorization mode: 0 transparency, 1 additive, 2 substractive
|
||||
GFX2_GLOBAL byte Colorize_current_mode;
|
||||
///
|
||||
/// Table of precomputed factors used by Colorize mode. It hold 0 to 255 when
|
||||
/// opacity is 100%, 0 to 128 when opacity is 50%, etc.
|
||||
// FIXME: This only caches a multiplication and a division. Maybe we should scrap it
|
||||
GFX2_GLOBAL word Factors_table[256];
|
||||
///
|
||||
/// Table of precomputed factors used by Colorize mode. It hold 255 to 0 when
|
||||
/// opacity is 100%, 128 to 0 when opacity is 50%, etc.
|
||||
// FIXME: This only caches a multiplication, a division, a substraction. Maybe we should scrap it
|
||||
GFX2_GLOBAL word Factors_inv_table[256];
|
||||
|
||||
// -- Smooth mode
|
||||
|
||||
/// Boolean, true when the Smooth mode is active
|
||||
GFX2_GLOBAL byte Smooth_mode;
|
||||
/// Matrix of "weights" used by the Smooth mode.
|
||||
GFX2_GLOBAL byte Smooth_matrix[3][3];
|
||||
|
||||
// -- Tiling mode
|
||||
|
||||
/// Boolean, true when the Tiling mode is active
|
||||
GFX2_GLOBAL byte Tiling_mode;
|
||||
/// Position of the starting pixel in Tiling mode.
|
||||
GFX2_GLOBAL short Tiling_offset_X;
|
||||
/// Position of the starting pixel in Tiling mode.
|
||||
GFX2_GLOBAL short Tiling_offset_Y;
|
||||
|
||||
// -- Mask mode
|
||||
|
||||
/// Boolean, true when the Tiling mode is active
|
||||
GFX2_GLOBAL byte Mask_mode;
|
||||
/// Array of booleans. True if the indexed color is protected by the mask.
|
||||
GFX2_GLOBAL byte Mask_table[256];
|
||||
|
||||
// -- Magnifier data
|
||||
|
||||
#ifdef GLOBAL_VARIABLES
|
||||
word ZOOM_FACTOR[NB_ZOOM_FACTORS]={2,3,4,5,6,8,10,12,14,16,18,20, 24, 28, 32};
|
||||
#else
|
||||
/// Successive zoom factors, used by the Magnifier.
|
||||
extern word ZOOM_FACTOR[NB_ZOOM_FACTORS];
|
||||
#endif
|
||||
|
||||
// -- Data for ellipses and circles
|
||||
// FIXME: move most of these to graph.c
|
||||
GFX2_GLOBAL long Ellipse_cursor_X;
|
||||
GFX2_GLOBAL long Ellipse_cursor_Y;
|
||||
GFX2_GLOBAL long Ellipse_vertical_radius_squared;
|
||||
GFX2_GLOBAL long Ellipse_horizontal_radius_squared;
|
||||
GFX2_GLOBAL qword Ellipse_limit;
|
||||
GFX2_GLOBAL long Circle_cursor_X;
|
||||
GFX2_GLOBAL long Circle_cursor_Y;
|
||||
GFX2_GLOBAL long Circle_limit;
|
||||
|
||||
// -- Data for gradients
|
||||
|
||||
/// First color of the gradient.
|
||||
GFX2_GLOBAL short Gradient_lower_bound;
|
||||
/// Last color of the gradient
|
||||
GFX2_GLOBAL short Gradient_upper_bound;
|
||||
/// Boolean, true if the gradient should use colors in descending order
|
||||
GFX2_GLOBAL int Gradient_is_inverted;
|
||||
/// Number of colors in the range ::Gradient_lower_bound to ::Gradient_upper_bound (included)
|
||||
GFX2_GLOBAL long Gradient_bounds_range;
|
||||
/// Maximum value passed to the gradient function. The pixels assigned this value should use last gradient color.
|
||||
GFX2_GLOBAL long Gradient_total_range;
|
||||
/// Amount of randomness to use in gradient (1-256+)
|
||||
GFX2_GLOBAL long Gradient_random_factor;
|
||||
/// Pointer to a gradient function, depending on the selected method.
|
||||
GFX2_GLOBAL Func_gradient Gradient_function;
|
||||
///
|
||||
/// Pointer to the pixel-drawing function that gradients should use:
|
||||
/// either ::Pixel (if the gradient must be drawn on menus only)
|
||||
/// or ::Display_pixel (if the gradient must be drawn on the image)
|
||||
GFX2_GLOBAL Func_pixel Gradient_pixel;
|
||||
/// Settings for all gradients
|
||||
GFX2_GLOBAL T_Gradient_array Gradient_array[16];
|
||||
/// Index in ::Gradient_array of the currently selected gradient.
|
||||
GFX2_GLOBAL byte Current_gradient;
|
||||
|
||||
// -- Airbrush data
|
||||
|
||||
/// Mode to use in airbrush: 0 for multicolor, 1 for mono.
|
||||
GFX2_GLOBAL byte Airbrush_mode;
|
||||
/// Diameter of the airbrush, in pixels.
|
||||
GFX2_GLOBAL short Airbrush_size;
|
||||
/// Delay between two airbrush "shots", in 1/100s
|
||||
GFX2_GLOBAL byte Airbrush_delay;
|
||||
/// Number of pixels that are emitted by the airbrush, in mono mode.
|
||||
GFX2_GLOBAL byte Airbrush_mono_flow;
|
||||
/// Number of pixels that are emitted by the airbrush for each color (multi mode)
|
||||
GFX2_GLOBAL byte Airbrush_multi_flow[256];
|
||||
|
||||
/// -- Misc data about the program
|
||||
|
||||
/// Boolean, set to true to exit the program.
|
||||
GFX2_GLOBAL byte Quitting;
|
||||
/// Name of the directory that was current when the program was run.
|
||||
GFX2_GLOBAL char Initial_directory[256];
|
||||
/// Name of the directory that holds the program's (read-only) data: skins, icon, etc.
|
||||
GFX2_GLOBAL char Data_directory[256];
|
||||
/// Name of the directory where grafx2 reads and writes configuration (gfx2.ini, gfx2.cfg)
|
||||
GFX2_GLOBAL char Config_directory[256];
|
||||
/// Current foreground color for drawing.
|
||||
GFX2_GLOBAL byte Fore_color;
|
||||
/// Current background color for drawing.
|
||||
GFX2_GLOBAL byte Back_color;
|
||||
/// For the "Freehand draw" tool, this determines which variant is selected, from ::OPERATION_CONTINUOUS_DRAW to ::OPERATION_FILLED_CONTOUR
|
||||
GFX2_GLOBAL byte Selected_freehand_mode;
|
||||
/// For the Curve tool, this determines which variant is selected, either ::OPERATION_3_POINTS_CURVE or ::OPERATION_4_POINTS_CURVE
|
||||
GFX2_GLOBAL byte Selected_curve_mode;
|
||||
/// For the Line tool, this determines which variant is selected, either ::OPERATION_LINE, ::OPERATION_K_LIGNE or ::OPERATION_CENTERED_LINES
|
||||
GFX2_GLOBAL byte Selected_line_mode;
|
||||
/// Determines which color appears in the first cell of the menu palette. Change this value to "scroll" the palette.
|
||||
GFX2_GLOBAL byte First_color_in_palette;
|
||||
/// Boolean, true if Grafx2 was run with a command-line argument to set a resolution on startup (overrides config)
|
||||
GFX2_GLOBAL byte Resolution_in_command_line;
|
||||
|
||||
// - Graphic
|
||||
|
||||
/// Pointer to the font selected for menus.
|
||||
GFX2_GLOBAL byte * Menu_font;
|
||||
|
||||
/// Pointer to the current active skin.
|
||||
GFX2_GLOBAL T_Gui_skin * Gfx;
|
||||
|
||||
// -- Help data
|
||||
|
||||
/// Index of the ::Help_section shown by the Help screen.
|
||||
GFX2_GLOBAL byte Current_help_section;
|
||||
/// Line number of the help viewer, in current ::Help_section. 0 for top, increase value to scroll down.
|
||||
GFX2_GLOBAL word Help_position;
|
||||
|
||||
// -- Operation data
|
||||
|
||||
/// Index of the operation which was selected (ex: drawing rectangle) before the current interruption (ex: colorpicking).
|
||||
GFX2_GLOBAL word Operation_before_interrupt;
|
||||
/// Index of the current operation. This is the active "tool".
|
||||
GFX2_GLOBAL word Current_operation;
|
||||
///
|
||||
/// This stack is used to memorize all parameters needed during the course of
|
||||
/// an operation. For example when drawing a rectangle: color, starting
|
||||
/// coordinates, ending coordinates.
|
||||
GFX2_GLOBAL word Operation_stack[OPERATION_STACK_SIZE];
|
||||
/// Number of parameters stored in ::Operation_stack (0=empty)
|
||||
GFX2_GLOBAL byte Operation_stack_size;
|
||||
/// Boolean, true if the operation (drawing) started in the magnified area.
|
||||
GFX2_GLOBAL byte Operation_in_magnifier;
|
||||
/// Last color hovered by the colorpicker. -1 if it wasn't over the image.
|
||||
GFX2_GLOBAL short Colorpicker_color;
|
||||
/// Position of the colorpicker tool, in image coordinates.
|
||||
GFX2_GLOBAL short Colorpicker_X;
|
||||
/// Position of the colorpicker tool, in image coordinates.
|
||||
GFX2_GLOBAL short Colorpicker_Y;
|
||||
|
||||
GFX2_GLOBAL short * Polyfill_table_of_points;
|
||||
GFX2_GLOBAL int Polyfill_number_of_points;
|
||||
|
||||
/// Brush container
|
||||
GFX2_GLOBAL T_Brush_template Brush_container[BRUSH_CONTAINER_COLUMNS*BRUSH_CONTAINER_ROWS];
|
||||
|
||||
#ifdef GLOBAL_VARIABLES
|
||||
byte CURSOR_FOR_OPERATION[NB_OPERATIONS]=
|
||||
{
|
||||
CURSOR_SHAPE_TARGET , // Freehand continuous draw
|
||||
CURSOR_SHAPE_TARGET , // Freehand discontinuous draw
|
||||
CURSOR_SHAPE_TARGET , // Freehand point-by-point draw
|
||||
CURSOR_SHAPE_TARGET , // Filled contour
|
||||
CURSOR_SHAPE_TARGET , // Lines
|
||||
CURSOR_SHAPE_TARGET , // Linked lines
|
||||
CURSOR_SHAPE_TARGET , // Centered lines
|
||||
CURSOR_SHAPE_XOR_TARGET , // Empty rectangle
|
||||
CURSOR_SHAPE_XOR_TARGET , // Filled rectangle
|
||||
CURSOR_SHAPE_TARGET , // Empty circle
|
||||
CURSOR_SHAPE_TARGET , // Filled circle
|
||||
CURSOR_SHAPE_TARGET , // Empty ellipse
|
||||
CURSOR_SHAPE_TARGET , // Filled ellipse
|
||||
CURSOR_SHAPE_TARGET , // Fill
|
||||
CURSOR_SHAPE_TARGET , // Color replacer
|
||||
CURSOR_SHAPE_XOR_TARGET , // Rectangular brush grabbing
|
||||
CURSOR_SHAPE_TARGET , // Polygonal brush grabbing
|
||||
CURSOR_SHAPE_COLORPICKER , // Colorpicker
|
||||
CURSOR_SHAPE_XOR_RECTANGLE , // Position the magnify window
|
||||
CURSOR_SHAPE_TARGET , // Curve with 3 control points
|
||||
CURSOR_SHAPE_TARGET , // Curve with 4 control points
|
||||
CURSOR_SHAPE_TARGET , // Airbrush
|
||||
CURSOR_SHAPE_TARGET , // Polygon
|
||||
CURSOR_SHAPE_TARGET , // Polyform
|
||||
CURSOR_SHAPE_TARGET , // Filled polygon
|
||||
CURSOR_SHAPE_TARGET , // Filled polyform
|
||||
CURSOR_SHAPE_MULTIDIRECTIONAL , // Scroll (pan)
|
||||
CURSOR_SHAPE_TARGET , // Gradient-filled circle
|
||||
CURSOR_SHAPE_TARGET , // Gradient-filled ellipse
|
||||
CURSOR_SHAPE_XOR_ROTATION , // Rotate brush
|
||||
CURSOR_SHAPE_XOR_TARGET , // Stretch brush
|
||||
CURSOR_SHAPE_TARGET , // Distort brush
|
||||
CURSOR_SHAPE_XOR_TARGET , // Gradient-filled rectangle
|
||||
};
|
||||
#else
|
||||
/// ::Cursor_shape to use for each operation.
|
||||
extern byte CURSOR_FOR_OPERATION[NB_OPERATIONS];
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Procedures to call for each state (determined by ::Operation_stack_size) of
|
||||
/// each operation, and for each mouse state (no button,left button,right button)
|
||||
GFX2_GLOBAL struct
|
||||
{
|
||||
Func_action Action; ///< Function to call
|
||||
byte Hide_cursor; ///< Boolean: Need to hide/unhide cursor during this step
|
||||
byte Fast_mouse; ///< Operation should take shortcuts with mouse movements
|
||||
} Operation[NB_OPERATIONS][3][OPERATION_STACK_SIZE];
|
||||
|
||||
// -- misc
|
||||
|
||||
///
|
||||
/// Indicator of error in previous file operations.
|
||||
/// - 0: OK
|
||||
/// - 1: Error when beginning operation. Existing data should be ok.
|
||||
/// - 2: Error while operation was in progress. Data is modified.
|
||||
/// - -1: Interruption of a preview.
|
||||
GFX2_GLOBAL signed char File_error;
|
||||
/// Current line number when reading/writing gfx2.ini
|
||||
GFX2_GLOBAL int Line_number_in_INI_file;
|
||||
|
||||
// -- Specific to SDL
|
||||
|
||||
/// Pointer to the program's screen.
|
||||
GFX2_GLOBAL SDL_Surface * Screen_SDL;
|
||||
/// Pointer to the current joystick controller.
|
||||
GFX2_GLOBAL SDL_Joystick* Joystick;
|
||||
|
||||
/// Indicates "no keyboard shortcut".
|
||||
#define KEY_NONE 0
|
||||
///
|
||||
/// This is the "key identifier" for the mouse 3rd button.
|
||||
/// It was chosen to not conflict with any SDL key number.
|
||||
#define KEY_MOUSEMIDDLE (SDLK_LAST+1)
|
||||
///
|
||||
/// This is the "key identifier" for the mouse wheelup.
|
||||
/// It was chosen to not conflict with any SDL key number.
|
||||
#define KEY_MOUSEWHEELUP (SDLK_LAST+2)
|
||||
///
|
||||
/// This is the "key identifier" for the mouse wheeldown.
|
||||
/// It was chosen to not conflict with any SDL key number.
|
||||
#define KEY_MOUSEWHEELDOWN (SDLK_LAST+3)
|
||||
///
|
||||
/// This is the "key identifier" for joystick button number 0.
|
||||
/// All numbers starting with this one are reserved for joystick buttons
|
||||
/// (since their is an unknown number of them, and for example 18 on GP2X)
|
||||
/// It was chosen to not conflict with any SDL key number.
|
||||
#define KEY_JOYBUTTON (SDLK_LAST+4)
|
||||
|
||||
/// Button definitions for the gp2x
|
||||
#define GP2X_BUTTON_UP (0)
|
||||
#define GP2X_BUTTON_DOWN (4)
|
||||
#define GP2X_BUTTON_LEFT (2)
|
||||
#define GP2X_BUTTON_RIGHT (6)
|
||||
#define GP2X_BUTTON_UPLEFT (1)
|
||||
#define GP2X_BUTTON_UPRIGHT (7)
|
||||
#define GP2X_BUTTON_DOWNLEFT (3)
|
||||
#define GP2X_BUTTON_DOWNRIGHT (5)
|
||||
#define GP2X_BUTTON_CLICK (18)
|
||||
#define GP2X_BUTTON_A (12)
|
||||
#define GP2X_BUTTON_B (13)
|
||||
#define GP2X_BUTTON_Y (14)
|
||||
#define GP2X_BUTTON_X (15)
|
||||
#define GP2X_BUTTON_L (10)
|
||||
#define GP2X_BUTTON_R (11)
|
||||
#define GP2X_BUTTON_START (8)
|
||||
#define GP2X_BUTTON_SELECT (9)
|
||||
#define GP2X_BUTTON_VOLUP (16)
|
||||
#define GP2X_BUTTON_VOLDOWN (17)
|
||||
|
||||
#ifdef __gp2x__
|
||||
#define KEY_ESC (KEY_JOYBUTTON+GP2X_BUTTON_X)
|
||||
#else
|
||||
///
|
||||
/// This is the key identifier for ESC. When hard-coding keyboard shortcuts
|
||||
/// for buttons, etc. we use this instead of SDLK_ESCAPE,
|
||||
/// so the GP2X port can get a joybutton equivalent of it.
|
||||
#define KEY_ESC SDLK_ESCAPE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
2941
src/graph.c
Normal file
2941
src/graph.c
Normal file
File diff suppressed because it is too large
Load Diff
120
src/graph.h
Normal file
120
src/graph.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007-2008 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 graph.h
|
||||
/// Graphic functions that target the screen and/or image.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Shade_list_to_lookup_tables(word * list, short step, byte mode, byte * table_inc,
|
||||
byte * table_dec
|
||||
);
|
||||
|
||||
void Transform_point(short x, short y,
|
||||
float cos_a, float sin_a, short * rx, short * ry);
|
||||
|
||||
int Init_mode_video(int width, int height, int fullscreen,int pixel_ratio);
|
||||
|
||||
byte No_effect(word x,word y,byte color);
|
||||
byte Effect_shade(word x,word y,byte color);
|
||||
byte Effect_quick_shade(word x,word y,byte color);
|
||||
byte Effect_tiling(word x,word y,byte color);
|
||||
byte Effect_smooth(word x,word y,byte color);
|
||||
|
||||
void Display_foreback(void);
|
||||
|
||||
|
||||
void Display_pixel(word x,word y,byte color);
|
||||
|
||||
void Display_paintbrush(short x,short y,byte color,byte is_preview);
|
||||
void Hide_paintbrush(short x,short y);
|
||||
|
||||
void Resize_image(word chosen_width,word chosen_height);
|
||||
|
||||
void Fill_general(byte fill_color);
|
||||
void Replace(byte New_color);
|
||||
|
||||
void Pixel_figure_preview (word x_pos,word y_pos,byte color);
|
||||
void Pixel_figure_preview_auto(word x_pos,word y_pos);
|
||||
void Pixel_figure_preview_xor(word x_pos,word y_pos,byte color);
|
||||
void Pixel_figure_preview_xorback(word x_pos,word y_pos,byte color);
|
||||
void Pixel_figure_in_brush(word x_pos,word y_pos,byte color);
|
||||
|
||||
void Draw_empty_circle_permanent(short center_x,short center_y,short radius,byte color);
|
||||
void Draw_empty_circle_preview (short center_x,short center_y,short radius,byte color);
|
||||
void Hide_empty_circle_preview (short center_x,short center_y,short radius);
|
||||
void Draw_filled_circle (short center_x,short center_y,short radius,byte color);
|
||||
|
||||
void Draw_empty_ellipse_permanent(short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color);
|
||||
void Draw_empty_ellipse_preview (short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color);
|
||||
void Hide_empty_ellipse_preview (short center_x,short center_y,short horizontal_radius,short vertical_radius);
|
||||
void Draw_filled_ellipse (short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color);
|
||||
|
||||
void Clamp_coordinates_regular_angle(short ax, short ay, short* bx, short* by);
|
||||
void Draw_line_general(short start_x,short start_y,short end_x,short end_y, byte color);
|
||||
void Draw_line_permanent (short start_x,short start_y,short end_x,short end_y,byte color);
|
||||
void Draw_line_preview (short start_x,short start_y,short end_x,short end_y,byte color);
|
||||
void Draw_line_preview_xor(short start_x,short start_y,short end_x,short end_y,byte color);
|
||||
void Draw_line_preview_xorback(short start_x,short start_y,short end_x,short end_y,byte color);
|
||||
void Hide_line_preview (short start_x,short start_y,short end_x,short end_y);
|
||||
|
||||
void Draw_empty_rectangle(short start_x,short start_y,short end_x,short end_y,byte color);
|
||||
void Draw_filled_rectangle(short start_x,short start_y,short end_x,short end_y,byte color);
|
||||
|
||||
void Draw_curve_permanent(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, byte color);
|
||||
void Draw_curve_preview (short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, byte color);
|
||||
void Hide_curve_preview (short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, byte color);
|
||||
|
||||
void Airbrush(short clicked_button);
|
||||
|
||||
void Gradient_basic (long index,short x_pos,short y_pos);
|
||||
void Gradient_dithered (long index,short x_pos,short y_pos);
|
||||
void Gradient_extra_dithered(long index,short x_pos,short y_pos);
|
||||
void Degrade_aleatoire (long index,short x_pos,short y_pos);
|
||||
|
||||
void Draw_grad_circle (short center_x,short center_y,short radius,short spot_x,short spot_y);
|
||||
void Draw_grad_ellipse(short center_x,short center_y,short horizontal_radius,short vertical_radius,short spot_x,short spot_y);
|
||||
void Draw_grad_rectangle(short rax,short ray,short rbx,short rby,short vax,short vay, short vbx, short vby);
|
||||
|
||||
void Polyfill_general(int vertices, short * points, int color);
|
||||
void Polyfill(int vertices, short * points, int color);
|
||||
|
||||
/// Remap the spare page according to the main page's palette
|
||||
void Remap_spare(void);
|
||||
|
||||
///
|
||||
/// All the figure-drawing functions work by calling this function for each
|
||||
/// pixel to draw. Before calling these functions, you should assign
|
||||
/// ::Pixel_figure depending on what you where you want to draw:
|
||||
/// - ::Pixel_figure_preview : On screen.
|
||||
/// - ::Pixel_figure_preview_xor : On screen, XORing the color.
|
||||
/// - ::Pixel_figure_permanent : On screen and in the image.
|
||||
/// - ::Pixel_figure_clear_preview : On screen, reverting to the image's pixels.
|
||||
extern Func_pixel Pixel_figure;
|
||||
|
||||
void Update_part_of_screen(short x, short y, short width, short height);
|
||||
|
||||
void Redraw_grid(short x, short y, unsigned short w, unsigned short h);
|
||||
|
||||
void Pixel_in_current_screen (word x,word y,byte color,int with_preview);
|
||||
void Pixel_in_current_layer(word x,word y, byte color);
|
||||
byte Read_pixel_from_current_screen (word x,word y);
|
||||
byte Read_pixel_from_current_layer(word x,word y);
|
||||
726
src/help.c
Normal file
726
src/help.c
Normal file
@@ -0,0 +1,726 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Peter Gordon
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#include <windows.h>
|
||||
#elif defined(__macosx__) || defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#elif defined (__linux__)
|
||||
#include <sys/vfs.h>
|
||||
#endif
|
||||
|
||||
#include "const.h"
|
||||
#include "struct.h"
|
||||
#include "global.h"
|
||||
#include "misc.h"
|
||||
#include "engine.h"
|
||||
#include "helpfile.h"
|
||||
#include "help.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "text.h"
|
||||
#include "keyboard.h"
|
||||
#include "windows.h"
|
||||
#include "input.h"
|
||||
#include "hotkeys.h"
|
||||
#include "errors.h"
|
||||
#include "pages.h"
|
||||
|
||||
extern char Program_version[]; // generated in pversion.c
|
||||
extern char SVN_revision[]; // generated in pversion.c
|
||||
|
||||
// Recherche un raccourci clavier:
|
||||
word * Shortcut(word shortcut_number)
|
||||
{
|
||||
if (shortcut_number & 0x100)
|
||||
return &(Buttons_Pool[shortcut_number & 0xFF].Left_shortcut[0]);
|
||||
if (shortcut_number & 0x200)
|
||||
return &(Buttons_Pool[shortcut_number & 0xFF].Right_shortcut[0]);
|
||||
return &(Config_Key[shortcut_number & 0xFF][0]);
|
||||
}
|
||||
|
||||
// Nom de la touche actuallement assignée à un raccourci d'après son numéro
|
||||
// de type 0x100+BOUTON_* ou SPECIAL_*
|
||||
const char * Keyboard_shortcut_value(word shortcut_number)
|
||||
{
|
||||
static char shortcuts_name[80];
|
||||
word * pointer = Shortcut(shortcut_number);
|
||||
if (pointer == NULL)
|
||||
return "(Problem)";
|
||||
else
|
||||
{
|
||||
if (pointer[0] == 0 && pointer[1] == 0)
|
||||
return "None";
|
||||
if (pointer[0] != 0 && pointer[1] == 0)
|
||||
return Key_name(pointer[0]);
|
||||
if (pointer[0] == 0 && pointer[1] != 0)
|
||||
return Key_name(pointer[1]);
|
||||
|
||||
strcpy(shortcuts_name, Key_name(pointer[0]));
|
||||
strcat(shortcuts_name, " or ");
|
||||
strcat(shortcuts_name, Key_name(pointer[1]));
|
||||
return shortcuts_name;
|
||||
}
|
||||
}
|
||||
void Redefine_control(word *shortcut, int x_pos, int y_pos)
|
||||
{
|
||||
Hide_cursor();
|
||||
Print_in_window(x_pos,y_pos,"*PRESS KEY OR BUTTON*",MC_Black,MC_Light);
|
||||
Display_cursor();
|
||||
while (1)
|
||||
{
|
||||
while(!Get_input())SDL_Delay(20);
|
||||
if (Key==KEY_ESC)
|
||||
return;
|
||||
if (Key!=0)
|
||||
{
|
||||
*shortcut=Key;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Window_set_shortcut(int action_id)
|
||||
{
|
||||
short clicked_button;
|
||||
short order_index;
|
||||
short config_index;
|
||||
short redraw_controls=1;
|
||||
word * shortcut_ptr=NULL;
|
||||
word backup_shortcut[2];
|
||||
|
||||
shortcut_ptr=Shortcut(action_id);
|
||||
|
||||
backup_shortcut[0]=shortcut_ptr[0];
|
||||
backup_shortcut[1]=shortcut_ptr[1];
|
||||
|
||||
// Recherche dans hotkeys
|
||||
order_index=0;
|
||||
while (Ordering[order_index]!=action_id)
|
||||
{
|
||||
order_index++;
|
||||
if (order_index>=NB_SHORTCUTS)
|
||||
{
|
||||
Error(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
config_index=0;
|
||||
while (ConfigKey[config_index].Number!=order_index)
|
||||
{
|
||||
config_index++;
|
||||
if (config_index>=NB_SHORTCUTS)
|
||||
{
|
||||
Error(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
config_index=order_index; // Comprends pas... ça devrait pas marcher
|
||||
|
||||
Open_window(302,131,"Keyboard shortcut");
|
||||
Window_set_normal_button(181,111,55,14,"Cancel",0,1,KEY_ESC); // 1
|
||||
Window_set_normal_button(241,111,55,14,"OK",0,1,SDLK_RETURN); // 2
|
||||
|
||||
Window_set_normal_button(6,111,111,14,"Reset default",0,1,KEY_NONE); // 3
|
||||
|
||||
// Titre
|
||||
Block(Window_pos_X+(Menu_factor_X*5),
|
||||
Window_pos_Y+(Menu_factor_Y*16),
|
||||
Menu_factor_X*292,Menu_factor_Y*11,MC_Black);
|
||||
Print_in_window(7,18,ConfigKey[config_index].Label,MC_White,MC_Black);
|
||||
|
||||
// Zone de description
|
||||
Window_display_frame_in(5,68,292,37);
|
||||
Print_in_window(8,70,ConfigKey[config_index].Explanation1,MC_Black,MC_Light);
|
||||
Print_in_window(8,78,ConfigKey[config_index].Explanation2,MC_Black,MC_Light);
|
||||
Print_in_window(8,86,ConfigKey[config_index].Explanation3,MC_Black,MC_Light);
|
||||
|
||||
// Shortcut 0
|
||||
Window_set_normal_button(27,30,177,14,"",0,1,KEY_NONE); // 4
|
||||
Window_set_normal_button(209,30,56,14,"Remove",0,1,KEY_NONE); // 5
|
||||
|
||||
// Shortcut 1
|
||||
Window_set_normal_button(27,49,177,14,"",0,1,KEY_NONE); // 6
|
||||
Window_set_normal_button(209,49,56,14,"Remove",0,1,KEY_NONE); // 7
|
||||
|
||||
Display_cursor();
|
||||
do
|
||||
{
|
||||
if (redraw_controls)
|
||||
{
|
||||
Hide_cursor();
|
||||
Block(Window_pos_X+(Menu_factor_X*32),
|
||||
Window_pos_Y+(Menu_factor_Y*33),
|
||||
Menu_factor_X*21*8,Menu_factor_Y*8,MC_Light);
|
||||
Print_in_window_limited(32,33,Key_name(shortcut_ptr[0]),21,MC_Black,MC_Light);
|
||||
Block(Window_pos_X+(Menu_factor_X*32),
|
||||
Window_pos_Y+(Menu_factor_Y*52),
|
||||
Menu_factor_X*21*8,Menu_factor_Y*8,MC_Light);
|
||||
Print_in_window_limited(32,52,Key_name(shortcut_ptr[1]),21,MC_Black,MC_Light);
|
||||
|
||||
Update_rect(Window_pos_X,Window_pos_Y,302*Menu_factor_X,131*Menu_factor_Y);
|
||||
|
||||
Display_cursor();
|
||||
redraw_controls=0;
|
||||
}
|
||||
|
||||
clicked_button=Window_clicked_button();
|
||||
|
||||
switch (clicked_button)
|
||||
{
|
||||
case -1:
|
||||
case 0:
|
||||
break;
|
||||
case 4: // Change 0
|
||||
Redefine_control(&shortcut_ptr[0], 32, 33);
|
||||
redraw_controls=1;
|
||||
break;
|
||||
case 6: // Change 1
|
||||
Redefine_control(&shortcut_ptr[1], 32, 52);
|
||||
redraw_controls=1;
|
||||
break;
|
||||
case 5: // Remove 0
|
||||
shortcut_ptr[0]=0;
|
||||
redraw_controls=1;
|
||||
break;
|
||||
case 7: // Remove 1
|
||||
shortcut_ptr[1]=0;
|
||||
redraw_controls=1;
|
||||
break;
|
||||
case 3: // Defaults
|
||||
shortcut_ptr[0]=ConfigKey[config_index].Key;
|
||||
shortcut_ptr[1]=ConfigKey[config_index].Key2;
|
||||
redraw_controls=1;
|
||||
break;
|
||||
case 1: // Cancel
|
||||
shortcut_ptr[0]=backup_shortcut[0];
|
||||
shortcut_ptr[1]=backup_shortcut[1];
|
||||
case 2: // OK
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
while ((clicked_button!=1) && (clicked_button!=2) && (Key!=SDLK_RETURN));
|
||||
Key=0;
|
||||
Close_window();
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
// -- Menu d'aide -----------------------------------------------------------
|
||||
|
||||
void Display_help(void)
|
||||
{
|
||||
short x; // Indices d'affichage d'un caractère
|
||||
short y;
|
||||
short x_position; // Parcours de remplissage du buffer de ligne
|
||||
short line_index; // 0-15 (16 lignes de textes)
|
||||
short char_index; // Parcours des caractères d'une ligne
|
||||
short start_line=Help_position;
|
||||
short repeat_menu_x_factor;
|
||||
short repeat_menu_y_factor;
|
||||
short real_x_pos;
|
||||
short real_y_pos;
|
||||
byte * char_pixel;
|
||||
short width; // Largeur physique d'une ligne de texte
|
||||
char line_type; // N: Normale, T: Titre, S: Sous-titre
|
||||
// -: Ligne inférieur de sous-titre
|
||||
const char * line;
|
||||
char buffer[45]; // buffer texte utilisé pour formater les noms de
|
||||
// raccourcis clavier
|
||||
short link_position=0; // Position du premier caractère "variable"
|
||||
short link_size=0; // Taille de la partie variable
|
||||
|
||||
real_x_pos=Window_pos_X+(13*Menu_factor_X);
|
||||
real_y_pos=Window_pos_Y+(19*Menu_factor_Y);
|
||||
|
||||
for (line_index=0;line_index<16;line_index++)
|
||||
{
|
||||
// Shortcut au cas ou la section fait moins de 16 lignes
|
||||
if (line_index >= Help_section[Current_help_section].Length)
|
||||
{
|
||||
Block (real_x_pos,
|
||||
real_y_pos,
|
||||
44*6*Menu_factor_X,
|
||||
// 44 = Nb max de char (+1 pour éviter les plantages en mode X
|
||||
// causés par une largeur = 0)
|
||||
(Menu_factor_Y<<3) * (16 - line_index),
|
||||
MC_Black);
|
||||
break;
|
||||
}
|
||||
// On affiche la ligne
|
||||
line = Help_section[Current_help_section].Help_table[start_line + line_index].Text;
|
||||
line_type = Help_section[Current_help_section].Help_table[start_line + line_index].Line_type;
|
||||
// Si c'est une sous-ligne de titre, on utilise le texte de la ligne précédente
|
||||
if (line_type == '-' && (start_line + line_index > 0))
|
||||
line = Help_section[Current_help_section].Help_table[start_line + line_index - 1].Text;
|
||||
else if (line_type == 'K')
|
||||
{
|
||||
const char *hyperlink;
|
||||
const char * escaped_percent_pos;
|
||||
// Determine link position:
|
||||
link_position = strstr(line,"%s") - line;
|
||||
// Adjust for any escaped %% that would precede it.
|
||||
escaped_percent_pos = line;
|
||||
do
|
||||
{
|
||||
escaped_percent_pos = strstr(escaped_percent_pos,"%%");
|
||||
if (escaped_percent_pos && escaped_percent_pos - line < link_position)
|
||||
{
|
||||
link_position--;
|
||||
escaped_percent_pos+=2;
|
||||
}
|
||||
} while (escaped_percent_pos);
|
||||
//
|
||||
hyperlink=Keyboard_shortcut_value(Help_section[Current_help_section].Help_table[start_line + line_index].Line_parameter);
|
||||
link_size=strlen(hyperlink);
|
||||
snprintf(buffer, 44, line, hyperlink);
|
||||
if (strlen(line)+link_size-2>44)
|
||||
{
|
||||
buffer[43]=ELLIPSIS_CHARACTER;
|
||||
buffer[44]='\0';
|
||||
}
|
||||
line = buffer;
|
||||
}
|
||||
|
||||
// Calcul de la taille
|
||||
width=strlen(line);
|
||||
// Les lignes de titres prennent plus de place
|
||||
if (line_type == 'T' || line_type == '-')
|
||||
width = width*2;
|
||||
|
||||
// Pour chaque ligne dans la fenêtre:
|
||||
for (y=0;y<8;y++)
|
||||
{
|
||||
x_position=0;
|
||||
// On crée une nouvelle ligne à splotcher
|
||||
for (char_index=0;char_index<width;char_index++)
|
||||
{
|
||||
// Recherche du caractère dans les fontes de l'aide.
|
||||
// Ligne titre : Si l'indice est impair on dessine le quart de caractère
|
||||
// qui va a gauche, sinon celui qui va a droite.
|
||||
if (line_type=='T')
|
||||
{
|
||||
if (line[char_index/2]>'_' || line[char_index/2]<' ')
|
||||
char_pixel=&(Gfx->Help_font_norm['!'][0][0]); // Caractère pas géré
|
||||
else if (char_index & 1)
|
||||
char_pixel=&(Gfx->Help_font_t2[(unsigned char)(line[char_index/2])-' '][0][0]);
|
||||
else
|
||||
char_pixel=&(Gfx->Help_font_t1[(unsigned char)(line[char_index/2])-' '][0][0]);
|
||||
}
|
||||
else if (line_type=='-')
|
||||
{
|
||||
if (line[char_index/2]>'_' || line[char_index/2]<' ')
|
||||
char_pixel=&(Gfx->Help_font_norm['!'][0][0]); // Caractère pas géré
|
||||
else if (char_index & 1)
|
||||
char_pixel=&(Gfx->Help_font_t4[(unsigned char)(line[char_index/2])-' '][0][0]);
|
||||
else
|
||||
char_pixel=&(Gfx->Help_font_t3[(unsigned char)(line[char_index/2])-' '][0][0]);
|
||||
}
|
||||
else if (line_type=='S')
|
||||
char_pixel=&(Gfx->Bold_font[(unsigned char)(line[char_index])][0][0]);
|
||||
else if (line_type=='N' || line_type=='K')
|
||||
char_pixel=&(Gfx->Help_font_norm[(unsigned char)(line[char_index])][0][0]);
|
||||
else
|
||||
char_pixel=&(Gfx->Help_font_norm['!'][0][0]); // Un garde-fou en cas de probleme
|
||||
|
||||
for (x=0;x<6;x++)
|
||||
for (repeat_menu_x_factor=0;repeat_menu_x_factor<Menu_factor_X;repeat_menu_x_factor++)
|
||||
{
|
||||
byte color = *(char_pixel+x+y*6);
|
||||
byte repetition = Pixel_width-1;
|
||||
// Surlignement pour liens
|
||||
if (line_type=='K' && char_index>=link_position
|
||||
&& char_index<(link_position+link_size))
|
||||
{
|
||||
if (color == MC_Light)
|
||||
color=MC_White;
|
||||
else if (color == MC_Dark)
|
||||
color=MC_Light;
|
||||
else if (y<7)
|
||||
color=MC_Dark;
|
||||
}
|
||||
Horizontal_line_buffer[x_position++]=color;
|
||||
while (repetition--)
|
||||
Horizontal_line_buffer[x_position++]=color;
|
||||
}
|
||||
}
|
||||
// On la splotche
|
||||
for (repeat_menu_y_factor=0;repeat_menu_y_factor<Menu_factor_Y;repeat_menu_y_factor++)
|
||||
Display_line_fast(real_x_pos,real_y_pos++,width*Menu_factor_X*6,Horizontal_line_buffer);
|
||||
}
|
||||
|
||||
// On efface la fin de la ligne:
|
||||
Block (real_x_pos+width*Menu_factor_X*6,
|
||||
real_y_pos-(8*Menu_factor_Y),
|
||||
((44*6*Menu_factor_X)-width*Menu_factor_X*6)+1,
|
||||
// 44 = Nb max de char (+1 pour éviter les plantages en mode X
|
||||
// causés par une largeur = 0)
|
||||
Menu_factor_Y<<3,
|
||||
MC_Black);
|
||||
}
|
||||
Update_rect(Window_pos_X+13*Menu_factor_X,Window_pos_Y+19*Menu_factor_Y,44*6*Menu_factor_X,16*8*Menu_factor_Y);
|
||||
}
|
||||
|
||||
|
||||
void Scroll_help(T_Scroller_button * scroller)
|
||||
{
|
||||
Hide_cursor();
|
||||
scroller->Position=Help_position;
|
||||
Compute_slider_cursor_height(scroller);
|
||||
Window_draw_slider(scroller);
|
||||
Display_help();
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
|
||||
void Button_Help(void)
|
||||
{
|
||||
short btn_number;
|
||||
|
||||
// Aide contextuelle
|
||||
if (Key!=0)
|
||||
{
|
||||
btn_number = Button_under_mouse();
|
||||
if (btn_number != -1)
|
||||
{
|
||||
Window_help(btn_number, NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Window_help(-1, NULL);
|
||||
}
|
||||
// Ouvre l'ecran d'aide. Passer -1 pour la section par défaut (ou derniere,)
|
||||
// Ou un nombre de l'enumération BUTTON_NUMBERS pour l'aide contextuelle.
|
||||
void Window_help(int section, const char *sub_section)
|
||||
{
|
||||
short clicked_button;
|
||||
short nb_lines;
|
||||
T_Scroller_button * scroller;
|
||||
|
||||
if (section!=-1)
|
||||
{
|
||||
Current_help_section = 4 + section;
|
||||
Help_position = 0;
|
||||
}
|
||||
nb_lines=Help_section[Current_help_section].Length;
|
||||
if (section!=-1 && sub_section!=NULL)
|
||||
{
|
||||
int index=0;
|
||||
for (index=0; index<nb_lines; index++)
|
||||
if (Help_section[Current_help_section].Help_table[index].Line_type == 'T' &&
|
||||
!strcmp(Help_section[Current_help_section].Help_table[index].Text, sub_section))
|
||||
{
|
||||
Help_position = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Open_window(310,175,"Help / About...");
|
||||
|
||||
// dessiner de la fenêtre où va défiler le texte
|
||||
Window_display_frame_in(8,17,274,132);
|
||||
Block(Window_pos_X+(Menu_factor_X*9),
|
||||
Window_pos_Y+(Menu_factor_Y*18),
|
||||
Menu_factor_X*272,Menu_factor_Y*130,MC_Black);
|
||||
|
||||
Window_set_normal_button(266,153,35,14,"Exit",0,1,KEY_ESC); // 1
|
||||
scroller=Window_set_scroller_button(290,18,130,nb_lines,
|
||||
16,Help_position); // 2
|
||||
|
||||
Window_set_normal_button( 9,154, 6*8,14,"About" ,1,1,SDLK_a); // 3
|
||||
|
||||
Window_set_normal_button( 9+6*8+4,154, 8*8,14,"License",1,1,SDLK_l); // 4
|
||||
Window_set_normal_button( 9+6*8+4+8*8+4,154, 5*8,14,"Help",1,1,SDLK_h); // 5
|
||||
Window_set_normal_button(9+6*8+4+8*8+4+5*8+4,154, 8*8,14,"Credits",1,1,SDLK_c); // 6
|
||||
|
||||
Window_set_special_button(9,18,272,130); // 7
|
||||
|
||||
Display_help();
|
||||
|
||||
Update_rect(Window_pos_X,Window_pos_Y,310*Menu_factor_X,175*Menu_factor_Y);
|
||||
|
||||
Display_cursor();
|
||||
|
||||
do
|
||||
{
|
||||
clicked_button=Window_clicked_button();
|
||||
|
||||
switch (clicked_button)
|
||||
{
|
||||
case -1:
|
||||
case 0:
|
||||
case 1:
|
||||
break;
|
||||
case 7: // Zone de texte
|
||||
{
|
||||
int line = ((Mouse_Y-Window_pos_Y)/Menu_factor_Y - 18)/8;
|
||||
Wait_end_of_click();
|
||||
if (line == ((Mouse_Y-Window_pos_Y)/Menu_factor_Y - 18)/8)
|
||||
{
|
||||
if (Help_position+line<nb_lines)
|
||||
{
|
||||
switch (Help_section[Current_help_section].Help_table[Help_position+line].Line_type)
|
||||
{
|
||||
case 'K':
|
||||
Window_set_shortcut(Help_section[Current_help_section].Help_table[Help_position+line].Line_parameter);
|
||||
break;
|
||||
// Ici on peut gérer un cas 'lien hypertexte'
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Hide_cursor();
|
||||
Display_help();
|
||||
Display_cursor();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Hide_cursor();
|
||||
if (clicked_button>2)
|
||||
{
|
||||
Current_help_section=clicked_button-3;
|
||||
Help_position=0;
|
||||
nb_lines=Help_section[Current_help_section].Length;
|
||||
scroller->Position=0;
|
||||
scroller->Nb_elements=nb_lines;
|
||||
Compute_slider_cursor_height(scroller);
|
||||
Window_draw_slider(scroller);
|
||||
}
|
||||
else
|
||||
Help_position=Window_attribute2;
|
||||
|
||||
Display_help();
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
|
||||
// Gestion des touches de déplacement dans la liste
|
||||
switch (Key)
|
||||
{
|
||||
case SDLK_UP : // Haut
|
||||
if (Help_position>0)
|
||||
Help_position--;
|
||||
Scroll_help(scroller);
|
||||
Key=0;
|
||||
break;
|
||||
case SDLK_DOWN : // Bas
|
||||
if (Help_position<nb_lines-16)
|
||||
Help_position++;
|
||||
Scroll_help(scroller);
|
||||
Key=0;
|
||||
break;
|
||||
case SDLK_PAGEUP : // PageUp
|
||||
if (Help_position>15)
|
||||
Help_position-=15;
|
||||
else
|
||||
Help_position=0;
|
||||
Scroll_help(scroller);
|
||||
Key=0;
|
||||
break;
|
||||
case (KEY_MOUSEWHEELUP) : // WheelUp
|
||||
if (Help_position>3)
|
||||
Help_position-=3;
|
||||
else
|
||||
Help_position=0;
|
||||
Scroll_help(scroller);
|
||||
Key=0;
|
||||
break;
|
||||
case SDLK_PAGEDOWN : // PageDown
|
||||
if (nb_lines>16)
|
||||
{
|
||||
if (Help_position<nb_lines-16-15)
|
||||
Help_position+=15;
|
||||
else
|
||||
Help_position=nb_lines-16;
|
||||
Scroll_help(scroller);
|
||||
Key=0;
|
||||
}
|
||||
break;
|
||||
case (KEY_MOUSEWHEELDOWN) : // Wheeldown
|
||||
if (nb_lines>16)
|
||||
{
|
||||
if (Help_position<nb_lines-16-3)
|
||||
Help_position+=3;
|
||||
else
|
||||
Help_position=nb_lines-16;
|
||||
Scroll_help(scroller);
|
||||
Key=0;
|
||||
}
|
||||
break;
|
||||
case SDLK_HOME : // Home
|
||||
Help_position=0;
|
||||
Scroll_help(scroller);
|
||||
Key=0;
|
||||
break;
|
||||
case SDLK_END : // End
|
||||
if (nb_lines>16)
|
||||
{
|
||||
Help_position=nb_lines-16;
|
||||
Scroll_help(scroller);
|
||||
Key=0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (Is_shortcut(Key,0x100+BUTTON_HELP))
|
||||
clicked_button=1;
|
||||
}
|
||||
while ((clicked_button!=1) && (Key!=SDLK_RETURN));
|
||||
|
||||
Key=0;
|
||||
Close_window();
|
||||
Unselect_button(BUTTON_HELP);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
|
||||
#define STATS_TITLE_COLOR MC_White
|
||||
#define STATS_DATA_COLOR MC_Light
|
||||
void Button_Stats(void)
|
||||
{
|
||||
short clicked_button;
|
||||
char buffer[37];
|
||||
dword color_usage[256];
|
||||
unsigned long long freeRam;
|
||||
qword mem_size = 0;
|
||||
|
||||
Open_window(310,174,"Statistics");
|
||||
|
||||
// Dessin de la fenetre ou va s'afficher le texte
|
||||
Window_display_frame_in(8,17,294,132);
|
||||
Block(Window_pos_X+(Menu_factor_X*9),
|
||||
Window_pos_Y+(Menu_factor_Y*18),
|
||||
Menu_factor_X*292,Menu_factor_Y*130,MC_Black);
|
||||
|
||||
Window_set_normal_button(120,153,70,14,"OK",0,1,KEY_ESC); // 1
|
||||
|
||||
// Affichage du numéro de version
|
||||
Print_in_window(10,19,"Program version:",STATS_TITLE_COLOR,MC_Black);
|
||||
sprintf(buffer,"%s.%s",Program_version, SVN_revision);
|
||||
Print_in_window(146,19,buffer,STATS_DATA_COLOR,MC_Black);
|
||||
Print_in_window(10,35,"Build options:",STATS_TITLE_COLOR,MC_Black);
|
||||
Print_in_window(146,35,TrueType_is_supported()?"TTF fonts":"no TTF fonts",STATS_DATA_COLOR,MC_Black);
|
||||
|
||||
|
||||
// Affichage de la mémoire restante
|
||||
Print_in_window(10,51,"Free memory: ",STATS_TITLE_COLOR,MC_Black);
|
||||
|
||||
freeRam = Memory_free();
|
||||
|
||||
if(freeRam > (100ULL*1024*1024*1024))
|
||||
sprintf(buffer,"%u Gigabytes",(unsigned int)(freeRam/(1024*1024*1024)));
|
||||
else if(freeRam > (100*1024*1024))
|
||||
sprintf(buffer,"%u Megabytes",(unsigned int)(freeRam/(1024*1024)));
|
||||
else if(freeRam > 100*1024)
|
||||
sprintf(buffer,"%u Kilobytes",(unsigned int)(freeRam/1024));
|
||||
else
|
||||
sprintf(buffer,"%u bytes",(unsigned int)freeRam);
|
||||
Print_in_window(114,51,buffer,STATS_DATA_COLOR,MC_Black);
|
||||
|
||||
// Used memory
|
||||
Print_in_window(10,59,"Used memory pages: ",STATS_TITLE_COLOR,MC_Black);
|
||||
if(Stats_pages_memory > (100LL*1024*1024*1024))
|
||||
sprintf(buffer,"%ld (%lld Gb)",Stats_pages_number, Stats_pages_memory/(1024*1024*1024));
|
||||
else if(Stats_pages_memory > (100*1024*1024))
|
||||
sprintf(buffer,"%ld (%lld Mb)",Stats_pages_number, Stats_pages_memory/(1024*1024));
|
||||
else
|
||||
sprintf(buffer,"%ld (%lld Kb)",Stats_pages_number, Stats_pages_memory/1024);
|
||||
Print_in_window(162,59,buffer,STATS_DATA_COLOR,MC_Black);
|
||||
|
||||
// Affichage de l'espace disque libre
|
||||
sprintf(buffer,"Free space on %c:",Main_current_directory[0]);
|
||||
Print_in_window(10,67,buffer,STATS_TITLE_COLOR,MC_Black);
|
||||
|
||||
#if defined(__WIN32__)
|
||||
{
|
||||
ULARGE_INTEGER tailleU;
|
||||
GetDiskFreeSpaceEx(Main_current_directory,&tailleU,NULL,NULL);
|
||||
mem_size = tailleU.QuadPart;
|
||||
}
|
||||
#elif defined(__linux__) || defined(__macosx__) || defined(__FreeBSD__)
|
||||
// Note: under MacOSX, both macros are defined anyway.
|
||||
{
|
||||
struct statfs disk_info;
|
||||
statfs(Main_current_directory,&disk_info);
|
||||
mem_size=(qword) disk_info.f_bfree * (qword) disk_info.f_bsize;
|
||||
}
|
||||
#else
|
||||
// Free disk space is only for shows. Other platforms can display 0.
|
||||
#warning "Missing code for your platform !!! Check and correct please :)"
|
||||
mem_size=0;
|
||||
#endif
|
||||
|
||||
if(mem_size > (100ULL*1024*1024*1024))
|
||||
sprintf(buffer,"%u Gigabytes",(unsigned int)(mem_size/(1024*1024*1024)));
|
||||
else if(mem_size > (100*1024*1024))
|
||||
sprintf(buffer,"%u Megabytes",(unsigned int)(mem_size/(1024*1024)));
|
||||
else if(mem_size > (100*1024))
|
||||
sprintf(buffer,"%u Kilobytes",(unsigned int)(mem_size/1024));
|
||||
else
|
||||
sprintf(buffer,"%u bytes",(unsigned int)mem_size);
|
||||
Print_in_window(146,67,buffer,STATS_DATA_COLOR,MC_Black);
|
||||
|
||||
// Affichage des informations sur l'image
|
||||
Print_in_window(10,83,"Picture info.:",STATS_TITLE_COLOR,MC_Black);
|
||||
|
||||
// Affichage des dimensions de l'image
|
||||
Print_in_window(18,91,"Dimensions :",STATS_TITLE_COLOR,MC_Black);
|
||||
sprintf(buffer,"%dx%d",Main_image_width,Main_image_height);
|
||||
Print_in_window(122,91,buffer,STATS_DATA_COLOR,MC_Black);
|
||||
|
||||
// Affichage du nombre de couleur utilisé
|
||||
Print_in_window(18,99,"Colors used:",STATS_TITLE_COLOR,MC_Black);
|
||||
memset(color_usage,0,sizeof(color_usage));
|
||||
sprintf(buffer,"%d",Count_used_colors(color_usage));
|
||||
Print_in_window(122,99,buffer,STATS_DATA_COLOR,MC_Black);
|
||||
|
||||
// Affichage des dimensions de l'écran
|
||||
Print_in_window(10,115,"Resolution:",STATS_TITLE_COLOR,MC_Black);
|
||||
sprintf(buffer,"%dx%d",Screen_width,Screen_height);
|
||||
Print_in_window(106,115,buffer,STATS_DATA_COLOR,MC_Black);
|
||||
|
||||
Update_rect(Window_pos_X,Window_pos_Y,Menu_factor_X*310,Menu_factor_Y*174);
|
||||
|
||||
Display_cursor();
|
||||
|
||||
do
|
||||
{
|
||||
clicked_button=Window_clicked_button();
|
||||
if (Is_shortcut(Key,0x200+BUTTON_HELP))
|
||||
clicked_button=1;
|
||||
}
|
||||
while ( (clicked_button!=1) && (Key!=SDLK_RETURN) );
|
||||
|
||||
if(Key==SDLK_RETURN)Key=0;
|
||||
|
||||
Close_window();
|
||||
Unselect_button(BUTTON_HELP);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
50
src/help.h
Normal file
50
src/help.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 help.h
|
||||
/// Functions related to the help browser. The help data is in helpfile.h
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __HELP_H_
|
||||
#define __HELP_H_
|
||||
|
||||
/*!
|
||||
Called to open the help window with the keyboard shortcut.
|
||||
If the mouse is over a button, its contextual help will be displayed.
|
||||
Else, the default helpscreen will be shown.
|
||||
*/
|
||||
void Button_Help(void);
|
||||
|
||||
/*!
|
||||
Displays and runs the "Statistics" window
|
||||
*/
|
||||
void Button_Stats(void);
|
||||
|
||||
/*!
|
||||
Displays and runs the "Help / About..." window
|
||||
@param section Number of the help section page to display (equals the button number the mouse was hovering for the contextual help), -1 for the main help page.
|
||||
@param sub_section Help sub-section title (the page will be scrolled so this title is at the top).
|
||||
*/
|
||||
void Window_help(int section, const char * sub_section);
|
||||
|
||||
#endif
|
||||
|
||||
2691
src/helpfile.h
Normal file
2691
src/helpfile.h
Normal file
File diff suppressed because it is too large
Load Diff
1665
src/hotkeys.c
Normal file
1665
src/hotkeys.c
Normal file
File diff suppressed because it is too large
Load Diff
58
src/hotkeys.h
Normal file
58
src/hotkeys.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 hotkeys.h
|
||||
/// Definition of the tables used by the keyboard shortcuts.
|
||||
/// The actual data is in hotkeys.c
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(__VBCC__)
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
#define bool char
|
||||
#endif
|
||||
#include <SDL.h>
|
||||
|
||||
/*** Types definitions and structs ***/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
word Number; ///< Identifier for shortcut. This is a number starting from 0, which matches ::T_Config_shortcut_info.Number
|
||||
char Label[36]; ///< Text to show in the screen where you can edit the shortcut.
|
||||
char Explanation1[37]; ///< Explanation text (1/3) to show in the screen where you can edit the shortcut.
|
||||
char Explanation2[37]; ///< Explanation text (2/3) to show in the screen where you can edit the shortcut.
|
||||
char Explanation3[37]; ///< Explanation text (3/3) to show in the screen where you can edit the shortcut.
|
||||
bool Suppr; ///< Boolean, true if the shortcut can be removed.
|
||||
word Key; ///< Primary shortcut. Value is a keycode, see keyboard.h
|
||||
word Key2; ///< Secondary shortcut. Value is a keycode, see keyboard.h
|
||||
} T_Key_config;
|
||||
|
||||
/// Table with all the configurable shortcuts, whether they are for a menu button or a special action.
|
||||
extern T_Key_config ConfigKey[NB_SHORTCUTS];
|
||||
///
|
||||
/// Translation table from a shortcut index to a shortcut identifier.
|
||||
/// The value is either:
|
||||
/// - 0x000 + special shortcut number
|
||||
/// - 0x100 + button number (left click)
|
||||
/// - 0x200 + button number (right click)
|
||||
extern word Ordering[NB_SHORTCUTS];
|
||||
2686
src/init.c
Normal file
2686
src/init.c
Normal file
File diff suppressed because it is too large
Load Diff
52
src/init.h
Normal file
52
src/init.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 init.h
|
||||
/// Initialization (and some de-initialization) functions.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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_operations(void);
|
||||
void Init_brush_container(void);
|
||||
int Load_CFG(int reload_all);
|
||||
int Save_CFG(void);
|
||||
void Set_all_video_modes(void);
|
||||
void Set_config_defaults(void);
|
||||
void Init_sighandler(void);
|
||||
|
||||
extern char Gui_loading_error_message[512];
|
||||
|
||||
///
|
||||
/// Loads a 8x8 monochrome font, the kind used in all menus and screens.
|
||||
/// This function allocates the memory, and returns a pointer to it when
|
||||
/// successful.
|
||||
/// If an error is encountered, it frees what needs it, prints an error message
|
||||
/// in ::Gui_loading_error_message, and returns NULL.
|
||||
byte * Load_font(const char * font_name);
|
||||
|
||||
///
|
||||
/// Based on which toolbars are visible, updates their offsets and
|
||||
/// computes ::Menu_height and ::Menu_Y
|
||||
void Compute_menu_offsets(void);
|
||||
|
||||
798
src/input.c
Normal file
798
src/input.c
Normal file
@@ -0,0 +1,798 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2009 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "keyboard.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "windows.h"
|
||||
#include "errors.h"
|
||||
#include "misc.h"
|
||||
#include "input.h"
|
||||
|
||||
#ifdef __VBCC__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
void Handle_window_resize(SDL_ResizeEvent event);
|
||||
void Handle_window_exit(SDL_QuitEvent event);
|
||||
|
||||
// public Globals (available as extern)
|
||||
|
||||
int Input_sticky_control = 0;
|
||||
int Snap_axis = 0;
|
||||
int Snap_axis_origin_X;
|
||||
int Snap_axis_origin_Y;
|
||||
|
||||
// --
|
||||
|
||||
byte Directional_up;
|
||||
byte Directional_up_right;
|
||||
byte Directional_right;
|
||||
byte Directional_down_right;
|
||||
byte Directional_down;
|
||||
byte Directional_down_left;
|
||||
byte Directional_left;
|
||||
byte Directional_up_left;
|
||||
byte Directional_click;
|
||||
|
||||
long Directional_delay;
|
||||
long Directional_last_move;
|
||||
long Directional_step;
|
||||
int Mouse_moved; ///< Boolean, Set to true if any cursor movement occurs.
|
||||
|
||||
word Input_new_mouse_X;
|
||||
word Input_new_mouse_Y;
|
||||
byte Input_new_mouse_K;
|
||||
|
||||
byte Mouse_mode = 0; ///< Mouse mode = 0:normal, 1:emulated with custom sensitivity.
|
||||
short Mouse_virtual_x_position;
|
||||
short Mouse_virtual_y_position;
|
||||
short Mouse_virtual_width;
|
||||
short Mouse_virtual_height;
|
||||
|
||||
// TODO: move to config
|
||||
#ifdef __GP2X__
|
||||
short Joybutton_shift=GP2X_BUTTON_L; // Button number that serves as a "shift" modifier
|
||||
short Joybutton_control=GP2X_BUTTON_R; // Button number that serves as a "ctrl" modifier
|
||||
short Joybutton_alt=GP2X_BUTTON_CLICK; // Button number that serves as a "alt" modifier
|
||||
short Joybutton_left_click=GP2X_BUTTON_B; // Button number that serves as left click
|
||||
short Joybutton_right_click=GP2X_BUTTON_Y; // Button number that serves as right-click
|
||||
#else
|
||||
short Joybutton_shift=-1; // Button number that serves as a "shift" modifier
|
||||
short Joybutton_control=-1; // Button number that serves as a "ctrl" modifier
|
||||
short Joybutton_alt=-1; // Button number that serves as a "alt" modifier
|
||||
short Joybutton_left_click=0; // Button number that serves as left click
|
||||
short Joybutton_right_click=0; // Button number that serves as right-click
|
||||
#endif
|
||||
|
||||
int Is_shortcut(word Key, word function)
|
||||
{
|
||||
if (Key == 0 || function == 0xFFFF)
|
||||
return 0;
|
||||
|
||||
if (function & 0x100)
|
||||
{
|
||||
if (Buttons_Pool[function&0xFF].Left_shortcut[0]==Key)
|
||||
return 1;
|
||||
if (Buttons_Pool[function&0xFF].Left_shortcut[1]==Key)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
if (function & 0x200)
|
||||
{
|
||||
if (Buttons_Pool[function&0xFF].Right_shortcut[0]==Key)
|
||||
return 1;
|
||||
if (Buttons_Pool[function&0xFF].Right_shortcut[1]==Key)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
if(Key == Config_Key[function][0])
|
||||
return 1;
|
||||
if(Key == Config_Key[function][1])
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Called each time there is a cursor move, either triggered by mouse or keyboard shortcuts
|
||||
int Move_cursor_with_constraints()
|
||||
{
|
||||
int feedback=0;
|
||||
int mouse_blocked=0; ///< Boolean, Set to true if mouse movement was clipped.
|
||||
|
||||
|
||||
// Clip mouse to the editing area. There can be a border when using big
|
||||
// pixels, if the SDL screen dimensions are not factors of the pixel size.
|
||||
if (Input_new_mouse_Y>=Screen_height)
|
||||
{
|
||||
Input_new_mouse_Y=Screen_height-1;
|
||||
mouse_blocked=1;
|
||||
}
|
||||
if (Input_new_mouse_X>=Screen_width)
|
||||
{
|
||||
Input_new_mouse_X=Screen_width-1;
|
||||
mouse_blocked=1;
|
||||
}
|
||||
//Gestion "avancée" du curseur: interdire la descente du curseur dans le
|
||||
//menu lorsqu'on est en train de travailler dans l'image
|
||||
if (Operation_stack_size != 0)
|
||||
{
|
||||
|
||||
|
||||
//Si le curseur ne se trouve plus dans l'image
|
||||
if(Menu_Y<=Input_new_mouse_Y)
|
||||
{
|
||||
//On bloque le curseur en fin d'image
|
||||
mouse_blocked=1;
|
||||
Input_new_mouse_Y=Menu_Y-1; //La ligne !!au-dessus!! du menu
|
||||
}
|
||||
|
||||
if(Main_magnifier_mode)
|
||||
{
|
||||
if(Operation_in_magnifier==0)
|
||||
{
|
||||
if(Input_new_mouse_X>=Main_separator_position)
|
||||
{
|
||||
mouse_blocked=1;
|
||||
Input_new_mouse_X=Main_separator_position-1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Input_new_mouse_X<Main_X_zoom)
|
||||
{
|
||||
mouse_blocked=1;
|
||||
Input_new_mouse_X=Main_X_zoom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((Input_new_mouse_X != Mouse_X) ||
|
||||
(Input_new_mouse_Y != Mouse_Y) ||
|
||||
(Input_new_mouse_K != Mouse_K))
|
||||
{
|
||||
// On every change of mouse state
|
||||
if ((Input_new_mouse_K != Mouse_K))
|
||||
{
|
||||
feedback=1;
|
||||
|
||||
if (Input_new_mouse_K == 0)
|
||||
Input_sticky_control = 0;
|
||||
}
|
||||
// Hide cursor, because even just a click change needs it
|
||||
if (!Mouse_moved)
|
||||
{
|
||||
Mouse_moved++;
|
||||
// Hide cursor (erasing icon and brush on screen
|
||||
// before changing the coordinates.
|
||||
Hide_cursor();
|
||||
}
|
||||
if (Input_new_mouse_X != Mouse_X || Input_new_mouse_Y != Mouse_Y)
|
||||
{
|
||||
Mouse_X=Input_new_mouse_X;
|
||||
Mouse_Y=Input_new_mouse_Y;
|
||||
}
|
||||
Mouse_K=Input_new_mouse_K;
|
||||
|
||||
if (Mouse_moved > Config.Mouse_merge_movement)
|
||||
if (! Operation[Current_operation][Mouse_K_unique]
|
||||
[Operation_stack_size].Fast_mouse)
|
||||
feedback=1;
|
||||
}
|
||||
if (mouse_blocked)
|
||||
Set_mouse_position();
|
||||
return feedback;
|
||||
}
|
||||
|
||||
// WM events management
|
||||
|
||||
void Handle_window_resize(SDL_ResizeEvent event)
|
||||
{
|
||||
Resize_width = event.w;
|
||||
Resize_height = event.h;
|
||||
}
|
||||
|
||||
void Handle_window_exit(__attribute__((unused)) SDL_QuitEvent event)
|
||||
{
|
||||
Quit_is_required = 1;
|
||||
}
|
||||
|
||||
// Mouse events management
|
||||
|
||||
int Handle_mouse_move(SDL_MouseMotionEvent event)
|
||||
{
|
||||
if (Mouse_mode == 0)
|
||||
{
|
||||
Input_new_mouse_X = event.x/Pixel_width;
|
||||
Input_new_mouse_Y = event.y/Pixel_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
Mouse_virtual_x_position += event.xrel * 12 / Config.Mouse_sensitivity_index_x;
|
||||
// Clip
|
||||
if (Mouse_virtual_x_position > Mouse_virtual_width)
|
||||
Mouse_virtual_x_position = Mouse_virtual_width;
|
||||
else if (Mouse_virtual_x_position < 0)
|
||||
Mouse_virtual_x_position = 0;
|
||||
|
||||
Mouse_virtual_y_position += event.yrel * 12 / Config.Mouse_sensitivity_index_y;
|
||||
// Clip
|
||||
if (Mouse_virtual_y_position > Mouse_virtual_height)
|
||||
Mouse_virtual_y_position = Mouse_virtual_height;
|
||||
else if (Mouse_virtual_y_position < 0)
|
||||
Mouse_virtual_y_position = 0;
|
||||
|
||||
Input_new_mouse_X = Mouse_virtual_x_position / 12 / Pixel_width;
|
||||
Input_new_mouse_Y = Mouse_virtual_y_position / 12 / Pixel_height;
|
||||
}
|
||||
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
|
||||
int Handle_mouse_click(SDL_MouseButtonEvent event)
|
||||
{
|
||||
switch(event.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
Input_new_mouse_K |= 1;
|
||||
break;
|
||||
|
||||
case SDL_BUTTON_RIGHT:
|
||||
Input_new_mouse_K |= 2;
|
||||
break;
|
||||
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
Key = KEY_MOUSEMIDDLE|Key_modifiers(SDL_GetModState());
|
||||
// TODO: repeat system maybe?
|
||||
return 0;
|
||||
|
||||
case SDL_BUTTON_WHEELUP:
|
||||
Key = KEY_MOUSEWHEELUP|Key_modifiers(SDL_GetModState());
|
||||
return 0;
|
||||
|
||||
case SDL_BUTTON_WHEELDOWN:
|
||||
Key = KEY_MOUSEWHEELDOWN|Key_modifiers(SDL_GetModState());
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
|
||||
int Handle_mouse_release(SDL_MouseButtonEvent event)
|
||||
{
|
||||
switch(event.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
Input_new_mouse_K &= ~1;
|
||||
break;
|
||||
|
||||
case SDL_BUTTON_RIGHT:
|
||||
Input_new_mouse_K &= ~2;
|
||||
break;
|
||||
}
|
||||
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
|
||||
// Keyboard management
|
||||
|
||||
int Handle_key_press(SDL_KeyboardEvent event)
|
||||
{
|
||||
//Appui sur une touche du clavier
|
||||
Key = Keysym_to_keycode(event.keysym);
|
||||
Key_ANSI = Keysym_to_ANSI(event.keysym);
|
||||
|
||||
if(Is_shortcut(Key,SPECIAL_MOUSE_UP))
|
||||
{
|
||||
Directional_up=1;
|
||||
return 0;
|
||||
}
|
||||
else if(Is_shortcut(Key,SPECIAL_MOUSE_DOWN))
|
||||
{
|
||||
Directional_down=1;
|
||||
return 0;
|
||||
}
|
||||
else if(Is_shortcut(Key,SPECIAL_MOUSE_LEFT))
|
||||
{
|
||||
Directional_left=1;
|
||||
return 0;
|
||||
}
|
||||
else if(Is_shortcut(Key,SPECIAL_MOUSE_RIGHT))
|
||||
{
|
||||
Directional_right=1;
|
||||
return 0;
|
||||
}
|
||||
else if(Is_shortcut(Key,SPECIAL_CLICK_LEFT) && Keyboard_click_allowed > 0)
|
||||
{
|
||||
Input_new_mouse_K=1;
|
||||
Directional_click=1;
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
else if(Is_shortcut(Key,SPECIAL_CLICK_RIGHT) && Keyboard_click_allowed > 0)
|
||||
{
|
||||
Input_new_mouse_K=2;
|
||||
Directional_click=2;
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Release_control(int key_code, int modifier)
|
||||
{
|
||||
int need_feedback = 0;
|
||||
|
||||
if (modifier == MOD_SHIFT)
|
||||
{
|
||||
// Disable "snap axis" mode
|
||||
Snap_axis = 0;
|
||||
need_feedback = 1;
|
||||
}
|
||||
|
||||
if((key_code && key_code == (Config_Key[SPECIAL_MOUSE_UP][0]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_UP][0]&modifier) ||
|
||||
(key_code && key_code == (Config_Key[SPECIAL_MOUSE_UP][1]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_UP][1]&modifier))
|
||||
{
|
||||
Directional_up=0;
|
||||
}
|
||||
if((key_code && key_code == (Config_Key[SPECIAL_MOUSE_DOWN][0]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_DOWN][0]&modifier) ||
|
||||
(key_code && key_code == (Config_Key[SPECIAL_MOUSE_DOWN][1]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_DOWN][1]&modifier))
|
||||
{
|
||||
Directional_down=0;
|
||||
}
|
||||
if((key_code && key_code == (Config_Key[SPECIAL_MOUSE_LEFT][0]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_LEFT][0]&modifier) ||
|
||||
(key_code && key_code == (Config_Key[SPECIAL_MOUSE_LEFT][1]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_LEFT][1]&modifier))
|
||||
{
|
||||
Directional_left=0;
|
||||
}
|
||||
if((key_code && key_code == (Config_Key[SPECIAL_MOUSE_RIGHT][0]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_RIGHT][0]&modifier) ||
|
||||
(key_code && key_code == (Config_Key[SPECIAL_MOUSE_RIGHT][1]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_RIGHT][1]&modifier))
|
||||
{
|
||||
Directional_right=0;
|
||||
}
|
||||
if((key_code && key_code == (Config_Key[SPECIAL_CLICK_LEFT][0]&0x0FFF)) || (Config_Key[SPECIAL_CLICK_LEFT][0]&modifier) ||
|
||||
(key_code && key_code == (Config_Key[SPECIAL_CLICK_LEFT][1]&0x0FFF)) || (Config_Key[SPECIAL_CLICK_LEFT][1]&modifier))
|
||||
{
|
||||
if (Directional_click & 1)
|
||||
{
|
||||
Directional_click &= ~1;
|
||||
Input_new_mouse_K &= ~1;
|
||||
return Move_cursor_with_constraints() || need_feedback;
|
||||
}
|
||||
}
|
||||
if((key_code && key_code == (Config_Key[SPECIAL_CLICK_RIGHT][0]&0x0FFF)) || (Config_Key[SPECIAL_CLICK_RIGHT][0]&modifier) ||
|
||||
(key_code && key_code == (Config_Key[SPECIAL_CLICK_RIGHT][1]&0x0FFF)) || (Config_Key[SPECIAL_CLICK_RIGHT][1]&modifier))
|
||||
{
|
||||
if (Directional_click & 2)
|
||||
{
|
||||
Directional_click &= ~2;
|
||||
Input_new_mouse_K &= ~2;
|
||||
return Move_cursor_with_constraints() || need_feedback;
|
||||
}
|
||||
}
|
||||
|
||||
// Other keys don't need to be released : they are handled as "events" and procesed only once.
|
||||
// These clicks are apart because they need to be continuous (ie move while key pressed)
|
||||
// We are relying on "hardware" keyrepeat to achieve that.
|
||||
return need_feedback;
|
||||
}
|
||||
|
||||
|
||||
int Handle_key_release(SDL_KeyboardEvent event)
|
||||
{
|
||||
int modifier;
|
||||
int released_key = Keysym_to_keycode(event.keysym) & 0x0FFF;
|
||||
|
||||
switch(event.keysym.sym)
|
||||
{
|
||||
case SDLK_RSHIFT:
|
||||
case SDLK_LSHIFT:
|
||||
modifier=MOD_SHIFT;
|
||||
break;
|
||||
|
||||
case SDLK_RCTRL:
|
||||
case SDLK_LCTRL:
|
||||
modifier=MOD_CTRL;
|
||||
break;
|
||||
|
||||
case SDLK_RALT:
|
||||
case SDLK_LALT:
|
||||
case SDLK_MODE:
|
||||
modifier=MOD_ALT;
|
||||
break;
|
||||
|
||||
case SDLK_RMETA:
|
||||
case SDLK_LMETA:
|
||||
modifier=MOD_META;
|
||||
break;
|
||||
|
||||
default:
|
||||
modifier=0;
|
||||
}
|
||||
return Release_control(released_key, modifier);
|
||||
}
|
||||
|
||||
|
||||
// Joystick management
|
||||
|
||||
int Handle_joystick_press(SDL_JoyButtonEvent event)
|
||||
{
|
||||
if (event.button == Joybutton_shift)
|
||||
{
|
||||
SDL_SetModState(SDL_GetModState() | KMOD_SHIFT);
|
||||
return 0;
|
||||
}
|
||||
if (event.button == Joybutton_control)
|
||||
{
|
||||
SDL_SetModState(SDL_GetModState() | KMOD_CTRL);
|
||||
return 0;
|
||||
}
|
||||
if (event.button == Joybutton_alt)
|
||||
{
|
||||
SDL_SetModState(SDL_GetModState() | (KMOD_ALT|KMOD_META));
|
||||
return 0;
|
||||
}
|
||||
if (event.button == Joybutton_left_click)
|
||||
{
|
||||
Input_new_mouse_K=1;
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
if (event.button == Joybutton_right_click)
|
||||
{
|
||||
Input_new_mouse_K=2;
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
#ifdef __GP2X__
|
||||
switch(event.button)
|
||||
{
|
||||
case GP2X_BUTTON_UP:
|
||||
Directional_up=1;
|
||||
break;
|
||||
case GP2X_BUTTON_UPRIGHT:
|
||||
Directional_up_right=1;
|
||||
break;
|
||||
case GP2X_BUTTON_RIGHT:
|
||||
Directional_right=1;
|
||||
break;
|
||||
case GP2X_BUTTON_DOWNRIGHT:
|
||||
Directional_down_right=1;
|
||||
break;
|
||||
case GP2X_BUTTON_DOWN:
|
||||
Directional_down=1;
|
||||
break;
|
||||
case GP2X_BUTTON_DOWNLEFT:
|
||||
Directional_down_left=1;
|
||||
break;
|
||||
case GP2X_BUTTON_LEFT:
|
||||
Directional_left=1;
|
||||
break;
|
||||
case GP2X_BUTTON_UPLEFT:
|
||||
Directional_up_left=1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
Key = (KEY_JOYBUTTON+event.button)|Key_modifiers(SDL_GetModState());
|
||||
// TODO: systeme de répétition
|
||||
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
|
||||
int Handle_joystick_release(SDL_JoyButtonEvent event)
|
||||
{
|
||||
if (event.button == Joybutton_shift)
|
||||
{
|
||||
SDL_SetModState(SDL_GetModState() & ~KMOD_SHIFT);
|
||||
return Release_control(0,MOD_SHIFT);
|
||||
}
|
||||
if (event.button == Joybutton_control)
|
||||
{
|
||||
SDL_SetModState(SDL_GetModState() & ~KMOD_CTRL);
|
||||
return Release_control(0,MOD_CTRL);
|
||||
}
|
||||
if (event.button == Joybutton_alt)
|
||||
{
|
||||
SDL_SetModState(SDL_GetModState() & ~(KMOD_ALT|KMOD_META));
|
||||
return Release_control(0,MOD_ALT);
|
||||
}
|
||||
if (event.button == Joybutton_left_click)
|
||||
{
|
||||
Input_new_mouse_K &= ~1;
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
if (event.button == Joybutton_right_click)
|
||||
{
|
||||
Input_new_mouse_K &= ~2;
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
|
||||
#ifdef __GP2X__
|
||||
switch(event.button)
|
||||
{
|
||||
case GP2X_BUTTON_UP:
|
||||
Directional_up=0;
|
||||
break;
|
||||
case GP2X_BUTTON_UPRIGHT:
|
||||
Directional_up_right=0;
|
||||
break;
|
||||
case GP2X_BUTTON_RIGHT:
|
||||
Directional_right=0;
|
||||
break;
|
||||
case GP2X_BUTTON_DOWNRIGHT:
|
||||
Directional_down_right=0;
|
||||
break;
|
||||
case GP2X_BUTTON_DOWN:
|
||||
Directional_down=0;
|
||||
break;
|
||||
case GP2X_BUTTON_DOWNLEFT:
|
||||
Directional_down_left=0;
|
||||
break;
|
||||
case GP2X_BUTTON_LEFT:
|
||||
Directional_left=0;
|
||||
break;
|
||||
case GP2X_BUTTON_UPLEFT:
|
||||
Directional_up_left=0;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
|
||||
void Handle_joystick_movement(SDL_JoyAxisEvent event)
|
||||
{
|
||||
if (event.axis==0) // X
|
||||
{
|
||||
Directional_right=Directional_left=0;
|
||||
if (event.value<-1000)
|
||||
{
|
||||
Directional_left=1;
|
||||
}
|
||||
else if (event.value>1000)
|
||||
Directional_right=1;
|
||||
}
|
||||
else if (event.axis==1) // Y
|
||||
{
|
||||
Directional_up=Directional_down=0;
|
||||
if (event.value<-1000)
|
||||
{
|
||||
Directional_up=1;
|
||||
}
|
||||
else if (event.value>1000)
|
||||
Directional_down=1;
|
||||
}
|
||||
}
|
||||
|
||||
// Attempts to move the mouse cursor by the given deltas (may be more than 1 pixel at a time)
|
||||
int Cursor_displace(short delta_x, short delta_y)
|
||||
{
|
||||
short x=Input_new_mouse_X;
|
||||
short y=Input_new_mouse_Y;
|
||||
|
||||
if(Main_magnifier_mode && Input_new_mouse_Y < Menu_Y && Input_new_mouse_X > Main_separator_position)
|
||||
{
|
||||
// Cursor in zoomed area
|
||||
|
||||
if (delta_x<0)
|
||||
Input_new_mouse_X = Max(Main_separator_position, x-Main_magnifier_factor);
|
||||
else if (delta_x>0)
|
||||
Input_new_mouse_X = Min(Screen_width-1, x+Main_magnifier_factor);
|
||||
if (delta_y<0)
|
||||
Input_new_mouse_Y = Max(0, y-Main_magnifier_factor);
|
||||
else if (delta_y>0)
|
||||
Input_new_mouse_Y = Min(Screen_height-1, y+Main_magnifier_factor);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (delta_x<0)
|
||||
Input_new_mouse_X = Max(0, x+delta_x);
|
||||
else if (delta_x>0)
|
||||
Input_new_mouse_X = Min(Screen_width-1, x+delta_x);
|
||||
if (delta_y<0)
|
||||
Input_new_mouse_Y = Max(0, y+delta_y);
|
||||
else if (delta_y>0)
|
||||
Input_new_mouse_Y = Min(Screen_height-1, y+delta_y);
|
||||
}
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
|
||||
|
||||
// Main input handling function
|
||||
|
||||
int Get_input(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
int user_feedback_required = 0; // Flag qui indique si on doit arrêter de traiter les évènements ou si on peut enchainer
|
||||
|
||||
Key_ANSI = 0;
|
||||
Key = 0;
|
||||
Mouse_moved=0;
|
||||
Input_new_mouse_X = Mouse_X;
|
||||
Input_new_mouse_Y = Mouse_Y;
|
||||
|
||||
// Process as much events as possible without redrawing the screen.
|
||||
// This mostly allows us to merge mouse events for people with an high
|
||||
// resolution mouse
|
||||
while( (!user_feedback_required) && SDL_PollEvent(&event)) // Try to cumulate for a full VBL except if there is a required feedback
|
||||
{
|
||||
switch(event.type)
|
||||
{
|
||||
case SDL_VIDEORESIZE:
|
||||
Handle_window_resize(event.resize);
|
||||
user_feedback_required = 1;
|
||||
break;
|
||||
|
||||
case SDL_QUIT:
|
||||
Handle_window_exit(event.quit);
|
||||
user_feedback_required = 1;
|
||||
break;
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
user_feedback_required = Handle_mouse_move(event.motion);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
Handle_mouse_click(event.button);
|
||||
user_feedback_required = 1;
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
Handle_mouse_release(event.button);
|
||||
user_feedback_required = 1;
|
||||
break;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
Handle_key_press(event.key);
|
||||
user_feedback_required = 1;
|
||||
break;
|
||||
|
||||
case SDL_KEYUP:
|
||||
Handle_key_release(event.key);
|
||||
break;
|
||||
|
||||
// Start of Joystik handling
|
||||
#ifdef USE_JOYSTICK
|
||||
|
||||
case SDL_JOYBUTTONUP:
|
||||
Handle_joystick_release(event.jbutton);
|
||||
user_feedback_required = 1;
|
||||
break;
|
||||
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
Handle_joystick_press(event.jbutton);
|
||||
user_feedback_required = 1;
|
||||
break;
|
||||
|
||||
case SDL_JOYAXISMOTION:
|
||||
Handle_joystick_movement(event.jaxis);
|
||||
break;
|
||||
|
||||
#endif
|
||||
// End of Joystick handling
|
||||
|
||||
default:
|
||||
// DEBUG("Unhandled SDL event number : ",event.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Directional controller
|
||||
if (!(Directional_up||Directional_up_right||Directional_right||
|
||||
Directional_down_right||Directional_down||Directional_down_left||
|
||||
Directional_left||Directional_up_left))
|
||||
{
|
||||
Directional_delay=-1;
|
||||
Directional_last_move=SDL_GetTicks();
|
||||
}
|
||||
else
|
||||
{
|
||||
long time_now;
|
||||
|
||||
time_now=SDL_GetTicks();
|
||||
|
||||
if (time_now>Directional_last_move+Directional_delay)
|
||||
{
|
||||
// Speed parameters, acceleration etc. are here
|
||||
if (Directional_delay==-1)
|
||||
{
|
||||
Directional_delay=150;
|
||||
Directional_step=16;
|
||||
}
|
||||
else if (Directional_delay==150)
|
||||
Directional_delay=40;
|
||||
else if (Directional_delay!=0)
|
||||
Directional_delay=Directional_delay*8/10;
|
||||
else if (Directional_step<16*4)
|
||||
Directional_step++;
|
||||
Directional_last_move = time_now;
|
||||
|
||||
// Directional controller UP
|
||||
if ((Directional_up||Directional_up_left||Directional_up_right) &&
|
||||
!(Directional_down_right||Directional_down||Directional_down_left))
|
||||
{
|
||||
Cursor_displace(0, -Directional_step/16);
|
||||
}
|
||||
// Directional controller RIGHT
|
||||
if ((Directional_up_right||Directional_right||Directional_down_right) &&
|
||||
!(Directional_down_left||Directional_left||Directional_up_left))
|
||||
{
|
||||
Cursor_displace(Directional_step/16,0);
|
||||
}
|
||||
// Directional controller DOWN
|
||||
if ((Directional_down_right||Directional_down||Directional_down_left) &&
|
||||
!(Directional_up_left||Directional_up||Directional_up_right))
|
||||
{
|
||||
Cursor_displace(0, Directional_step/16);
|
||||
}
|
||||
// Directional controller LEFT
|
||||
if ((Directional_down_left||Directional_left||Directional_up_left) &&
|
||||
!(Directional_up_right||Directional_right||Directional_down_right))
|
||||
{
|
||||
Cursor_displace(-Directional_step/16,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
// If the cursor was moved since last update,
|
||||
// it was erased, so we need to redraw it (with the preview brush)
|
||||
if (Mouse_moved)
|
||||
{
|
||||
Compute_paintbrush_coordinates();
|
||||
Display_cursor();
|
||||
}
|
||||
// Commit any pending screen update.
|
||||
// This is done in this function because it's called after reading
|
||||
// some user input.
|
||||
Flush_update();
|
||||
|
||||
|
||||
return (Mouse_moved!=0) || user_feedback_required;
|
||||
}
|
||||
|
||||
void Adjust_mouse_sensitivity(word fullscreen)
|
||||
{
|
||||
if (fullscreen == 0)
|
||||
{
|
||||
Mouse_mode = 0;
|
||||
return;
|
||||
}
|
||||
Mouse_mode = 1;
|
||||
Mouse_virtual_x_position = 12*Mouse_X*Pixel_width;
|
||||
Mouse_virtual_y_position = 12*Mouse_Y*Pixel_height;
|
||||
Mouse_virtual_width = 12*(Screen_width-1)*Pixel_width;
|
||||
Mouse_virtual_height = 12*(Screen_height-1)*Pixel_height;
|
||||
}
|
||||
|
||||
void Set_mouse_position(void)
|
||||
{
|
||||
if (Mouse_mode == 0)
|
||||
{
|
||||
SDL_WarpMouse(
|
||||
Mouse_X*Pixel_width,
|
||||
Mouse_Y*Pixel_height
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mouse_virtual_x_position = 12*Mouse_X*Pixel_width;
|
||||
Mouse_virtual_y_position = 12*Mouse_Y*Pixel_height;
|
||||
}
|
||||
}
|
||||
58
src/input.h
Normal file
58
src/input.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 input.h
|
||||
/// Functions for mouse, keyboard and joystick input.
|
||||
/// Joystick input is used to emulate mouse on platforms that don't have a
|
||||
/// pointing device, ie: the GP2X.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///
|
||||
/// This is the keyboard/mouse/joystick input polling function.
|
||||
/// Returns 1 if a significant changed occurred, such as a mouse button pressed
|
||||
/// or depressed, or a new keypress was in the keyboard buffer.
|
||||
/// The latest input variables are held in ::Key, ::Key_ANSI, ::Mouse_X, ::Mouse_Y, ::Mouse_K.
|
||||
/// Note that ::Key and ::Key_ANSI are not persistent, they will be reset to 0
|
||||
/// on subsequent calls to ::Get_input().
|
||||
int Get_input(void);
|
||||
|
||||
/// Returns true if the keycode has been set as a keyboard shortcut for the function.
|
||||
int Is_shortcut(word Key, word function);
|
||||
|
||||
/// Adjust mouse sensitivity (and actual mouse input mode)
|
||||
void Adjust_mouse_sensitivity(word fullscreen);
|
||||
|
||||
void Set_mouse_position(void);
|
||||
|
||||
///
|
||||
/// This holds the ID of the GUI control that the mouse
|
||||
/// is manipulating. The input system will reset it to zero
|
||||
/// when mouse button is released, but it's the engine
|
||||
/// that will record and retrieve a real control ID.
|
||||
extern int Input_sticky_control;
|
||||
|
||||
/// Allows locking movement to X or Y axis: 0=normal, 1=lock on next move, 2=locked horizontally, 3=locked vertically.
|
||||
extern int Snap_axis;
|
||||
/// For the :Snap_axis mode, sets the origin's point (in image coordinates)
|
||||
extern int Snap_axis_origin_X;
|
||||
/// For the :Snap_axis mode, sets the origin's point (in image coordinates)
|
||||
extern int Snap_axis_origin_Y;
|
||||
360
src/io.c
Normal file
360
src/io.c
Normal file
@@ -0,0 +1,360 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
// Fonctions de lecture/ecriture file, gèrent les systèmes big-endian et
|
||||
// little-endian.
|
||||
|
||||
#define _XOPEN_SOURCE 500
|
||||
|
||||
#include <SDL_endian.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(__amigaos4__)
|
||||
#include <proto/dos.h>
|
||||
#include <dirent.h>
|
||||
#elif defined(__WIN32__)
|
||||
#include <dirent.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#include "struct.h"
|
||||
#include "io.h"
|
||||
#include "realpath.h"
|
||||
|
||||
// Lit un octet
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int Read_byte(FILE *file, byte *dest)
|
||||
{
|
||||
return fread(dest, 1, 1, file) == 1;
|
||||
}
|
||||
// Ecrit un octet
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int Write_byte(FILE *file, byte b)
|
||||
{
|
||||
return fwrite(&b, 1, 1, file) == 1;
|
||||
}
|
||||
// Lit des octets
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int Read_bytes(FILE *file, void *dest, size_t size)
|
||||
{
|
||||
return fread(dest, 1, size, file) == size;
|
||||
}
|
||||
// Ecrit des octets
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int Write_bytes(FILE *file, void *src, size_t size)
|
||||
{
|
||||
return fwrite(src, 1, size, file) == size;
|
||||
}
|
||||
|
||||
// Lit un word (little-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int Read_word_le(FILE *file, word *dest)
|
||||
{
|
||||
if (fread(dest, 1, sizeof(word), file) != sizeof(word))
|
||||
return 0;
|
||||
#if SDL_BYTEORDER != SDL_LIL_ENDIAN
|
||||
*dest = SDL_Swap16(*dest);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
// Ecrit un word (little-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int Write_word_le(FILE *file, word w)
|
||||
{
|
||||
#if SDL_BYTEORDER != SDL_LIL_ENDIAN
|
||||
w = SDL_Swap16(w);
|
||||
#endif
|
||||
return fwrite(&w, 1, sizeof(word), file) == sizeof(word);
|
||||
}
|
||||
// Lit un word (big-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int Read_word_be(FILE *file, word *dest)
|
||||
{
|
||||
if (fread(dest, 1, sizeof(word), file) != sizeof(word))
|
||||
return 0;
|
||||
#if SDL_BYTEORDER != SDL_BIG_ENDIAN
|
||||
*dest = SDL_Swap16(*dest);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
// Ecrit un word (big-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int Write_word_be(FILE *file, word w)
|
||||
{
|
||||
#if SDL_BYTEORDER != SDL_BIG_ENDIAN
|
||||
w = SDL_Swap16(w);
|
||||
#endif
|
||||
return fwrite(&w, 1, sizeof(word), file) == sizeof(word);
|
||||
}
|
||||
// Lit un dword (little-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int Read_dword_le(FILE *file, dword *dest)
|
||||
{
|
||||
if (fread(dest, 1, sizeof(dword), file) != sizeof(dword))
|
||||
return 0;
|
||||
#if SDL_BYTEORDER != SDL_LIL_ENDIAN
|
||||
*dest = SDL_Swap32(*dest);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
// Ecrit un dword (little-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int Write_dword_le(FILE *file, dword dw)
|
||||
{
|
||||
#if SDL_BYTEORDER != SDL_LIL_ENDIAN
|
||||
dw = SDL_Swap32(dw);
|
||||
#endif
|
||||
return fwrite(&dw, 1, sizeof(dword), file) == sizeof(dword);
|
||||
}
|
||||
|
||||
// Lit un dword (big-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int Read_dword_be(FILE *file, dword *dest)
|
||||
{
|
||||
if (fread(dest, 1, sizeof(dword), file) != sizeof(dword))
|
||||
return 0;
|
||||
#if SDL_BYTEORDER != SDL_BIG_ENDIAN
|
||||
*dest = SDL_Swap32(*dest);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
// Ecrit un dword (big-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int Write_dword_be(FILE *file, dword dw)
|
||||
{
|
||||
#if SDL_BYTEORDER != SDL_BIG_ENDIAN
|
||||
dw = SDL_Swap32(dw);
|
||||
#endif
|
||||
return fwrite(&dw, 1, sizeof(dword), file) == sizeof(dword);
|
||||
}
|
||||
|
||||
// Détermine la position du dernier '/' ou '\\' dans une chaine,
|
||||
// typiquement pour séparer le nom de file d'un chemin.
|
||||
// Attention, sous Windows, il faut s'attendre aux deux car
|
||||
// par exemple un programme lancé sous GDB aura comme argv[0]:
|
||||
// d:\Data\C\GFX2\grafx2/grafx2.exe
|
||||
char * Find_last_slash(const char * str)
|
||||
{
|
||||
const char * position = NULL;
|
||||
for (; *str != '\0'; str++)
|
||||
if (*str == PATH_SEPARATOR[0]
|
||||
#ifdef __WIN32__
|
||||
|| *str == '/'
|
||||
#endif
|
||||
)
|
||||
position = str;
|
||||
return (char *)position;
|
||||
}
|
||||
// Récupère la partie "nom de file seul" d'un chemin
|
||||
void Extract_filename(char *dest, const char *source)
|
||||
{
|
||||
const char * position = Find_last_slash(source);
|
||||
|
||||
if (position)
|
||||
strcpy(dest,position+1);
|
||||
else
|
||||
strcpy(dest,source);
|
||||
}
|
||||
// Récupère la partie "répertoire+/" d'un chemin.
|
||||
void Extract_path(char *dest, const char *source)
|
||||
{
|
||||
char * position=NULL;
|
||||
|
||||
Realpath(source,dest);
|
||||
position = Find_last_slash(dest);
|
||||
if (position)
|
||||
*(position+1) = '\0';
|
||||
else
|
||||
strcat(dest, PATH_SEPARATOR);
|
||||
}
|
||||
|
||||
int File_exists(char * fname)
|
||||
// Détermine si un file passé en paramètre existe ou non dans le
|
||||
// répertoire courant.
|
||||
{
|
||||
struct stat buf;
|
||||
int result;
|
||||
|
||||
result=stat(fname,&buf);
|
||||
if (result!=0)
|
||||
return(errno!=ENOENT);
|
||||
else
|
||||
return 1;
|
||||
|
||||
}
|
||||
int Directory_exists(char * directory)
|
||||
// Détermine si un répertoire passé en paramètre existe ou non dans le
|
||||
// répertoire courant.
|
||||
{
|
||||
DIR* entry; // Structure de lecture des éléments
|
||||
|
||||
if (strcmp(directory,PARENT_DIR)==0)
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
// On va chercher si le répertoire existe à l'aide d'un Opendir. S'il
|
||||
// renvoie NULL c'est que le répertoire n'est pas accessible...
|
||||
|
||||
entry=opendir(directory);
|
||||
if (entry==NULL)
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
closedir(entry);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Taille de fichier, en octets
|
||||
int File_length(const char * fname)
|
||||
{
|
||||
struct stat infos_fichier;
|
||||
if (stat(fname,&infos_fichier))
|
||||
return 0;
|
||||
return infos_fichier.st_size;
|
||||
}
|
||||
int File_length_file(FILE * file)
|
||||
{
|
||||
struct stat infos_fichier;
|
||||
if (fstat(fileno(file),&infos_fichier))
|
||||
return 0;
|
||||
return infos_fichier.st_size;
|
||||
}
|
||||
|
||||
void For_each_file(const char * directory_name, void Callback(const char *))
|
||||
{
|
||||
// Pour scan de répertoire
|
||||
DIR* current_directory; //Répertoire courant
|
||||
struct dirent* entry; // Structure de lecture des éléments
|
||||
char full_filename[MAX_PATH_CHARACTERS];
|
||||
int filename_position;
|
||||
strcpy(full_filename, directory_name);
|
||||
current_directory=opendir(directory_name);
|
||||
if(current_directory == NULL) return; // Répertoire invalide ...
|
||||
filename_position = strlen(full_filename);
|
||||
if (filename_position==0 || strcmp(full_filename+filename_position-1,PATH_SEPARATOR))
|
||||
{
|
||||
strcat(full_filename, PATH_SEPARATOR);
|
||||
filename_position = strlen(full_filename);
|
||||
}
|
||||
while ((entry=readdir(current_directory)))
|
||||
{
|
||||
struct stat Infos_enreg;
|
||||
strcpy(&full_filename[filename_position], entry->d_name);
|
||||
stat(full_filename,&Infos_enreg);
|
||||
if (S_ISREG(Infos_enreg.st_mode))
|
||||
{
|
||||
Callback(full_filename);
|
||||
}
|
||||
}
|
||||
closedir(current_directory);
|
||||
}
|
||||
|
||||
void Get_full_filename(char * output_name, char * file_name, char * directory_name)
|
||||
{
|
||||
strcpy(output_name,directory_name);
|
||||
if (output_name[0] != '\0')
|
||||
{
|
||||
// Append a separator at the end of path, if there isn't one already.
|
||||
// This handles the case of directory variables which contain one,
|
||||
// as well as directories like "/" on Unix.
|
||||
if (output_name[strlen(output_name)-1]!=PATH_SEPARATOR[0])
|
||||
strcat(output_name,PATH_SEPARATOR);
|
||||
}
|
||||
strcat(output_name,file_name);
|
||||
}
|
||||
|
||||
/// Lock file used to prevent several instances of grafx2 from harming each others' backups
|
||||
#ifdef __WIN32__
|
||||
HANDLE Lock_file_handle = INVALID_HANDLE_VALUE;
|
||||
#else
|
||||
int Lock_file_handle = -1;
|
||||
#endif
|
||||
|
||||
byte Create_lock_file(const char *file_directory)
|
||||
{
|
||||
char lock_filename[MAX_PATH_CHARACTERS];
|
||||
|
||||
strcpy(lock_filename,file_directory);
|
||||
strcat(lock_filename,"gfx2.lck");
|
||||
|
||||
#ifdef __WIN32__
|
||||
// Windowzy method for creating a lock file
|
||||
Lock_file_handle = CreateFile(
|
||||
lock_filename,
|
||||
GENERIC_WRITE,
|
||||
0, // No sharing
|
||||
NULL,
|
||||
OPEN_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if (Lock_file_handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
// Unixy method for lock file
|
||||
Lock_file_handle = open(lock_filename,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR);
|
||||
if (Lock_file_handle == -1)
|
||||
{
|
||||
// Usually write-protected media
|
||||
return -1;
|
||||
}
|
||||
if (lockf(Lock_file_handle, F_TLOCK, 0)==-1)
|
||||
{
|
||||
close(Lock_file_handle);
|
||||
// Usually write-protected media
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Release_lock_file(const char *file_directory)
|
||||
{
|
||||
char lock_filename[MAX_PATH_CHARACTERS];
|
||||
|
||||
#ifdef __WIN32__
|
||||
if (Lock_file_handle != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(Lock_file_handle);
|
||||
}
|
||||
#else
|
||||
if (Lock_file_handle != -1)
|
||||
{
|
||||
close(Lock_file_handle);
|
||||
Lock_file_handle = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Actual deletion
|
||||
strcpy(lock_filename,file_directory);
|
||||
strcat(lock_filename,"gfx2.lck");
|
||||
remove(lock_filename);
|
||||
}
|
||||
106
src/io.h
Normal file
106
src/io.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 io.h
|
||||
/// Low-level endian-neutral file operations, and also some filesystem operations.
|
||||
/// Many of these may seem trivial, but the wrappers eliminate the need for a
|
||||
/// forest of preprocessor defines in each file.
|
||||
/// You MUST use the functions in this file instead of:
|
||||
/// - fread() and fwrite()
|
||||
/// - stat()
|
||||
/// - fstat()
|
||||
/// - opendir()
|
||||
/// - readdir()
|
||||
/// - Also, don't assume "/" or "\\", use PATH_SEPARATOR
|
||||
/// If you don't, you break another platform.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Reads a single byte from an open file. Returns true if OK, false if a file i/o error occurred.
|
||||
int Read_byte(FILE *file, byte *dest);
|
||||
/// Writes a single byte to an open file. Returns true if OK, false if a file i/o error occurred.
|
||||
int Write_byte(FILE *file, byte b);
|
||||
|
||||
/// Reads several bytes from an open file. Returns true if OK, false if a file i/o error occurred.
|
||||
int Read_bytes(FILE *file, void *dest, size_t size);
|
||||
/// Writes several bytes to an open file. Returns true if OK, false if a file i/o error occurred.
|
||||
int Write_bytes(FILE *file, void *dest, size_t size);
|
||||
|
||||
/// Reads a 16-bit Low-Endian word from an open file. Returns true if OK, false if a file i/o error occurred.
|
||||
int Read_word_le(FILE *file, word *dest);
|
||||
/// Writes a 16-bit Low-Endian word to an open file. Returns true if OK, false if a file i/o error occurred.
|
||||
int Write_word_le(FILE *file, word w);
|
||||
/// Reads a 32-bit Low-Endian dword from an open file. Returns true if OK, false if a file i/o error occurred.
|
||||
int Read_dword_le(FILE *file, dword *dest);
|
||||
/// Writes a 32-bit Low-Endian dword to an open file. Returns true if OK, false if a file i/o error occurred.
|
||||
int Write_dword_le(FILE *file, dword dw);
|
||||
|
||||
/// Reads a 16-bit Big-Endian word from an open file. Returns true if OK, false if a file i/o error occurred.
|
||||
int Read_word_be(FILE *file, word *dest);
|
||||
/// Writes a 16-bit Big-Endian word to an open file. Returns true if OK, false if a file i/o error occurred.
|
||||
int Write_word_be(FILE *file, word w);
|
||||
/// Reads a 32-bit Big-Endian dword from an open file. Returns true if OK, false if a file i/o error occurred.
|
||||
int Read_dword_be(FILE *file, dword *dest);
|
||||
/// Writes a 32-bit Big-Endian dword to an open file. Returns true if OK, false if a file i/o error occurred.
|
||||
int Write_dword_be(FILE *file, dword dw);
|
||||
|
||||
/// Extracts the filename part from a full file name.
|
||||
void Extract_filename(char *dest, const char *source);
|
||||
/// Extracts the directory from a full file name.
|
||||
void Extract_path(char *dest, const char *source);
|
||||
|
||||
/// Finds the rightmost path separator in a full filename. Used to separate directory from file.
|
||||
char * Find_last_slash(const char * str);
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#define PATH_SEPARATOR "\\"
|
||||
#else
|
||||
#define PATH_SEPARATOR "/"
|
||||
#endif
|
||||
|
||||
/// Size of a file, in bytes. Returns 0 in case of error.
|
||||
int File_length(const char *fname);
|
||||
|
||||
/// Size of a file, in bytes. Takes an open file as argument, returns 0 in case of error.
|
||||
int File_length_file(FILE * file);
|
||||
|
||||
/// Returns true if a file passed as a parameter exists in the current directory.
|
||||
int File_exists(char * fname);
|
||||
|
||||
/// Returns true if a directory passed as a parameter exists in the current directory.
|
||||
int Directory_exists(char * directory);
|
||||
|
||||
/// Scans a directory, calls Callback for each file in it,
|
||||
void For_each_file(const char * directory_name, void Callback(const char *));
|
||||
|
||||
///
|
||||
/// Creates a fully qualified name from a directory and filename.
|
||||
/// The point is simply to insert a PATH_SEPARATOR when needed.
|
||||
void Get_full_filename(char * output_name, char * file_name, char * directory_name);
|
||||
|
||||
///
|
||||
/// Creates a lock file, to check if an other instance of Grafx2 is running.
|
||||
/// @return 0 on success (first instance), -1 on failure (others are running)
|
||||
byte Create_lock_file(const char *file_directory);
|
||||
|
||||
///
|
||||
/// Release a lock file created by ::Create_Lock_file
|
||||
void Release_lock_file(const char *file_directory);
|
||||
|
||||
652
src/keyboard.c
Normal file
652
src/keyboard.c
Normal file
@@ -0,0 +1,652 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2009 Franck Charlet
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "global.h"
|
||||
#include "keyboard.h"
|
||||
|
||||
// Table de correspondance des scancode de clavier IBM PC AT vers
|
||||
// les symboles de touches SDL (sym).
|
||||
// La correspondance est bonne si le clavier est QWERTY US, ou si
|
||||
// l'utilisateur est sous Windows.
|
||||
// Dans l'ordre des colonnes: Normal, +Shift, +Control, +Alt
|
||||
const word Scancode_to_sym[256][4] =
|
||||
{
|
||||
/* 00 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 01 Esc */ { SDLK_ESCAPE ,SDLK_ESCAPE ,SDLK_ESCAPE ,SDLK_ESCAPE },
|
||||
/* 02 1 ! */ { SDLK_1 ,SDLK_1 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 03 2 @ */ { SDLK_2 ,SDLK_2 ,SDLK_2 ,SDLK_UNKNOWN },
|
||||
/* 04 3 # */ { SDLK_3 ,SDLK_3 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 05 4 $ */ { SDLK_4 ,SDLK_4 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 06 5 % */ { SDLK_5 ,SDLK_5 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 07 6 ^ */ { SDLK_6 ,SDLK_6 ,SDLK_6 ,SDLK_UNKNOWN },
|
||||
/* 08 7 & */ { SDLK_7 ,SDLK_7 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 09 8 * */ { SDLK_8 ,SDLK_8 ,SDLK_8 ,SDLK_UNKNOWN },
|
||||
/* 0A 9 ( */ { SDLK_9 ,SDLK_9 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 0B 0 ) */ { SDLK_0 ,SDLK_0 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 0C - _ */ { SDLK_MINUS ,SDLK_MINUS ,SDLK_MINUS ,SDLK_UNKNOWN },
|
||||
/* 0D = + */ { SDLK_EQUALS ,SDLK_EQUALS ,SDLK_EQUALS ,SDLK_UNKNOWN },
|
||||
/* 0E BkSpc */ { SDLK_BACKSPACE ,SDLK_BACKSPACE ,SDLK_BACKSPACE ,SDLK_BACKSPACE },
|
||||
/* 0F Tab */ { SDLK_TAB ,SDLK_TAB ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 10 Q */ { SDLK_q ,SDLK_q ,SDLK_q ,SDLK_q },
|
||||
/* 11 W */ { SDLK_w ,SDLK_w ,SDLK_w ,SDLK_w },
|
||||
/* 12 E */ { SDLK_e ,SDLK_e ,SDLK_e ,SDLK_e },
|
||||
/* 13 R */ { SDLK_r ,SDLK_r ,SDLK_r ,SDLK_r },
|
||||
/* 14 T */ { SDLK_t ,SDLK_t ,SDLK_t ,SDLK_t },
|
||||
/* 15 Y */ { SDLK_y ,SDLK_y ,SDLK_y ,SDLK_y },
|
||||
/* 16 U */ { SDLK_u ,SDLK_u ,SDLK_u ,SDLK_u },
|
||||
/* 17 I */ { SDLK_i ,SDLK_i ,SDLK_i ,SDLK_i },
|
||||
/* 18 O */ { SDLK_o ,SDLK_o ,SDLK_o ,SDLK_o },
|
||||
/* 19 P */ { SDLK_p ,SDLK_p ,SDLK_p ,SDLK_p },
|
||||
/* 1A [ */ { SDLK_LEFTBRACKET ,SDLK_LEFTBRACKET ,SDLK_LEFTBRACKET ,SDLK_LEFTBRACKET },
|
||||
/* 1B ] */ { SDLK_RIGHTBRACKET,SDLK_RIGHTBRACKET,SDLK_RIGHTBRACKET,SDLK_RIGHTBRACKET},
|
||||
/* 1C Retrn */ { SDLK_RETURN ,SDLK_RETURN ,SDLK_RETURN ,SDLK_RETURN },
|
||||
/* 1D ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 1E A */ { SDLK_a ,SDLK_a ,SDLK_a ,SDLK_a },
|
||||
/* 1F S */ { SDLK_s ,SDLK_s ,SDLK_s ,SDLK_s },
|
||||
/* 20 D */ { SDLK_d ,SDLK_d ,SDLK_d ,SDLK_d },
|
||||
/* 21 F */ { SDLK_f ,SDLK_f ,SDLK_f ,SDLK_f },
|
||||
/* 22 G */ { SDLK_g ,SDLK_g ,SDLK_g ,SDLK_g },
|
||||
/* 23 H */ { SDLK_h ,SDLK_h ,SDLK_h ,SDLK_h },
|
||||
/* 24 J */ { SDLK_j ,SDLK_j ,SDLK_j ,SDLK_j },
|
||||
/* 25 K */ { SDLK_k ,SDLK_k ,SDLK_k ,SDLK_k },
|
||||
/* 26 L */ { SDLK_l ,SDLK_l ,SDLK_l ,SDLK_l },
|
||||
/* 27 ; : */ { SDLK_SEMICOLON ,SDLK_SEMICOLON ,SDLK_SEMICOLON ,SDLK_SEMICOLON },
|
||||
/* 28 ' */ { SDLK_QUOTE ,SDLK_QUOTE ,SDLK_UNKNOWN ,SDLK_QUOTE },
|
||||
/* 29 ` ~ */ { SDLK_BACKQUOTE ,SDLK_BACKQUOTE ,SDLK_UNKNOWN ,SDLK_BACKQUOTE },
|
||||
/* 2A ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 2B \\ */ { SDLK_BACKSLASH ,SDLK_BACKSLASH ,SDLK_BACKSLASH ,SDLK_BACKSLASH },
|
||||
/* 2C Z */ { SDLK_z ,SDLK_z ,SDLK_z ,SDLK_z },
|
||||
/* 2D X */ { SDLK_x ,SDLK_x ,SDLK_x ,SDLK_x },
|
||||
/* 2E C */ { SDLK_c ,SDLK_c ,SDLK_c ,SDLK_c },
|
||||
/* 2F V */ { SDLK_v ,SDLK_v ,SDLK_v ,SDLK_v },
|
||||
/* 30 B */ { SDLK_b ,SDLK_b ,SDLK_b ,SDLK_b },
|
||||
/* 31 N */ { SDLK_n ,SDLK_n ,SDLK_n ,SDLK_n },
|
||||
/* 32 M */ { SDLK_m ,SDLK_m ,SDLK_m ,SDLK_m },
|
||||
/* 33 , < */ { SDLK_COMMA ,SDLK_COMMA ,SDLK_UNKNOWN ,SDLK_COMMA },
|
||||
/* 34 . > */ { SDLK_PERIOD ,SDLK_PERIOD ,SDLK_UNKNOWN ,SDLK_PERIOD },
|
||||
/* 35 / ? */ { SDLK_SLASH ,SDLK_SLASH ,SDLK_UNKNOWN ,SDLK_SLASH },
|
||||
/* 36 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 37 Grey* */ { SDLK_KP_MULTIPLY ,SDLK_KP_MULTIPLY ,SDLK_UNKNOWN ,SDLK_KP_MULTIPLY },
|
||||
/* 38 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 39 Space */ { SDLK_SPACE ,SDLK_SPACE ,SDLK_SPACE ,SDLK_SPACE },
|
||||
/* 3A ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 3B F1 */ { SDLK_F1 ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 3C F2 */ { SDLK_F2 ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 3D F3 */ { SDLK_F3 ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 3E F4 */ { SDLK_F4 ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 3F F5 */ { SDLK_F5 ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 40 F6 */ { SDLK_F6 ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 41 F7 */ { SDLK_F7 ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 42 F8 */ { SDLK_F8 ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 43 F9 */ { SDLK_F9 ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 44 F10 */ { SDLK_F10 ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 45 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 46 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 47 Home */ { SDLK_HOME ,SDLK_HOME ,SDLK_UNKNOWN ,SDLK_HOME },
|
||||
/* 48 Up */ { SDLK_UP ,SDLK_UP ,SDLK_UNKNOWN ,SDLK_UP },
|
||||
/* 49 PgUp */ { SDLK_PAGEUP ,SDLK_PAGEUP ,SDLK_UNKNOWN ,SDLK_PAGEUP },
|
||||
/* 4A Grey- */ { SDLK_KP_MINUS ,SDLK_KP_MINUS ,SDLK_UNKNOWN ,SDLK_KP_MINUS },
|
||||
/* 4B Left */ { SDLK_LEFT ,SDLK_LEFT ,SDLK_UNKNOWN ,SDLK_LEFT },
|
||||
/* 4C Kpad5 */ { SDLK_KP5 ,SDLK_KP5 ,SDLK_UNKNOWN ,SDLK_KP5 },
|
||||
/* 4D Right */ { SDLK_RIGHT ,SDLK_RIGHT ,SDLK_UNKNOWN ,SDLK_RIGHT },
|
||||
/* 4E Grey+ */ { SDLK_KP_PLUS ,SDLK_KP_PLUS ,SDLK_UNKNOWN ,SDLK_KP_PLUS },
|
||||
/* 4F End */ { SDLK_END ,SDLK_END ,SDLK_UNKNOWN ,SDLK_END },
|
||||
/* 50 Down */ { SDLK_DOWN ,SDLK_DOWN ,SDLK_UNKNOWN ,SDLK_DOWN },
|
||||
/* 51 PgDn */ { SDLK_PAGEDOWN ,SDLK_PAGEDOWN ,SDLK_UNKNOWN ,SDLK_PAGEDOWN },
|
||||
/* 52 Ins */ { SDLK_INSERT ,SDLK_INSERT ,SDLK_UNKNOWN ,SDLK_INSERT },
|
||||
/* 53 Del */ { SDLK_DELETE ,SDLK_DELETE ,SDLK_UNKNOWN ,SDLK_DELETE },
|
||||
/* 54 ??? */ { SDLK_UNKNOWN ,SDLK_F1 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 55 ??? */ { SDLK_UNKNOWN ,SDLK_F2 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 56 Lft| */ { SDLK_UNKNOWN ,SDLK_F3 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 57 ??? */ { SDLK_UNKNOWN ,SDLK_F4 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 58 ??? */ { SDLK_UNKNOWN ,SDLK_F5 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 59 ??? */ { SDLK_UNKNOWN ,SDLK_F6 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 5A ??? */ { SDLK_UNKNOWN ,SDLK_F7 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 5B ??? */ { SDLK_UNKNOWN ,SDLK_F8 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 5C ??? */ { SDLK_UNKNOWN ,SDLK_F9 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 5D ??? */ { SDLK_UNKNOWN ,SDLK_F10 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 5E ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F1 ,SDLK_UNKNOWN },
|
||||
/* 5F ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F2 ,SDLK_UNKNOWN },
|
||||
/* 60 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F3 ,SDLK_UNKNOWN },
|
||||
/* 61 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F4 ,SDLK_UNKNOWN },
|
||||
/* 62 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F5 ,SDLK_UNKNOWN },
|
||||
/* 63 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F6 ,SDLK_UNKNOWN },
|
||||
/* 64 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F7 ,SDLK_UNKNOWN },
|
||||
/* 65 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F8 ,SDLK_UNKNOWN },
|
||||
/* 66 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F9 ,SDLK_UNKNOWN },
|
||||
/* 67 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F10 ,SDLK_UNKNOWN },
|
||||
/* 68 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F1 },
|
||||
/* 69 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F2 },
|
||||
/* 6A ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F3 },
|
||||
/* 6B ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F4 },
|
||||
/* 6C ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F5 },
|
||||
/* 6D ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F6 },
|
||||
/* 6E ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F7 },
|
||||
/* 6F ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F8 },
|
||||
/* 70 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F9 },
|
||||
/* 71 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F10 },
|
||||
/* 72 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 73 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_LEFT ,SDLK_UNKNOWN },
|
||||
/* 74 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_RIGHT ,SDLK_UNKNOWN },
|
||||
/* 75 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_END ,SDLK_UNKNOWN },
|
||||
/* 76 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_PAGEDOWN ,SDLK_UNKNOWN },
|
||||
/* 77 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_HOME ,SDLK_UNKNOWN },
|
||||
/* 78 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_1 },
|
||||
/* 79 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_2 },
|
||||
/* 7A ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_3 },
|
||||
/* 7B ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_4 },
|
||||
/* 7C ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_5 },
|
||||
/* 7D ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_6 },
|
||||
/* 7E ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_7 },
|
||||
/* 7F ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_8 },
|
||||
/* 80 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_9 },
|
||||
/* 81 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_0 },
|
||||
/* 82 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_MINUS },
|
||||
/* 83 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_EQUALS },
|
||||
/* 84 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_PAGEUP ,SDLK_UNKNOWN },
|
||||
/* 85 F11 */ { SDLK_F11 ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 86 F12 */ { SDLK_F12 ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 87 ??? */ { SDLK_UNKNOWN ,SDLK_F11 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 88 ??? */ { SDLK_UNKNOWN ,SDLK_F12 ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 89 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F11 ,SDLK_UNKNOWN },
|
||||
/* 8A ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F12 ,SDLK_UNKNOWN },
|
||||
/* 8B ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F11 },
|
||||
/* 8C ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_F12 },
|
||||
/* 8D ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UP ,SDLK_UNKNOWN },
|
||||
/* 8E ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_KP_MINUS ,SDLK_UNKNOWN },
|
||||
/* 8F ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_KP5 ,SDLK_UNKNOWN },
|
||||
/* 90 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_KP_PLUS ,SDLK_UNKNOWN },
|
||||
/* 91 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_DOWN ,SDLK_UNKNOWN },
|
||||
/* 92 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_INSERT ,SDLK_UNKNOWN },
|
||||
/* 93 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_DELETE ,SDLK_UNKNOWN },
|
||||
/* 94 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_TAB ,SDLK_UNKNOWN },
|
||||
/* 95 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_KP_DIVIDE ,SDLK_UNKNOWN },
|
||||
/* 96 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_KP_MULTIPLY ,SDLK_UNKNOWN },
|
||||
/* 97 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_HOME },
|
||||
/* 98 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UP },
|
||||
/* 99 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_PAGEUP },
|
||||
/* 9A ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 9B ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_LEFT },
|
||||
/* 9C ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 9D ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_RIGHT },
|
||||
/* 9E ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* 9F ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_END },
|
||||
/* A0 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_DOWN },
|
||||
/* A1 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_PAGEUP },
|
||||
/* A2 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_INSERT },
|
||||
/* A3 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_DELETE },
|
||||
/* A4 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_KP_DIVIDE },
|
||||
/* A5 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_TAB },
|
||||
/* A6 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_KP_ENTER },
|
||||
/* A7 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* A8 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* A9 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* AA ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* AB ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* AC ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* AD ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* AE ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* AF ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* B0 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* B1 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* B2 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* B3 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* B4 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* B5 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* B6 Win L */ { SDLK_LSUPER ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* B7 Win R */ { SDLK_RSUPER ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* B8 Win M */ { SDLK_MENU ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* B9 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* BA ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* BB ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* BC ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* BD ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* BE ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* BF ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* C0 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* C1 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* C2 ??? */ { SDLK_UNKNOWN ,SDLK_LSUPER ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* C3 ??? */ { SDLK_UNKNOWN ,SDLK_RSUPER ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* C4 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* C5 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* C6 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* C7 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* C8 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* C9 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* CA ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* CB ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* CC ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* CD ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* CE ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_LSUPER ,SDLK_UNKNOWN },
|
||||
/* CF ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_RSUPER ,SDLK_UNKNOWN },
|
||||
/* D0 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_MENU ,SDLK_UNKNOWN },
|
||||
/* D1 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* D2 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* D3 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* D4 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* D5 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* D6 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* D7 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* D8 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* D9 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* DA ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_LSUPER },
|
||||
/* DB ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_RSUPER },
|
||||
/* DC ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_MENU },
|
||||
/* DD ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* DE ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* DF ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* E0 Enter */ { SDLK_KP_ENTER ,SDLK_KP_ENTER ,SDLK_KP_ENTER ,SDLK_UNKNOWN },
|
||||
/* E1 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* E2 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* E3 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* E4 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* E5 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* E6 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* E7 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* E8 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* E9 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* EA ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* EB ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* EC ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* ED ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* EE ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* EF ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* F0 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* F1 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* F2 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* F3 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* F4 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* F5 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* F6 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* F7 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* F8 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* F9 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* FA ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* FB ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* FC ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* FD ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* FE ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
/* FF ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
|
||||
};
|
||||
|
||||
// Conversion de l'ancien codage des touches:
|
||||
// 0x00FF le scancode (maintenant code sym sur 0x0FFF)
|
||||
// 0x0100 shift (maintenant 0x1000)
|
||||
// 0x0200 control (maintenant 0x2000)
|
||||
// 0x0400 alt (maintenant 0x4000)
|
||||
word Key_for_scancode(word scancode)
|
||||
{
|
||||
if (scancode & 0x0400)
|
||||
return Scancode_to_sym[scancode & 0xFF][3] |
|
||||
(scancode & 0x0700) << 4;
|
||||
else if (scancode & 0x0200)
|
||||
return Scancode_to_sym[scancode & 0xFF][2] |
|
||||
(scancode & 0x0700) << 4;
|
||||
else if (scancode & 0x0100)
|
||||
return Scancode_to_sym[scancode & 0xFF][1] |
|
||||
(scancode & 0x0700) << 4;
|
||||
else
|
||||
return Scancode_to_sym[scancode & 0xFF][0];
|
||||
}
|
||||
|
||||
// Convertit des modificateurs de touches SDL en modificateurs GrafX2
|
||||
word Key_modifiers(SDLMod mod)
|
||||
{
|
||||
word modifiers=0;
|
||||
|
||||
if (mod & KMOD_CTRL )
|
||||
modifiers|=MOD_CTRL;
|
||||
if (mod & KMOD_SHIFT )
|
||||
modifiers|=MOD_SHIFT;
|
||||
if (mod & (KMOD_ALT|KMOD_MODE))
|
||||
modifiers|=MOD_ALT;
|
||||
if (mod & (KMOD_META))
|
||||
modifiers|=MOD_META;
|
||||
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
word Keysym_to_keycode(SDL_keysym keysym)
|
||||
{
|
||||
word key_code = 0;
|
||||
word mod;
|
||||
|
||||
// On ignore shift, alt et control isolés.
|
||||
if (keysym.sym == SDLK_RSHIFT || keysym.sym == SDLK_LSHIFT ||
|
||||
keysym.sym == SDLK_RCTRL || keysym.sym == SDLK_LCTRL ||
|
||||
keysym.sym == SDLK_RALT || keysym.sym == SDLK_LALT ||
|
||||
keysym.sym == SDLK_RMETA || keysym.sym == SDLK_LMETA ||
|
||||
keysym.sym == SDLK_MODE) // AltGr
|
||||
return 0;
|
||||
|
||||
// Les touches qui n'ont qu'une valeur unicode (très rares)
|
||||
// seront codées sur 11 bits, le 12e bit est mis à 1 (0x0800)
|
||||
if (keysym.sym != 0)
|
||||
key_code = keysym.sym;
|
||||
else if (keysym.scancode != 0)
|
||||
{
|
||||
key_code = (keysym.scancode & 0x07FF) | 0x0800;
|
||||
}
|
||||
|
||||
// Normally I should test keysym.mod here, but on windows the implementation
|
||||
// is buggy: if you release a modifier key, the following keys (when they repeat)
|
||||
// still name the original modifiers.
|
||||
mod=Key_modifiers(SDL_GetModState());
|
||||
|
||||
// SDL_GetModState() seems to get the right up-to-date info.
|
||||
key_code |= mod;
|
||||
return key_code;
|
||||
}
|
||||
|
||||
const char * Key_name(word Key)
|
||||
{
|
||||
typedef struct
|
||||
{
|
||||
word keysym;
|
||||
char *Key_name;
|
||||
} T_key_label;
|
||||
T_key_label key_labels[] =
|
||||
{
|
||||
{ SDLK_BACKSPACE , "Backspace" },
|
||||
{ SDLK_TAB , "Tab" },
|
||||
{ SDLK_CLEAR , "Clear" },
|
||||
{ SDLK_RETURN , "Return" },
|
||||
{ SDLK_PAUSE , "Pause" },
|
||||
{ SDLK_ESCAPE , "Esc" },
|
||||
{ SDLK_DELETE , "Del" },
|
||||
{ SDLK_KP0 , "KP 0" },
|
||||
{ SDLK_KP1 , "KP 1" },
|
||||
{ SDLK_KP2 , "KP 2" },
|
||||
{ SDLK_KP3 , "KP 3" },
|
||||
{ SDLK_KP4 , "KP 4" },
|
||||
{ SDLK_KP5 , "KP 5" },
|
||||
{ SDLK_KP6 , "KP 6" },
|
||||
{ SDLK_KP7 , "KP 7" },
|
||||
{ SDLK_KP8 , "KP 8" },
|
||||
{ SDLK_KP9 , "KP 9" },
|
||||
{ SDLK_KP_PERIOD , "KP ." },
|
||||
{ SDLK_KP_DIVIDE , "KP /" },
|
||||
{ SDLK_KP_MULTIPLY, "KP *" },
|
||||
{ SDLK_KP_MINUS , "KP -" },
|
||||
{ SDLK_KP_PLUS , "KP +" },
|
||||
{ SDLK_KP_ENTER , "KP Enter" },
|
||||
{ SDLK_KP_EQUALS , "KP =" },
|
||||
{ SDLK_UP , "Up" },
|
||||
{ SDLK_DOWN , "Down" },
|
||||
{ SDLK_RIGHT , "Right" },
|
||||
{ SDLK_LEFT , "Left" },
|
||||
{ SDLK_INSERT , "Ins" },
|
||||
{ SDLK_HOME , "Home" },
|
||||
{ SDLK_END , "End" },
|
||||
{ SDLK_PAGEUP , "PgUp" },
|
||||
{ SDLK_PAGEDOWN , "PgDn" },
|
||||
{ SDLK_F1 , "F1" },
|
||||
{ SDLK_F2 , "F2" },
|
||||
{ SDLK_F3 , "F3" },
|
||||
{ SDLK_F4 , "F4" },
|
||||
{ SDLK_F5 , "F5" },
|
||||
{ SDLK_F6 , "F6" },
|
||||
{ SDLK_F7 , "F7" },
|
||||
{ SDLK_F8 , "F8" },
|
||||
{ SDLK_F9 , "F9" },
|
||||
{ SDLK_F10 , "F10" },
|
||||
{ SDLK_F11 , "F11" },
|
||||
{ SDLK_F12 , "F12" },
|
||||
{ SDLK_F13 , "F13" },
|
||||
{ SDLK_F14 , "F14" },
|
||||
{ SDLK_F15 , "F15" },
|
||||
{ SDLK_NUMLOCK , "NumLock" },
|
||||
{ SDLK_CAPSLOCK , "CapsLck" },
|
||||
{ SDLK_SCROLLOCK , "ScrlLock" },
|
||||
{ SDLK_RSHIFT , "RShift" },
|
||||
{ SDLK_LSHIFT , "LShift" },
|
||||
{ SDLK_RCTRL , "RCtrl" },
|
||||
{ SDLK_LCTRL , "LCtrl" },
|
||||
{ SDLK_RALT , "RAlt" },
|
||||
{ SDLK_LALT , "LAlt" },
|
||||
{ SDLK_RMETA , "RMeta" },
|
||||
{ SDLK_LMETA , "LMeta" },
|
||||
{ SDLK_LSUPER , "LWin" },
|
||||
{ SDLK_RSUPER , "RWin" },
|
||||
{ SDLK_MODE , "AltGr" },
|
||||
{ SDLK_COMPOSE , "Comp" },
|
||||
{ SDLK_HELP , "Help" },
|
||||
{ SDLK_PRINT , "Print" },
|
||||
{ SDLK_SYSREQ , "SysReq" },
|
||||
{ SDLK_BREAK , "Break" },
|
||||
{ SDLK_MENU , "Menu" },
|
||||
{ SDLK_POWER , "Power" },
|
||||
{ SDLK_EURO , "Euro" },
|
||||
{ SDLK_UNDO , "Undo" },
|
||||
{ KEY_MOUSEMIDDLE, "Mouse3" },
|
||||
{ KEY_MOUSEWHEELUP, "WheelUp" },
|
||||
{ KEY_MOUSEWHEELDOWN, "WheelDown" }
|
||||
};
|
||||
|
||||
int index;
|
||||
static char buffer[41];
|
||||
buffer[0] = '\0';
|
||||
|
||||
if (Key == SDLK_UNKNOWN)
|
||||
return "None";
|
||||
|
||||
if (Key & MOD_CTRL)
|
||||
strcat(buffer, "Ctrl+");
|
||||
if (Key & MOD_ALT)
|
||||
strcat(buffer, "Alt+");
|
||||
if (Key & MOD_SHIFT)
|
||||
strcat(buffer, "Shift+");
|
||||
if (Key & MOD_META)
|
||||
strcat(buffer, "\201");
|
||||
// Note: Apple's "command" character is not present in the ANSI table, so we
|
||||
// recycled an ANSI value that doesn't have any displayable character
|
||||
// associated.
|
||||
|
||||
|
||||
Key=Key & ~(MOD_CTRL|MOD_ALT|MOD_SHIFT);
|
||||
|
||||
if (Key>=KEY_JOYBUTTON && Key<=KEY_JOYBUTTON+18)
|
||||
{
|
||||
#ifdef __GP2X__
|
||||
|
||||
char *button_name;
|
||||
switch(Key-KEY_JOYBUTTON)
|
||||
{
|
||||
case GP2X_BUTTON_UP: button_name="[UP]"; break;
|
||||
case GP2X_BUTTON_DOWN: button_name="[DOWN]"; break;
|
||||
case GP2X_BUTTON_LEFT: button_name="[LEFT]"; break;
|
||||
case GP2X_BUTTON_RIGHT: button_name="[RIGHT]"; break;
|
||||
case GP2X_BUTTON_UPLEFT: button_name="[UP-LEFT]"; break;
|
||||
case GP2X_BUTTON_UPRIGHT: button_name="[UP-RIGHT]"; break;
|
||||
case GP2X_BUTTON_DOWNLEFT: button_name="[DOWN-LEFT]"; break;
|
||||
case GP2X_BUTTON_DOWNRIGHT: button_name="[DOWN-RIGHT]"; break;
|
||||
case GP2X_BUTTON_CLICK: button_name="[CLICK]"; break;
|
||||
case GP2X_BUTTON_A: button_name="[A]"; break;
|
||||
case GP2X_BUTTON_B: button_name="[B]"; break;
|
||||
case GP2X_BUTTON_X: button_name="[X]"; break;
|
||||
case GP2X_BUTTON_Y: button_name="[Y]"; break;
|
||||
case GP2X_BUTTON_L: button_name="[L]"; break;
|
||||
case GP2X_BUTTON_R: button_name="[R]"; break;
|
||||
case GP2X_BUTTON_START: button_name="[START]"; break;
|
||||
case GP2X_BUTTON_SELECT: button_name="[SELECT]"; break;
|
||||
case GP2X_BUTTON_VOLUP: button_name="[VOL UP]"; break;
|
||||
case GP2X_BUTTON_VOLDOWN: button_name="[VOL DOWN]"; break;
|
||||
default: sprintf(buffer+strlen(buffer), "[B%d]", Key);return buffer;
|
||||
}
|
||||
strcat(buffer,button_name);
|
||||
#else
|
||||
sprintf(buffer+strlen(buffer), "[B%d]", Key-KEY_JOYBUTTON);
|
||||
#endif
|
||||
return buffer;
|
||||
}
|
||||
|
||||
if (Key & 0x800)
|
||||
{
|
||||
sprintf(buffer+strlen(buffer), "[%d]", Key & 0x7FF);
|
||||
return buffer;
|
||||
}
|
||||
Key = Key & 0x7FF;
|
||||
// Touches ASCII
|
||||
if (Key>=' ' && Key < 127)
|
||||
{
|
||||
sprintf(buffer+strlen(buffer), "'%c'", toupper(Key));
|
||||
return buffer;
|
||||
}
|
||||
// Touches 'World'
|
||||
if (Key>=SDLK_WORLD_0 && Key <= SDLK_WORLD_95)
|
||||
{
|
||||
sprintf(buffer+strlen(buffer), "w%d", Key - SDLK_WORLD_0);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// Touches au libellé connu
|
||||
for (index=0; index < (long)sizeof(key_labels)/(long)sizeof(T_key_label);index++)
|
||||
{
|
||||
if (Key == key_labels[index].keysym)
|
||||
{
|
||||
sprintf(buffer+strlen(buffer), "%s", key_labels[index].Key_name);
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
// Autres touches inconnues
|
||||
sprintf(buffer+strlen(buffer), "0x%X", Key & 0x7FF);
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
// Obtient le caractère ANSI tapé, à partir d'un keysym.
|
||||
// (Valeur 32 à 255)
|
||||
// Renvoie 0 s'il n'y a pas de caractère associé (shift, backspace, etc)
|
||||
word Keysym_to_ANSI(SDL_keysym keysym)
|
||||
{
|
||||
// This part was removed from the MacOSX port, but I put it back for others
|
||||
// as on Linux and Windows, it's what allows editing a text line with the keys
|
||||
// SDLK_LEFT, SDLK_RIGHT, SDLK_HOME, SDLK_END etc.
|
||||
#if !(defined(__macosx__) || defined(__FreeBSD__))
|
||||
if ( keysym.unicode == 0)
|
||||
{
|
||||
switch(keysym.sym)
|
||||
{
|
||||
case SDLK_DELETE:
|
||||
case SDLK_LEFT:
|
||||
case SDLK_RIGHT:
|
||||
case SDLK_HOME:
|
||||
case SDLK_END:
|
||||
case SDLK_BACKSPACE:
|
||||
case KEY_ESC:
|
||||
case SDLK_RETURN:
|
||||
return keysym.sym;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//
|
||||
if ( keysym.unicode > 32 && keysym.unicode < 127)
|
||||
{
|
||||
return keysym.unicode; // Pas de souci, on est en ASCII standard
|
||||
}
|
||||
|
||||
// Quelques conversions Unicode-ANSI
|
||||
switch(keysym.unicode)
|
||||
{
|
||||
case 0x8100:
|
||||
return 'ü'; // ü
|
||||
case 0x1A20:
|
||||
return 'é'; // é
|
||||
case 0x201A:
|
||||
return 'è'; // è
|
||||
case 0x9201:
|
||||
return 'â'; // â
|
||||
case 0x1E20:
|
||||
return 'ä'; // ä
|
||||
case 0x2620:
|
||||
return 'à'; // à
|
||||
case 0x2020:
|
||||
return 'å'; // å
|
||||
case 0x2120:
|
||||
return 'ç'; // ç
|
||||
case 0xC602:
|
||||
return 'ê'; // ê
|
||||
case 0x3020:
|
||||
return 'ë'; // ë
|
||||
case 0x6001:
|
||||
return 'è'; // è
|
||||
case 0x3920:
|
||||
return 'ï'; // ï
|
||||
case 0x5201:
|
||||
return 'î'; // î
|
||||
case 0x8D00:
|
||||
return 'ì'; // ì
|
||||
case 0x1C20:
|
||||
return 'ô'; // ô
|
||||
case 0x1D20:
|
||||
return 'ö'; // ö
|
||||
case 0x2220:
|
||||
return 'ò'; // ò
|
||||
case 0x1320:
|
||||
return 'û'; // û
|
||||
case 0x1420:
|
||||
return 'ù'; // ù
|
||||
case 0xDC02:
|
||||
return 'ÿ'; // ÿ
|
||||
case 0x5301:
|
||||
return '£'; // £
|
||||
case 0xA000:
|
||||
return 'á'; // á
|
||||
case 0xA100:
|
||||
return 'í'; // í
|
||||
case 0xA200:
|
||||
return 'ó'; // ó
|
||||
case 0xA300:
|
||||
return 'ú'; // ú
|
||||
case 0xA400:
|
||||
return 'ñ'; // ñ
|
||||
case 0xA700:
|
||||
return 'º'; // º
|
||||
case 0xC600:
|
||||
return 'ã'; // ã
|
||||
}
|
||||
|
||||
// Key entre 127 et 255
|
||||
if (keysym.unicode<256)
|
||||
{
|
||||
#if defined(__macosx__) || defined(__FreeBSD__)
|
||||
// fc: Looks like there's a mismatch with delete & backspace
|
||||
// i don't why SDLK_DELETE was returned instead of SDLK_BACKSPACE
|
||||
if(keysym.unicode == 127)
|
||||
{
|
||||
return(SDLK_BACKSPACE);
|
||||
}
|
||||
// We don't make any difference between return & enter in the app context.
|
||||
if(keysym.unicode == 3)
|
||||
{
|
||||
return(SDLK_RETURN);
|
||||
}
|
||||
#endif
|
||||
return keysym.unicode;
|
||||
}
|
||||
|
||||
// Sinon c'est une touche spéciale, on retourne son scancode
|
||||
return keysym.sym;
|
||||
}
|
||||
77
src/keyboard.h
Normal file
77
src/keyboard.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 keyboard.h
|
||||
/// Functions to convert bewteen the SDL key formats and the keycode we use
|
||||
/// in grafx2.
|
||||
/// The keycode we're using is generalized to handle mouse and joystick shortcuts
|
||||
/// as well. The format can be broken down as:
|
||||
/// - 0x0000 + a number between 0 and SDLK_LAST (about 324) : the SDL "sym" key number.
|
||||
/// - 0x0000 + SDLK_LAST+1: Mouse middle button.
|
||||
/// - 0x0000 + SDLK_LAST+2: Mouse wheel up.
|
||||
/// - 0x0000 + SDLK_LAST+3: Mouse wheel down.
|
||||
/// - 0x0000 + SDLK_LAST+4+B : Joystick button number "B", starting at B=0.
|
||||
/// - 0x0800 + a number between 0 and 0x7FF: The scancode key number, for keys which have no "sym", such as keys from multimedia keyboards, and "fn" and "Thinkpad" key for a laptop.
|
||||
/// Add 0x1000 for the Shift modifier MOD_SHIFT
|
||||
/// Add 0x2000 for the Control modifier ::MOD_CONTROL
|
||||
/// Add 0x4000 for the Alt modifier ::MOD_ALT
|
||||
/// Add 0x8000 for the "Meta" modifier ::MOD_META (On MacOS X it's the CMD key)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*!
|
||||
Convert an SDL keysym to an ANSI/ASCII character.
|
||||
This is used to type text and numeric values in input boxes.
|
||||
@param keysym SDL symbol to convert
|
||||
*/
|
||||
word Keysym_to_ANSI(SDL_keysym keysym);
|
||||
|
||||
/*!
|
||||
Convert an SDL keysym to an internal keycode number.
|
||||
This is needed because SDL tends to split the information across the unicode sym, the regular sym, and the raw keycode.
|
||||
We also need to differenciate 1 (keypad) and 1 (regular keyboard), and some other things.
|
||||
See the notice at the beginning of keyboard.h for the format of a keycode.
|
||||
@param keysym SDL symbol to convert
|
||||
*/
|
||||
word Keysym_to_keycode(SDL_keysym keysym);
|
||||
|
||||
/*!
|
||||
Helper function to convert between SDL system and the old coding for PC keycodes.
|
||||
This is only used to convert configuration files from the DOS version of
|
||||
Grafx2, where keyboard codes are in in the IBM PC AT form.
|
||||
@param scancode Scancode to convert
|
||||
*/
|
||||
word Key_for_scancode(word scancode);
|
||||
|
||||
/*!
|
||||
Returns key name in a string. Used to display them in the helpscreens and in the keymapper window.
|
||||
@param Key keycode of the key to translate, including modifiers
|
||||
*/
|
||||
const char * Key_name(word Key);
|
||||
|
||||
/*!
|
||||
Gets the modifiers in our format from the SDL_Mod information.
|
||||
Returns a combination of ::MOD_SHIFT, ::MOD_ALT, ::MOD_CONTROL
|
||||
@param mod SDL modifiers state
|
||||
*/
|
||||
word Key_modifiers(SDLMod mod);
|
||||
|
||||
391
src/layers.c
Normal file
391
src/layers.c
Normal file
@@ -0,0 +1,391 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2009 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
#include "const.h"
|
||||
#include "struct.h"
|
||||
#include "global.h"
|
||||
#include "windows.h"
|
||||
#include "engine.h"
|
||||
#include "pages.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "input.h"
|
||||
#include "help.h"
|
||||
#include "misc.h"
|
||||
|
||||
void Layer_activate(byte layer, short side)
|
||||
{
|
||||
word old_layers;
|
||||
|
||||
if (layer >= Main_backups->Pages->Nb_layers)
|
||||
return;
|
||||
|
||||
// Keep a copy of which layers were visible
|
||||
old_layers = Main_layers_visible;
|
||||
|
||||
#ifndef NOLAYERS
|
||||
|
||||
if (side == RIGHT_SIDE)
|
||||
{
|
||||
// Right-click on current layer
|
||||
if (Main_current_layer == layer)
|
||||
{
|
||||
if (Main_layers_visible == (dword)(1<<layer))
|
||||
{
|
||||
// Set all layers visible
|
||||
Main_layers_visible = 0xFFFFFFFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set only this one visible
|
||||
Main_layers_visible = 1<<layer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Right-click on an other layer : toggle its visibility
|
||||
Main_layers_visible ^= 1<<layer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Left-click on any layer
|
||||
Main_current_layer = layer;
|
||||
Main_layers_visible |= 1<<layer;
|
||||
}
|
||||
#else
|
||||
// Handler for limited layers support: only allow one visible at a time
|
||||
if (side == LEFT_SIDE)
|
||||
{
|
||||
Main_current_layer = layer;
|
||||
Main_layers_visible = 1<<layer;
|
||||
|
||||
Update_screen_targets();
|
||||
}
|
||||
#endif
|
||||
|
||||
Hide_cursor();
|
||||
if (Main_layers_visible != old_layers)
|
||||
Redraw_layered_image();
|
||||
else
|
||||
Update_depth_buffer(); // Only need the depth buffer
|
||||
//Download_infos_page_main(Main_backups->Pages);
|
||||
//Update_FX_feedback(Config.FX_Feedback);
|
||||
Display_all_screen();
|
||||
Display_layerbar();
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
void Button_Layer_add(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
|
||||
if (Main_backups->Pages->Nb_layers < MAX_NB_LAYERS)
|
||||
{
|
||||
// Backup with unchanged layers
|
||||
Backup_layers(0);
|
||||
if (!Add_layer(Main_backups,Main_current_layer+1))
|
||||
{
|
||||
Update_depth_buffer();
|
||||
Display_all_screen();
|
||||
Display_layerbar();
|
||||
End_of_modification();
|
||||
}
|
||||
}
|
||||
|
||||
Unselect_button(BUTTON_LAYER_ADD);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
void Button_Layer_remove(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
|
||||
if (Main_backups->Pages->Nb_layers > 1)
|
||||
{
|
||||
// Backup with unchanged layers
|
||||
Backup_layers(0);
|
||||
if (!Delete_layer(Main_backups,Main_current_layer))
|
||||
{
|
||||
Update_screen_targets();
|
||||
Redraw_layered_image();
|
||||
|
||||
Display_all_screen();
|
||||
Display_layerbar();
|
||||
End_of_modification();
|
||||
}
|
||||
}
|
||||
Unselect_button(BUTTON_LAYER_REMOVE);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
void Button_Layer_select(void)
|
||||
{
|
||||
short layer;
|
||||
// Determine which button is clicked according to mouse position
|
||||
layer = (Mouse_X/Menu_factor_X - Menu_bars[MENUBAR_LAYERS].Skin_width)
|
||||
/ Layer_button_width;
|
||||
|
||||
// Safety required because the mouse cursor can have slided outside button.
|
||||
if (layer < 0)
|
||||
layer=0;
|
||||
else if (layer > Main_backups->Pages->Nb_layers-1)
|
||||
layer=Main_backups->Pages->Nb_layers-1;
|
||||
|
||||
Layer_activate(layer, LEFT_SIDE);
|
||||
}
|
||||
|
||||
void Button_Layer_toggle(void)
|
||||
{
|
||||
short layer;
|
||||
// Determine which button is clicked according to mouse position
|
||||
layer = (Mouse_X/Menu_factor_X - Menu_bars[MENUBAR_LAYERS].Skin_width)
|
||||
/ Layer_button_width;
|
||||
|
||||
// Safety required because the mouse cursor can have slided outside button.
|
||||
if (layer < 0)
|
||||
layer=0;
|
||||
else if (layer > Main_backups->Pages->Nb_layers-1)
|
||||
layer=Main_backups->Pages->Nb_layers-1;
|
||||
|
||||
Layer_activate(layer, RIGHT_SIDE);
|
||||
}
|
||||
|
||||
static void Draw_transparent_color(byte color)
|
||||
{
|
||||
char buf[4];
|
||||
Num2str(color, buf, 3);
|
||||
Print_in_window(63,39,buf,MC_Black,MC_Light);
|
||||
Window_rectangle(90,39,13,7,color);
|
||||
}
|
||||
|
||||
static void Draw_transparent_background(byte background)
|
||||
{
|
||||
Print_in_window(99,57,background?"X":" ",MC_Black,MC_Light);
|
||||
}
|
||||
|
||||
|
||||
void Button_Layer_menu(void)
|
||||
{
|
||||
byte transparent_color = Main_backups->Pages->Transparent_color;
|
||||
byte transparent_background = Main_backups->Pages->Background_transparent;
|
||||
short clicked_button;
|
||||
byte color;
|
||||
byte click;
|
||||
|
||||
Open_window(122,100,"Layers");
|
||||
|
||||
Window_display_frame_in( 6, 21,110, 52);
|
||||
Print_in_window(14,18,"Transparency",MC_Dark,MC_Light);
|
||||
|
||||
Print_in_window(11,38,"Color",MC_Black,MC_Light);
|
||||
Window_set_normal_button(54, 36, 56,13,"" , 0,1,KEY_NONE); // 1
|
||||
Draw_transparent_color(transparent_color);
|
||||
|
||||
Print_in_window(11,57,"Background",MC_Black,MC_Light);
|
||||
Window_set_normal_button(95, 54, 15,13,"" , 0,1,KEY_NONE); // 2
|
||||
Draw_transparent_background(transparent_background);
|
||||
|
||||
Window_set_normal_button( 7, 78, 51,14,"OK" , 0,1,SDLK_RETURN); // 3
|
||||
Window_set_normal_button(63, 78, 51,14,"Cancel", 0,1,KEY_ESC); // 4
|
||||
|
||||
Update_window_area(0,0,Window_width, Window_height);
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
clicked_button=Window_clicked_button();
|
||||
if (Is_shortcut(Key,0x100+BUTTON_HELP))
|
||||
Window_help(BUTTON_LAYER_MENU, NULL);
|
||||
switch(clicked_button)
|
||||
{
|
||||
case 1: // color
|
||||
Get_color_behind_window(&color,&click);
|
||||
if (click && transparent_color!=color)
|
||||
{
|
||||
transparent_color=color;
|
||||
Hide_cursor();
|
||||
Draw_transparent_color(transparent_color);
|
||||
Display_cursor();
|
||||
Wait_end_of_click();
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: // background
|
||||
transparent_background = !transparent_background;
|
||||
Hide_cursor();
|
||||
Draw_transparent_background(transparent_background);
|
||||
Display_cursor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (clicked_button<3);
|
||||
|
||||
// On exit
|
||||
Hide_cursor();
|
||||
Close_window();
|
||||
if (clicked_button==3)
|
||||
{
|
||||
// Accept changes
|
||||
if (Main_backups->Pages->Transparent_color != transparent_color ||
|
||||
Main_backups->Pages->Background_transparent != transparent_background)
|
||||
{
|
||||
Backup_layers(-1);
|
||||
Main_backups->Pages->Transparent_color = transparent_color;
|
||||
Main_backups->Pages->Background_transparent = transparent_background;
|
||||
Redraw_layered_image();
|
||||
Display_all_screen();
|
||||
End_of_modification();
|
||||
}
|
||||
}
|
||||
Unselect_button(BUTTON_LAYER_MENU);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
void Button_Layer_set_transparent(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
|
||||
if (Main_backups->Pages->Transparent_color != Back_color)
|
||||
{
|
||||
Backup_layers(-1);
|
||||
Main_backups->Pages->Transparent_color = Back_color;
|
||||
|
||||
Redraw_layered_image();
|
||||
Display_all_screen();
|
||||
End_of_modification();
|
||||
}
|
||||
|
||||
Unselect_button(BUTTON_LAYER_COLOR);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
void Button_Layer_get_transparent(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
|
||||
if (Main_backups->Pages->Transparent_color != Back_color)
|
||||
{
|
||||
Set_back_color(Main_backups->Pages->Transparent_color);
|
||||
}
|
||||
|
||||
Unselect_button(BUTTON_LAYER_COLOR);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
void Button_Layer_merge(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
|
||||
if (Main_current_layer>0)
|
||||
{
|
||||
// Backup layer below the current
|
||||
Backup_layers(1<<(Main_current_layer-1));
|
||||
|
||||
Merge_layer();
|
||||
|
||||
Update_screen_targets();
|
||||
Redraw_layered_image();
|
||||
Display_all_screen();
|
||||
Display_layerbar();
|
||||
End_of_modification();
|
||||
}
|
||||
|
||||
Unselect_button(BUTTON_LAYER_MERGE);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
void Button_Layer_up(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
|
||||
if (Main_current_layer < (Main_backups->Pages->Nb_layers-1))
|
||||
{
|
||||
byte * tmp;
|
||||
dword layer_flags;
|
||||
|
||||
// Backup with unchanged layers
|
||||
Backup_layers(0);
|
||||
|
||||
// swap
|
||||
tmp = Main_backups->Pages->Image[Main_current_layer];
|
||||
Main_backups->Pages->Image[Main_current_layer] = Main_backups->Pages->Image[Main_current_layer+1];
|
||||
Main_backups->Pages->Image[Main_current_layer+1] = tmp;
|
||||
|
||||
// Swap visibility indicators
|
||||
layer_flags = (Main_layers_visible >> Main_current_layer) & 3;
|
||||
// Only needed if they are different.
|
||||
if (layer_flags == 1 || layer_flags == 2)
|
||||
{
|
||||
// One is on, the other is off. Negating them will
|
||||
// perform the swap.
|
||||
Main_layers_visible ^= (3 << Main_current_layer);
|
||||
}
|
||||
Main_current_layer++;
|
||||
|
||||
Update_screen_targets();
|
||||
Redraw_layered_image();
|
||||
Display_all_screen();
|
||||
Display_layerbar();
|
||||
End_of_modification();
|
||||
}
|
||||
|
||||
Unselect_button(BUTTON_LAYER_UP);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
void Button_Layer_down(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
|
||||
if (Main_current_layer > 0)
|
||||
{
|
||||
byte * tmp;
|
||||
dword layer_flags;
|
||||
|
||||
// Backup with unchanged layers
|
||||
Backup_layers(0);
|
||||
|
||||
// swap
|
||||
tmp = Main_backups->Pages->Image[Main_current_layer];
|
||||
Main_backups->Pages->Image[Main_current_layer] = Main_backups->Pages->Image[Main_current_layer-1];
|
||||
Main_backups->Pages->Image[Main_current_layer-1] = tmp;
|
||||
|
||||
// Swap visibility indicators
|
||||
layer_flags = (Main_layers_visible >> (Main_current_layer-1)) & 3;
|
||||
// Only needed if they are different.
|
||||
if (layer_flags == 1 || layer_flags == 2)
|
||||
{
|
||||
// Only needed if they are different.
|
||||
// One is on, the other is off. Negating them will
|
||||
// perform the swap.
|
||||
Main_layers_visible ^= (3 << (Main_current_layer-1));
|
||||
}
|
||||
Main_current_layer--;
|
||||
Update_screen_targets();
|
||||
Redraw_layered_image();
|
||||
Display_layerbar();
|
||||
Display_all_screen();
|
||||
End_of_modification();
|
||||
}
|
||||
|
||||
Unselect_button(BUTTON_LAYER_DOWN);
|
||||
Display_cursor();
|
||||
}
|
||||
35
src/layers.h
Normal file
35
src/layers.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2009 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
void Button_Layer_add(void);
|
||||
void Button_Layer_remove(void);
|
||||
void Button_Layer_menu(void);
|
||||
void Button_Layer_set_transparent(void);
|
||||
void Button_Layer_get_transparent(void);
|
||||
void Button_Layer_merge(void);
|
||||
void Button_Layer_up(void);
|
||||
void Button_Layer_down(void);
|
||||
void Button_Layer_select(void);
|
||||
void Button_Layer_toggle(void);
|
||||
void Layer_activate(byte layer, short side);
|
||||
|
||||
|
||||
190
src/libraw2crtc.c
Normal file
190
src/libraw2crtc.c
Normal file
@@ -0,0 +1,190 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* GFX2CRTC - libraw2crtc.c
|
||||
* CloudStrife - 20080921
|
||||
* Diffusé sous licence libre CeCILL v2
|
||||
* Voire LICENCE
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "const.h"
|
||||
#include "global.h"
|
||||
#include "struct.h"
|
||||
#include "loadsave.h"
|
||||
|
||||
unsigned short addrCalc(unsigned char vcc, unsigned char rcc, unsigned char hcc, unsigned char cclk, unsigned char r1, unsigned char r12, unsigned char r13)
|
||||
{
|
||||
unsigned short MA;
|
||||
unsigned short addr;
|
||||
|
||||
//MA = vcc*r1 + hcc + (0x0C)*256;
|
||||
MA = vcc*r1 + hcc + r12*256 + r13;
|
||||
addr = cclk | ((MA & 0x03FF) << 1);
|
||||
addr = addr | ((rcc & 0x07) << 11);
|
||||
addr = addr | ((MA & 0x3000) << 2);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
unsigned char mode0interlace(T_IO_Context * context, unsigned char x, unsigned char y)
|
||||
{
|
||||
unsigned char mode0pixel[] = {0, 64, 4, 68, 16, 80, 20, 84, 1, 65, 5, 69, 17, 81, 21, 85};
|
||||
return mode0pixel[Get_pixel(context,x,y)] << 1 | mode0pixel[Get_pixel(context,x+1,y)];
|
||||
}
|
||||
|
||||
unsigned char mode1interlace(T_IO_Context * context, unsigned char x, unsigned char y)
|
||||
{
|
||||
unsigned char mode1pixel[] = {0, 16, 1, 17};
|
||||
return mode1pixel[Get_pixel(context,x,y)] << 3 | mode1pixel[Get_pixel(context,x+1,y)] << 2 | mode1pixel[Get_pixel(context,x+2,y)] << 1 | mode1pixel[Get_pixel(context,x+3,y)];
|
||||
}
|
||||
|
||||
unsigned char mode2interlace(T_IO_Context * context, unsigned char x, unsigned char y)
|
||||
{
|
||||
unsigned char out = 0;
|
||||
int i;
|
||||
for(i = 0; i < 8; i++) out += ((Get_pixel(context,x+7-i,y)&1) << i);
|
||||
return out;
|
||||
}
|
||||
|
||||
unsigned char mode3interlace(T_IO_Context * context, unsigned char x, unsigned char y)
|
||||
{
|
||||
unsigned char mode3pixel[] = {0, 16, 1, 17};
|
||||
return mode3pixel[Get_pixel(context, x,y)] << 3 | mode3pixel[Get_pixel(context,x+1,y)] << 2;
|
||||
}
|
||||
|
||||
unsigned char (*ptrMode)(T_IO_Context * context, unsigned char x, unsigned char y);
|
||||
|
||||
unsigned char *raw2crtc(T_IO_Context *context, unsigned short width, unsigned short height, unsigned char mode, unsigned char r9, unsigned long *outSize, unsigned char *r1, unsigned char r12, unsigned char r13)
|
||||
{
|
||||
unsigned char *outBuffer;
|
||||
unsigned char *tmpBuffer;
|
||||
unsigned char *allocationBuffer;
|
||||
unsigned short minAddr = 0;
|
||||
unsigned char minAddrIsDefined = 0;
|
||||
unsigned short maxAddr = 0;
|
||||
|
||||
unsigned char nbPixPerByte;
|
||||
int y,x;
|
||||
unsigned char r6;
|
||||
unsigned short i;
|
||||
unsigned char *ptrTmp;
|
||||
unsigned char *ptrOut;
|
||||
unsigned char vcc;
|
||||
unsigned char rcc;
|
||||
unsigned char hcc;
|
||||
unsigned char cclk;
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
*r1 = (width+3)/4;
|
||||
nbPixPerByte = 2;
|
||||
ptrMode = mode0interlace;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
*r1 = (width+7)/8;
|
||||
nbPixPerByte = 4;
|
||||
ptrMode = mode1interlace;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
*r1 = (width+15)/16;
|
||||
nbPixPerByte = 8;
|
||||
ptrMode = mode2interlace;
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
*r1 = (width+3)/4;
|
||||
nbPixPerByte = 2;
|
||||
ptrMode = mode3interlace;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
exit(4);
|
||||
}
|
||||
}
|
||||
|
||||
tmpBuffer = (unsigned char*)malloc(0xFFFF);
|
||||
if (tmpBuffer == NULL)
|
||||
{
|
||||
printf("Allocation tmpBuffer raté\n");
|
||||
exit(4);
|
||||
}
|
||||
|
||||
allocationBuffer = (unsigned char*)malloc(0xFFFF);
|
||||
if(allocationBuffer == NULL)
|
||||
{
|
||||
printf("Allocation allocationBuffer raté\n");
|
||||
exit(4);
|
||||
}
|
||||
memset(allocationBuffer, 0, 0xFFFF);
|
||||
|
||||
r6 = height/(r9+1);
|
||||
|
||||
for(vcc = 0; vcc < r6; vcc++)
|
||||
{
|
||||
for(rcc = 0; rcc < (r9+1); rcc++)
|
||||
{
|
||||
for(hcc = 0; hcc < *r1; hcc++)
|
||||
{
|
||||
for(cclk = 0; cclk < 2; cclk++)
|
||||
{
|
||||
x = (hcc << 1 | cclk);
|
||||
y = vcc*(r9+1) + rcc;
|
||||
*(tmpBuffer + addrCalc(vcc, rcc, hcc, cclk, *r1, r12, r13)) = (*ptrMode)(context,x,y);
|
||||
*(allocationBuffer + addrCalc(vcc, rcc, hcc, cclk, *r1, r12, r13)) += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < 0xFFFF; i++)
|
||||
{
|
||||
if(*(allocationBuffer + i) > 1)
|
||||
{
|
||||
printf("Attention : Ecriture multiple a l'adresse mémoire %d\n",i);
|
||||
}
|
||||
if(*(allocationBuffer + i) > 0)
|
||||
{
|
||||
maxAddr = i;
|
||||
}
|
||||
if((*(allocationBuffer + i) == 1) && (minAddrIsDefined == 0))
|
||||
{
|
||||
minAddr = i;
|
||||
minAddrIsDefined = 1;
|
||||
}
|
||||
}
|
||||
|
||||
*outSize = (maxAddr + 1) - minAddr;
|
||||
|
||||
outBuffer = (unsigned char*)malloc((*outSize));
|
||||
if (outBuffer == NULL)
|
||||
{
|
||||
printf("Allocation outBuffer raté\n");
|
||||
exit(4);
|
||||
}
|
||||
|
||||
ptrTmp = tmpBuffer + minAddr;
|
||||
ptrOut = outBuffer;
|
||||
|
||||
for(i = minAddr; i <= maxAddr; i++)
|
||||
{
|
||||
*(ptrOut++) = *(ptrTmp++);
|
||||
}
|
||||
|
||||
free(tmpBuffer);
|
||||
tmpBuffer = NULL;
|
||||
free(allocationBuffer);
|
||||
allocationBuffer = NULL;
|
||||
|
||||
return outBuffer;
|
||||
}
|
||||
14
src/libraw2crtc.h
Normal file
14
src/libraw2crtc.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* GFX2CRTC - libraw2crtc.h
|
||||
* CloudStrife - 20080921
|
||||
* Diffusé sous licence libre CeCILL v2
|
||||
* Voire LICENCE
|
||||
*/
|
||||
|
||||
#ifndef LIBRAW2CRTC_H
|
||||
#define LIBRAW2CRTC_H 1
|
||||
|
||||
unsigned char * raw2crtc(unsigned short width, unsigned short height, unsigned char mode, unsigned char r9, unsigned long *outSize, unsigned char *r1, unsigned char r12, unsigned char r13);
|
||||
|
||||
#endif
|
||||
1421
src/loadsave.c
Normal file
1421
src/loadsave.c
Normal file
File diff suppressed because it is too large
Load Diff
240
src/loadsave.h
Normal file
240
src/loadsave.h
Normal file
@@ -0,0 +1,240 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 loadsave.h
|
||||
/// Saving and loading different picture formats.
|
||||
/// Also handles showing the preview in fileselectors.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __LOADSAVE_H__
|
||||
#define __LOADSAVE_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <SDL_image.h>
|
||||
|
||||
enum CONTEXT_TYPE {
|
||||
CONTEXT_MAIN_IMAGE,
|
||||
CONTEXT_BRUSH,
|
||||
CONTEXT_PREVIEW,
|
||||
CONTEXT_SURFACE,
|
||||
};
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/// Kind of context. Internally used to differentiate the "sub-classes"
|
||||
enum CONTEXT_TYPE Type;
|
||||
|
||||
// File properties
|
||||
|
||||
char * File_name;
|
||||
char * File_directory;
|
||||
byte Format;
|
||||
|
||||
// Image properties
|
||||
|
||||
T_Palette Palette;
|
||||
short Width;
|
||||
short Height;
|
||||
byte Nb_layers;
|
||||
char Comment[COMMENT_SIZE+1];
|
||||
byte Background_transparent;
|
||||
byte Transparent_color;
|
||||
/// Pixel ratio of the image
|
||||
enum PIXEL_RATIO Ratio;
|
||||
|
||||
/// Load/save address of first pixel
|
||||
byte *Target_address;
|
||||
/// Pitch: Difference of addresses between one pixel and the one just "below" it
|
||||
long Pitch;
|
||||
|
||||
/// Internal: during load, marks which layer is being loaded.
|
||||
short Current_layer;
|
||||
|
||||
/// Internal: Used to mark truecolor images on loading. Only used by preview.
|
||||
//byte Is_truecolor;
|
||||
/// Internal: Temporary RGB buffer when loading 24bit images
|
||||
T_Components *Buffer_image_24b;
|
||||
|
||||
/// Internal: Temporary buffer when saving the flattened copy of something
|
||||
byte *Buffer_image;
|
||||
|
||||
// Internal: working data for preview case
|
||||
short Preview_factor_X;
|
||||
short Preview_factor_Y;
|
||||
short Preview_pos_X;
|
||||
short Preview_pos_Y;
|
||||
|
||||
// Internal: returned surface for SDL_Surface case
|
||||
SDL_Surface * Surface;
|
||||
|
||||
} T_IO_Context;
|
||||
|
||||
/// Type of a function that can be called for a T_IO_Context. Kind of a method.
|
||||
typedef void (* Func_IO) (T_IO_Context *);
|
||||
|
||||
/*
|
||||
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_brush (word x_pos, word y_pos, byte color);
|
||||
*/
|
||||
|
||||
// Setup for loading a preview in fileselector
|
||||
void Init_context_preview(T_IO_Context * context, char *file_name, char *file_directory);
|
||||
// Setup for loading/saving the current main image
|
||||
void Init_context_layered_image(T_IO_Context * context, char *file_name, char *file_directory);
|
||||
// Setup for loading/saving the flattened version of current main image
|
||||
void Init_context_flat_image(T_IO_Context * context, char *file_name, char *file_directory);
|
||||
// Setup for loading/saving the user's brush
|
||||
void Init_context_brush(T_IO_Context * context, char *file_name, char *file_directory);
|
||||
// Setup for saving an arbitrary undo/redo step, from either the main or spare page.
|
||||
void Init_context_history_step(T_IO_Context * context, T_Page *page);
|
||||
// Setup for loading an image into a new SDL surface.
|
||||
void Init_context_surface(T_IO_Context * context, char *file_name, char *file_directory);
|
||||
|
||||
// Cleans up resources (currently: the 24bit buffer)
|
||||
void Destroy_context(T_IO_Context *context);
|
||||
|
||||
///
|
||||
/// High-level picture loading function.
|
||||
void Load_image(T_IO_Context *context);
|
||||
|
||||
///
|
||||
/// High-level picture saving function.
|
||||
void Save_image(T_IO_Context *context);
|
||||
|
||||
///
|
||||
/// Checks if there are any pending safety backups, and then opens them.
|
||||
/// Returns 0 if there were none
|
||||
/// Returns non-zero if some backups were loaded.
|
||||
int Check_recovery(void);
|
||||
|
||||
/// Makes a safety backup periodically.
|
||||
void Rotate_safety_backups(void);
|
||||
|
||||
/// Remove safety backups. Need to call on normal program exit.
|
||||
void Delete_safety_backups(void);
|
||||
|
||||
/// Data for an image file format.
|
||||
typedef struct {
|
||||
byte Identifier; ///< Identifier for this format in enum :FILE_FORMATS
|
||||
char *Label; ///< Five-letter label
|
||||
Func_IO Test; ///< Function which tests if the file is of this format
|
||||
Func_IO Load; ///< Function which loads an image of this format
|
||||
Func_IO Save; ///< Function which saves an image of this format
|
||||
byte Palette_only; ///< Boolean, true if this format saves/loads only the palette.
|
||||
byte Comment; ///< This file format allows a text comment
|
||||
byte Supports_layers; ///< Boolean, true if this format preserves layers on saving
|
||||
char *Default_extension; ///< Default file extension
|
||||
char *Extensions; ///< List of semicolon-separated file extensions
|
||||
} T_Format;
|
||||
|
||||
/// Array of the known file formats
|
||||
extern T_Format File_formats[];
|
||||
|
||||
///
|
||||
/// Function which attempts to save backups of the images (main and spare),
|
||||
/// called in case of SIGSEGV.
|
||||
/// It will save an image only if it has just one layer... otherwise,
|
||||
/// the risk of flattening a layered image (or saving just one detail layer)
|
||||
/// is too high.
|
||||
void Image_emergency_backup(void);
|
||||
|
||||
/// Load an arbitrary SDL_Surface.
|
||||
SDL_Surface * Load_surface(char *full_name);
|
||||
|
||||
|
||||
/*
|
||||
/// Pixel ratio of last loaded image: one of :PIXEL_SIMPLE, :PIXEL_WIDE or :PIXEL_TALL
|
||||
extern enum PIXEL_RATIO Ratio_of_loaded_image;
|
||||
*/
|
||||
|
||||
T_Format * Get_fileformat(byte format);
|
||||
|
||||
// -- File formats
|
||||
|
||||
#ifndef __no_pnglib__
|
||||
#define NB_KNOWN_FORMATS 19 ///< Total number of known file formats.
|
||||
#else
|
||||
// Without pnglib
|
||||
#define NB_KNOWN_FORMATS 18 ///< Total number of known file formats.
|
||||
#endif
|
||||
|
||||
// Internal use
|
||||
|
||||
/// Generic allocation and similar stuff, done at beginning of image load, as soon as size is known.
|
||||
void Pre_load(T_IO_Context *context, short width, short height, long file_size, int format, enum PIXEL_RATIO ratio, byte truecolor);
|
||||
/// Remaps the window. To call after palette (last) changes.
|
||||
void Palette_loaded(T_IO_Context *context);
|
||||
/// Generic cleanup done on end of loading (ex: color-conversion from the temporary 24b buffer)
|
||||
//void Post_load(T_IO_Context *context);
|
||||
|
||||
/// Query the color of a pixel (to save)
|
||||
byte Get_pixel(T_IO_Context *context, short x, short y);
|
||||
/// Set the color of a pixel (on load)
|
||||
void Set_pixel(T_IO_Context *context, short x, short y, byte c);
|
||||
/// Set the color of a 24bit pixel (on load)
|
||||
void Set_pixel_24b(T_IO_Context *context, short x, short y, byte r, byte g, byte b);
|
||||
/// Function to call when need to switch layers.
|
||||
void Set_layer(T_IO_Context *context, byte layer);
|
||||
|
||||
|
||||
// =================================================================
|
||||
// What follows here are the definitions of functions and data
|
||||
// useful for fileformats.c, miscfileformats.c etc.
|
||||
// =================================================================
|
||||
|
||||
// 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()
|
||||
|
||||
// Data for 24bit loading
|
||||
|
||||
/*
|
||||
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 Init_preview_24b(short width,short height,long size,int format);
|
||||
void Pixel_load_in_24b_preview(short x_pos,short y_pos,byte r,byte g,byte b);
|
||||
*/
|
||||
//
|
||||
|
||||
void Set_file_error(int value);
|
||||
|
||||
/*
|
||||
void Init_preview(short width,short height,long size,int format,enum PIXEL_RATIO ratio);
|
||||
*/
|
||||
void Init_write_buffer(void);
|
||||
void Write_one_byte(FILE *file, byte b);
|
||||
void End_write(FILE *file);
|
||||
|
||||
#endif
|
||||
920
src/main.c
Normal file
920
src/main.c
Normal file
@@ -0,0 +1,920 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2009 Pasi Kallinen
|
||||
Copyright 2008 Peter Gordon
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
#define GLOBAL_VARIABLES
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <SDL.h>
|
||||
#include <SDL_image.h>
|
||||
|
||||
// There is no WM on the GP2X...
|
||||
#ifndef __GP2X__
|
||||
#include <SDL_syswm.h>
|
||||
#endif
|
||||
|
||||
#include "const.h"
|
||||
#include "struct.h"
|
||||
#include "global.h"
|
||||
#include "graph.h"
|
||||
#include "misc.h"
|
||||
#include "init.h"
|
||||
#include "buttons.h"
|
||||
#include "engine.h"
|
||||
#include "pages.h"
|
||||
#include "loadsave.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "errors.h"
|
||||
#include "readini.h"
|
||||
#include "saveini.h"
|
||||
#include "io.h"
|
||||
#include "text.h"
|
||||
#include "setup.h"
|
||||
#include "windows.h"
|
||||
#include "brush.h"
|
||||
#include "palette.h"
|
||||
#include "realpath.h"
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#include <windows.h>
|
||||
#include <shlwapi.h>
|
||||
#define chdir(dir) SetCurrentDirectory(dir)
|
||||
#elif defined(__macosx__)
|
||||
#import <corefoundation/corefoundation.h>
|
||||
#import <sys/param.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#import <sys/param.h>
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (__WIN32__)
|
||||
// On Windows, SDL_putenv is not present in any compilable header.
|
||||
// It can be linked anyway, this declaration only avoids
|
||||
// a compilation warning.
|
||||
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
|
||||
#endif
|
||||
|
||||
//--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles ---
|
||||
void Display_syntax(void)
|
||||
{
|
||||
int mode_index;
|
||||
printf("Syntax: grafx2 [<arguments>] [<picture1>] [<picture2>]\n\n");
|
||||
printf("<arguments> can be:]\n");
|
||||
printf("\t-? -h -H -help for this help screen\n");
|
||||
printf("\t-wide to emulate a video mode with wide pixels (2x1)\n");
|
||||
printf("\t-tall to emulate a video mode with tall pixels (1x2)\n");
|
||||
printf("\t-double to emulate a video mode with double pixels (2x2)\n");
|
||||
printf("\t-wide2 to emulate a video mode with double wide pixels (4x2)\n");
|
||||
printf("\t-tall2 to emulate a video mode with double tall pixels (2x4)\n");
|
||||
printf("\t-triple to emulate a video mode with triple pixels (3x3)\n");
|
||||
printf("\t-quadruple to emulate a video mode with quadruple pixels (4x4)\n");
|
||||
printf("\t-rgb n to reduce RGB precision from 256 to n levels\n");
|
||||
printf("\t-skin <filename> to use an alternate file with the menu graphics\n");
|
||||
printf("\t-mode <videomode> to set a video mode\n");
|
||||
printf("Arguments can be prefixed either by / - or --\n");
|
||||
printf("They can also be abbreviated.\n\n");
|
||||
printf("Available video modes:\n\n");
|
||||
for (mode_index = 0; mode_index < Nb_video_modes; mode_index += 12)
|
||||
{
|
||||
int k;
|
||||
for (k = 0; k < 6; k++)
|
||||
{
|
||||
if (mode_index + k >= Nb_video_modes) break;
|
||||
printf("%12s",Mode_label(mode_index + k));
|
||||
}
|
||||
puts("");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------- Sortie impromptue ----------------------------
|
||||
void Warning_function(const char *message, const char *filename, int line_number, const char *function_name)
|
||||
{
|
||||
printf("Warning in file %s, line %d, function %s : %s\n", filename, line_number, function_name, message);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------- Sortie impromptue ----------------------------
|
||||
void Error_function(int error_code, const char *filename, int line_number, const char *function_name)
|
||||
{
|
||||
T_Palette temp_palette;
|
||||
int index;
|
||||
printf("Error number %d occured in file %s, line %d, function %s.\n", error_code, filename,line_number,function_name);
|
||||
|
||||
if (error_code==0)
|
||||
{
|
||||
// L'erreur 0 n'est pas une vraie erreur, elle fait seulement un flash rouge de l'écran pour dire qu'il y a un problème.
|
||||
// Toutes les autres erreurs déclenchent toujours une sortie en catastrophe du programme !
|
||||
memcpy(temp_palette,Main_palette,sizeof(T_Palette));
|
||||
for (index=0;index<=255;index++)
|
||||
temp_palette[index].R=255;
|
||||
Set_palette(temp_palette);
|
||||
SDL_Delay(500);
|
||||
Set_palette(Main_palette);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (error_code)
|
||||
{
|
||||
case ERROR_GUI_MISSING : printf("Error: File containing the GUI graphics is missing!\n");
|
||||
printf("This program cannot run without this file.\n");
|
||||
break;
|
||||
case ERROR_GUI_CORRUPTED : printf("Error: File containing the GUI graphics couldn't be parsed!\n");
|
||||
printf("This program cannot run without a correct version of this file.\n");
|
||||
break;
|
||||
case ERROR_INI_MISSING : printf("Error: File gfx2def.ini is missing!\n");
|
||||
printf("This program cannot run without this file.\n");
|
||||
break;
|
||||
case ERROR_MEMORY : printf("Error: Not enough memory!\n\n");
|
||||
printf("You should try exiting other programs to free some bytes for Grafx2.\n\n");
|
||||
break;
|
||||
case ERROR_FORBIDDEN_MODE : printf("Error: The requested video mode has been disabled from the resolution menu!\n");
|
||||
printf("If you want to run the program in this mode, you'll have to start it with an\n");
|
||||
printf("enabled mode, then enter the resolution menu and enable the mode you want.\n");
|
||||
printf("Check also if the 'Default_video_mode' parameter in gfx2.ini is correct.\n");
|
||||
break;
|
||||
case ERROR_COMMAND_LINE : printf("Error: Invalid parameter or file not found.\n\n");
|
||||
Display_syntax();
|
||||
break;
|
||||
case ERROR_SAVING_CFG : printf("Error: Write error while saving settings!\n");
|
||||
printf("Settings have not been saved correctly, and the gfx2.cfg file may have been\n");
|
||||
printf("corrupt. If so, please delete it and Grafx2 will restore default settings.\n");
|
||||
break;
|
||||
case ERROR_MISSING_DIRECTORY : printf("Error: Directory you ran the program from not found!\n");
|
||||
break;
|
||||
case ERROR_INI_CORRUPTED : printf("Error: File gfx2.ini is corrupt!\n");
|
||||
printf("It contains bad values at line %d.\n",Line_number_in_INI_file);
|
||||
printf("You can re-generate it by deleting the file and running GrafX2 again.\n");
|
||||
break;
|
||||
case ERROR_SAVING_INI : printf("Error: Cannot rewrite file gfx2.ini!\n");
|
||||
break;
|
||||
case ERROR_SORRY_SORRY_SORRY : printf("Error: Sorry! Sorry! Sorry! Please forgive me!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
exit(error_code);
|
||||
}
|
||||
}
|
||||
|
||||
enum CMD_PARAMS
|
||||
{
|
||||
CMDPARAM_HELP,
|
||||
CMDPARAM_MODE,
|
||||
CMDPARAM_PIXELRATIO_TALL,
|
||||
CMDPARAM_PIXELRATIO_WIDE,
|
||||
CMDPARAM_PIXELRATIO_DOUBLE,
|
||||
CMDPARAM_PIXELRATIO_TRIPLE,
|
||||
CMDPARAM_PIXELRATIO_QUAD,
|
||||
CMDPARAM_PIXELRATIO_TALL2,
|
||||
CMDPARAM_PIXELRATIO_WIDE2,
|
||||
CMDPARAM_RGB,
|
||||
CMDPARAM_SKIN
|
||||
};
|
||||
|
||||
struct {
|
||||
const char *param;
|
||||
int id;
|
||||
} cmdparams[] = {
|
||||
{"?", CMDPARAM_HELP},
|
||||
{"h", CMDPARAM_HELP},
|
||||
{"H", CMDPARAM_HELP},
|
||||
{"help", CMDPARAM_HELP},
|
||||
{"mode", CMDPARAM_MODE},
|
||||
{"tall", CMDPARAM_PIXELRATIO_TALL},
|
||||
{"wide", CMDPARAM_PIXELRATIO_WIDE},
|
||||
{"double", CMDPARAM_PIXELRATIO_DOUBLE},
|
||||
{"triple", CMDPARAM_PIXELRATIO_TRIPLE},
|
||||
{"quadruple", CMDPARAM_PIXELRATIO_QUAD},
|
||||
{"tall2", CMDPARAM_PIXELRATIO_TALL2},
|
||||
{"wide2", CMDPARAM_PIXELRATIO_WIDE2},
|
||||
{"rgb", CMDPARAM_RGB},
|
||||
{"skin", CMDPARAM_SKIN}
|
||||
};
|
||||
|
||||
#define ARRAY_SIZE(x) (int)(sizeof(x) / sizeof(x[0]))
|
||||
|
||||
// --------------------- Analyse de la ligne de commande ---------------------
|
||||
int Analyze_command_line(int argc, char * argv[], char *main_filename, char *main_directory, char *spare_filename, char *spare_directory)
|
||||
{
|
||||
char *buffer ;
|
||||
int index;
|
||||
int file_in_command_line;
|
||||
|
||||
file_in_command_line = 0;
|
||||
Resolution_in_command_line = 0;
|
||||
|
||||
Current_resolution = Config.Default_resolution;
|
||||
|
||||
for (index = 1; index<argc; index++)
|
||||
{
|
||||
char *s = argv[index];
|
||||
int is_switch = ((strchr(s,'/') == s) || (strchr(s,'-') == s) || (strstr(s,"--") == s));
|
||||
int tmpi;
|
||||
int paramtype = -1;
|
||||
if (is_switch)
|
||||
{
|
||||
int param_matches = 0;
|
||||
int param_match = -1;
|
||||
if (*s == '-')
|
||||
{
|
||||
s++;
|
||||
if (*s == '-')
|
||||
s++;
|
||||
}
|
||||
else
|
||||
s++;
|
||||
|
||||
for (tmpi = 0; tmpi < ARRAY_SIZE(cmdparams); tmpi++)
|
||||
{
|
||||
if (!strcmp(s, cmdparams[tmpi].param))
|
||||
{
|
||||
paramtype = cmdparams[tmpi].id;
|
||||
break;
|
||||
}
|
||||
else if (strstr(cmdparams[tmpi].param, s))
|
||||
{
|
||||
param_matches++;
|
||||
param_match = cmdparams[tmpi].id;
|
||||
}
|
||||
}
|
||||
if (paramtype == -1 && param_matches == 1)
|
||||
paramtype = param_match;
|
||||
|
||||
}
|
||||
switch (paramtype)
|
||||
{
|
||||
case CMDPARAM_HELP:
|
||||
Display_syntax();
|
||||
exit(0);
|
||||
case CMDPARAM_MODE:
|
||||
index++;
|
||||
if (index<argc)
|
||||
{
|
||||
Resolution_in_command_line = 1;
|
||||
Current_resolution = Convert_videomode_arg(argv[index]);
|
||||
if (Current_resolution == -1)
|
||||
{
|
||||
Error(ERROR_COMMAND_LINE);
|
||||
Display_syntax();
|
||||
exit(0);
|
||||
}
|
||||
if ((Video_mode[Current_resolution].State & 0x7F) == 3)
|
||||
{
|
||||
Error(ERROR_FORBIDDEN_MODE);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(ERROR_COMMAND_LINE);
|
||||
Display_syntax();
|
||||
exit(0);
|
||||
}
|
||||
break;
|
||||
case CMDPARAM_PIXELRATIO_TALL:
|
||||
Pixel_ratio = PIXEL_TALL;
|
||||
break;
|
||||
case CMDPARAM_PIXELRATIO_WIDE:
|
||||
Pixel_ratio = PIXEL_WIDE;
|
||||
break;
|
||||
case CMDPARAM_PIXELRATIO_DOUBLE:
|
||||
Pixel_ratio = PIXEL_DOUBLE;
|
||||
break;
|
||||
case CMDPARAM_PIXELRATIO_TRIPLE:
|
||||
Pixel_ratio = PIXEL_TRIPLE;
|
||||
break;
|
||||
case CMDPARAM_PIXELRATIO_QUAD:
|
||||
Pixel_ratio = PIXEL_QUAD;
|
||||
break;
|
||||
case CMDPARAM_PIXELRATIO_TALL2:
|
||||
Pixel_ratio = PIXEL_TALL2;
|
||||
break;
|
||||
case CMDPARAM_PIXELRATIO_WIDE2:
|
||||
Pixel_ratio = PIXEL_WIDE2;
|
||||
break;
|
||||
case CMDPARAM_RGB:
|
||||
// echelle des composants RGB
|
||||
index++;
|
||||
if (index<argc)
|
||||
{
|
||||
int scale;
|
||||
scale = atoi(argv[index]);
|
||||
if (scale < 2 || scale > 256)
|
||||
{
|
||||
Error(ERROR_COMMAND_LINE);
|
||||
Display_syntax();
|
||||
exit(0);
|
||||
}
|
||||
Set_palette_RGB_scale(scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(ERROR_COMMAND_LINE);
|
||||
Display_syntax();
|
||||
exit(0);
|
||||
}
|
||||
break;
|
||||
case CMDPARAM_SKIN:
|
||||
// GUI skin file
|
||||
index++;
|
||||
if (index<argc)
|
||||
{
|
||||
strcpy(Config.Skin_file,argv[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(ERROR_COMMAND_LINE);
|
||||
Display_syntax();
|
||||
exit(0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Si ce n'est pas un paramètre, c'est le nom du fichier à ouvrir
|
||||
if (file_in_command_line > 1)
|
||||
{
|
||||
// Il y a déjà 2 noms de fichiers et on vient d'en trouver un 3ème
|
||||
Error(ERROR_COMMAND_LINE);
|
||||
Display_syntax();
|
||||
exit(0);
|
||||
}
|
||||
else if (File_exists(argv[index]))
|
||||
{
|
||||
file_in_command_line ++;
|
||||
buffer = Realpath(argv[index], NULL);
|
||||
|
||||
if (file_in_command_line == 1)
|
||||
{
|
||||
// Separate path from filename
|
||||
Extract_path(main_directory, buffer);
|
||||
Extract_filename(main_filename, buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Separate path from filename
|
||||
Extract_path(spare_directory, buffer);
|
||||
Extract_filename(spare_filename, buffer);
|
||||
}
|
||||
free(buffer);
|
||||
buffer = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(ERROR_COMMAND_LINE);
|
||||
Display_syntax();
|
||||
exit(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return file_in_command_line;
|
||||
}
|
||||
|
||||
// ------------------------ Initialiser le programme -------------------------
|
||||
// Returns 0 on fail
|
||||
int Init_program(int argc,char * argv[])
|
||||
{
|
||||
int temp;
|
||||
int starting_videomode;
|
||||
static char program_directory[MAX_PATH_CHARACTERS];
|
||||
T_Gui_skin *gfx;
|
||||
int file_in_command_line;
|
||||
static char main_filename [MAX_PATH_CHARACTERS];
|
||||
static char main_directory[MAX_PATH_CHARACTERS];
|
||||
static char spare_filename [MAX_PATH_CHARACTERS];
|
||||
static char spare_directory[MAX_PATH_CHARACTERS];
|
||||
|
||||
|
||||
|
||||
// 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
|
||||
// invalide lors des appels aux multiples fonctions manipulées à
|
||||
// l'initialisation du programme.
|
||||
Main_backups=(T_List_of_pages *)malloc(sizeof(T_List_of_pages));
|
||||
Spare_backups=(T_List_of_pages *)malloc(sizeof(T_List_of_pages));
|
||||
Init_list_of_pages(Main_backups);
|
||||
Init_list_of_pages(Spare_backups);
|
||||
|
||||
// Determine the executable directory
|
||||
Set_program_directory(argv[0],program_directory);
|
||||
// Choose directory for data (read only)
|
||||
Set_data_directory(program_directory,Data_directory);
|
||||
// Choose directory for settings (read/write)
|
||||
Set_config_directory(program_directory,Config_directory);
|
||||
|
||||
// On détermine le répertoire courant:
|
||||
getcwd(Main_current_directory,256);
|
||||
|
||||
// On en profite pour le mémoriser dans le répertoire principal:
|
||||
strcpy(Initial_directory,Main_current_directory);
|
||||
|
||||
// On initialise les données sur le nom de fichier de l'image de brouillon:
|
||||
strcpy(Spare_current_directory,Main_current_directory);
|
||||
|
||||
Main_fileformat=DEFAULT_FILEFORMAT;
|
||||
Spare_fileformat =Main_fileformat;
|
||||
|
||||
strcpy(Brush_current_directory,Main_current_directory);
|
||||
strcpy(Brush_file_directory,Main_current_directory);
|
||||
strcpy(Brush_filename ,"NO_NAME.GIF");
|
||||
Brush_fileformat =Main_fileformat;
|
||||
|
||||
// On initialise ce qu'il faut pour que les fileselects ne plantent pas:
|
||||
|
||||
Main_fileselector_position=0; // Au début, le fileselect est en haut de la liste des fichiers
|
||||
Main_fileselector_offset=0; // Au début, le fileselect est en haut de la liste des fichiers
|
||||
Main_format=FORMAT_ALL_IMAGES;
|
||||
Main_current_layer=0;
|
||||
Main_layers_visible=0xFFFFFFFF;
|
||||
Spare_current_layer=0;
|
||||
Spare_layers_visible=0xFFFFFFFF;
|
||||
|
||||
Spare_fileselector_position=0;
|
||||
Spare_fileselector_offset=0;
|
||||
Spare_format=FORMAT_ALL_IMAGES;
|
||||
Brush_fileselector_position=0;
|
||||
Brush_fileselector_offset=0;
|
||||
Brush_format=FORMAT_ALL_IMAGES;
|
||||
|
||||
// On initialise les commentaires des images à des chaînes vides
|
||||
Main_comment[0]='\0';
|
||||
Brush_comment[0]='\0';
|
||||
|
||||
// On initialise d'ot' trucs
|
||||
Main_offset_X=0;
|
||||
Main_offset_Y=0;
|
||||
Old_main_offset_X=0;
|
||||
Old_main_offset_Y=0;
|
||||
Main_separator_position=0;
|
||||
Main_X_zoom=0;
|
||||
Main_separator_proportion=INITIAL_SEPARATOR_PROPORTION;
|
||||
Main_magnifier_mode=0;
|
||||
Main_magnifier_factor=DEFAULT_ZOOM_FACTOR;
|
||||
Main_magnifier_height=0;
|
||||
Main_magnifier_width=0;
|
||||
Main_magnifier_offset_X=0;
|
||||
Main_magnifier_offset_Y=0;
|
||||
Spare_offset_X=0;
|
||||
Spare_offset_Y=0;
|
||||
Old_spare_offset_X=0;
|
||||
Old_spare_offset_Y=0;
|
||||
Spare_separator_position=0;
|
||||
Spare_X_zoom=0;
|
||||
Spare_separator_proportion=INITIAL_SEPARATOR_PROPORTION;
|
||||
Spare_magnifier_mode=0;
|
||||
Spare_magnifier_factor=DEFAULT_ZOOM_FACTOR;
|
||||
Spare_magnifier_height=0;
|
||||
Spare_magnifier_width=0;
|
||||
Spare_magnifier_offset_X=0;
|
||||
Spare_magnifier_offset_Y=0;
|
||||
Keyboard_click_allowed = 0;
|
||||
|
||||
Main_safety_backup_prefix = 'a';
|
||||
Spare_safety_backup_prefix = 'b';
|
||||
Main_time_of_safety_backup = 0;
|
||||
Spare_time_of_safety_backup = 0;
|
||||
|
||||
|
||||
// SDL
|
||||
if(SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0)
|
||||
{
|
||||
// The program can't continue without that anyway
|
||||
printf("Couldn't initialize SDL.\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
Joystick = SDL_JoystickOpen(0);
|
||||
SDL_EnableKeyRepeat(250, 32);
|
||||
SDL_EnableUNICODE(SDL_ENABLE);
|
||||
SDL_WM_SetCaption("GrafX2","GrafX2");
|
||||
|
||||
{
|
||||
// Routine pour définir l'icone.
|
||||
char icon_path[MAX_PATH_CHARACTERS];
|
||||
SDL_Surface * icon;
|
||||
sprintf(icon_path, "%s%s", Data_directory, "gfx2.gif");
|
||||
icon = IMG_Load(icon_path);
|
||||
if (icon && icon->w == 32 && icon->h == 32)
|
||||
{
|
||||
Uint32 pink;
|
||||
pink = SDL_MapRGB(icon->format, 255, 0, 255);
|
||||
|
||||
if (icon->format->BitsPerPixel == 8)
|
||||
{
|
||||
SDL_SetColorKey(icon, SDL_SRCCOLORKEY, pink);
|
||||
SDL_WM_SetIcon(icon,NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte *icon_mask;
|
||||
int x,y;
|
||||
|
||||
icon_mask=malloc(128);
|
||||
memset(icon_mask,0,128);
|
||||
for (y=0;y<32;y++)
|
||||
for (x=0;x<32;x++)
|
||||
if (Get_SDL_pixel_hicolor(icon, x, y) != pink)
|
||||
icon_mask[(y*32+x)/8] |=0x80>>(x&7);
|
||||
SDL_WM_SetIcon(icon,icon_mask);
|
||||
free(icon_mask);
|
||||
icon_mask = NULL;
|
||||
}
|
||||
|
||||
SDL_FreeSurface(icon);
|
||||
}
|
||||
}
|
||||
|
||||
// Texte
|
||||
Init_text();
|
||||
|
||||
// On initialise tous les modes vidéo
|
||||
Set_all_video_modes();
|
||||
Pixel_ratio=PIXEL_SIMPLE;
|
||||
// On initialise les données sur l'état du programme:
|
||||
// Donnée sur la sortie du programme:
|
||||
Quit_is_required=0;
|
||||
Quitting=0;
|
||||
// Données sur l'état du menu:
|
||||
Menu_is_visible=1;
|
||||
// Données sur les couleurs et la palette:
|
||||
First_color_in_palette=0;
|
||||
// Données sur le curseur:
|
||||
Cursor_shape=CURSOR_SHAPE_TARGET;
|
||||
Cursor_hidden=0;
|
||||
// Données sur le pinceau:
|
||||
Paintbrush_X=0;
|
||||
Paintbrush_Y=0;
|
||||
Paintbrush_shape=PAINTBRUSH_SHAPE_ROUND;
|
||||
Paintbrush_hidden=0;
|
||||
|
||||
// On initialise tout ce qui concerne les opérations et les effets
|
||||
Operation_stack_size=0;
|
||||
Selected_freehand_mode=OPERATION_CONTINUOUS_DRAW;
|
||||
Selected_line_mode =OPERATION_LINE;
|
||||
Selected_curve_mode =OPERATION_3_POINTS_CURVE;
|
||||
Effect_function=No_effect;
|
||||
// On initialise les infos de la loupe:
|
||||
Main_magnifier_mode=0;
|
||||
Main_magnifier_factor=DEFAULT_ZOOM_FACTOR;
|
||||
Main_separator_proportion=INITIAL_SEPARATOR_PROPORTION;
|
||||
Spare_separator_proportion=INITIAL_SEPARATOR_PROPORTION;
|
||||
// On initialise les infos du mode smear:
|
||||
Smear_mode=0;
|
||||
Smear_brush_width=PAINTBRUSH_WIDTH;
|
||||
Smear_brush_height=PAINTBRUSH_HEIGHT;
|
||||
// On initialise les infos du mode smooth:
|
||||
Smooth_mode=0;
|
||||
// On initialise les infos du mode shade:
|
||||
Shade_mode=0; // Les autres infos du Shade sont chargées avec la config
|
||||
Quick_shade_mode=0; // idem
|
||||
// On initialise les infos sur les dégradés:
|
||||
Gradient_pixel =Display_pixel; // Les autres infos sont chargées avec la config
|
||||
// On initialise les infos de la grille:
|
||||
Snap_mode=0;
|
||||
Snap_width=8;
|
||||
Snap_height=8;
|
||||
Snap_offset_X=0;
|
||||
Snap_offset_Y=0;
|
||||
// On initialise les infos du mode Colorize:
|
||||
Colorize_mode=0; // Mode colorize inactif par défaut
|
||||
Colorize_opacity=50; // Une interpolation de 50% par défaut
|
||||
Colorize_current_mode=0; // Par défaut, la méthode par interpolation
|
||||
Compute_colorize_table();
|
||||
// On initialise les infos du mode Tiling:
|
||||
Tiling_mode=0; // Pas besoin d'initialiser les décalages car ça se fait
|
||||
// en prenant une brosse (toujours mis à 0).
|
||||
// On initialise les infos du mode Mask:
|
||||
Mask_mode=0;
|
||||
|
||||
// Infos du Spray
|
||||
Airbrush_mode=1; // Mode Mono
|
||||
Airbrush_size=31;
|
||||
Airbrush_delay=1;
|
||||
Airbrush_mono_flow=10;
|
||||
memset(Airbrush_multi_flow,0,256);
|
||||
srand(time(NULL)); // On randomize un peu tout ça...
|
||||
|
||||
// Initialisation des boutons
|
||||
Init_buttons();
|
||||
// Initialisation des opérations
|
||||
Init_operations();
|
||||
|
||||
// Initialize the brush container
|
||||
Init_brush_container();
|
||||
|
||||
Windows_open=0;
|
||||
|
||||
// Charger la configuration des touches
|
||||
Set_config_defaults();
|
||||
|
||||
switch(Load_CFG(1))
|
||||
{
|
||||
case ERROR_CFG_MISSING:
|
||||
// Pas un problème, on a les valeurs par défaut.
|
||||
break;
|
||||
case ERROR_CFG_CORRUPTED:
|
||||
DEBUG("Corrupted CFG file.",0);
|
||||
break;
|
||||
case ERROR_CFG_OLD:
|
||||
DEBUG("Unknown CFG file version, not loaded.",0);
|
||||
break;
|
||||
}
|
||||
// Charger la configuration du .INI
|
||||
temp=Load_INI(&Config);
|
||||
if (temp)
|
||||
Error(temp);
|
||||
|
||||
Compute_menu_offsets();
|
||||
|
||||
file_in_command_line=Analyze_command_line(argc, argv, main_filename, main_directory, spare_filename, spare_directory);
|
||||
|
||||
Current_help_section=0;
|
||||
Help_position=0;
|
||||
|
||||
// Load sprites, palette etc.
|
||||
gfx = Load_graphics(Config.Skin_file);
|
||||
if (gfx == NULL)
|
||||
{
|
||||
gfx = Load_graphics("skin_modern.png");
|
||||
if (gfx == NULL)
|
||||
{
|
||||
printf("%s", Gui_loading_error_message);
|
||||
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)
|
||||
Sieve_mode=0;
|
||||
Copy_preset_sieve(0);
|
||||
|
||||
// Font
|
||||
if (!(Menu_font=Load_font(Config.Font_file)))
|
||||
if (!(Menu_font=Load_font("font_Classic.png")))
|
||||
{
|
||||
printf("Unable to open the default font file: %s\n", "font_Classic.png");
|
||||
Error(ERROR_GUI_MISSING);
|
||||
}
|
||||
|
||||
memcpy(Main_palette, Gfx->Default_palette, sizeof(T_Palette));
|
||||
|
||||
// Allocation de mémoire pour la brosse
|
||||
if (!(Brush =(byte *)malloc( 1* 1))) Error(ERROR_MEMORY);
|
||||
if (!(Smear_brush =(byte *)malloc(MAX_PAINTBRUSH_SIZE*MAX_PAINTBRUSH_SIZE))) Error(ERROR_MEMORY);
|
||||
|
||||
// Pinceau
|
||||
if (!(Paintbrush_sprite=(byte *)malloc(MAX_PAINTBRUSH_SIZE*MAX_PAINTBRUSH_SIZE))) Error(ERROR_MEMORY);
|
||||
*Paintbrush_sprite=1;
|
||||
Paintbrush_width=1;
|
||||
Paintbrush_height=1;
|
||||
|
||||
starting_videomode=Current_resolution;
|
||||
Horizontal_line_buffer=NULL;
|
||||
Screen_width=Screen_height=Current_resolution=0;
|
||||
|
||||
Init_mode_video(
|
||||
Video_mode[starting_videomode].Width,
|
||||
Video_mode[starting_videomode].Height,
|
||||
Video_mode[starting_videomode].Fullscreen,
|
||||
Pixel_ratio);
|
||||
|
||||
// Windows only: move back the window to its original position.
|
||||
#if defined(__WIN32__)
|
||||
if (!Video_mode[starting_videomode].Fullscreen)
|
||||
{
|
||||
if (Config.Window_pos_x != 9999 && Config.Window_pos_y != 9999)
|
||||
{
|
||||
//RECT r;
|
||||
static SDL_SysWMinfo pInfo;
|
||||
SDL_VERSION(&pInfo.version);
|
||||
SDL_GetWMInfo(&pInfo);
|
||||
//GetWindowRect(pInfo.window, &r);
|
||||
SetWindowPos(pInfo.window, 0, Config.Window_pos_x, Config.Window_pos_y, 0, 0, SWP_NOSIZE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Main_image_width=Screen_width/Pixel_width;
|
||||
Main_image_height=Screen_height/Pixel_height;
|
||||
Spare_image_width=Screen_width/Pixel_width;
|
||||
Spare_image_height=Screen_height/Pixel_height;
|
||||
|
||||
// Allocation de mémoire pour les différents écrans virtuels (et brosse)
|
||||
if (Init_all_backup_lists(Screen_width,Screen_height)==0)
|
||||
Error(ERROR_MEMORY);
|
||||
|
||||
// Nettoyage de l'écran virtuel (les autres recevront celui-ci par copie)
|
||||
memset(Main_screen,0,Main_image_width*Main_image_height);
|
||||
|
||||
// Initialisation de diverses variables par calcul:
|
||||
Compute_magnifier_data();
|
||||
Compute_limits();
|
||||
Compute_paintbrush_coordinates();
|
||||
|
||||
// On affiche le menu:
|
||||
Display_menu();
|
||||
Display_paintbrush_in_menu();
|
||||
Display_sprite_in_menu(BUTTON_PAL_LEFT,18+(Config.Palette_vertical!=0));
|
||||
|
||||
// On affiche le curseur pour débutter correctement l'état du programme:
|
||||
Display_cursor();
|
||||
|
||||
Spare_image_is_modified=0;
|
||||
Main_image_is_modified=0;
|
||||
|
||||
// Gestionnaire de signaux, quand il ne reste plus aucun espoir
|
||||
Init_sighandler();
|
||||
|
||||
// Le programme débute en mode de dessin à la main
|
||||
Select_button(BUTTON_DRAW,LEFT_SIDE);
|
||||
|
||||
// On initialise la brosse initiale à 1 pixel blanc:
|
||||
Brush_width=1;
|
||||
Brush_height=1;
|
||||
Capture_brush(0,0,0,0,0);
|
||||
*Brush=MC_White;
|
||||
|
||||
// Test de recuperation de fichiers sauvés
|
||||
switch (Check_recovery())
|
||||
{
|
||||
T_IO_Context context;
|
||||
|
||||
default:
|
||||
// Some files were loaded from last crash-exit.
|
||||
// Do not load files from command-line, nor show splash screen.
|
||||
Compute_optimal_menu_colors(Main_palette);
|
||||
Display_all_screen();
|
||||
Display_menu();
|
||||
Display_cursor();
|
||||
Verbose_message("Images recovered",
|
||||
"Grafx2 has recovered images from\n"
|
||||
"last session, before a crash or\n"
|
||||
"shutdown. Browse the history using\n"
|
||||
"the Undo/Redo button, and when\n"
|
||||
"you find a state that you want to\n"
|
||||
"save, use the 'Save as' button to\n"
|
||||
"save the image.\n"
|
||||
"Some backups can be present in\n"
|
||||
"the spare page too.\n");
|
||||
break;
|
||||
|
||||
case -1: // Unable to write lock file
|
||||
Verbose_message("Warning",
|
||||
"Safety backups (every minute) are\n"
|
||||
"disabled because Grafx2 is running\n"
|
||||
"from a read-only device, or other\n"
|
||||
"instances are running.");
|
||||
break;
|
||||
|
||||
case 0:
|
||||
|
||||
switch (file_in_command_line)
|
||||
{
|
||||
case 0:
|
||||
if (Config.Opening_message)
|
||||
Button_Message_initial();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// Load this file
|
||||
Init_context_layered_image(&context, spare_filename, spare_directory);
|
||||
Load_image(&context);
|
||||
Destroy_context(&context);
|
||||
Redraw_layered_image();
|
||||
End_of_modification();
|
||||
|
||||
Button_Page();
|
||||
// no break ! proceed with the other file now
|
||||
case 1:
|
||||
Init_context_layered_image(&context, main_filename, main_directory);
|
||||
Load_image(&context);
|
||||
Destroy_context(&context);
|
||||
Redraw_layered_image();
|
||||
End_of_modification();
|
||||
|
||||
Hide_cursor();
|
||||
Compute_optimal_menu_colors(Main_palette);
|
||||
Display_all_screen();
|
||||
Display_menu();
|
||||
Display_cursor();
|
||||
Resolution_in_command_line = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
// ------------------------- Fermeture du programme --------------------------
|
||||
void Program_shutdown(void)
|
||||
{
|
||||
int return_code;
|
||||
|
||||
// Windows only: Recover the window position.
|
||||
#if defined(__WIN32__)
|
||||
{
|
||||
RECT r;
|
||||
static SDL_SysWMinfo pInfo;
|
||||
|
||||
SDL_GetWMInfo(&pInfo);
|
||||
GetWindowRect(pInfo.window, &r);
|
||||
|
||||
Config.Window_pos_x = r.left;
|
||||
Config.Window_pos_y = r.top;
|
||||
}
|
||||
#else
|
||||
// All other targets: irrelevant dimensions.
|
||||
// Do not attempt to force them back on next program run.
|
||||
Config.Window_pos_x = 9999;
|
||||
Config.Window_pos_y = 9999;
|
||||
#endif
|
||||
|
||||
// Remove the safety backups, this is normal exit
|
||||
Delete_safety_backups();
|
||||
|
||||
// On libère le buffer de gestion de lignes
|
||||
free(Horizontal_line_buffer);
|
||||
Horizontal_line_buffer = NULL;
|
||||
|
||||
// On libère le pinceau spécial
|
||||
free(Paintbrush_sprite);
|
||||
Paintbrush_sprite = NULL;
|
||||
|
||||
// On libère les différents écrans virtuels et brosse:
|
||||
free(Brush);
|
||||
Brush = NULL;
|
||||
Set_number_of_backups(0);
|
||||
|
||||
// Free the skin (Gui graphics) data
|
||||
free(Gfx);
|
||||
Gfx=NULL;
|
||||
|
||||
// On prend bien soin de passer dans le répertoire initial:
|
||||
if (chdir(Initial_directory)!=-1)
|
||||
{
|
||||
// On sauvegarde les données dans le .CFG et dans le .INI
|
||||
if (Config.Auto_save)
|
||||
{
|
||||
return_code=Save_CFG();
|
||||
if (return_code)
|
||||
Error(return_code);
|
||||
return_code=Save_INI(&Config);
|
||||
if (return_code)
|
||||
Error(return_code);
|
||||
}
|
||||
}
|
||||
else
|
||||
Error(ERROR_MISSING_DIRECTORY);
|
||||
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
|
||||
// -------------------------- Procédure principale ---------------------------
|
||||
int main(int argc,char * argv[])
|
||||
{
|
||||
|
||||
if(!Init_program(argc,argv))
|
||||
{
|
||||
Program_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Main_handler();
|
||||
|
||||
Program_shutdown();
|
||||
return 0;
|
||||
}
|
||||
856
src/misc.c
Normal file
856
src/misc.c
Normal file
@@ -0,0 +1,856 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
#include <SDL.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "struct.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "global.h"
|
||||
#include "errors.h"
|
||||
#include "buttons.h"
|
||||
#include "engine.h"
|
||||
#include "misc.h"
|
||||
#include "keyboard.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "windows.h"
|
||||
#include "palette.h"
|
||||
#include "input.h"
|
||||
#include "graph.h"
|
||||
#include "pages.h"
|
||||
|
||||
///Count used palette indexes in the whole picture
|
||||
///Return the total number of different colors
|
||||
///Fill in "usage" with the count for each color
|
||||
word Count_used_colors(dword* usage)
|
||||
{
|
||||
int nb_pixels = 0;
|
||||
Uint8* current_pixel;
|
||||
Uint8 color;
|
||||
word nb_colors = 0;
|
||||
int i;
|
||||
int layer;
|
||||
|
||||
for (i = 0; i < 256; i++) usage[i]=0;
|
||||
|
||||
// Compute total number of pixels in the picture
|
||||
nb_pixels = Main_image_height * Main_image_width;
|
||||
|
||||
// For each layer
|
||||
for (layer = 0; layer < Main_backups->Pages->Nb_layers; layer++)
|
||||
{
|
||||
current_pixel = Main_backups->Pages->Image[layer];
|
||||
// For each pixel in picture
|
||||
for (i = 0; i < nb_pixels; i++)
|
||||
{
|
||||
color=*current_pixel; // get color in picture for this pixel
|
||||
|
||||
usage[color]++; // add it to the counter
|
||||
|
||||
// go to next pixel
|
||||
current_pixel++;
|
||||
}
|
||||
}
|
||||
|
||||
// count the total number of unique used colors
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
if (usage[i]!=0)
|
||||
nb_colors++;
|
||||
}
|
||||
|
||||
return nb_colors;
|
||||
}
|
||||
|
||||
/// Same as ::Count_used_colors, but use a block screen memory instead of
|
||||
/// picture data. Used to count colors in the loading screen.
|
||||
word Count_used_colors_screen_area(dword* usage, word start_x, word start_y,
|
||||
word width, word height)
|
||||
{
|
||||
Uint8 color;
|
||||
word x, y;
|
||||
word nb_colors = 0;
|
||||
int i;
|
||||
|
||||
// Init usage table
|
||||
for (i = 0; i < 256; i++) usage[i]=0;
|
||||
|
||||
// For each pixel in screen area
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
// Get color in screen memory
|
||||
color=*(Screen_pixels+((start_x + x)+(start_y + y) * Screen_width
|
||||
* Pixel_height) * Pixel_width);
|
||||
usage[color]++; //Un point de plus pour cette couleur
|
||||
}
|
||||
}
|
||||
//On va maintenant compter dans la table les couleurs utilisées:
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
if (usage[i]!=0)
|
||||
nb_colors++;
|
||||
}
|
||||
return nb_colors;
|
||||
}
|
||||
|
||||
|
||||
/// Same as ::Count_used_colors, but for a given rectangle in the picture only.
|
||||
/// Used bu the C64 block constraint checker.
|
||||
word Count_used_colors_area(dword* usage, word start_x, word start_y,
|
||||
word width, word height)
|
||||
{
|
||||
Uint8 color;
|
||||
word x, y;
|
||||
word nb_colors = 0;
|
||||
int i;
|
||||
|
||||
// Init usage table
|
||||
for (i = 0; i < 256; i++) usage[i]=0;
|
||||
|
||||
// On parcourt l'écran courant pour compter les utilisations des couleurs
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
// Get color from picture
|
||||
color=*(Main_screen+((start_x + x)+(start_y + y)*Main_image_width));
|
||||
usage[color]++; //Un point de plus pour cette couleur
|
||||
}
|
||||
}
|
||||
|
||||
//On va maintenant compter dans la table les couleurs utilisées:
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
if (usage[i]!=0)
|
||||
nb_colors++;
|
||||
}
|
||||
return nb_colors;
|
||||
}
|
||||
|
||||
|
||||
void Set_palette(T_Palette palette)
|
||||
{
|
||||
register int i;
|
||||
SDL_Color PaletteSDL[256];
|
||||
for(i=0;i<256;i++)
|
||||
{
|
||||
PaletteSDL[i].r=(palette[i].R=Round_palette_component(palette[i].R));
|
||||
PaletteSDL[i].g=(palette[i].G=Round_palette_component(palette[i].G));
|
||||
PaletteSDL[i].b=(palette[i].B=Round_palette_component(palette[i].B));
|
||||
}
|
||||
SDL_SetPalette(Screen_SDL, SDL_PHYSPAL | SDL_LOGPAL, PaletteSDL,0,256);
|
||||
}
|
||||
|
||||
void Set_color(byte color, byte red, byte green, byte blue)
|
||||
{
|
||||
SDL_Color comp;
|
||||
comp.r=red;
|
||||
comp.g=green;
|
||||
comp.b=blue;
|
||||
SDL_SetPalette(Screen_SDL, SDL_PHYSPAL | SDL_LOGPAL, &comp, color, 1);
|
||||
}
|
||||
|
||||
void Wait_end_of_click(void)
|
||||
{
|
||||
// On désactive tous les raccourcis clavier
|
||||
|
||||
while(Mouse_K) if(!Get_input()) SDL_Delay(20);
|
||||
}
|
||||
|
||||
void Clear_current_image_with_stencil(byte color, byte * stencil)
|
||||
//Effacer l'image courante avec une certaine couleur en mode Stencil
|
||||
{
|
||||
int nb_pixels=0; //ECX
|
||||
//al=color
|
||||
//edi=Screen_pixels
|
||||
byte* pixel=Main_backups->Pages->Image[Main_current_layer];
|
||||
int i;
|
||||
|
||||
nb_pixels=Main_image_height*Main_image_width;
|
||||
|
||||
for(i=0;i<nb_pixels;i++)
|
||||
{
|
||||
if (stencil[*pixel]==0)
|
||||
*pixel=color;
|
||||
pixel++;
|
||||
}
|
||||
}
|
||||
|
||||
void Clear_current_image(byte color)
|
||||
// Effacer l'image courante avec une certaine couleur
|
||||
{
|
||||
memset(
|
||||
Main_backups->Pages->Image[Main_current_layer],
|
||||
color ,
|
||||
Main_image_width * Main_image_height
|
||||
);
|
||||
}
|
||||
|
||||
void Init_chrono(dword delay)
|
||||
// Démarrer le chrono
|
||||
{
|
||||
Timer_delay = delay;
|
||||
Timer_start = SDL_GetTicks()/55;
|
||||
return;
|
||||
}
|
||||
|
||||
void Pixel_in_brush (word x, word y, byte color)
|
||||
{
|
||||
*(Brush + y * Brush_width + x)=color;
|
||||
}
|
||||
|
||||
byte Read_pixel_from_brush (word x, word y)
|
||||
{
|
||||
return *(Brush + y * Brush_width + x);
|
||||
}
|
||||
|
||||
void Replace_a_color(byte old_color, byte new_color)
|
||||
{
|
||||
word x;
|
||||
word y;
|
||||
|
||||
// Update all pixels
|
||||
for (y=0; y<Main_image_height; y++)
|
||||
for (x=0; x<Main_image_width; x++)
|
||||
if (Read_pixel_from_current_layer(x,y) == old_color)
|
||||
Pixel_in_current_screen(x,y,new_color,0);
|
||||
Update_rect(0,0,0,0); // On peut TOUT a jour
|
||||
// C'est pas un problème car il n'y a pas de preview
|
||||
}
|
||||
// FIXME: move to graph.c, it's the only caller
|
||||
|
||||
void Ellipse_compute_limites(short horizontal_radius,short vertical_radius)
|
||||
{
|
||||
Ellipse_horizontal_radius_squared =
|
||||
(long)horizontal_radius * horizontal_radius;
|
||||
Ellipse_vertical_radius_squared =
|
||||
(long)vertical_radius * vertical_radius;
|
||||
Ellipse_limit = (qword)Ellipse_horizontal_radius_squared * Ellipse_vertical_radius_squared;
|
||||
}
|
||||
|
||||
// FIXME: move to graph.c, it's the only caller
|
||||
byte Pixel_in_ellipse(void)
|
||||
{
|
||||
qword ediesi = (qword)Ellipse_cursor_X * Ellipse_cursor_X * Ellipse_vertical_radius_squared +
|
||||
(qword)Ellipse_cursor_Y * Ellipse_cursor_Y * Ellipse_horizontal_radius_squared;
|
||||
if((ediesi) <= Ellipse_limit) return 255;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// FIXME: move to graph.c, it's the only caller
|
||||
byte Pixel_in_circle(void)
|
||||
{
|
||||
if(Circle_cursor_X * Circle_cursor_X +
|
||||
Circle_cursor_Y * Circle_cursor_Y <= Circle_limit)
|
||||
return 255;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Copy_part_of_image_to_another(byte * source,word source_x,word source_y,word width,word height,word source_width,byte * dest,word dest_x,word dest_y,word destination_width)
|
||||
{
|
||||
// ESI = adresse de la source en (S_Pox_X,source_y)
|
||||
byte* esi = source + source_y * source_width + source_x;
|
||||
|
||||
// EDI = adresse de la destination (dest_x,dest_y)
|
||||
byte* edi = dest + dest_y * destination_width + dest_x;
|
||||
|
||||
int line;
|
||||
|
||||
// Pour chaque ligne
|
||||
for (line=0;line < height; line++)
|
||||
{
|
||||
memcpy(edi,esi,width);
|
||||
|
||||
// Passe à la ligne suivante
|
||||
esi+=source_width;
|
||||
edi+=destination_width;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
byte Read_pixel_from_spare_screen(word x,word y)
|
||||
{
|
||||
// return *(Spare_screen+y*Spare_image_width+x);
|
||||
|
||||
// Clipping is required as this can be called with coordinates from main image
|
||||
// (can be a bigger or smaller image)
|
||||
if (x>=Spare_image_width || y>=Spare_image_height)
|
||||
return Spare_backups->Pages->Transparent_color;
|
||||
#ifndef NOLAYERS
|
||||
return *(Spare_visible_image.Image + y*Spare_image_width + x);
|
||||
#else
|
||||
return *(Spare_backups->Pages->Image[Spare_current_layer] + y*Spare_image_width + x);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void Rotate_90_deg_lowlevel(byte * source, byte * dest, short width, short height)
|
||||
{
|
||||
word x,y;
|
||||
|
||||
for(y=0;y<height;y++)
|
||||
{
|
||||
for(x=0;x<width;x++)
|
||||
{
|
||||
*(dest+height*(width-1-x)+y)=*source;
|
||||
source++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Rotate_270_deg_lowlevel(byte * source, byte * dest, short width, short height)
|
||||
{
|
||||
word x,y;
|
||||
|
||||
for(y=0;y<height;y++)
|
||||
{
|
||||
for(x=0;x<width;x++)
|
||||
{
|
||||
*(dest+(height-1-y)+x*height)=*source;
|
||||
source++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Replace une couleur par une autre dans un buffer
|
||||
|
||||
void Remap_general_lowlevel(byte * conversion_table,byte * buffer,short width,short height,short buffer_width)
|
||||
{
|
||||
int dx,cx;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(dx=height;dx>0;dx--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(cx=width;cx>0;cx--)
|
||||
{
|
||||
*buffer = conversion_table[*buffer];
|
||||
buffer++;
|
||||
}
|
||||
buffer += buffer_width-width;
|
||||
}
|
||||
}
|
||||
|
||||
void Copy_image_to_brush(short start_x,short start_y,short Brush_width,short Brush_height,word image_width)
|
||||
{
|
||||
byte* src=start_y*image_width+start_x+Main_backups->Pages->Image[Main_current_layer]; //Adr départ image (ESI)
|
||||
byte* dest=Brush; //Adr dest brosse (EDI)
|
||||
int dx;
|
||||
|
||||
for (dx=Brush_height;dx!=0;dx--)
|
||||
//Pour chaque ligne
|
||||
{
|
||||
|
||||
// On fait une copie de la ligne
|
||||
memcpy(dest,src,Brush_width);
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width;
|
||||
dest+=Brush_width;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
byte Read_pixel_from_feedback_screen (word x,word y)
|
||||
{
|
||||
return *(FX_feedback_screen+y*Main_image_width+x);
|
||||
}
|
||||
|
||||
dword Round_div(dword numerator,dword divisor)
|
||||
{
|
||||
return numerator/divisor;
|
||||
}
|
||||
|
||||
byte Effect_sieve(word x,word y)
|
||||
{
|
||||
return Sieve[x % Sieve_width][y % Sieve_height];
|
||||
}
|
||||
|
||||
void Replace_colors_within_limits(byte * replace_table)
|
||||
{
|
||||
int y;
|
||||
int x;
|
||||
byte* pixel;
|
||||
|
||||
// Pour chaque ligne :
|
||||
for(y = Limit_top;y <= Limit_bottom; y++)
|
||||
{
|
||||
// Pour chaque pixel sur la ligne :
|
||||
for (x = Limit_left;x <= Limit_right;x ++)
|
||||
{
|
||||
pixel = Main_backups->Pages->Image[Main_current_layer]+y*Main_image_width+x;
|
||||
*pixel = replace_table[*pixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
byte Read_pixel_from_backup_screen (word x,word y)
|
||||
{
|
||||
return *(Screen_backup + x + Main_image_width * y);
|
||||
}
|
||||
|
||||
void Palette_256_to_64(T_Palette palette)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<256;i++)
|
||||
{
|
||||
palette[i].R = palette[i].R >> 2;
|
||||
palette[i].G = palette[i].G >> 2;
|
||||
palette[i].B = palette[i].B >> 2;
|
||||
}
|
||||
}
|
||||
|
||||
void Palette_64_to_256(T_Palette palette)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<256;i++)
|
||||
{
|
||||
palette[i].R = (palette[i].R << 2)|(palette[i].R >> 4);
|
||||
palette[i].G = (palette[i].G << 2)|(palette[i].G >> 4);
|
||||
palette[i].B = (palette[i].B << 2)|(palette[i].B >> 4);
|
||||
}
|
||||
}
|
||||
|
||||
byte Effect_interpolated_colorize (word x,word y,byte color)
|
||||
{
|
||||
// factor_a = 256*(100-Colorize_opacity)/100
|
||||
// factor_b = 256*( Colorize_opacity)/100
|
||||
//
|
||||
// (Couleur_dessous*factor_a+color*facteur_B)/256
|
||||
//
|
||||
|
||||
// On place dans ESI 3*Couleur_dessous ( = position de cette couleur dans la
|
||||
// palette des teintes) et dans EDI, 3*color.
|
||||
byte color_under = Read_pixel_from_feedback_screen(x,y);
|
||||
byte blue_under=Main_palette[color_under].B;
|
||||
byte blue=Main_palette[color].B;
|
||||
byte green_under=Main_palette[color_under].G;
|
||||
byte green=Main_palette[color].G;
|
||||
byte red_under=Main_palette[color_under].R;
|
||||
byte red=Main_palette[color].R;
|
||||
|
||||
// On récupère les 3 composantes RVB
|
||||
|
||||
// blue
|
||||
blue = (Factors_inv_table[blue]
|
||||
+ Factors_table[blue_under]) / 256;
|
||||
green = (Factors_inv_table[green]
|
||||
+ Factors_table[green_under]) / 256;
|
||||
red = (Factors_inv_table[red]
|
||||
+ Factors_table[red_under]) / 256;
|
||||
return Best_color(red,green,blue);
|
||||
|
||||
}
|
||||
|
||||
byte Effect_additive_colorize (word x,word y,byte color)
|
||||
{
|
||||
byte color_under = Read_pixel_from_feedback_screen(x,y);
|
||||
byte blue_under=Main_palette[color_under].B;
|
||||
byte green_under=Main_palette[color_under].G;
|
||||
byte red_under=Main_palette[color_under].R;
|
||||
byte blue=Main_palette[color].B;
|
||||
byte green=Main_palette[color].G;
|
||||
byte red=Main_palette[color].R;
|
||||
|
||||
return Best_color(
|
||||
red>red_under?red:red_under,
|
||||
green>green_under?green:green_under,
|
||||
blue>blue_under?blue:blue_under);
|
||||
}
|
||||
|
||||
byte Effect_substractive_colorize(word x,word y,byte color)
|
||||
{
|
||||
byte color_under = Read_pixel_from_feedback_screen(x,y);
|
||||
byte blue_under=Main_palette[color_under].B;
|
||||
byte green_under=Main_palette[color_under].G;
|
||||
byte red_under=Main_palette[color_under].R;
|
||||
byte blue=Main_palette[color].B;
|
||||
byte green=Main_palette[color].G;
|
||||
byte red=Main_palette[color].R;
|
||||
|
||||
return Best_color(
|
||||
red<red_under?red:red_under,
|
||||
green<green_under?green:green_under,
|
||||
blue<blue_under?blue:blue_under);
|
||||
}
|
||||
|
||||
void Check_timer(void)
|
||||
{
|
||||
if((SDL_GetTicks()/55)-Timer_delay>Timer_start) Timer_state=1;
|
||||
}
|
||||
|
||||
void Flip_Y_lowlevel(byte *src, short width, short height)
|
||||
{
|
||||
// ESI pointe sur la partie haute de la brosse
|
||||
// EDI sur la partie basse
|
||||
byte* ESI = src ;
|
||||
byte* EDI = src + (height - 1) *width;
|
||||
byte tmp;
|
||||
word cx;
|
||||
|
||||
while(ESI < EDI)
|
||||
{
|
||||
// Il faut inverser les lignes pointées par ESI et
|
||||
// EDI ("Brush_width" octets en tout)
|
||||
|
||||
for(cx = width;cx>0;cx--)
|
||||
{
|
||||
tmp = *ESI;
|
||||
*ESI = *EDI;
|
||||
*EDI = tmp;
|
||||
ESI++;
|
||||
EDI++;
|
||||
}
|
||||
|
||||
// On change de ligne :
|
||||
// ESI pointe déjà sur le début de la ligne suivante
|
||||
// EDI pointe sur la fin de la ligne en cours, il
|
||||
// doit pointer sur le début de la précédente...
|
||||
EDI -= 2 * width; // On recule de 2 lignes
|
||||
}
|
||||
}
|
||||
|
||||
void Flip_X_lowlevel(byte *src, short width, short height)
|
||||
{
|
||||
// ESI pointe sur la partie gauche et EDI sur la partie
|
||||
// droite
|
||||
byte* ESI = src;
|
||||
byte* EDI = src + width - 1;
|
||||
|
||||
byte* line_start;
|
||||
byte* line_end;
|
||||
byte tmp;
|
||||
word cx;
|
||||
|
||||
while(ESI<EDI)
|
||||
{
|
||||
line_start = ESI;
|
||||
line_end = EDI;
|
||||
|
||||
// On échange par colonnes
|
||||
for(cx=height;cx>0;cx--)
|
||||
{
|
||||
tmp=*ESI;
|
||||
*ESI=*EDI;
|
||||
*EDI=tmp;
|
||||
EDI+=width;
|
||||
ESI+=width;
|
||||
}
|
||||
|
||||
// On change de colonne
|
||||
// ESI > colonne suivante
|
||||
// EDI > colonne précédente
|
||||
ESI = line_start + 1;
|
||||
EDI = line_end - 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Rotate a pixel buffer 180º on itself.
|
||||
void Rotate_180_deg_lowlevel(byte *src, short width, short height)
|
||||
{
|
||||
// ESI pointe sur la partie supérieure de la brosse
|
||||
// EDI pointe sur la partie basse
|
||||
byte* ESI = src;
|
||||
byte* EDI = src + height*width - 1;
|
||||
// EDI pointe sur le dernier pixel de la derniere ligne
|
||||
byte tmp;
|
||||
word cx;
|
||||
|
||||
// In case of odd height, the algorithm in this function would
|
||||
// miss the middle line, so we do it this way:
|
||||
if (height & 1)
|
||||
{
|
||||
Flip_X_lowlevel(src, width, height);
|
||||
Flip_Y_lowlevel(src, width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
while(ESI < EDI)
|
||||
{
|
||||
// On échange les deux lignes pointées par EDI et
|
||||
// ESI (Brush_width octets)
|
||||
// En même temps, on échange les pixels, donc EDI
|
||||
// pointe sur la FIN de sa ligne
|
||||
|
||||
for(cx=width;cx>0;cx--)
|
||||
{
|
||||
tmp = *ESI;
|
||||
*ESI = *EDI;
|
||||
*EDI = tmp;
|
||||
|
||||
EDI--; // Attention ici on recule !
|
||||
ESI++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Rescale(byte *src_buffer, short src_width, short src_height, byte *dst_buffer, short dst_width, short dst_height, short x_flipped, short y_flipped)
|
||||
{
|
||||
int offset,line,column;
|
||||
|
||||
int x_pos_in_brush; // Position courante dans l'ancienne brosse
|
||||
int y_pos_in_brush;
|
||||
int delta_x_in_brush; // "Vecteur incrémental" du point précédent
|
||||
int delta_y_in_brush;
|
||||
int initial_x_pos; // Position X de début de parcours de ligne
|
||||
|
||||
// Calcul du "vecteur incrémental":
|
||||
delta_x_in_brush=(src_width<<16) * (x_flipped?-1:1) / (dst_width);
|
||||
delta_y_in_brush=(src_height<<16) * (y_flipped?-1:1) / (dst_height);
|
||||
|
||||
offset=0;
|
||||
|
||||
// Calcul de la valeur initiale de y_pos:
|
||||
if (y_flipped)
|
||||
y_pos_in_brush=(src_height<<16)-1; // Inversion en Y de la brosse
|
||||
else
|
||||
y_pos_in_brush=0; // Pas d'inversion en Y de la brosse
|
||||
|
||||
// Calcul de la valeur initiale de x_pos pour chaque ligne:
|
||||
if (x_flipped)
|
||||
initial_x_pos = (src_width<<16)-1; // Inversion en X de la brosse
|
||||
else
|
||||
initial_x_pos = 0; // Pas d'inversion en X de la brosse
|
||||
|
||||
// Pour chaque ligne
|
||||
for (line=0;line<dst_height;line++)
|
||||
{
|
||||
// On repart du début de la ligne:
|
||||
x_pos_in_brush=initial_x_pos;
|
||||
|
||||
// Pour chaque colonne:
|
||||
for (column=0;column<dst_width;column++)
|
||||
{
|
||||
// On copie le pixel:
|
||||
dst_buffer[offset]=*(src_buffer + (x_pos_in_brush>>16) + (y_pos_in_brush>>16)*src_width);
|
||||
// On passe à la colonne de brosse suivante:
|
||||
x_pos_in_brush+=delta_x_in_brush;
|
||||
// On passe au pixel suivant de la nouvelle brosse:
|
||||
offset++;
|
||||
}
|
||||
// On passe à la ligne de brosse suivante:
|
||||
y_pos_in_brush+=delta_y_in_brush;
|
||||
}
|
||||
}
|
||||
|
||||
void Slider_timer(byte speed)
|
||||
//Boucle d'attente pour faire bouger les scrollbars à une vitesse correcte
|
||||
{
|
||||
Uint32 end;
|
||||
byte original_mouse_k = Mouse_K;
|
||||
end = SDL_GetTicks() + speed*10;
|
||||
do
|
||||
{
|
||||
if (!Get_input()) SDL_Delay(20);
|
||||
} while (Mouse_K == original_mouse_k && SDL_GetTicks()<end);
|
||||
}
|
||||
|
||||
void Scroll_picture(byte * main_src, byte * main_dest, short x_offset,short y_offset)
|
||||
{
|
||||
byte* src = main_src; //source de la copie
|
||||
byte* dest = main_dest + y_offset * Main_image_width + x_offset;
|
||||
const word length = Main_image_width - x_offset; // Nombre de pixels à copier à droite
|
||||
word y;
|
||||
for(y = Main_image_height - y_offset;y>0;y--)
|
||||
{
|
||||
// Pour chaque ligne
|
||||
memcpy(dest,src,length);
|
||||
memcpy(dest - x_offset,src+length,x_offset);
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest += Main_image_width;
|
||||
src += Main_image_width;
|
||||
}
|
||||
|
||||
// On vient de faire le traitement pour otutes les lignes au-dessous de y_offset
|
||||
// Maintenant on traite celles au dessus
|
||||
dest = x_offset + main_dest;
|
||||
for(y = y_offset;y>0;y--)
|
||||
{
|
||||
memcpy(dest,src,length);
|
||||
memcpy(dest - x_offset,src+length,x_offset);
|
||||
|
||||
dest += Main_image_width;
|
||||
src += Main_image_width;
|
||||
}
|
||||
|
||||
Update_rect(0,0,0,0);
|
||||
}
|
||||
|
||||
void Zoom_a_line(byte* original_line, byte* zoomed_line,
|
||||
word factor, word width
|
||||
)
|
||||
{
|
||||
byte color;
|
||||
word x;
|
||||
|
||||
// Pour chaque pixel
|
||||
for(x=0;x<width;x++){
|
||||
color = *original_line;
|
||||
|
||||
memset(zoomed_line,color,factor);
|
||||
zoomed_line+=factor;
|
||||
|
||||
original_line++;
|
||||
}
|
||||
}
|
||||
|
||||
/*############################################################################*/
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#define _WIN32_WINNT 0x0500
|
||||
#include <windows.h>
|
||||
#elif defined(__macosx__) || defined(__FreeBSD__)
|
||||
#include <sys/sysctl.h>
|
||||
#elif defined(__BEOS__) || defined(__HAIKU__)
|
||||
// sysinfo not implemented
|
||||
#elif defined(__AROS__) || defined(__amigaos4__) || defined(__MORPHOS__) || defined(__amigaos__)
|
||||
#include <proto/exec.h>
|
||||
#elif defined(__SKYOS__)
|
||||
#include <skyos/sysinfo.h>
|
||||
#else
|
||||
#include <sys/sysinfo.h> // sysinfo() for free RAM
|
||||
#endif
|
||||
|
||||
|
||||
// Indique quelle est la mémoire disponible
|
||||
unsigned long Memory_free(void)
|
||||
{
|
||||
// Memory is no longer relevant. If there is ANY problem or doubt here,
|
||||
// you can simply return 10*1024*1024 (10Mb), to make the "Pages"something
|
||||
// memory allocation functions happy.
|
||||
|
||||
// However, it is still a good idea to make a proper function if you can...
|
||||
// If Grafx2 thinks the memory is full, weird things may happen. And if memory
|
||||
// ever becomes full and you're still saying there are 10MB free here, the
|
||||
// program will crash without saving any picture backup ! You've been warned...
|
||||
#if defined(__WIN32__)
|
||||
MEMORYSTATUS mstt;
|
||||
mstt.dwLength = sizeof(MEMORYSTATUS);
|
||||
GlobalMemoryStatus(&mstt);
|
||||
return mstt.dwAvailPhys;
|
||||
#elif defined(__macosx__) || defined(__FreeBSD__)
|
||||
int mib[2];
|
||||
int maxmem;
|
||||
size_t len;
|
||||
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_USERMEM;
|
||||
len = sizeof(maxmem);
|
||||
sysctl(mib,2,&maxmem,&len,NULL,0);
|
||||
return maxmem;
|
||||
#elif defined(__BEOS__) || defined(__HAIKU__) || defined(__SKYOS__) || defined(__amigaos4__) || defined(__TRU64__)
|
||||
// No <sys/sysctl.h> on BeOS or Haiku
|
||||
// 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 :)"
|
||||
return 10*1024*1024;
|
||||
#elif defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
|
||||
return AvailMem(MEMF_ANY);
|
||||
#else
|
||||
struct sysinfo info;
|
||||
sysinfo(&info);
|
||||
return info.freeram*info.mem_unit;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Arrondir un nombre réel à la valeur entière la plus proche
|
||||
// TODO : this should probably be replaced with round() from C99...
|
||||
short Round(float value)
|
||||
{
|
||||
short temp=value;
|
||||
|
||||
if (value>=0)
|
||||
{ if ((value-temp)>= 0.5) temp++; }
|
||||
else
|
||||
{ if ((value-temp)<=-0.5) temp--; }
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
// Arrondir le résultat d'une division à la valeur entière supérieure
|
||||
short Round_div_max(short numerator,short divisor)
|
||||
{
|
||||
if (!(numerator % divisor))
|
||||
return (numerator/divisor);
|
||||
else
|
||||
return (numerator/divisor)+1;
|
||||
}
|
||||
|
||||
|
||||
// Retourne le minimum entre deux nombres
|
||||
int Min(int a,int b)
|
||||
{
|
||||
return (a<b)?a:b;
|
||||
}
|
||||
|
||||
|
||||
// Retourne le maximum entre deux nombres
|
||||
int Max(int a,int b)
|
||||
{
|
||||
return (a>b)?a:b;
|
||||
}
|
||||
|
||||
/* Round number n to d decimal points */
|
||||
double Fround(double n, unsigned d)
|
||||
{
|
||||
double exp;
|
||||
exp = pow(10.0, d);
|
||||
return floor(n * exp + 0.5) / exp;
|
||||
}
|
||||
|
||||
|
||||
// Fonction retournant le libellé d'une mode (ex: " 320x200")
|
||||
char * Mode_label(int mode)
|
||||
{
|
||||
static char str[24];
|
||||
if (! Video_mode[mode].Fullscreen)
|
||||
return "window";
|
||||
sprintf(str, "%dx%d", Video_mode[mode].Width, Video_mode[mode].Height);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
// Trouve un mode video à partir d'une chaine: soit "window",
|
||||
// soit de la forme "320x200"
|
||||
// Renvoie -1 si la chaine n'est pas convertible
|
||||
int Convert_videomode_arg(const char *argument)
|
||||
{
|
||||
// Je suis paresseux alors je vais juste tester les libellés
|
||||
int mode_index;
|
||||
for (mode_index=0; mode_index<Nb_video_modes; mode_index++)
|
||||
// Attention les vieilles fonctions de lecture .ini mettent tout en MAJUSCULE.
|
||||
if (!strcasecmp(Mode_label(mode_index), argument) && (Video_mode[mode_index].State &128) ==0)
|
||||
return mode_index;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
167
src/misc.h
Normal file
167
src/misc.h
Normal file
@@ -0,0 +1,167 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 misc.h
|
||||
/// Miscellanous unsorted functions.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
#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_DWORDS(a,b) { dword 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;}
|
||||
#define SWAP_PBYTES(a,b) { byte * c=a; a=b; b=c;}
|
||||
|
||||
void Copy_image_to_brush(short start_x,short start_y,short Brush_width,short Brush_height,word image_width);
|
||||
void Remap_general_lowlevel(byte * conversion_table,byte * buffer,short width,short height,short buffer_width);
|
||||
void Scroll_picture(byte * main_src, byte * main_dest, short x_offset,short y_offset);
|
||||
void Wait_end_of_click(void);
|
||||
void Set_color(byte color, byte red, byte green, byte blue);
|
||||
void Set_palette(T_Palette palette);
|
||||
void Palette_256_to_64(T_Palette palette);
|
||||
void Palette_64_to_256(T_Palette palette);
|
||||
void Clear_current_image(byte color);
|
||||
void Clear_current_image_with_stencil(byte color, byte * stencil);
|
||||
void Slider_timer(byte speed);
|
||||
dword Round_div(dword numerator,dword divisor);
|
||||
word Count_used_colors(dword * usage);
|
||||
word Count_used_colors_area(dword* usage, word start_x, word start_y, word width, word height);
|
||||
word Count_used_colors_screen_area(dword* usage, word start_x, word start_y, word width, word height);
|
||||
void Pixel_in_brush (word x,word y,byte color);
|
||||
byte Read_pixel_from_spare_screen(word x,word y);
|
||||
byte Read_pixel_from_backup_screen (word x,word y);
|
||||
byte Read_pixel_from_feedback_screen (word x,word y);
|
||||
byte Read_pixel_from_brush (word x,word y);
|
||||
|
||||
void Ellipse_compute_limites(short horizontal_radius,short vertical_radius);
|
||||
// Calcule les valeurs suivantes en fonction des deux paramètres:
|
||||
//
|
||||
// Ellipse_vertical_radius_squared
|
||||
// Ellipse_horizontal_radius_squared
|
||||
// Ellipse_Limit_High
|
||||
// Ellipse_Limit_Low
|
||||
|
||||
|
||||
byte Pixel_in_ellipse(void);
|
||||
// Indique si le pixel se trouvant à Ellipse_cursor_X pixels
|
||||
// (Ellipse_cursor_X>0 = à droite, Ellipse_cursor_X<0 = à gauche) et à
|
||||
// Ellipse_cursor_Y pixels (Ellipse_cursor_Y>0 = en bas,
|
||||
// Ellipse_cursor_Y<0 = en haut) du centre se trouve dans l'ellipse en
|
||||
// cours.
|
||||
|
||||
byte Pixel_in_circle(void);
|
||||
// Indique si le pixel se trouvant à Circle_cursor_X pixels
|
||||
// (Circle_cursor_X>0 = à droite, Circle_cursor_X<0 = à gauche) et à
|
||||
// Circle_cursor_Y pixels (Circle_cursor_Y>0 = en bas,
|
||||
// Circle_cursor_Y<0 = en haut) du centre se trouve dans le cercle en
|
||||
// cours.
|
||||
|
||||
// Gestion du chrono dans les fileselects
|
||||
void Init_chrono(dword delay);
|
||||
void Check_timer(void);
|
||||
|
||||
void Replace_a_color(byte old_color, byte New_color);
|
||||
void Replace_colors_within_limits(byte * replace_table);
|
||||
|
||||
byte Effect_interpolated_colorize (word x,word y,byte color);
|
||||
byte Effect_additive_colorize (word x,word y,byte color);
|
||||
byte Effect_substractive_colorize(word x,word y,byte color);
|
||||
byte Effect_sieve(word x,word y);
|
||||
|
||||
///
|
||||
/// Inverts a pixel buffer, according to a horizontal axis.
|
||||
/// @param src Pointer to the pixel buffer to process.
|
||||
/// @param width Width of the buffer.
|
||||
/// @param height Height of the buffer.
|
||||
void Flip_Y_lowlevel(byte *src, short width, short height);
|
||||
|
||||
///
|
||||
/// Inverts a pixel buffer, according to a vertical axis.
|
||||
/// @param src Pointer to the pixel buffer to process.
|
||||
/// @param width Width of the buffer.
|
||||
/// @param height Height of the buffer.
|
||||
void Flip_X_lowlevel(byte *src, short width, short height);
|
||||
///
|
||||
/// Rotate a pixel buffer by 90 degrees, clockwise.
|
||||
/// @param source Source pixel buffer.
|
||||
/// @param dest Destination pixel buffer.
|
||||
/// @param width Width of the original buffer (height of the destination one).
|
||||
/// @param height Height of the original buffer (width of the destination one).
|
||||
void Rotate_90_deg_lowlevel(byte * source, byte * dest, short width, short height);
|
||||
///
|
||||
/// Rotate a pixel buffer by 90 degrees, counter-clockwise.
|
||||
/// @param source Source pixel buffer.
|
||||
/// @param dest Destination pixel buffer.
|
||||
/// @param width Width of the original buffer (height of the destination one).
|
||||
/// @param height Height of the original buffer (width of the destination one).
|
||||
void Rotate_270_deg_lowlevel(byte * source, byte * dest, short width, short height);
|
||||
///
|
||||
/// Rotate a pixel buffer by 180 degrees.
|
||||
/// @param src The pixel buffer (source and destination).
|
||||
/// @param width Width of the buffer.
|
||||
/// @param height Height of the buffer.
|
||||
void Rotate_180_deg_lowlevel(byte *src, short width, short height);
|
||||
|
||||
///
|
||||
/// Copies an image to another, rescaling it and optionally flipping it.
|
||||
/// @param src_buffer Original image (address of first byte)
|
||||
/// @param src_width Original image's width in pixels
|
||||
/// @param src_height Original image's height in pixels
|
||||
/// @param dst_buffer Destination image (address of first byte)
|
||||
/// @param dst_width Destination image's width in pixels
|
||||
/// @param dst_height Destination image's height in pixels
|
||||
/// @param x_flipped Boolean, true to flip the image horizontally
|
||||
/// @param y_flipped Boolean, true to flip the image vertically
|
||||
void Rescale(byte *src_buffer, short src_width, short src_height, byte *dst_buffer, short dst_width, short dst_height, short x_flipped, short y_flipped);
|
||||
|
||||
void Zoom_a_line(byte * original_line,byte * zoomed_line,word factor,word width);
|
||||
void Copy_part_of_image_to_another(byte * source,word source_x,word source_y,word width,word height,word source_width,byte * dest,word dest_x,word dest_y,word destination_width);
|
||||
|
||||
// -- Gestion du chrono --
|
||||
byte Timer_state; // State du chrono: 0=Attente d'un Xème de seconde
|
||||
// 1=Il faut afficher la preview
|
||||
// 2=Plus de chrono à gerer pour l'instant
|
||||
dword Timer_delay; // Nombre de 18.2ème de secondes demandés
|
||||
dword Timer_start; // Heure de départ du chrono
|
||||
byte New_preview_is_needed; // Booléen "Il faut relancer le chrono de preview"
|
||||
|
||||
|
||||
unsigned long Memory_free(void);
|
||||
|
||||
#define Num2str(a,b,c) sprintf(b,"%*lu",c,(long)(a))
|
||||
|
||||
#define Dec2str(a,b,c) sprintf(b,"%.*f",c,(double)(a))
|
||||
|
||||
short Round(float value);
|
||||
short Round_div_max(short numerator,short divisor);
|
||||
|
||||
/* round number n to d decimal points */
|
||||
double Fround(double n, unsigned d);
|
||||
|
||||
|
||||
|
||||
int Min(int a,int b);
|
||||
int Max(int a,int b);
|
||||
|
||||
char* Mode_label(int mode);
|
||||
int Convert_videomode_arg(const char *argument);
|
||||
2665
src/miscfileformats.c
Normal file
2665
src/miscfileformats.c
Normal file
File diff suppressed because it is too large
Load Diff
929
src/mountlist.c
Normal file
929
src/mountlist.c
Normal file
@@ -0,0 +1,929 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* mountlist.c -- return a list of mounted file systems
|
||||
|
||||
Copyright (C) 1991, 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
|
||||
2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program 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 this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// This file is not used on some platforms, so don't do anything for them
|
||||
#if(!defined(__WIN32__))&&(!defined(__amigaos4__))&&(!defined(__AROS__))&&(!defined(__MORPHOS__))&&(!defined(__amigaos__))
|
||||
|
||||
// We don't use autoconf and all that in grafx2, so let's do the config here ...
|
||||
#if defined(__macosx__) || defined(__FreeBSD__) // MacOS X is POSIX compliant
|
||||
#define MOUNTED_GETMNTINFO
|
||||
#elif defined(__BEOS__) || defined(__HAIKU__)
|
||||
#define MOUNTED_FS_STAT_DEV
|
||||
#elif defined(__TRU64__)
|
||||
#define MOUNTED_GETFSSTAT 1
|
||||
#define HAVE_SYS_MOUNT_H 1
|
||||
#include <sys/types.h>
|
||||
#elif defined(__SKYOS__)
|
||||
#warning "Your platform is missing some specific code here ! please check and fix :)"
|
||||
#else
|
||||
#define MOUNTED_GETMNTENT1
|
||||
#endif
|
||||
|
||||
#define _XOPEN_SOURCE 500
|
||||
// --- END GRAFX2 CUSTOM CONFIG ---
|
||||
|
||||
#include "mountlist.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#if HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#if defined MOUNTED_GETFSSTAT /* OSF_1 and Darwin1.3.x */
|
||||
# if HAVE_SYS_UCRED_H
|
||||
# include <grp.h> /* needed on OSF V4.0 for definition of NGROUPS,
|
||||
NGROUPS is used as an array dimension in ucred.h */
|
||||
# include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
|
||||
# endif
|
||||
# if HAVE_SYS_MOUNT_H
|
||||
# include <sys/mount.h>
|
||||
# endif
|
||||
# if HAVE_SYS_FS_TYPES_H
|
||||
# include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
|
||||
# endif
|
||||
# if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
|
||||
# define FS_TYPE(Ent) ((Ent).f_fstypename)
|
||||
# else
|
||||
# define FS_TYPE(Ent) mnt_names[(Ent).f_type]
|
||||
# endif
|
||||
#endif /* MOUNTED_GETFSSTAT */
|
||||
|
||||
#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
|
||||
# include <mntent.h>
|
||||
# if !defined MOUNTED
|
||||
# if defined _PATH_MOUNTED /* GNU libc */
|
||||
# define MOUNTED _PATH_MOUNTED
|
||||
# endif
|
||||
# if defined MNT_MNTTAB /* HP-UX. */
|
||||
# define MOUNTED MNT_MNTTAB
|
||||
# endif
|
||||
# if defined MNTTABNAME /* Dynix. */
|
||||
# define MOUNTED MNTTABNAME
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */
|
||||
# include <sys/mount.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */
|
||||
# include <sys/statvfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_GETMNT /* Ultrix. */
|
||||
# include <sys/mount.h>
|
||||
# include <sys/fs_types.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_FS_STAT_DEV /* BeOS. */
|
||||
# include <fs_info.h>
|
||||
# include <dirent.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_FREAD /* SVR2. */
|
||||
# include <mnttab.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_FREAD_FSTYP /* SVR3. */
|
||||
# include <mnttab.h>
|
||||
# include <sys/fstyp.h>
|
||||
# include <sys/statfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_LISTMNTENT
|
||||
# include <mntent.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_GETMNTENT2 /* SVR4. */
|
||||
# include <sys/mnttab.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_VMOUNT /* AIX. */
|
||||
# include <fshelp.h>
|
||||
# include <sys/vfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef DOLPHIN
|
||||
/* So special that it's not worth putting this in autoconf. */
|
||||
# undef MOUNTED_FREAD_FSTYP
|
||||
# define MOUNTED_GETMNTTBL
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_MNTENT_H
|
||||
/* This is to get MNTOPT_IGNORE on e.g. SVR4. */
|
||||
# include <sys/mntent.h>
|
||||
#endif
|
||||
|
||||
#undef MNT_IGNORE
|
||||
#if defined MNTOPT_IGNORE && defined HAVE_HASMNTOPT
|
||||
# define MNT_IGNORE(M) hasmntopt ((M), MNTOPT_IGNORE)
|
||||
#else
|
||||
# define MNT_IGNORE(M) 0
|
||||
#endif
|
||||
|
||||
#if USE_UNLOCKED_IO
|
||||
# include "unlocked-io.h"
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
/* The results of open() in this file are not used with fchdir,
|
||||
therefore save some unnecessary work in fchdir.c. */
|
||||
#undef open
|
||||
#undef close
|
||||
|
||||
/* The results of opendir() in this file are not used with dirfd and fchdir,
|
||||
therefore save some unnecessary work in fchdir.c. */
|
||||
#undef opendir
|
||||
#undef closedir
|
||||
|
||||
// gcc2 under haiku and beos don't like these macros for some reason.
|
||||
// As they are not used there anyways, we remove them and everyone is happy.
|
||||
#if !defined(__HAIKU__) && !defined(__BEOS__)
|
||||
#ifndef ME_DUMMY
|
||||
# define ME_DUMMY(Fs_name, Fs_type) \
|
||||
(strcmp (Fs_type, "autofs") == 0 \
|
||||
|| strcmp (Fs_type, "none") == 0 \
|
||||
|| strcmp (Fs_type, "proc") == 0 \
|
||||
|| strcmp (Fs_type, "subfs") == 0 \
|
||||
|| strcmp (Fs_type, "sysfs") == 0 \
|
||||
|| strcmp (Fs_type, "usbfs") == 0 \
|
||||
|| strcmp (Fs_type, "devpts") == 0 \
|
||||
|| strcmp (Fs_type, "tmpfs") == 0 \
|
||||
/* for NetBSD 3.0 */ \
|
||||
|| strcmp (Fs_type, "kernfs") == 0 \
|
||||
/* for Irix 6.5 */ \
|
||||
|| strcmp (Fs_type, "ignore") == 0 \
|
||||
/* for MacOSX */ \
|
||||
|| strcmp (Fs_type, "devfs") == 0 \
|
||||
|| strcmp (Fs_type, "fdesc") == 0 \
|
||||
|| strcmp (Fs_type, "nfs") == 0 \
|
||||
|| strcmp (Fs_type, "volfs") == 0)
|
||||
#endif
|
||||
|
||||
#ifndef ME_REMOTE
|
||||
/* A file system is `remote' if its Fs_name contains a `:'
|
||||
or if (it is of type (smbfs or cifs) and its Fs_name starts with `//'). */
|
||||
# define ME_REMOTE(Fs_name, Fs_type) \
|
||||
(strchr (Fs_name, ':') != NULL \
|
||||
|| ((Fs_name)[0] == '/' \
|
||||
&& (Fs_name)[1] == '/' \
|
||||
&& (strcmp (Fs_type, "smbfs") == 0 \
|
||||
|| strcmp (Fs_type, "cifs") == 0)))
|
||||
#endif
|
||||
#endif // HAIKU / BEOS
|
||||
|
||||
#ifdef MOUNTED_GETMNTINFO
|
||||
|
||||
# if ! HAVE_STRUCT_STATFS_F_FSTYPENAME
|
||||
static char *
|
||||
fstype_to_string (short int t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
# ifdef MOUNT_PC
|
||||
case MOUNT_PC:
|
||||
return "pc";
|
||||
# endif
|
||||
# ifdef MOUNT_MFS
|
||||
case MOUNT_MFS:
|
||||
return "mfs";
|
||||
# endif
|
||||
# ifdef MOUNT_LO
|
||||
case MOUNT_LO:
|
||||
return "lo";
|
||||
# endif
|
||||
# ifdef MOUNT_TFS
|
||||
case MOUNT_TFS:
|
||||
return "tfs";
|
||||
# endif
|
||||
# ifdef MOUNT_TMP
|
||||
case MOUNT_TMP:
|
||||
return "tmp";
|
||||
# endif
|
||||
# ifdef MOUNT_UFS
|
||||
case MOUNT_UFS:
|
||||
return "ufs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_NFS
|
||||
case MOUNT_NFS:
|
||||
return "nfs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_MSDOS
|
||||
case MOUNT_MSDOS:
|
||||
return "msdos" ;
|
||||
# endif
|
||||
# ifdef MOUNT_LFS
|
||||
case MOUNT_LFS:
|
||||
return "lfs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_LOFS
|
||||
case MOUNT_LOFS:
|
||||
return "lofs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_FDESC
|
||||
case MOUNT_FDESC:
|
||||
return "fdesc" ;
|
||||
# endif
|
||||
# ifdef MOUNT_PORTAL
|
||||
case MOUNT_PORTAL:
|
||||
return "portal" ;
|
||||
# endif
|
||||
# ifdef MOUNT_NULL
|
||||
case MOUNT_NULL:
|
||||
return "null" ;
|
||||
# endif
|
||||
# ifdef MOUNT_UMAP
|
||||
case MOUNT_UMAP:
|
||||
return "umap" ;
|
||||
# endif
|
||||
# ifdef MOUNT_KERNFS
|
||||
case MOUNT_KERNFS:
|
||||
return "kernfs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_PROCFS
|
||||
case MOUNT_PROCFS:
|
||||
return "procfs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_AFS
|
||||
case MOUNT_AFS:
|
||||
return "afs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_CD9660
|
||||
case MOUNT_CD9660:
|
||||
return "cd9660" ;
|
||||
# endif
|
||||
# ifdef MOUNT_UNION
|
||||
case MOUNT_UNION:
|
||||
return "union" ;
|
||||
# endif
|
||||
# ifdef MOUNT_DEVFS
|
||||
case MOUNT_DEVFS:
|
||||
return "devfs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_EXT2FS
|
||||
case MOUNT_EXT2FS:
|
||||
return "ext2fs" ;
|
||||
# endif
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
static char *
|
||||
fsp_to_string (const struct statfs *fsp)
|
||||
{
|
||||
# if HAVE_STRUCT_STATFS_F_FSTYPENAME
|
||||
return (char *) (fsp->f_fstypename);
|
||||
# else
|
||||
return fstype_to_string (fsp->f_type);
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif /* MOUNTED_GETMNTINFO */
|
||||
|
||||
#ifdef MOUNTED_VMOUNT /* AIX. */
|
||||
static char *
|
||||
fstype_to_string (int t)
|
||||
{
|
||||
struct vfs_ent *e;
|
||||
|
||||
e = getvfsbytype (t);
|
||||
if (!e || !e->vfsent_name)
|
||||
return "none";
|
||||
else
|
||||
return e->vfsent_name;
|
||||
}
|
||||
#endif /* MOUNTED_VMOUNT */
|
||||
|
||||
|
||||
#if defined MOUNTED_GETMNTENT1 || defined MOUNTED_GETMNTENT2
|
||||
|
||||
/* Return the device number from MOUNT_OPTIONS, if possible.
|
||||
Otherwise return (dev_t) -1. */
|
||||
|
||||
#ifdef __linux__
|
||||
#define BROKEN __attribute__((unused))
|
||||
#else
|
||||
#define BROKEN
|
||||
#endif
|
||||
|
||||
static dev_t
|
||||
dev_from_mount_options (BROKEN char const *mount_options)
|
||||
{
|
||||
/* GNU/Linux allows file system implementations to define their own
|
||||
meaning for "dev=" mount options, so don't trust the meaning
|
||||
here. */
|
||||
# ifndef __linux__
|
||||
|
||||
static char const dev_pattern[] = ",dev=";
|
||||
char const *devopt = strstr (mount_options, dev_pattern);
|
||||
|
||||
if (devopt)
|
||||
{
|
||||
char const *optval = devopt + sizeof dev_pattern - 1;
|
||||
char *optvalend;
|
||||
unsigned long int dev;
|
||||
errno = 0;
|
||||
dev = strtoul (optval, &optvalend, 16);
|
||||
if (optval != optvalend
|
||||
&& (*optvalend == '\0' || *optvalend == ',')
|
||||
&& ! (dev == ULONG_MAX && errno == ERANGE)
|
||||
&& dev == (dev_t) dev)
|
||||
return dev;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Return a list of the currently mounted file systems, or NULL on error.
|
||||
Add each entry to the tail of the list so that they stay in order.
|
||||
If NEED_FS_TYPE is true, ensure that the file system type fields in
|
||||
the returned list are valid. Otherwise, they might not be. */
|
||||
|
||||
struct mount_entry *
|
||||
read_file_system_list (BROKEN bool need_fs_type)
|
||||
{
|
||||
struct mount_entry *mount_list;
|
||||
struct mount_entry *me;
|
||||
struct mount_entry **mtail = &mount_list;
|
||||
|
||||
#ifdef MOUNTED_LISTMNTENT
|
||||
{
|
||||
struct tabmntent *mntlist, *p;
|
||||
struct mntent *mnt;
|
||||
struct mount_entry *me;
|
||||
|
||||
/* the third and fourth arguments could be used to filter mounts,
|
||||
but Crays doesn't seem to have any mounts that we want to
|
||||
remove. Specifically, automount create normal NFS mounts.
|
||||
*/
|
||||
|
||||
if (listmntent (&mntlist, KMTAB, NULL, NULL) < 0)
|
||||
return NULL;
|
||||
for (p = mntlist; p; p = p->next) {
|
||||
mnt = p->ment;
|
||||
me = xmalloc (sizeof *me);
|
||||
me->me_devname = xstrdup (mnt->mnt_fsname);
|
||||
me->me_mountdir = xstrdup (mnt->mnt_dir);
|
||||
me->me_type = xstrdup (mnt->mnt_type);
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = -1;
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
freemntlist (mntlist);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_GETMNTENT1 /* GNU/Linux, 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
|
||||
{
|
||||
struct mntent *mnt;
|
||||
char *table = MOUNTED;
|
||||
FILE *fp;
|
||||
|
||||
fp = setmntent (table, "r");
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
|
||||
while ((mnt = getmntent (fp)))
|
||||
{
|
||||
me = malloc (sizeof *me);
|
||||
me->me_devname = strdup (mnt->mnt_fsname);
|
||||
me->me_mountdir = strdup (mnt->mnt_dir);
|
||||
me->me_type = strdup (mnt->mnt_type);
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = dev_from_mount_options (mnt->mnt_opts);
|
||||
|
||||
/* Add to the linked list. */
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
|
||||
if (endmntent (fp) == 0)
|
||||
goto free_then_fail;
|
||||
}
|
||||
#endif /* MOUNTED_GETMNTENT1. */
|
||||
|
||||
#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */
|
||||
{
|
||||
struct statfs *fsp;
|
||||
int entries;
|
||||
|
||||
entries = getmntinfo (&fsp, MNT_NOWAIT);
|
||||
if (entries < 0)
|
||||
return NULL;
|
||||
for (; entries-- > 0; fsp++)
|
||||
{
|
||||
me = malloc (sizeof *me);
|
||||
me->me_devname = strdup (fsp->f_mntfromname);
|
||||
me->me_mountdir = strdup (fsp->f_mntonname);
|
||||
#if defined(__macosx__)
|
||||
me->me_type = fsp->f_fstypename;
|
||||
#else
|
||||
me->me_type = fsp->fs_typename;
|
||||
#endif
|
||||
me->me_type_malloced = 0;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
|
||||
/* Add to the linked list. */
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
}
|
||||
#endif /* MOUNTED_GETMNTINFO */
|
||||
|
||||
#ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */
|
||||
{
|
||||
struct statvfs *fsp;
|
||||
int entries;
|
||||
|
||||
entries = getmntinfo (&fsp, MNT_NOWAIT);
|
||||
if (entries < 0)
|
||||
return NULL;
|
||||
for (; entries-- > 0; fsp++)
|
||||
{
|
||||
me = xmalloc (sizeof *me);
|
||||
me->me_devname = xstrdup (fsp->f_mntfromname);
|
||||
me->me_mountdir = xstrdup (fsp->f_mntonname);
|
||||
me->me_type = xstrdup (fsp->f_fstypename);
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
|
||||
/* Add to the linked list. */
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
}
|
||||
#endif /* MOUNTED_GETMNTINFO2 */
|
||||
|
||||
#ifdef MOUNTED_GETMNT /* Ultrix. */
|
||||
{
|
||||
int offset = 0;
|
||||
int val;
|
||||
struct fs_data fsd;
|
||||
|
||||
while (errno = 0,
|
||||
0 < (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
|
||||
(char *) 0)))
|
||||
{
|
||||
me = xmalloc (sizeof *me);
|
||||
me->me_devname = xstrdup (fsd.fd_req.devname);
|
||||
me->me_mountdir = xstrdup (fsd.fd_req.path);
|
||||
me->me_type = gt_names[fsd.fd_req.fstype];
|
||||
me->me_type_malloced = 0;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = fsd.fd_req.dev;
|
||||
|
||||
/* Add to the linked list. */
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
if (val < 0)
|
||||
goto free_then_fail;
|
||||
}
|
||||
#endif /* MOUNTED_GETMNT. */
|
||||
|
||||
#if defined MOUNTED_FS_STAT_DEV /* BeOS */
|
||||
{
|
||||
/* The next_dev() and fs_stat_dev() system calls give the list of
|
||||
all file systems, including the information returned by statvfs()
|
||||
(fs type, total blocks, free blocks etc.), but without the mount
|
||||
point. But on BeOS all file systems except / are mounted in the
|
||||
rootfs, directly under /.
|
||||
The directory name of the mount point is often, but not always,
|
||||
identical to the volume name of the device.
|
||||
We therefore get the list of subdirectories of /, and the list
|
||||
of all file systems, and match the two lists. */
|
||||
|
||||
DIR *dirp;
|
||||
struct rootdir_entry
|
||||
{
|
||||
char *name;
|
||||
dev_t dev;
|
||||
ino_t ino;
|
||||
struct rootdir_entry *next;
|
||||
};
|
||||
struct rootdir_entry *rootdir_list;
|
||||
struct rootdir_entry **rootdir_tail;
|
||||
int32 pos;
|
||||
dev_t dev;
|
||||
fs_info fi;
|
||||
|
||||
/* All volumes are mounted in the rootfs, directly under /. */
|
||||
rootdir_list = NULL;
|
||||
rootdir_tail = &rootdir_list;
|
||||
dirp = opendir ("/");
|
||||
if (dirp)
|
||||
{
|
||||
struct dirent *d;
|
||||
|
||||
while ((d = readdir (dirp)) != NULL)
|
||||
{
|
||||
char *name;
|
||||
struct stat statbuf;
|
||||
|
||||
if (strcmp (d->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
if (strcmp (d->d_name, ".") == 0)
|
||||
name = strdup ("/");
|
||||
else
|
||||
{
|
||||
name = malloc (1 + strlen (d->d_name) + 1);
|
||||
name[0] = '/';
|
||||
strcpy (name + 1, d->d_name);
|
||||
}
|
||||
|
||||
if (lstat (name, &statbuf) >= 0 && S_ISDIR (statbuf.st_mode))
|
||||
{
|
||||
struct rootdir_entry *re = malloc (sizeof *re);
|
||||
re->name = name;
|
||||
re->dev = statbuf.st_dev;
|
||||
re->ino = statbuf.st_ino;
|
||||
|
||||
/* Add to the linked list. */
|
||||
*rootdir_tail = re;
|
||||
rootdir_tail = &re->next;
|
||||
}
|
||||
else
|
||||
free (name);
|
||||
}
|
||||
closedir (dirp);
|
||||
}
|
||||
*rootdir_tail = NULL;
|
||||
|
||||
for (pos = 0; (dev = next_dev (&pos)) >= 0; )
|
||||
if (fs_stat_dev (dev, &fi) >= 0)
|
||||
{
|
||||
/* Note: fi.dev == dev. */
|
||||
struct rootdir_entry *re;
|
||||
|
||||
for (re = rootdir_list; re; re = re->next)
|
||||
if (re->dev == fi.dev && re->ino == fi.root)
|
||||
break;
|
||||
|
||||
me = malloc (sizeof *me);
|
||||
me->me_devname = strdup (fi.device_name[0] != '\0' ? fi.device_name : fi.fsh_name);
|
||||
me->me_mountdir = strdup (re != NULL ? re->name : fi.fsh_name);
|
||||
me->me_type = strdup (fi.fsh_name);
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dev = fi.dev;
|
||||
me->me_dummy = 0;
|
||||
me->me_remote = (fi.flags & B_FS_IS_SHARED) != 0;
|
||||
|
||||
/* Add to the linked list. */
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
*mtail = NULL;
|
||||
|
||||
while (rootdir_list != NULL)
|
||||
{
|
||||
struct rootdir_entry *re = rootdir_list;
|
||||
rootdir_list = re->next;
|
||||
free (re->name);
|
||||
free (re);
|
||||
}
|
||||
}
|
||||
#endif /* MOUNTED_FS_STAT_DEV */
|
||||
|
||||
#if defined MOUNTED_GETFSSTAT /* __alpha running OSF_1 */
|
||||
{
|
||||
int numsys, counter;
|
||||
size_t bufsize;
|
||||
struct statfs *stats;
|
||||
|
||||
numsys = getfsstat ((struct statfs *)0, 0L, MNT_NOWAIT);
|
||||
if (numsys < 0)
|
||||
return (NULL);
|
||||
/*
|
||||
if (SIZE_MAX / sizeof *stats <= numsys)
|
||||
xalloc_die ();*/
|
||||
|
||||
bufsize = (1 + numsys) * sizeof *stats;
|
||||
stats = malloc (bufsize);
|
||||
numsys = getfsstat (stats, bufsize, MNT_NOWAIT);
|
||||
|
||||
if (numsys < 0)
|
||||
{
|
||||
free (stats);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
for (counter = 0; counter < numsys; counter++)
|
||||
{
|
||||
me = malloc (sizeof *me);
|
||||
me->me_devname = strdup (stats[counter].f_mntfromname);
|
||||
me->me_mountdir = strdup (stats[counter].f_mntonname);
|
||||
//me->me_type = strdup (FS_TYPE (stats[counter]));
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
|
||||
/* Add to the linked list. */
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
|
||||
free (stats);
|
||||
}
|
||||
#endif /* MOUNTED_GETFSSTAT */
|
||||
|
||||
#if defined MOUNTED_FREAD || defined MOUNTED_FREAD_FSTYP /* SVR[23]. */
|
||||
{
|
||||
struct mnttab mnt;
|
||||
char *table = "/etc/mnttab";
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen (table, "r");
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
|
||||
while (fread (&mnt, sizeof mnt, 1, fp) > 0)
|
||||
{
|
||||
me = xmalloc (sizeof *me);
|
||||
# ifdef GETFSTYP /* SVR3. */
|
||||
me->me_devname = xstrdup (mnt.mt_dev);
|
||||
# else
|
||||
me->me_devname = xmalloc (strlen (mnt.mt_dev) + 6);
|
||||
strcpy (me->me_devname, "/dev/");
|
||||
strcpy (me->me_devname + 5, mnt.mt_dev);
|
||||
# endif
|
||||
me->me_mountdir = xstrdup (mnt.mt_filsys);
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
me->me_type = "";
|
||||
me->me_type_malloced = 0;
|
||||
# ifdef GETFSTYP /* SVR3. */
|
||||
if (need_fs_type)
|
||||
{
|
||||
struct statfs fsd;
|
||||
char typebuf[FSTYPSZ];
|
||||
|
||||
if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1
|
||||
&& sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
|
||||
{
|
||||
me->me_type = xstrdup (typebuf);
|
||||
me->me_type_malloced = 1;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
|
||||
/* Add to the linked list. */
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
|
||||
if (ferror (fp))
|
||||
{
|
||||
/* The last fread() call must have failed. */
|
||||
int saved_errno = errno;
|
||||
fclose (fp);
|
||||
errno = saved_errno;
|
||||
goto free_then_fail;
|
||||
}
|
||||
|
||||
if (fclose (fp) == EOF)
|
||||
goto free_then_fail;
|
||||
}
|
||||
#endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP. */
|
||||
|
||||
#ifdef MOUNTED_GETMNTTBL /* DolphinOS goes its own way. */
|
||||
{
|
||||
struct mntent **mnttbl = getmnttbl (), **ent;
|
||||
for (ent=mnttbl;*ent;ent++)
|
||||
{
|
||||
me = xmalloc (sizeof *me);
|
||||
me->me_devname = xstrdup ( (*ent)->mt_resource);
|
||||
me->me_mountdir = xstrdup ( (*ent)->mt_directory);
|
||||
me->me_type = xstrdup ((*ent)->mt_fstype);
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
|
||||
/* Add to the linked list. */
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
endmnttbl ();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_GETMNTENT2 /* SVR4. */
|
||||
{
|
||||
struct mnttab mnt;
|
||||
char *table = MNTTAB;
|
||||
FILE *fp;
|
||||
int ret;
|
||||
int lockfd = -1;
|
||||
|
||||
# if defined F_RDLCK && defined F_SETLKW
|
||||
/* MNTTAB_LOCK is a macro name of our own invention; it's not present in
|
||||
e.g. Solaris 2.6. If the SVR4 folks ever define a macro
|
||||
for this file name, we should use their macro name instead.
|
||||
(Why not just lock MNTTAB directly? We don't know.) */
|
||||
# ifndef MNTTAB_LOCK
|
||||
# define MNTTAB_LOCK "/etc/.mnttab.lock"
|
||||
# endif
|
||||
lockfd = open (MNTTAB_LOCK, O_RDONLY);
|
||||
if (0 <= lockfd)
|
||||
{
|
||||
struct flock flock;
|
||||
flock.l_type = F_RDLCK;
|
||||
flock.l_whence = SEEK_SET;
|
||||
flock.l_start = 0;
|
||||
flock.l_len = 0;
|
||||
while (fcntl (lockfd, F_SETLKW, &flock) == -1)
|
||||
if (errno != EINTR)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
close (lockfd);
|
||||
errno = saved_errno;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if (errno != ENOENT)
|
||||
return NULL;
|
||||
# endif
|
||||
|
||||
errno = 0;
|
||||
fp = fopen (table, "r");
|
||||
if (fp == NULL)
|
||||
ret = errno;
|
||||
else
|
||||
{
|
||||
while ((ret = getmntent (fp, &mnt)) == 0)
|
||||
{
|
||||
me = xmalloc (sizeof *me);
|
||||
me->me_devname = xstrdup (mnt.mnt_special);
|
||||
me->me_mountdir = xstrdup (mnt.mnt_mountp);
|
||||
me->me_type = xstrdup (mnt.mnt_fstype);
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dummy = MNT_IGNORE (&mnt) != 0;
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = dev_from_mount_options (mnt.mnt_mntopts);
|
||||
|
||||
/* Add to the linked list. */
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
|
||||
ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1;
|
||||
}
|
||||
|
||||
if (0 <= lockfd && close (lockfd) != 0)
|
||||
ret = errno;
|
||||
|
||||
if (0 <= ret)
|
||||
{
|
||||
errno = ret;
|
||||
goto free_then_fail;
|
||||
}
|
||||
}
|
||||
#endif /* MOUNTED_GETMNTENT2. */
|
||||
|
||||
#ifdef MOUNTED_VMOUNT /* AIX. */
|
||||
{
|
||||
int bufsize;
|
||||
char *entries, *thisent;
|
||||
struct vmount *vmp;
|
||||
int n_entries;
|
||||
int i;
|
||||
|
||||
/* Ask how many bytes to allocate for the mounted file system info. */
|
||||
if (mntctl (MCTL_QUERY, sizeof bufsize, (struct vmount *) &bufsize) != 0)
|
||||
return NULL;
|
||||
entries = xmalloc (bufsize);
|
||||
|
||||
/* Get the list of mounted file systems. */
|
||||
n_entries = mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries);
|
||||
if (n_entries < 0)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (entries);
|
||||
errno = saved_errno;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0, thisent = entries;
|
||||
i < n_entries;
|
||||
i++, thisent += vmp->vmt_length)
|
||||
{
|
||||
char *options, *ignore;
|
||||
|
||||
vmp = (struct vmount *) thisent;
|
||||
me = xmalloc (sizeof *me);
|
||||
if (vmp->vmt_flags & MNT_REMOTE)
|
||||
{
|
||||
char *host, *dir;
|
||||
|
||||
me->me_remote = 1;
|
||||
/* Prepend the remote dirname. */
|
||||
host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off;
|
||||
dir = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off;
|
||||
me->me_devname = xmalloc (strlen (host) + strlen (dir) + 2);
|
||||
strcpy (me->me_devname, host);
|
||||
strcat (me->me_devname, ":");
|
||||
strcat (me->me_devname, dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
me->me_remote = 0;
|
||||
me->me_devname = xstrdup (thisent +
|
||||
vmp->vmt_data[VMT_OBJECT].vmt_off);
|
||||
}
|
||||
me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
|
||||
me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype));
|
||||
me->me_type_malloced = 1;
|
||||
options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off;
|
||||
ignore = strstr (options, "ignore");
|
||||
me->me_dummy = (ignore
|
||||
&& (ignore == options || ignore[-1] == ',')
|
||||
&& (ignore[sizeof "ignore" - 1] == ','
|
||||
|| ignore[sizeof "ignore" - 1] == '\0'));
|
||||
me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */
|
||||
|
||||
/* Add to the linked list. */
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
free (entries);
|
||||
}
|
||||
#endif /* MOUNTED_VMOUNT. */
|
||||
|
||||
*mtail = NULL;
|
||||
return mount_list;
|
||||
|
||||
|
||||
free_then_fail:
|
||||
{
|
||||
int saved_errno = errno;
|
||||
*mtail = NULL;
|
||||
|
||||
while (mount_list)
|
||||
{
|
||||
me = mount_list->me_next;
|
||||
free (mount_list->me_devname);
|
||||
free (mount_list->me_mountdir);
|
||||
if (mount_list->me_type_malloced)
|
||||
free (mount_list->me_type);
|
||||
free (mount_list);
|
||||
mount_list = me;
|
||||
}
|
||||
|
||||
errno = saved_errno;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
54
src/mountlist.h
Normal file
54
src/mountlist.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* mountlist.h -- declarations for list of mounted file systems
|
||||
|
||||
Copyright (C) 1991, 1992, 1998, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program 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 this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///@file mountlist.h
|
||||
/// A function to enumerate the mounting points in the filesystem.
|
||||
/// Used to display them in fileselectors.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MOUNTLIST_H_
|
||||
# define MOUNTLIST_H_
|
||||
|
||||
#if !defined(__VBCC__)
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
#define bool char
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/* A mount table entry. */
|
||||
struct mount_entry
|
||||
{
|
||||
char *me_devname; /* Device node name, including "/dev/". */
|
||||
char *me_mountdir; /* Mount point directory name. */
|
||||
char *me_type; /* "nfs", "4.2", etc. */
|
||||
dev_t me_dev; /* Device number of me_mountdir. */
|
||||
unsigned int me_dummy : 1; /* Nonzero for dummy file systems. */
|
||||
unsigned int me_remote : 1; /* Nonzero for remote fileystems. */
|
||||
unsigned int me_type_malloced : 1; /* Nonzero if me_type was malloced. */
|
||||
struct mount_entry *me_next;
|
||||
};
|
||||
|
||||
struct mount_entry *read_file_system_list (bool need_fs_type);
|
||||
|
||||
#endif
|
||||
1369
src/op_c.c
Normal file
1369
src/op_c.c
Normal file
File diff suppressed because it is too large
Load Diff
217
src/op_c.h
Normal file
217
src/op_c.h
Normal file
@@ -0,0 +1,217 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 op_c.h
|
||||
/// Color reduction and color conversion (24b->8b, RGB<->HSL).
|
||||
/// This is called op_c because half of the process was originally
|
||||
/// coded in op_asm, in assembler.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OP_C_H_
|
||||
#define _OP_C_H_
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
//////////////////////////////////////////////// Définition des types de base
|
||||
|
||||
typedef T_Components * T_Bitmap24B;
|
||||
typedef byte * T_Bitmap256;
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////// Définition d'une table de conversion
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int nbb_r; // Nb de bits de précision sur les rouges
|
||||
int nbb_g; // Nb de bits de précision sur les verts
|
||||
int nbb_b; // Nb de bits de précision sur les bleu
|
||||
|
||||
int rng_r; // Nb de valeurs sur les rouges (= 1<<nbb_r)
|
||||
int rng_g; // Nb de valeurs sur les verts (= 1<<nbb_g)
|
||||
int rng_b; // Nb de valeurs sur les bleus (= 1<<nbb_b)
|
||||
|
||||
int dec_r; // Coefficient multiplicateur d'accès dans la table (= nbb_g+nbb_b)
|
||||
int dec_g; // Coefficient multiplicateur d'accès dans la table (= nbb_b)
|
||||
int dec_b; // Coefficient multiplicateur d'accès dans la table (= 0)
|
||||
|
||||
int red_r; // Coefficient réducteur de traduction d'une couleur rouge (= 8-nbb_r)
|
||||
int red_g; // Coefficient réducteur de traduction d'une couleur verte (= 8-nbb_g)
|
||||
int red_b; // Coefficient réducteur de traduction d'une couleur bleue (= 8-nbb_b)
|
||||
|
||||
byte * table;
|
||||
} T_Conversion_table;
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////// Définition d'une table d'occurences
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int nbb_r; // Nb de bits de précision sur les rouges
|
||||
int nbb_g; // Nb de bits de précision sur les verts
|
||||
int nbb_b; // Nb de bits de précision sur les bleu
|
||||
|
||||
int rng_r; // Nb de valeurs sur les rouges (= 1<<nbb_r)
|
||||
int rng_g; // Nb de valeurs sur les verts (= 1<<nbb_g)
|
||||
int rng_b; // Nb de valeurs sur les bleus (= 1<<nbb_b)
|
||||
|
||||
int dec_r; // Coefficient multiplicateur d'accès dans la table (= nbb_g+nbb_b)
|
||||
int dec_g; // Coefficient multiplicateur d'accès dans la table (= nbb_b)
|
||||
int dec_b; // Coefficient multiplicateur d'accès dans la table (= 0)
|
||||
|
||||
int red_r; // Coefficient réducteur de traduction d'une couleur rouge (= 8-nbb_r)
|
||||
int red_g; // Coefficient réducteur de traduction d'une couleur verte (= 8-nbb_g)
|
||||
int red_b; // Coefficient réducteur de traduction d'une couleur bleue (= 8-nbb_b)
|
||||
|
||||
int * table;
|
||||
} T_Occurrence_table;
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////// Définition d'un ensemble de couleur
|
||||
|
||||
typedef struct S_Cluster
|
||||
{
|
||||
int occurences; // Nb total d'occurences des couleurs de l'ensemble
|
||||
|
||||
// Grande couverture
|
||||
byte Rmin,Rmax;
|
||||
byte Gmin,Vmax;
|
||||
byte Bmin,Bmax;
|
||||
|
||||
// Couverture minimale
|
||||
byte rmin,rmax;
|
||||
byte vmin,vmax;
|
||||
byte bmin,bmax;
|
||||
|
||||
byte plus_large; // Composante ayant la plus grande variation (0=red,1=green,2=blue)
|
||||
byte r,g,b; // color synthétisant l'ensemble
|
||||
byte h; // Chrominance
|
||||
byte l; // Luminosité
|
||||
|
||||
struct S_Cluster* next;
|
||||
} T_Cluster;
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////// Définition d'un ensemble de clusters
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int nb;
|
||||
int nb_max;
|
||||
T_Cluster * clusters;
|
||||
} T_Cluster_set;
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////// Définition d'un dégradé
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int nb_colors; // Nombre de couleurs dans le dégradé
|
||||
float min; // Chrominance minimale du dégradé
|
||||
float max; // Chrominance maximale du dégradé
|
||||
float hue; // Chrominance moyenne du dégradé
|
||||
} T_Gradient;
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////// Définition d'un ensemble de dégradé
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int nb; // Nombre de dégradés dans l'ensemble
|
||||
int nb_max; // Nombre maximum de dégradés
|
||||
T_Gradient * gradients; // Les dégradés
|
||||
} T_Gradient_set;
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////// Méthodes de gestion des tables de conversion //
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
T_Conversion_table * CT_new(int nbb_r,int nbb_g,int nbb_b);
|
||||
void CT_delete(T_Conversion_table * t);
|
||||
byte CT_get(T_Conversion_table * t,int r,int g,int b);
|
||||
void CT_set(T_Conversion_table * t,int r,int g,int b,byte i);
|
||||
|
||||
void RGB_to_HSL(int r, int g,int b, byte* h, byte*s, byte* l);
|
||||
void HSL_to_RGB(byte h, byte s, byte l, byte* r, byte* g, byte* b);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////// Méthodes de gestion des tables d'occurence //
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OT_init(T_Occurrence_table * t);
|
||||
T_Occurrence_table * OT_new(int nbb_r,int nbb_g,int nbb_b);
|
||||
void OT_delete(T_Occurrence_table * t);
|
||||
int OT_get(T_Occurrence_table * t,int r,int g,int b);
|
||||
void OT_inc(T_Occurrence_table * t,int r,int g,int b);
|
||||
void OT_count_occurrences(T_Occurrence_table * t,T_Bitmap24B image,int size);
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////// Méthodes de gestion des clusters //
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Cluster_pack(T_Cluster * c,T_Occurrence_table * to);
|
||||
void Cluster_split(T_Cluster * c,T_Cluster * c1,T_Cluster * c2,int hue,T_Occurrence_table * to);
|
||||
void Cluster_compute_hue(T_Cluster * c,T_Occurrence_table * to);
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////// Méthodes de gestion des ensembles de clusters //
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CS_Init(T_Cluster_set * cs,T_Occurrence_table * to);
|
||||
T_Cluster_set * CS_New(int nbmax,T_Occurrence_table * to);
|
||||
void CS_Delete(T_Cluster_set * cs);
|
||||
void CS_Get(T_Cluster_set * cs,T_Cluster * c);
|
||||
void CS_Set(T_Cluster_set * cs,T_Cluster * c);
|
||||
void CS_Generate(T_Cluster_set * cs,T_Occurrence_table * to);
|
||||
void CS_Compute_colors(T_Cluster_set * cs,T_Occurrence_table * to);
|
||||
void CS_Generate_color_table_and_palette(T_Cluster_set * cs,T_Conversion_table * tc,T_Components * palette);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////// Méthodes de gestion des ensembles de dégradés //
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void GS_Init(T_Gradient_set * ds,T_Cluster_set * cs);
|
||||
T_Gradient_set * GS_New(T_Cluster_set * cs);
|
||||
void GS_Delete(T_Gradient_set * ds);
|
||||
void GS_Generate(T_Gradient_set * ds,T_Cluster_set * cs);
|
||||
|
||||
|
||||
|
||||
// Convertie avec le plus de précision possible une image 24b en 256c
|
||||
// Renvoie s'il y a eu une erreur ou pas..
|
||||
int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
4004
src/operatio.c
Normal file
4004
src/operatio.c
Normal file
File diff suppressed because it is too large
Load Diff
227
src/operatio.h
Normal file
227
src/operatio.h
Normal file
@@ -0,0 +1,227 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 operatio.h
|
||||
/// Code for the drawing tools operations.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
// General operation handling functions. These may be moved to ops_handler.h when operatio.c grows over 5000 lines again...
|
||||
|
||||
/// Do some housekeeping before starting work on a operation.
|
||||
void Start_operation_stack(word new_operation);
|
||||
/// Put a value on ::Operation_stack
|
||||
void Operation_push(short value);
|
||||
/// Take a value off ::Operation_stack
|
||||
void Operation_pop(short * value);
|
||||
void Init_start_operation(void);
|
||||
short Distance(short x1, short y1, short x2, short y2);
|
||||
|
||||
//////////////////////////////////////////////////// OPERATION_CONTINUOUS_DRAW
|
||||
void Freehand_mode1_1_0(void);
|
||||
void Freehand_mode1_1_2(void);
|
||||
void Freehand_mode12_0_2(void);
|
||||
void Freehand_mode1_2_0(void);
|
||||
void Freehand_mode1_2_2(void);
|
||||
|
||||
///////////////////////////////////////////////// OPERATION_DISCONTINUOUS_DRAW
|
||||
void Freehand_mode2_1_0(void);
|
||||
void Freehand_mode2_1_2(void);
|
||||
void Freehand_mode2_2_0(void);
|
||||
void Freehand_mode2_2_2(void);
|
||||
|
||||
////////////////////////////////////////////////////// OPERATION_POINT_DRAW
|
||||
void Freehand_mode3_1_0(void);
|
||||
void Freehand_Mode3_2_0(void);
|
||||
void Freehand_mode3_0_1(void);
|
||||
|
||||
///////////////////////////////////////////////////////////// OPERATION_LINE
|
||||
|
||||
void Line_12_0(void);
|
||||
void Line_12_5(void);
|
||||
void Line_0_5(void);
|
||||
|
||||
///////////////////////////////////////////////////////////// OPERATION_MAGNIFY
|
||||
|
||||
void Magnifier_12_0(void);
|
||||
|
||||
/////////////////////////////////////////////////// OPERATION_RECTANGLE_?????
|
||||
|
||||
void Rectangle_12_0(void);
|
||||
void Rectangle_12_5(void);
|
||||
void Empty_rectangle_0_5(void);
|
||||
void Filled_rectangle_0_5(void);
|
||||
|
||||
////////////////////////////////////////////////////// OPERATION_CERCLE_?????
|
||||
|
||||
void Circle_12_0(void);
|
||||
void Circle_12_5(void);
|
||||
void Empty_circle_0_5(void);
|
||||
void Filled_circle_0_5(void);
|
||||
|
||||
///////////////////////////////////////////////////// OPERATION_ELLIPSE_?????
|
||||
|
||||
void Ellipse_12_0(void);
|
||||
void Ellipse_12_5(void);
|
||||
void Empty_ellipse_0_5(void);
|
||||
void Filled_ellipse_0_5(void);
|
||||
|
||||
////////////////////////////////////////////////////// OPERATION_GRAB_BRUSH
|
||||
|
||||
void Brush_12_0(void);
|
||||
void Brush_12_5(void);
|
||||
void Brush_0_5(void);
|
||||
|
||||
///////////////////////////////////////////////////// OPERATION_STRETCH_BRUSH
|
||||
|
||||
void Stretch_brush_12_0(void);
|
||||
void Stretch_brush_1_7(void);
|
||||
void Stretch_brush_0_7(void);
|
||||
void Stretch_brush_2_7(void);
|
||||
|
||||
//////////////////////////////////////////////////// OPERATION_ROTATE_BRUSH
|
||||
|
||||
void Rotate_brush_12_0(void);
|
||||
void Rotate_brush_1_5(void);
|
||||
void Rotate_brush_0_5(void);
|
||||
void Rotate_brush_2_5(void);
|
||||
|
||||
///////////////////////////////////////////////////// OPERATION_DISTORT_BRUSH
|
||||
|
||||
void Distort_brush_0_0(void);
|
||||
void Distort_brush_1_0(void);
|
||||
void Distort_brush_2_0(void);
|
||||
void Distort_brush_1_8(void);
|
||||
void Distort_brush_2_8(void);
|
||||
void Distort_brush_1_9(void);
|
||||
void Distort_brush_0_9(void);
|
||||
|
||||
//////////////////////////////////////////////////////// OPERATION_POLYBRUSH
|
||||
|
||||
void Polybrush_12_8(void);
|
||||
|
||||
////////////////////////////////////////////////////////////// OPERATION_FILL
|
||||
|
||||
void Fill_1_0(void);
|
||||
void Fill_2_0(void);
|
||||
|
||||
///////////////////////////////////////////////////////// OPERATION_REPLACE
|
||||
|
||||
void Replace_1_0(void);
|
||||
void Replace_2_0(void);
|
||||
|
||||
/////////////////////////////////////////////////////////// OPERATION_COLORPICK
|
||||
|
||||
void Pipette_0_0(void);
|
||||
void Colorpicker_12_0(void);
|
||||
void Colorpicker_1_1(void);
|
||||
void Colorpicker_2_1(void);
|
||||
void Colorpicker_0_1(void);
|
||||
|
||||
/////////////////////////////////////////////////////////// OPERATION_K_LIGNE
|
||||
|
||||
void K_line_12_0(void);
|
||||
void K_line_12_6(void);
|
||||
void K_line_0_6(void);
|
||||
void K_line_12_7(void);
|
||||
|
||||
/////////////////////////////////////////////////// OPERATION_COURBE_?_POINTS
|
||||
|
||||
void Curve_34_points_1_0(void);
|
||||
void Curve_34_points_2_0(void);
|
||||
void Curve_34_points_1_5(void);
|
||||
void Curve_34_points_2_5(void);
|
||||
|
||||
void Curve_4_points_0_5(void);
|
||||
void Curve_4_points_1_9(void);
|
||||
void Curve_4_points_2_9(void);
|
||||
|
||||
void Curve_3_points_0_5(void);
|
||||
void Curve_3_points_0_11(void);
|
||||
void Curve_3_points_12_11(void);
|
||||
|
||||
///////////////////////////////////////////////////////////// OPERATION_AIRBRUSH
|
||||
|
||||
void Airbrush_1_0(void);
|
||||
void Airbrush_2_0(void);
|
||||
void Airbrush_12_2(void);
|
||||
void Airbrush_0_2(void);
|
||||
|
||||
//////////////////////////////////////////////////////////// OPERATION_*POLY*
|
||||
|
||||
void Polygon_12_0(void);
|
||||
void Polygon_12_9(void);
|
||||
|
||||
void Polyfill_12_0(void);
|
||||
void Polyfill_0_8(void);
|
||||
void Polyfill_12_8(void);
|
||||
void Polyfill_12_9(void);
|
||||
|
||||
void Polyform_12_0(void);
|
||||
void Polyform_12_8(void);
|
||||
void Polyform_0_8(void);
|
||||
|
||||
void Filled_polyform_12_0(void);
|
||||
void Filled_polyform_12_8(void);
|
||||
void Filled_polyform_0_8(void);
|
||||
void Filled_contour_0_8(void);
|
||||
|
||||
//////////////////////////////////////////////////////////// OPERATION_SCROLL
|
||||
|
||||
void Scroll_12_0(void);
|
||||
void Scroll_12_5(void);
|
||||
void Scroll_0_5(void);
|
||||
|
||||
//////////////////////////////////////////////////// OPERATION_GRAD_CIRCLE
|
||||
|
||||
void Grad_circle_12_0(void);
|
||||
void Grad_circle_12_6(void);
|
||||
void Grad_circle_0_6(void);
|
||||
void Grad_circle_12_8(void);
|
||||
void Grad_circle_or_ellipse_0_8(void);
|
||||
|
||||
////////////////////////////////////////////////// OPERATION_GRAD_ELLIPSE
|
||||
|
||||
void Grad_ellipse_12_0(void);
|
||||
void Grad_ellipse_12_6(void);
|
||||
void Grad_ellipse_0_6(void);
|
||||
void Grad_ellipse_12_8(void);
|
||||
|
||||
///////////////////////////////////////////////// OPERATION_GRAD_RECTANGLE
|
||||
|
||||
void Grad_rectangle_12_0(void);
|
||||
void Grad_rectangle_12_5(void);
|
||||
void Grad_rectangle_0_5(void);
|
||||
void Grad_rectangle_0_7(void);
|
||||
void Grad_rectangle_12_7(void);
|
||||
void Grad_rectangle_12_9(void);
|
||||
void Grad_rectangle_0_9(void);
|
||||
|
||||
/////////////////////////////////////////////////// OPERATION_CENTERED_LINES
|
||||
|
||||
void Centered_lines_12_0(void);
|
||||
void Centered_lines_12_3(void);
|
||||
void Centered_lines_0_3(void);
|
||||
void Centered_lines_12_7(void);
|
||||
void Centered_lines_0_7(void);
|
||||
|
||||
1260
src/pages.c
Normal file
1260
src/pages.c
Normal file
File diff suppressed because it is too large
Load Diff
133
src/pages.h
Normal file
133
src/pages.h
Normal file
@@ -0,0 +1,133 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 pages.h
|
||||
/// Handler for the Undo/Redo system.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PAGES_H_
|
||||
#define _PAGES_H_
|
||||
|
||||
///
|
||||
/// Pointer to the image to read, while drawing. It's either the last history
|
||||
/// layer page when FX feedback is on, or the history page before it
|
||||
/// when FX feedback is off.
|
||||
extern byte * FX_feedback_screen;
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////// BACKUP ///////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// The pixels of visible layers, flattened copy.
|
||||
extern T_Bitmap Main_visible_image;
|
||||
/// The pixels of visible layers, flattened copy, used for no-feedback effects.
|
||||
extern T_Bitmap Main_visible_image_backup;
|
||||
/// The index of visible pixels from ::Visible image. Points to the right layer.
|
||||
extern T_Bitmap Main_visible_image_depth_buffer;
|
||||
|
||||
/// The pixels of visible layers for the spare page, flattened copy.
|
||||
extern T_Bitmap Spare_visible_image;
|
||||
|
||||
///
|
||||
/// INDIVIDUAL PAGES
|
||||
///
|
||||
|
||||
void Download_infos_page_main(T_Page * page);
|
||||
void Upload_infos_page_main(T_Page * page);
|
||||
/// Add a new layer to latest page of a list. Returns 0 on success.
|
||||
byte Add_layer(T_List_of_pages *list, byte layer);
|
||||
/// Delete a layer from the latest page of a list. Returns 0 on success.
|
||||
byte Delete_layer(T_List_of_pages *list, byte layer);
|
||||
/// Merges the current layer onto the one below it.
|
||||
byte Merge_layer();
|
||||
|
||||
// private
|
||||
T_Page * New_page(byte nb_layers);
|
||||
void Download_infos_page_spare(T_Page * page);
|
||||
void Upload_infos_page_spare(T_Page * page);
|
||||
void Clear_page(T_Page * page);
|
||||
void Copy_S_page(T_Page * dest,T_Page * source);
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// LISTS OF PAGES
|
||||
///
|
||||
|
||||
void Init_list_of_pages(T_List_of_pages * list);
|
||||
// private
|
||||
int Allocate_list_of_pages(T_List_of_pages * list);
|
||||
void Backward_in_list_of_pages(T_List_of_pages * list);
|
||||
void Advance_in_list_of_pages(T_List_of_pages * list);
|
||||
void Free_last_page_of_list(T_List_of_pages * list);
|
||||
int Create_new_page(T_Page * new_page,T_List_of_pages * current_list, dword layer_mask);
|
||||
void Change_page_number_of_list(T_List_of_pages * list,int number);
|
||||
void Free_page_of_a_list(T_List_of_pages * list);
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// BACKUP HIGH-LEVEL FUNCTIONS
|
||||
///
|
||||
|
||||
int Init_all_backup_lists(int width,int height);
|
||||
void Set_number_of_backups(int nb_backups);
|
||||
int Backup_with_new_dimensions(int upload,byte layers,int width,int height);
|
||||
/// Backup the spare image, the one you don't see.
|
||||
void Backup_the_spare(dword layer_mask);
|
||||
int Backup_and_resize_the_spare(int width,int height);
|
||||
/// Backup with a new copy for the working layer, and references for all others.
|
||||
void Backup(void);
|
||||
/// Backup with a new copy of some layers (the others are references).
|
||||
void Backup_layers(dword layer_mask);
|
||||
void Undo(void);
|
||||
void Redo(void);
|
||||
void Free_current_page(void); // 'Kill' button
|
||||
void Exchange_main_and_spare(void);
|
||||
void End_of_modification(void);
|
||||
|
||||
void Update_depth_buffer(void);
|
||||
void Redraw_layered_image(void);
|
||||
void Redraw_current_layer(void);
|
||||
|
||||
void Update_screen_targets(void);
|
||||
/// Update all the special image buffers, if necessary.
|
||||
int Update_buffers(int width, int height);
|
||||
int Update_spare_buffers(int width, int height);
|
||||
void Redraw_spare_image(void);
|
||||
///
|
||||
/// Must be called after changing the head of Main_backups list, or
|
||||
/// Main_current_layer
|
||||
void Update_FX_feedback(byte with_feedback);
|
||||
|
||||
///
|
||||
/// STATISTICS
|
||||
///
|
||||
|
||||
/// Total number of unique bitmaps (layers, animation frames, backups)
|
||||
extern long Stats_pages_number;
|
||||
/// Total memory used by bitmaps (layers, animation frames, backups)
|
||||
extern long long Stats_pages_memory;
|
||||
|
||||
#endif
|
||||
2379
src/palette.c
Normal file
2379
src/palette.c
Normal file
File diff suppressed because it is too large
Load Diff
44
src/palette.h
Normal file
44
src/palette.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 palette.h
|
||||
/// Palette screen, and some palette-related high-level functions.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Open the palette menu and handles everything inside it.
|
||||
void Button_Palette(void);
|
||||
/// Open the secondary palette menu and handles it.
|
||||
void Button_Secondary_palette(void);
|
||||
|
||||
/// Choose the number of graduations for RGB components, from 2 to 256.
|
||||
void Set_palette_RGB_scale(int);
|
||||
|
||||
///
|
||||
/// Scale a component (R, G or B) according to the current RGB graduations.
|
||||
/// Returns the resulting value, in the [0-255] range.
|
||||
byte Round_palette_component(byte comp);
|
||||
|
||||
/*!
|
||||
Adds 4 menu colors in the current palette.
|
||||
@param color_usage An up-to-date color usage table (byte[256]) (read only)
|
||||
@param not_picture 0 if the caller is the palette screen, 1 if it's a preview in the file selector.
|
||||
*/
|
||||
void Set_nice_menu_colors(dword * color_usage,int not_picture);
|
||||
2
src/pversion.c
Normal file
2
src/pversion.c
Normal file
@@ -0,0 +1,2 @@
|
||||
char Program_version[]="2.2wip";
|
||||
|
||||
510
src/pxdouble.c
Normal file
510
src/pxdouble.c
Normal file
@@ -0,0 +1,510 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <SDL.h>
|
||||
#include "global.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "misc.h"
|
||||
#include "graph.h"
|
||||
#include "pxdouble.h"
|
||||
#include "pxwide.h" // for Display_transparent_line_on_screen_wide()
|
||||
|
||||
#define ZOOMX 2
|
||||
#define ZOOMY 2
|
||||
|
||||
#ifdef __VBCC__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
void Pixel_double (word x,word y,byte color)
|
||||
/* Affiche un pixel de la color aux coords x;y à l'écran */
|
||||
{
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1)* VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1)* VIDEO_LINE_WIDTH + 1)=color;
|
||||
}
|
||||
|
||||
byte Read_pixel_double (word x,word y)
|
||||
/* On retourne la couleur du pixel aux coords données */
|
||||
{
|
||||
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
|
||||
}
|
||||
|
||||
void Block_double (word start_x,word start_y,word width,word height,byte color)
|
||||
/* On affiche un rectangle de la couleur donnée */
|
||||
{
|
||||
SDL_Rect rectangle;
|
||||
rectangle.x=start_x*ZOOMX;
|
||||
rectangle.y=start_y*ZOOMY;
|
||||
rectangle.w=width*ZOOMX;
|
||||
rectangle.h=height*ZOOMY;
|
||||
SDL_FillRect(Screen_SDL,&rectangle,color);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_double (word width,word height,word image_width)
|
||||
/* Afficher une partie de l'image telle quelle sur l'écran */
|
||||
{
|
||||
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
int dy;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
// On fait une copie de la ligne
|
||||
for (dy=width;dy>0;dy--)
|
||||
{
|
||||
*(dest+1)=*dest=*src;
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
// On double la ligne qu'on vient de copier
|
||||
memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
}
|
||||
//Update_rect(0,0,width,height);
|
||||
}
|
||||
|
||||
void Pixel_preview_normal_double (word x,word y,byte color)
|
||||
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
|
||||
* dans l'écran, en mode normal (pas en mode loupe)
|
||||
* Note: si on modifie cette procédure, il faudra penser à faire également
|
||||
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */
|
||||
{
|
||||
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
|
||||
Pixel_double(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
}
|
||||
|
||||
void Pixel_preview_magnifier_double (word x,word y,byte color)
|
||||
{
|
||||
// Affiche le pixel dans la partie non zoomée
|
||||
Pixel_double(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
|
||||
// Regarde si on doit aussi l'afficher dans la partie zoomée
|
||||
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
|
||||
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
|
||||
{
|
||||
// On est dedans
|
||||
int height;
|
||||
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
|
||||
|
||||
if (Menu_Y - y_zoom < Main_magnifier_factor)
|
||||
// On ne doit dessiner qu'un morceau du pixel
|
||||
// sinon on dépasse sur le menu
|
||||
height = Menu_Y - y_zoom;
|
||||
else
|
||||
height = Main_magnifier_factor;
|
||||
|
||||
Block_double(
|
||||
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
|
||||
y_zoom, Main_magnifier_factor, height, color
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void Horizontal_XOR_line_double(word x_pos,word y_pos,word width)
|
||||
{
|
||||
//On calcule la valeur initiale de dest:
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
|
||||
|
||||
int x;
|
||||
|
||||
for (x=0;x<width*ZOOMX;x+=ZOOMX)
|
||||
*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+1)=*(dest+x)=~*(dest+x);
|
||||
}
|
||||
|
||||
void Vertical_XOR_line_double(word x_pos,word y_pos,word height)
|
||||
{
|
||||
int i;
|
||||
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
|
||||
for (i=height;i>0;i--)
|
||||
{
|
||||
*dest=*(dest+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=~*dest;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY;
|
||||
}
|
||||
}
|
||||
|
||||
void Display_brush_color_double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
// src = Position dans la brosse
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+1) = *dest = *src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_brush_mono_double(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset, word width, word height,
|
||||
byte transp_color, byte color, word brush_width)
|
||||
/* On affiche la brosse en monochrome */
|
||||
{
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à
|
||||
// l'écran
|
||||
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
|
||||
// la brosse
|
||||
int x,y;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
//Pour chaque ligne
|
||||
{
|
||||
for(x=width;x!=0;x--)
|
||||
//Pour chaque pixel
|
||||
{
|
||||
if (*src!=transp_color)
|
||||
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=color;
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=brush_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Clear_brush_double(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
|
||||
{
|
||||
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
int x;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
for(x=width;x!=0;x--)
|
||||
//Pour chaque pixel
|
||||
{
|
||||
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*src;
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
// Affiche une brosse (arbitraire) à l'écran
|
||||
void Display_brush_double(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
// src = Position dans la brosse
|
||||
byte* src = brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++; dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
}
|
||||
|
||||
void Remap_screen_double(word x_pos,word y_pos,word width,word height,byte * conversion_table)
|
||||
{
|
||||
// dest = coords a l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
int x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y=height;y>0;y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=
|
||||
conversion_table[*dest];
|
||||
dest +=ZOOMX;
|
||||
}
|
||||
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
}
|
||||
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_fast_double(word x_pos,word y_pos,word width,byte * line)
|
||||
/* On affiche toute une ligne de pixels telle quelle. */
|
||||
/* Utilisée si le buffer contient déja des pixel doublés. */
|
||||
{
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_double(word x_pos,word y_pos,word width,byte * line)
|
||||
/* On affiche une ligne de pixels en les doublant. */
|
||||
{
|
||||
int x;
|
||||
byte *dest;
|
||||
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*line;
|
||||
dest+=ZOOMX;
|
||||
line++;
|
||||
}
|
||||
}
|
||||
void Display_transparent_mono_line_on_screen_double(
|
||||
word x_pos, word y_pos, word width, byte* line,
|
||||
byte transp_color, byte color)
|
||||
// Affiche une ligne à l'écran avec une couleur + transparence.
|
||||
// Utilisé par les brosses en mode zoom
|
||||
{
|
||||
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
|
||||
int x;
|
||||
// Pour chaque pixel
|
||||
for(x=0;x<width;x++)
|
||||
{
|
||||
if (transp_color!=*line)
|
||||
{
|
||||
*(dest+1)=*dest=color;
|
||||
}
|
||||
line ++; // Pixel suivant
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
}
|
||||
|
||||
void Read_line_screen_double(word x_pos,word y_pos,word width,byte * line)
|
||||
{
|
||||
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_scaled_double(
|
||||
word width, // width non zoomée
|
||||
word height, // height zoomée
|
||||
word image_width,byte * buffer)
|
||||
{
|
||||
byte* src = Main_screen + Main_magnifier_offset_Y * image_width
|
||||
+ Main_magnifier_offset_X;
|
||||
int y = 0; // Ligne en cours de traitement
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1)
|
||||
{
|
||||
int x;
|
||||
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
|
||||
// On l'affiche Facteur fois, sur des lignes consécutives
|
||||
x = Main_magnifier_factor;
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
// On affiche la ligne zoomée
|
||||
Display_line_on_screen_fast_double(
|
||||
Main_X_zoom, y, width*Main_magnifier_factor,
|
||||
buffer
|
||||
);
|
||||
// On passe à la suivante
|
||||
y++;
|
||||
if(y==height)
|
||||
{
|
||||
Redraw_grid(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
Update_rect(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
return;
|
||||
}
|
||||
x--;
|
||||
}while (x > 0);
|
||||
src += image_width;
|
||||
}
|
||||
// ATTENTION on n'arrive jamais ici !
|
||||
}
|
||||
|
||||
// Affiche une partie de la brosse couleur zoomée
|
||||
void Display_brush_color_zoom_double(word x_pos,word y_pos,
|
||||
word x_offset,word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,byte transp_color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer)
|
||||
{
|
||||
byte* src = Brush+y_offset*brush_width + x_offset;
|
||||
word y = y_pos;
|
||||
byte bx;
|
||||
|
||||
// Pour chaque ligne
|
||||
while(1)
|
||||
{
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
// On affiche facteur fois la ligne zoomée
|
||||
for(bx=Main_magnifier_factor;bx>0;bx--)
|
||||
{
|
||||
Display_transparent_line_on_screen_wide(x_pos,y*ZOOMY,width*Main_magnifier_factor,buffer,transp_color);
|
||||
memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
src += brush_width;
|
||||
}
|
||||
// ATTENTION zone jamais atteinte
|
||||
}
|
||||
|
||||
void Display_brush_mono_zoom_double(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,
|
||||
byte transp_color, byte color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer
|
||||
)
|
||||
|
||||
{
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
int y=y_pos*ZOOMY;
|
||||
|
||||
//Pour chaque ligne à zoomer :
|
||||
while(1)
|
||||
{
|
||||
int bx;
|
||||
// src = Ligne originale
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
|
||||
// On affiche la ligne Facteur fois à l'écran (sur des
|
||||
// lignes consécutives)
|
||||
bx = Main_magnifier_factor*ZOOMY;
|
||||
|
||||
// Pour chaque ligne écran
|
||||
do
|
||||
{
|
||||
// On affiche la ligne zoomée
|
||||
Display_transparent_mono_line_on_screen_double(
|
||||
x_pos, y, width * Main_magnifier_factor,
|
||||
buffer, transp_color, color
|
||||
);
|
||||
// On passe à la ligne suivante
|
||||
y++;
|
||||
// On vérifie qu'on est pas à la ligne finale
|
||||
if(y == end_y_pos*ZOOMY)
|
||||
{
|
||||
Redraw_grid( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
Update_rect( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
return;
|
||||
}
|
||||
bx --;
|
||||
}
|
||||
while (bx > 0);
|
||||
|
||||
// Passage à la ligne suivante dans la brosse aussi
|
||||
src+=brush_width;
|
||||
}
|
||||
}
|
||||
|
||||
void Clear_brush_scaled_double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
|
||||
{
|
||||
|
||||
// En fait on va recopier l'image non zoomée dans la partie zoomée !
|
||||
byte* src = Main_screen + y_offset * image_width + x_offset;
|
||||
int y = y_pos;
|
||||
int bx;
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1){
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
|
||||
|
||||
bx=Main_magnifier_factor;
|
||||
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
Display_line_on_screen_fast_double(x_pos,y,
|
||||
width * Main_magnifier_factor,buffer);
|
||||
|
||||
// Ligne suivante
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
Redraw_grid(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
Update_rect(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
return;
|
||||
}
|
||||
bx--;
|
||||
}while(bx!=0);
|
||||
|
||||
src+= image_width;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
50
src/pxdouble.h
Normal file
50
src/pxdouble.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 pxdouble.h
|
||||
/// Renderer for double pixels (2x2).
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
void Pixel_double (word x,word y,byte color);
|
||||
byte Read_pixel_double (word x,word y);
|
||||
void Block_double (word start_x,word start_y,word width,word height,byte color);
|
||||
void Pixel_preview_normal_double (word x,word y,byte color);
|
||||
void Pixel_preview_magnifier_double (word x,word y,byte color);
|
||||
void Horizontal_XOR_line_double (word x_pos,word y_pos,word width);
|
||||
void Vertical_XOR_line_double (word x_pos,word y_pos,word height);
|
||||
void Display_brush_color_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
void Display_brush_mono_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
|
||||
void Clear_brush_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
|
||||
void Remap_screen_double (word x_pos,word y_pos,word width,word height,byte * conversion_table);
|
||||
void Display_part_of_screen_double (word width,word height,word image_width);
|
||||
void Display_line_on_screen_double (word x_pos,word y_pos,word width,byte * line);
|
||||
void Read_line_screen_double (word x_pos,word y_pos,word width,byte * line);
|
||||
void Display_part_of_screen_scaled_double(word width,word height,word image_width,byte * buffer);
|
||||
void Display_brush_color_zoom_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
|
||||
void Display_brush_mono_zoom_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
|
||||
void Clear_brush_scaled_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
|
||||
void Display_brush_double (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
|
||||
void Display_line_on_screen_fast_double (word x_pos,word y_pos,word width,byte * line);
|
||||
545
src/pxquad.c
Normal file
545
src/pxquad.c
Normal file
@@ -0,0 +1,545 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <SDL.h>
|
||||
#include "global.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "misc.h"
|
||||
#include "graph.h"
|
||||
#include "pxquad.h"
|
||||
|
||||
#define ZOOMX 4
|
||||
#define ZOOMY 4
|
||||
|
||||
#ifdef __VBCC__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
void Pixel_quad (word x,word y,byte color)
|
||||
/* Affiche un pixel de la color aux coords x;y à l'écran */
|
||||
{
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 2)=color;
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 3)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 1)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 2)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 3)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 1)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 2)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 3)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 1)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 2)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 3)=color;
|
||||
}
|
||||
|
||||
byte Read_pixel_quad (word x,word y)
|
||||
/* On retourne la couleur du pixel aux coords données */
|
||||
{
|
||||
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
|
||||
}
|
||||
|
||||
void Block_quad (word start_x,word start_y,word width,word height,byte color)
|
||||
/* On affiche un rectangle de la couleur donnée */
|
||||
{
|
||||
SDL_Rect rectangle;
|
||||
rectangle.x=start_x*ZOOMX;
|
||||
rectangle.y=start_y*ZOOMY;
|
||||
rectangle.w=width*ZOOMX;
|
||||
rectangle.h=height*ZOOMY;
|
||||
SDL_FillRect(Screen_SDL,&rectangle,color);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_quad (word width,word height,word image_width)
|
||||
/* Afficher une partie de l'image telle quelle sur l'écran */
|
||||
{
|
||||
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
int dy;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
// On fait une copie de la ligne
|
||||
for (dy=width;dy>0;dy--)
|
||||
{
|
||||
*(dest+3)=*(dest+2)=*(dest+1)=*dest=*src;
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
// On double la ligne qu'on vient de copier
|
||||
memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
|
||||
// On la triple
|
||||
memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
|
||||
// On la quadruple
|
||||
memcpy(dest-width*ZOOMX+3*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
}
|
||||
//Update_rect(0,0,width,height);
|
||||
}
|
||||
|
||||
void Pixel_preview_normal_quad (word x,word y,byte color)
|
||||
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
|
||||
* dans l'écran, en mode normal (pas en mode loupe)
|
||||
* Note: si on modifie cette procédure, il faudra penser à faire également
|
||||
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */
|
||||
{
|
||||
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
|
||||
Pixel_quad(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
}
|
||||
|
||||
void Pixel_preview_magnifier_quad (word x,word y,byte color)
|
||||
{
|
||||
// Affiche le pixel dans la partie non zoomée
|
||||
Pixel_quad(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
|
||||
// Regarde si on doit aussi l'afficher dans la partie zoomée
|
||||
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
|
||||
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
|
||||
{
|
||||
// On est dedans
|
||||
int height;
|
||||
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
|
||||
|
||||
if (Menu_Y - y_zoom < Main_magnifier_factor)
|
||||
// On ne doit dessiner qu'un morceau du pixel
|
||||
// sinon on dépasse sur le menu
|
||||
height = Menu_Y - y_zoom;
|
||||
else
|
||||
height = Main_magnifier_factor;
|
||||
|
||||
Block_quad(
|
||||
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
|
||||
y_zoom, Main_magnifier_factor, height, color
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void Horizontal_XOR_line_quad(word x_pos,word y_pos,word width)
|
||||
{
|
||||
//On calcule la valeur initiale de dest:
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
|
||||
|
||||
int x;
|
||||
|
||||
for (x=0;x<width*ZOOMX;x+=ZOOMX)
|
||||
*(dest+x+3*VIDEO_LINE_WIDTH+3)=*(dest+x+3*VIDEO_LINE_WIDTH+2)=*(dest+x+3*VIDEO_LINE_WIDTH+1)=*(dest+x+3*VIDEO_LINE_WIDTH)=*(dest+x+2*VIDEO_LINE_WIDTH+3)=*(dest+x+2*VIDEO_LINE_WIDTH+2)=*(dest+x+2*VIDEO_LINE_WIDTH+1)=*(dest+x+2*VIDEO_LINE_WIDTH)=*(dest+x+VIDEO_LINE_WIDTH+3)=*(dest+x+VIDEO_LINE_WIDTH+2)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+3)=*(dest+x+2)=*(dest+x+1)=*(dest+x)=~*(dest+x);
|
||||
}
|
||||
|
||||
void Vertical_XOR_line_quad(word x_pos,word y_pos,word height)
|
||||
{
|
||||
int i;
|
||||
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
|
||||
for (i=height;i>0;i--)
|
||||
{
|
||||
*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*(dest)=~*(dest);
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY;
|
||||
}
|
||||
}
|
||||
|
||||
void Display_brush_color_quad(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
// src = Position dans la brosse
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*(dest+3*VIDEO_LINE_WIDTH+3) = *(dest+3*VIDEO_LINE_WIDTH+2) = *(dest+3*VIDEO_LINE_WIDTH+1) = *(dest+3*VIDEO_LINE_WIDTH) = *(dest+2*VIDEO_LINE_WIDTH+3) = *(dest+2*VIDEO_LINE_WIDTH+2) = *(dest+2*VIDEO_LINE_WIDTH+1) = *(dest+2*VIDEO_LINE_WIDTH) = *(dest+VIDEO_LINE_WIDTH+3) = *(dest+VIDEO_LINE_WIDTH+2) = *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = *src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_brush_mono_quad(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset, word width, word height,
|
||||
byte transp_color, byte color, word brush_width)
|
||||
/* On affiche la brosse en monochrome */
|
||||
{
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à
|
||||
// l'écran
|
||||
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
|
||||
// la brosse
|
||||
int x,y;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
//Pour chaque ligne
|
||||
{
|
||||
for(x=width;x!=0;x--)
|
||||
//Pour chaque pixel
|
||||
{
|
||||
if (*src!=transp_color)
|
||||
*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=color;
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=brush_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Clear_brush_quad(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
|
||||
{
|
||||
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
int x;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
for(x=width;x!=0;x--)
|
||||
//Pour chaque pixel
|
||||
{
|
||||
*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*src;
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
// Affiche une brosse (arbitraire) à l'écran
|
||||
void Display_brush_quad(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
// src = Position dans la brosse
|
||||
byte* src = brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++; dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
}
|
||||
|
||||
void Remap_screen_quad(word x_pos,word y_pos,word width,word height,byte * conversion_table)
|
||||
{
|
||||
// dest = coords a l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
int x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y=height;y>0;y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=
|
||||
conversion_table[*dest];
|
||||
dest +=ZOOMX;
|
||||
}
|
||||
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
}
|
||||
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_fast_quad(word x_pos,word y_pos,word width,byte * line)
|
||||
/* On affiche toute une ligne de pixels telle quelle. */
|
||||
/* Utilisée si le buffer contient déja des pixel doublés. */
|
||||
{
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+2)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+3)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_quad(word x_pos,word y_pos,word width,byte * line)
|
||||
/* On affiche une ligne de pixels en les doublant. */
|
||||
{
|
||||
int x;
|
||||
byte *dest;
|
||||
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*line;
|
||||
dest+=ZOOMX;
|
||||
line++;
|
||||
}
|
||||
}
|
||||
void Display_transparent_mono_line_on_screen_quad(
|
||||
word x_pos, word y_pos, word width, byte* line,
|
||||
byte transp_color, byte color)
|
||||
// Affiche une ligne à l'écran avec une couleur + transparence.
|
||||
// Utilisé par les brosses en mode zoom
|
||||
{
|
||||
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
|
||||
int x;
|
||||
// Pour chaque pixel
|
||||
for(x=0;x<width;x++)
|
||||
{
|
||||
if (transp_color!=*line)
|
||||
{
|
||||
*(dest+3)=*(dest+2)=*(dest+1)=*dest=color;
|
||||
}
|
||||
line ++; // Pixel suivant
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
}
|
||||
|
||||
void Read_line_screen_quad(word x_pos,word y_pos,word width,byte * line)
|
||||
{
|
||||
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_scaled_quad(
|
||||
word width, // width non zoomée
|
||||
word height, // height zoomée
|
||||
word image_width,byte * buffer)
|
||||
{
|
||||
byte* src = Main_screen + Main_magnifier_offset_Y * image_width
|
||||
+ Main_magnifier_offset_X;
|
||||
int y = 0; // Ligne en cours de traitement
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1)
|
||||
{
|
||||
int x;
|
||||
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
|
||||
// On l'affiche Facteur fois, sur des lignes consécutives
|
||||
x = Main_magnifier_factor/**ZOOMY*/;
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
// On affiche la ligne zoomée
|
||||
Display_line_on_screen_fast_quad(
|
||||
Main_X_zoom, y, width*Main_magnifier_factor,
|
||||
buffer
|
||||
);
|
||||
// On passe à la suivante
|
||||
y++;
|
||||
if(y==height/**ZOOMY*/)
|
||||
{
|
||||
Redraw_grid(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
Update_rect(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
return;
|
||||
}
|
||||
x--;
|
||||
}while (x > 0);
|
||||
src += image_width;
|
||||
}
|
||||
// ATTENTION on n'arrive jamais ici !
|
||||
}
|
||||
|
||||
// Affiche une partie de la brosse couleur zoomée
|
||||
void Display_brush_color_zoom_quad(word x_pos,word y_pos,
|
||||
word x_offset,word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,byte transp_color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer)
|
||||
{
|
||||
byte* src = Brush+y_offset*brush_width + x_offset;
|
||||
word y = y_pos;
|
||||
byte bx;
|
||||
|
||||
// Pour chaque ligne
|
||||
while(1)
|
||||
{
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
// On affiche facteur fois la ligne zoomée
|
||||
for(bx=Main_magnifier_factor;bx>0;bx--)
|
||||
{
|
||||
byte* line_src = buffer;
|
||||
byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
word x;
|
||||
// Pour chaque pixel de la ligne
|
||||
for(x = width*Main_magnifier_factor;x > 0;x--)
|
||||
{
|
||||
if(*line_src!=transp_color)
|
||||
{
|
||||
*(dest+3)=*(dest+2)=*(dest+1)=*dest = *line_src;
|
||||
}
|
||||
line_src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
// Double the line
|
||||
memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
|
||||
// Triple the line
|
||||
memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
|
||||
// Quadruple it
|
||||
memcpy(Screen_pixels + (y*ZOOMY+3)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
src += brush_width;
|
||||
}
|
||||
// ATTENTION zone jamais atteinte
|
||||
}
|
||||
|
||||
void Display_brush_mono_zoom_quad(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,
|
||||
byte transp_color, byte color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer
|
||||
)
|
||||
|
||||
{
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
int y=y_pos*ZOOMY;
|
||||
|
||||
//Pour chaque ligne à zoomer :
|
||||
while(1)
|
||||
{
|
||||
int bx;
|
||||
// src = Ligne originale
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
|
||||
// On affiche la ligne Facteur fois à l'écran (sur des
|
||||
// lignes consécutives)
|
||||
bx = Main_magnifier_factor*ZOOMY;
|
||||
|
||||
// Pour chaque ligne écran
|
||||
do
|
||||
{
|
||||
// On affiche la ligne zoomée
|
||||
Display_transparent_mono_line_on_screen_quad(
|
||||
x_pos, y, width * Main_magnifier_factor,
|
||||
buffer, transp_color, color
|
||||
);
|
||||
// On passe à la ligne suivante
|
||||
y++;
|
||||
// On vérifie qu'on est pas à la ligne finale
|
||||
if(y == end_y_pos*ZOOMY)
|
||||
{
|
||||
Redraw_grid( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
Update_rect( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
return;
|
||||
}
|
||||
bx --;
|
||||
}
|
||||
while (bx > 0);
|
||||
|
||||
// Passage à la ligne suivante dans la brosse aussi
|
||||
src+=brush_width;
|
||||
}
|
||||
}
|
||||
|
||||
void Clear_brush_scaled_quad(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
|
||||
{
|
||||
|
||||
// En fait on va recopier l'image non zoomée dans la partie zoomée !
|
||||
byte* src = Main_screen + y_offset * image_width + x_offset;
|
||||
int y = y_pos;
|
||||
int bx;
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1){
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
|
||||
|
||||
bx=Main_magnifier_factor;
|
||||
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
// TODO a verifier
|
||||
Display_line_on_screen_fast_quad(x_pos,y,
|
||||
width * Main_magnifier_factor,buffer);
|
||||
|
||||
// Ligne suivante
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
Redraw_grid(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
Update_rect(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
return;
|
||||
}
|
||||
bx--;
|
||||
}while(bx!=0);
|
||||
|
||||
src+= image_width;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
50
src/pxquad.h
Normal file
50
src/pxquad.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 pxquad.h
|
||||
/// Renderer for quadruple pixels (4x4).
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
void Pixel_quad (word x,word y,byte color);
|
||||
byte Read_pixel_quad (word x,word y);
|
||||
void Block_quad (word start_x,word start_y,word width,word height,byte color);
|
||||
void Pixel_preview_normal_quad (word x,word y,byte color);
|
||||
void Pixel_preview_magnifier_quad (word x,word y,byte color);
|
||||
void Horizontal_XOR_line_quad (word x_pos,word y_pos,word width);
|
||||
void Vertical_XOR_line_quad (word x_pos,word y_pos,word height);
|
||||
void Display_brush_color_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
void Display_brush_mono_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
|
||||
void Clear_brush_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
|
||||
void Remap_screen_quad (word x_pos,word y_pos,word width,word height,byte * conversion_table);
|
||||
void Display_part_of_screen_quad (word width,word height,word image_width);
|
||||
void Display_line_on_screen_quad (word x_pos,word y_pos,word width,byte * line);
|
||||
void Read_line_screen_quad (word x_pos,word y_pos,word width,byte * line);
|
||||
void Display_part_of_screen_scaled_quad(word width,word height,word image_width,byte * buffer);
|
||||
void Display_brush_color_zoom_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
|
||||
void Display_brush_mono_zoom_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
|
||||
void Clear_brush_scaled_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
|
||||
void Display_brush_quad (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
|
||||
void Display_line_on_screen_fast_quad (word x_pos,word y_pos,word width,byte * line);
|
||||
481
src/pxsimple.c
Normal file
481
src/pxsimple.c
Normal file
@@ -0,0 +1,481 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <SDL.h>
|
||||
#include "global.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "misc.h"
|
||||
#include "graph.h"
|
||||
#include "pxsimple.h"
|
||||
|
||||
#ifdef __VBCC__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
void Pixel_simple (word x,word y,byte color)
|
||||
/* Affiche un pixel de la color aux coords x;y à l'écran */
|
||||
{
|
||||
*(Screen_pixels + x + y * VIDEO_LINE_WIDTH)=color;
|
||||
}
|
||||
|
||||
byte Read_pixel_simple (word x,word y)
|
||||
/* On retourne la couleur du pixel aux coords données */
|
||||
{
|
||||
return *( Screen_pixels + y * VIDEO_LINE_WIDTH + x );
|
||||
}
|
||||
|
||||
void Block_simple (word start_x,word start_y,word width,word height,byte color)
|
||||
/* On affiche un rectangle de la couleur donnée */
|
||||
{
|
||||
SDL_Rect rectangle;
|
||||
rectangle.x=start_x;
|
||||
rectangle.y=start_y;
|
||||
rectangle.w=width;
|
||||
rectangle.h=height;
|
||||
SDL_FillRect(Screen_SDL,&rectangle,color);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_simple (word width,word height,word image_width)
|
||||
/* Afficher une partie de l'image telle quelle sur l'écran */
|
||||
{
|
||||
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
// On fait une copie de la ligne
|
||||
memcpy(dest,src,width);
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width;
|
||||
dest+=VIDEO_LINE_WIDTH;
|
||||
}
|
||||
//Update_rect(0,0,width,height);
|
||||
}
|
||||
|
||||
void Pixel_preview_normal_simple (word x,word y,byte color)
|
||||
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
|
||||
* dans l'écran, en mode normal (pas en mode loupe)
|
||||
* Note: si on modifie cette procédure, il faudra penser à faire également
|
||||
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */
|
||||
{
|
||||
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
|
||||
Pixel_simple(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
}
|
||||
|
||||
void Pixel_preview_magnifier_simple (word x,word y,byte color)
|
||||
{
|
||||
// Affiche le pixel dans la partie non zoomée
|
||||
Pixel_simple(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
|
||||
// Regarde si on doit aussi l'afficher dans la partie zoomée
|
||||
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
|
||||
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
|
||||
{
|
||||
// On est dedans
|
||||
int height;
|
||||
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
|
||||
|
||||
if (Menu_Y - y_zoom < Main_magnifier_factor)
|
||||
// On ne doit dessiner qu'un morceau du pixel
|
||||
// sinon on dépasse sur le menu
|
||||
height = Menu_Y - y_zoom;
|
||||
else
|
||||
height = Main_magnifier_factor;
|
||||
|
||||
Block_simple(
|
||||
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
|
||||
y_zoom, Main_magnifier_factor, height, color
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void Horizontal_XOR_line_simple(word x_pos,word y_pos,word width)
|
||||
{
|
||||
//On calcule la valeur initiale de dest:
|
||||
byte* dest=y_pos*VIDEO_LINE_WIDTH+x_pos+Screen_pixels;
|
||||
|
||||
int x;
|
||||
|
||||
for (x=0;x<width;x++)
|
||||
*(dest+x)=~*(dest+x);
|
||||
}
|
||||
|
||||
void Vertical_XOR_line_simple(word x_pos,word y_pos,word height)
|
||||
{
|
||||
int i;
|
||||
byte color;
|
||||
for (i=y_pos;i<y_pos+height;i++)
|
||||
{
|
||||
color=*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH);
|
||||
*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH)=~color;
|
||||
}
|
||||
}
|
||||
|
||||
void Display_brush_color_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
|
||||
// src = Position dans la brosse
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*dest = *src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++; dest++;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH - width;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_brush_mono_simple(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset, word width, word height,
|
||||
byte transp_color, byte color, word brush_width)
|
||||
/* On affiche la brosse en monochrome */
|
||||
{
|
||||
byte* dest=y_pos*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; // dest = adr Destination à
|
||||
// l'écran
|
||||
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
|
||||
// la brosse
|
||||
int x,y;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
//Pour chaque ligne
|
||||
{
|
||||
for(x=width;x!=0;x--)
|
||||
//Pour chaque pixel
|
||||
{
|
||||
if (*src!=transp_color)
|
||||
*dest=color;
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest++;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=brush_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH-width;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Clear_brush_simple(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
|
||||
{
|
||||
byte* dest=Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
// On fait une copie de la ligne
|
||||
memcpy(dest,src,width);
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width;
|
||||
dest+=VIDEO_LINE_WIDTH;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
// Affiche une brosse (arbitraire) à l'écran
|
||||
void Display_brush_simple(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
|
||||
// src = Position dans la brosse
|
||||
byte* src = brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*dest = *src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++; dest++;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH - width;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
}
|
||||
|
||||
void Remap_screen_simple(word x_pos,word y_pos,word width,word height,byte * conversion_table)
|
||||
{
|
||||
// dest = coords a l'écran
|
||||
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
|
||||
int x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y=height;y>0;y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*dest = conversion_table[*dest];
|
||||
dest ++;
|
||||
}
|
||||
|
||||
dest = dest + VIDEO_LINE_WIDTH - width;
|
||||
}
|
||||
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_simple(word x_pos,word y_pos,word width,byte * line)
|
||||
/* On affiche toute une ligne de pixels. Utilisé pour les textes. */
|
||||
{
|
||||
memcpy(Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH,line,width);
|
||||
}
|
||||
|
||||
void Display_transparent_mono_line_on_screen_simple(
|
||||
word x_pos, word y_pos, word width, byte* line,
|
||||
byte transp_color, byte color)
|
||||
// Affiche une ligne à l'écran avec une couleur + transparence.
|
||||
// Utilisé par les brosses en mode zoom
|
||||
{
|
||||
byte* dest = Screen_pixels+ y_pos * VIDEO_LINE_WIDTH + x_pos;
|
||||
int x;
|
||||
// Pour chaque pixel
|
||||
for(x=0;x<width;x++)
|
||||
{
|
||||
if (transp_color!=*line)
|
||||
*dest = color;
|
||||
line ++; // Pixel suivant
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
|
||||
void Read_line_screen_simple(word x_pos,word y_pos,word width,byte * line)
|
||||
{
|
||||
memcpy(line,VIDEO_LINE_WIDTH * y_pos + x_pos + Screen_pixels,width);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_scaled_simple(
|
||||
word width, // width non zoomée
|
||||
word height, // height zoomée
|
||||
word image_width,byte * buffer)
|
||||
{
|
||||
byte* src = Main_screen + Main_magnifier_offset_Y * image_width
|
||||
+ Main_magnifier_offset_X;
|
||||
int y = 0; // Ligne en cours de traitement
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1)
|
||||
{
|
||||
int x;
|
||||
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
// On l'affiche Facteur fois, sur des lignes consécutives
|
||||
x = Main_magnifier_factor;
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
// On affiche la ligne zoomée
|
||||
Display_line_on_screen_simple(
|
||||
Main_X_zoom, y, width*Main_magnifier_factor,
|
||||
buffer
|
||||
);
|
||||
// On passe à la suivante
|
||||
y++;
|
||||
if(y==height)
|
||||
{
|
||||
Redraw_grid(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
Update_rect(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
return;
|
||||
}
|
||||
x--;
|
||||
}while (x > 0);
|
||||
src += image_width;
|
||||
}
|
||||
// ATTENTION on n'arrive jamais ici !
|
||||
}
|
||||
|
||||
void Display_transparent_line_on_screen_simple(word x_pos,word y_pos,word width,byte* line,byte transp_color)
|
||||
{
|
||||
byte* src = line;
|
||||
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
|
||||
|
||||
word x;
|
||||
|
||||
// Pour chaque pixel de la ligne
|
||||
for(x = width;x > 0;x--)
|
||||
{
|
||||
if(*src!=transp_color)
|
||||
*dest = *src;
|
||||
src++;
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
|
||||
// Affiche une partie de la brosse couleur zoomée
|
||||
void Display_brush_color_zoom_simple(word x_pos,word y_pos,
|
||||
word x_offset,word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,byte transp_color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer)
|
||||
{
|
||||
byte* src = Brush+y_offset*brush_width + x_offset;
|
||||
word y = y_pos;
|
||||
byte bx;
|
||||
|
||||
// Pour chaque ligne
|
||||
while(1)
|
||||
{
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
// On affiche facteur fois la ligne zoomée
|
||||
for(bx=Main_magnifier_factor;bx>0;bx--)
|
||||
{
|
||||
Display_transparent_line_on_screen_simple(x_pos,y,width*Main_magnifier_factor,buffer,transp_color);
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
src += brush_width;
|
||||
}
|
||||
// ATTENTION zone jamais atteinte
|
||||
}
|
||||
|
||||
void Display_brush_mono_zoom_simple(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,
|
||||
byte transp_color, byte color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer
|
||||
)
|
||||
|
||||
{
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
int y=y_pos;
|
||||
|
||||
//Pour chaque ligne à zoomer :
|
||||
while(1)
|
||||
{
|
||||
int bx;
|
||||
// src = Ligne originale
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
|
||||
// On affiche la ligne Facteur fois à l'écran (sur des
|
||||
// lignes consécutives)
|
||||
bx = Main_magnifier_factor;
|
||||
|
||||
// Pour chaque ligne écran
|
||||
do
|
||||
{
|
||||
// On affiche la ligne zoomée
|
||||
Display_transparent_mono_line_on_screen_simple(
|
||||
x_pos, y, width * Main_magnifier_factor,
|
||||
buffer, transp_color, color
|
||||
);
|
||||
// On passe à la ligne suivante
|
||||
y++;
|
||||
// On vérifie qu'on est pas à la ligne finale
|
||||
if(y == end_y_pos)
|
||||
{
|
||||
Redraw_grid( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
Update_rect( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
return;
|
||||
}
|
||||
bx --;
|
||||
}
|
||||
while (bx > 0);
|
||||
|
||||
// Passage à la ligne suivante dans la brosse aussi
|
||||
src+=brush_width;
|
||||
}
|
||||
}
|
||||
|
||||
void Clear_brush_scaled_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
|
||||
{
|
||||
// En fait on va recopier l'image non zoomée dans la partie zoomée !
|
||||
byte* src = Main_screen + y_offset * image_width + x_offset;
|
||||
int y = y_pos;
|
||||
int bx;
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1){
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
|
||||
bx=Main_magnifier_factor;
|
||||
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
Display_line_on_screen_simple(x_pos,y,
|
||||
width * Main_magnifier_factor,buffer);
|
||||
|
||||
// Ligne suivante
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
Redraw_grid(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
Update_rect(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
return;
|
||||
}
|
||||
bx--;
|
||||
}while(bx!=0);
|
||||
|
||||
src+= image_width;
|
||||
}
|
||||
}
|
||||
53
src/pxsimple.h
Normal file
53
src/pxsimple.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 pxsimple.h
|
||||
/// Renderer for simple pixels (1x1). This is the normal one.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
void Pixel_simple (word x,word y,byte color);
|
||||
byte Read_pixel_simple (word x,word y);
|
||||
void Block_simple (word start_x,word start_y,word width,word height,byte color);
|
||||
void Pixel_preview_normal_simple (word x,word y,byte color);
|
||||
void Pixel_preview_magnifier_simple (word x,word y,byte color);
|
||||
void Horizontal_XOR_line_simple (word x_pos,word y_pos,word width);
|
||||
void Vertical_XOR_line_simple (word x_pos,word y_pos,word height);
|
||||
void Display_brush_color_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
void Display_brush_mono_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
|
||||
void Clear_brush_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
|
||||
void Remap_screen_simple (word x_pos,word y_pos,word width,word height,byte * conversion_table);
|
||||
void Display_part_of_screen_simple (word width,word height,word image_width);
|
||||
void Display_line_on_screen_simple (word x_pos,word y_pos,word width,byte * line);
|
||||
void Read_line_screen_simple (word x_pos,word y_pos,word width,byte * line);
|
||||
void Display_part_of_screen_scaled_simple(word width,word height,word image_width,byte * buffer);
|
||||
void Display_brush_color_zoom_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
|
||||
void Display_brush_mono_zoom_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
|
||||
void Clear_brush_scaled_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
|
||||
void Display_brush_simple (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
|
||||
void Display_transparent_mono_line_on_screen_simple(
|
||||
word x_pos, word y_pos, word width, byte* line,
|
||||
byte transp_color, byte color);
|
||||
void Display_transparent_line_on_screen_simple(word x_pos,word y_pos,word width,byte* line,byte transp_color);
|
||||
466
src/pxtall.c
Normal file
466
src/pxtall.c
Normal file
@@ -0,0 +1,466 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <SDL.h>
|
||||
#include "global.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "misc.h"
|
||||
#include "graph.h"
|
||||
#include "pxtall.h"
|
||||
#include "pxsimple.h"
|
||||
|
||||
#define ZOOMX 1
|
||||
#define ZOOMY 2
|
||||
|
||||
#ifdef __VBCC__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
void Pixel_tall (word x,word y,byte color)
|
||||
/* Affiche un pixel de la color aux coords x;y à l'écran */
|
||||
{
|
||||
*(Screen_pixels + x + y*ZOOMY*VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x + (y*ZOOMY+1)*VIDEO_LINE_WIDTH)=color;
|
||||
}
|
||||
|
||||
byte Read_pixel_tall (word x,word y)
|
||||
/* On retourne la couleur du pixel aux coords données */
|
||||
{
|
||||
return *( Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x );
|
||||
}
|
||||
|
||||
void Block_tall (word start_x,word start_y,word width,word height,byte color)
|
||||
/* On affiche un rectangle de la couleur donnée */
|
||||
{
|
||||
SDL_Rect rectangle;
|
||||
rectangle.x=start_x;
|
||||
rectangle.y=start_y*ZOOMY;
|
||||
rectangle.w=width;
|
||||
rectangle.h=height*ZOOMY;
|
||||
SDL_FillRect(Screen_SDL,&rectangle,color);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_tall (word width,word height,word image_width)
|
||||
/* Afficher une partie de l'image telle quelle sur l'écran */
|
||||
{
|
||||
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
// On fait une copie de la ligne
|
||||
memcpy(dest,src,width);
|
||||
dest+=VIDEO_LINE_WIDTH;
|
||||
memcpy(dest,src,width);
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width;
|
||||
dest+=VIDEO_LINE_WIDTH;
|
||||
}
|
||||
//Update_rect(0,0,width,height);
|
||||
}
|
||||
|
||||
void Pixel_preview_normal_tall (word x,word y,byte color)
|
||||
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
|
||||
* dans l'écran, en mode normal (pas en mode loupe)
|
||||
* Note: si on modifie cette procédure, il faudra penser à faire également
|
||||
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */
|
||||
{
|
||||
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
|
||||
Pixel_tall(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
}
|
||||
|
||||
void Pixel_preview_magnifier_tall (word x,word y,byte color)
|
||||
{
|
||||
// Affiche le pixel dans la partie non zoomée
|
||||
Pixel_tall(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
|
||||
// Regarde si on doit aussi l'afficher dans la partie zoomée
|
||||
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
|
||||
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
|
||||
{
|
||||
// On est dedans
|
||||
int height;
|
||||
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
|
||||
|
||||
if (Menu_Y - y_zoom < Main_magnifier_factor)
|
||||
// On ne doit dessiner qu'un morceau du pixel
|
||||
// sinon on dépasse sur le menu
|
||||
height = Menu_Y - y_zoom;
|
||||
else
|
||||
height = Main_magnifier_factor;
|
||||
|
||||
Block_tall(
|
||||
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
|
||||
y_zoom, Main_magnifier_factor, height, color
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void Horizontal_XOR_line_tall(word x_pos,word y_pos,word width)
|
||||
{
|
||||
//On calcule la valeur initiale de dest:
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos+Screen_pixels;
|
||||
|
||||
int x;
|
||||
|
||||
for (x=0;x<width;x++)
|
||||
*(dest+x)=~*(dest+x);
|
||||
|
||||
dest=(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH+x_pos+Screen_pixels;
|
||||
for (x=0;x<width;x++)
|
||||
*(dest+x)=~*(dest+x);
|
||||
}
|
||||
|
||||
void Vertical_XOR_line_tall(word x_pos,word y_pos,word height)
|
||||
{
|
||||
int i;
|
||||
byte color;
|
||||
for (i=y_pos*ZOOMY;i<(y_pos+height)*ZOOMY;i++)
|
||||
{
|
||||
color=*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH);
|
||||
*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH)=~color;
|
||||
}
|
||||
}
|
||||
|
||||
void Display_brush_color_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos;
|
||||
// src = Position dans la brosse
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*dest = *src;
|
||||
*(dest+VIDEO_LINE_WIDTH) = *src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++; dest++;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + ZOOMY*VIDEO_LINE_WIDTH - width;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_brush_mono_tall(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset, word width, word height,
|
||||
byte transp_color, byte color, word brush_width)
|
||||
/* On affiche la brosse en monochrome */
|
||||
{
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; // dest = adr Destination à
|
||||
// l'écran
|
||||
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
|
||||
// la brosse
|
||||
int x,y;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
//Pour chaque ligne
|
||||
{
|
||||
for(x=width;x!=0;x--)
|
||||
//Pour chaque pixel
|
||||
{
|
||||
if (*src!=transp_color)
|
||||
{
|
||||
*dest=color;
|
||||
*(dest+VIDEO_LINE_WIDTH)=color;
|
||||
}
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest++;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=brush_width-width;
|
||||
dest+=ZOOMY*VIDEO_LINE_WIDTH-width;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Clear_brush_tall(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
|
||||
{
|
||||
byte* dest=Screen_pixels+x_pos+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
// On fait une copie de la ligne
|
||||
memcpy(dest,src,width);
|
||||
dest+=VIDEO_LINE_WIDTH;
|
||||
memcpy(dest,src,width);
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width;
|
||||
dest+=VIDEO_LINE_WIDTH;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
// Affiche une brosse (arbitraire) à l'écran
|
||||
void Display_brush_tall(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos;
|
||||
// src = Position dans la brosse
|
||||
byte* src = brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*dest = *src;
|
||||
*(dest+VIDEO_LINE_WIDTH) = *src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++; dest++;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
}
|
||||
|
||||
void Remap_screen_tall(word x_pos,word y_pos,word width,word height,byte * conversion_table)
|
||||
{
|
||||
// dest = coords a l'écran
|
||||
byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos;
|
||||
int x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y=height*ZOOMY;y>0;y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*dest = conversion_table[*dest];
|
||||
dest ++;
|
||||
}
|
||||
|
||||
dest = dest + VIDEO_LINE_WIDTH - width;
|
||||
}
|
||||
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_tall(word x_pos,word y_pos,word width,byte * line)
|
||||
/* On affiche toute une ligne de pixels. Utilisé pour les textes. */
|
||||
{
|
||||
memcpy(Screen_pixels+x_pos+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width);
|
||||
memcpy(Screen_pixels+x_pos+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width);
|
||||
}
|
||||
|
||||
void Read_line_screen_tall(word x_pos,word y_pos,word width,byte * line)
|
||||
{
|
||||
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY*y_pos + x_pos + Screen_pixels,width);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_scaled_tall(
|
||||
word width, // width non zoomée
|
||||
word height, // height zoomée
|
||||
word image_width,byte * buffer)
|
||||
{
|
||||
byte* src = Main_screen + Main_magnifier_offset_Y * image_width
|
||||
+ Main_magnifier_offset_X;
|
||||
int y = 0; // Ligne en cours de traitement
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1)
|
||||
{
|
||||
int x;
|
||||
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
// On l'affiche Facteur fois, sur des lignes consécutives
|
||||
x = Main_magnifier_factor*ZOOMY;
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
// On affiche la ligne zoomée
|
||||
Display_line_on_screen_simple(
|
||||
Main_X_zoom, y, width*Main_magnifier_factor,
|
||||
buffer
|
||||
);
|
||||
// On passe à la suivante
|
||||
y++;
|
||||
if(y==height*ZOOMY)
|
||||
{
|
||||
Redraw_grid(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
Update_rect(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
return;
|
||||
}
|
||||
x--;
|
||||
}while (x > 0);
|
||||
src += image_width;
|
||||
}
|
||||
// ATTENTION on n'arrive jamais ici !
|
||||
}
|
||||
|
||||
// Affiche une partie de la brosse couleur zoomée
|
||||
void Display_brush_color_zoom_tall(word x_pos,word y_pos,
|
||||
word x_offset,word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,byte transp_color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer)
|
||||
{
|
||||
byte* src = Brush+y_offset*brush_width + x_offset;
|
||||
word y = y_pos;
|
||||
byte bx;
|
||||
|
||||
// Pour chaque ligne
|
||||
while(1)
|
||||
{
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
// On affiche facteur fois la ligne zoomée
|
||||
for(bx=Main_magnifier_factor;bx>0;bx--)
|
||||
{
|
||||
Display_transparent_line_on_screen_simple(x_pos,y*ZOOMY,width*Main_magnifier_factor,buffer,transp_color);
|
||||
memcpy(Screen_pixels + (y*ZOOMY +1) * VIDEO_LINE_WIDTH + x_pos, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos, width*Main_magnifier_factor);
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
src += brush_width;
|
||||
}
|
||||
// ATTENTION zone jamais atteinte
|
||||
}
|
||||
|
||||
void Display_brush_mono_zoom_tall(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,
|
||||
byte transp_color, byte color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer
|
||||
)
|
||||
|
||||
{
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
int y=y_pos*ZOOMY;
|
||||
|
||||
//Pour chaque ligne à zoomer :
|
||||
while(1)
|
||||
{
|
||||
int bx;
|
||||
// src = Ligne originale
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
|
||||
// On affiche la ligne Facteur fois à l'écran (sur des
|
||||
// lignes consécutives)
|
||||
bx = Main_magnifier_factor*ZOOMY;
|
||||
|
||||
// Pour chaque ligne écran
|
||||
do
|
||||
{
|
||||
// On affiche la ligne zoomée
|
||||
Display_transparent_mono_line_on_screen_simple(
|
||||
x_pos, y, width * Main_magnifier_factor,
|
||||
buffer, transp_color, color
|
||||
);
|
||||
// On passe à la ligne suivante
|
||||
y++;
|
||||
// On vérifie qu'on est pas à la ligne finale
|
||||
if(y == end_y_pos*ZOOMY)
|
||||
{
|
||||
Redraw_grid( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
Update_rect( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
return;
|
||||
}
|
||||
bx --;
|
||||
}
|
||||
while (bx > 0);
|
||||
|
||||
// Passage à la ligne suivante dans la brosse aussi
|
||||
src+=brush_width;
|
||||
}
|
||||
}
|
||||
|
||||
void Clear_brush_scaled_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
|
||||
{
|
||||
// En fait on va recopier l'image non zoomée dans la partie zoomée !
|
||||
byte* src = Main_screen + y_offset * image_width + x_offset;
|
||||
int y = y_pos;
|
||||
int bx;
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1){
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
|
||||
bx=Main_magnifier_factor;
|
||||
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
Display_line_on_screen_tall(x_pos,y,
|
||||
width * Main_magnifier_factor,buffer);
|
||||
|
||||
// Ligne suivante
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
Redraw_grid(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
Update_rect(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
return;
|
||||
}
|
||||
bx--;
|
||||
}while(bx!=0);
|
||||
|
||||
src+= image_width;
|
||||
}
|
||||
}
|
||||
48
src/pxtall.h
Normal file
48
src/pxtall.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 pxtall.h
|
||||
/// Renderer for tall pixels (1x2).
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
void Pixel_tall (word x,word y,byte color);
|
||||
byte Read_pixel_tall (word x,word y);
|
||||
void Block_tall (word start_x,word start_y,word width,word height,byte color);
|
||||
void Pixel_preview_normal_tall (word x,word y,byte color);
|
||||
void Pixel_preview_magnifier_tall (word x,word y,byte color);
|
||||
void Horizontal_XOR_line_tall (word x_pos,word y_pos,word width);
|
||||
void Vertical_XOR_line_tall (word x_pos,word y_pos,word height);
|
||||
void Display_brush_color_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
void Display_brush_mono_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
|
||||
void Clear_brush_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
|
||||
void Remap_screen_tall (word x_pos,word y_pos,word width,word height,byte * conversion_table);
|
||||
void Display_part_of_screen_tall (word width,word height,word image_width);
|
||||
void Display_line_on_screen_tall (word x_pos,word y_pos,word width,byte * line);
|
||||
void Read_line_screen_tall (word x_pos,word y_pos,word width,byte * line);
|
||||
void Display_part_of_screen_scaled_tall(word width,word height,word image_width,byte * buffer);
|
||||
void Display_brush_color_zoom_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
|
||||
void Display_brush_mono_zoom_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
|
||||
void Clear_brush_scaled_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
|
||||
void Display_brush_tall (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
537
src/pxtall2.c
Normal file
537
src/pxtall2.c
Normal file
@@ -0,0 +1,537 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <SDL.h>
|
||||
#include "global.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "misc.h"
|
||||
#include "graph.h"
|
||||
#include "pxtall2.h"
|
||||
|
||||
#define ZOOMX 2
|
||||
#define ZOOMY 4
|
||||
|
||||
#ifdef __VBCC__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
void Pixel_tall2 (word x,word y,byte color)
|
||||
/* Affiche un pixel de la color aux coords x;y à l'écran */
|
||||
{
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 1)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 1)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 1)=color;
|
||||
}
|
||||
|
||||
byte Read_pixel_tall2 (word x,word y)
|
||||
/* On retourne la couleur du pixel aux coords données */
|
||||
{
|
||||
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
|
||||
}
|
||||
|
||||
void Block_tall2 (word start_x,word start_y,word width,word height,byte color)
|
||||
/* On affiche un rectangle de la couleur donnée */
|
||||
{
|
||||
SDL_Rect rectangle;
|
||||
rectangle.x=start_x*ZOOMX;
|
||||
rectangle.y=start_y*ZOOMY;
|
||||
rectangle.w=width*ZOOMX;
|
||||
rectangle.h=height*ZOOMY;
|
||||
SDL_FillRect(Screen_SDL,&rectangle,color);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_tall2 (word width,word height,word image_width)
|
||||
/* Afficher une partie de l'image telle quelle sur l'écran */
|
||||
{
|
||||
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
int dy;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
// On fait une copie de la ligne
|
||||
for (dy=width;dy>0;dy--)
|
||||
{
|
||||
*(dest+1)=*dest=*src;
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
// On double la ligne qu'on vient de copier
|
||||
memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
|
||||
// On la triple
|
||||
memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
|
||||
// On la quadruple
|
||||
memcpy(dest-width*ZOOMX+3*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
}
|
||||
//Update_rect(0,0,width,height);
|
||||
}
|
||||
|
||||
void Pixel_preview_normal_tall2 (word x,word y,byte color)
|
||||
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
|
||||
* dans l'écran, en mode normal (pas en mode loupe)
|
||||
* Note: si on modifie cette procédure, il faudra penser à faire également
|
||||
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */
|
||||
{
|
||||
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
|
||||
Pixel_tall2(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
}
|
||||
|
||||
void Pixel_preview_magnifier_tall2 (word x,word y,byte color)
|
||||
{
|
||||
// Affiche le pixel dans la partie non zoomée
|
||||
Pixel_tall2(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
|
||||
// Regarde si on doit aussi l'afficher dans la partie zoomée
|
||||
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
|
||||
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
|
||||
{
|
||||
// On est dedans
|
||||
int height;
|
||||
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
|
||||
|
||||
if (Menu_Y - y_zoom < Main_magnifier_factor)
|
||||
// On ne doit dessiner qu'un morceau du pixel
|
||||
// sinon on dépasse sur le menu
|
||||
height = Menu_Y - y_zoom;
|
||||
else
|
||||
height = Main_magnifier_factor;
|
||||
|
||||
Block_tall2(
|
||||
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
|
||||
y_zoom, Main_magnifier_factor, height, color
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void Horizontal_XOR_line_tall2(word x_pos,word y_pos,word width)
|
||||
{
|
||||
//On calcule la valeur initiale de dest:
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
|
||||
|
||||
int x;
|
||||
|
||||
for (x=0;x<width*ZOOMX;x+=ZOOMX)
|
||||
*(dest+x+3*VIDEO_LINE_WIDTH+1)=*(dest+x+3*VIDEO_LINE_WIDTH)=*(dest+x+2*VIDEO_LINE_WIDTH+1)=*(dest+x+2*VIDEO_LINE_WIDTH)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+1)=*(dest+x)=~*(dest+x);
|
||||
}
|
||||
|
||||
void Vertical_XOR_line_tall2(word x_pos,word y_pos,word height)
|
||||
{
|
||||
int i;
|
||||
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
|
||||
for (i=height;i>0;i--)
|
||||
{
|
||||
*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=~*(dest);
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY;
|
||||
}
|
||||
}
|
||||
|
||||
void Display_brush_color_tall2(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
// src = Position dans la brosse
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*(dest+3*VIDEO_LINE_WIDTH+1) = *(dest+3*VIDEO_LINE_WIDTH) = *(dest+2*VIDEO_LINE_WIDTH+1) = *(dest+2*VIDEO_LINE_WIDTH) = *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+1) = *dest = *src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_brush_mono_tall2(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset, word width, word height,
|
||||
byte transp_color, byte color, word brush_width)
|
||||
/* On affiche la brosse en monochrome */
|
||||
{
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à
|
||||
// l'écran
|
||||
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
|
||||
// la brosse
|
||||
int x,y;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
//Pour chaque ligne
|
||||
{
|
||||
for(x=width;x!=0;x--)
|
||||
//Pour chaque pixel
|
||||
{
|
||||
if (*src!=transp_color)
|
||||
*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=color;
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=brush_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Clear_brush_tall2(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
|
||||
{
|
||||
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
int x;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
for(x=width;x!=0;x--)
|
||||
//Pour chaque pixel
|
||||
{
|
||||
*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=*src;
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
// Affiche une brosse (arbitraire) à l'écran
|
||||
void Display_brush_tall2(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
// src = Position dans la brosse
|
||||
byte* src = brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=*src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++; dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
}
|
||||
|
||||
void Remap_screen_tall2(word x_pos,word y_pos,word width,word height,byte * conversion_table)
|
||||
{
|
||||
// dest = coords a l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
int x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y=height;y>0;y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=
|
||||
conversion_table[*dest];
|
||||
dest +=ZOOMX;
|
||||
}
|
||||
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
}
|
||||
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_fast_tall2(word x_pos,word y_pos,word width,byte * line)
|
||||
/* On affiche toute une ligne de pixels telle quelle. */
|
||||
/* Utilisée si le buffer contient déja des pixel doublés. */
|
||||
{
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+2)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+3)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_tall2(word x_pos,word y_pos,word width,byte * line)
|
||||
/* On affiche une ligne de pixels en les doublant. */
|
||||
{
|
||||
int x;
|
||||
byte *dest;
|
||||
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=*line;
|
||||
dest+=ZOOMX;
|
||||
line++;
|
||||
}
|
||||
}
|
||||
void Display_transparent_mono_line_on_screen_tall2(
|
||||
word x_pos, word y_pos, word width, byte* line,
|
||||
byte transp_color, byte color)
|
||||
// Affiche une ligne à l'écran avec une couleur + transparence.
|
||||
// Utilisé par les brosses en mode zoom
|
||||
{
|
||||
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
|
||||
int x;
|
||||
// Pour chaque pixel
|
||||
for(x=0;x<width;x++)
|
||||
{
|
||||
if (transp_color!=*line)
|
||||
{
|
||||
*(dest+1)=*dest=color;
|
||||
}
|
||||
line ++; // Pixel suivant
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
}
|
||||
|
||||
void Read_line_screen_tall2(word x_pos,word y_pos,word width,byte * line)
|
||||
{
|
||||
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_scaled_tall2(
|
||||
word width, // width non zoomée
|
||||
word height, // height zoomée
|
||||
word image_width,byte * buffer)
|
||||
{
|
||||
byte* src = Main_screen + Main_magnifier_offset_Y * image_width
|
||||
+ Main_magnifier_offset_X;
|
||||
int y = 0; // Ligne en cours de traitement
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1)
|
||||
{
|
||||
int x;
|
||||
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
|
||||
// On l'affiche Facteur fois, sur des lignes consécutives
|
||||
x = Main_magnifier_factor/**ZOOMY*/;
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
// On affiche la ligne zoomée
|
||||
Display_line_on_screen_fast_tall2(
|
||||
Main_X_zoom, y, width*Main_magnifier_factor,
|
||||
buffer
|
||||
);
|
||||
// On passe à la suivante
|
||||
y++;
|
||||
if(y==height/**ZOOMY*/)
|
||||
{
|
||||
Redraw_grid(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
Update_rect(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
return;
|
||||
}
|
||||
x--;
|
||||
}while (x > 0);
|
||||
src += image_width;
|
||||
}
|
||||
// ATTENTION on n'arrive jamais ici !
|
||||
}
|
||||
|
||||
// Affiche une partie de la brosse couleur zoomée
|
||||
void Display_brush_color_zoom_tall2(word x_pos,word y_pos,
|
||||
word x_offset,word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,byte transp_color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer)
|
||||
{
|
||||
byte* src = Brush+y_offset*brush_width + x_offset;
|
||||
word y = y_pos;
|
||||
byte bx;
|
||||
|
||||
// Pour chaque ligne
|
||||
while(1)
|
||||
{
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
// On affiche facteur fois la ligne zoomée
|
||||
for(bx=Main_magnifier_factor;bx>0;bx--)
|
||||
{
|
||||
byte* line_src = buffer;
|
||||
byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
word x;
|
||||
// Pour chaque pixel de la ligne
|
||||
for(x = width*Main_magnifier_factor;x > 0;x--)
|
||||
{
|
||||
if(*line_src!=transp_color)
|
||||
{
|
||||
*(dest+1)=*dest = *line_src;
|
||||
}
|
||||
line_src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
// Double the line
|
||||
memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
|
||||
// Triple the line
|
||||
memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
|
||||
// Quadruple it
|
||||
memcpy(Screen_pixels + (y*ZOOMY+3)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
src += brush_width;
|
||||
}
|
||||
// ATTENTION zone jamais atteinte
|
||||
}
|
||||
|
||||
void Display_brush_mono_zoom_tall2(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,
|
||||
byte transp_color, byte color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer
|
||||
)
|
||||
|
||||
{
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
int y=y_pos*ZOOMY;
|
||||
|
||||
//Pour chaque ligne à zoomer :
|
||||
while(1)
|
||||
{
|
||||
int bx;
|
||||
// src = Ligne originale
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
|
||||
// On affiche la ligne Facteur fois à l'écran (sur des
|
||||
// lignes consécutives)
|
||||
bx = Main_magnifier_factor*ZOOMY;
|
||||
|
||||
// Pour chaque ligne écran
|
||||
do
|
||||
{
|
||||
// On affiche la ligne zoomée
|
||||
Display_transparent_mono_line_on_screen_tall2(
|
||||
x_pos, y, width * Main_magnifier_factor,
|
||||
buffer, transp_color, color
|
||||
);
|
||||
// On passe à la ligne suivante
|
||||
y++;
|
||||
// On vérifie qu'on est pas à la ligne finale
|
||||
if(y == end_y_pos*ZOOMY)
|
||||
{
|
||||
Redraw_grid( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
Update_rect( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
return;
|
||||
}
|
||||
bx --;
|
||||
}
|
||||
while (bx > 0);
|
||||
|
||||
// Passage à la ligne suivante dans la brosse aussi
|
||||
src+=brush_width;
|
||||
}
|
||||
}
|
||||
|
||||
void Clear_brush_scaled_tall2(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
|
||||
{
|
||||
|
||||
// En fait on va recopier l'image non zoomée dans la partie zoomée !
|
||||
byte* src = Main_screen + y_offset * image_width + x_offset;
|
||||
int y = y_pos;
|
||||
int bx;
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1){
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
|
||||
|
||||
bx=Main_magnifier_factor;
|
||||
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
// TODO a verifier
|
||||
Display_line_on_screen_fast_tall2(x_pos,y,
|
||||
width * Main_magnifier_factor,buffer);
|
||||
|
||||
// Ligne suivante
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
Redraw_grid(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
Update_rect(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
return;
|
||||
}
|
||||
bx--;
|
||||
}while(bx!=0);
|
||||
|
||||
src+= image_width;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
50
src/pxtall2.h
Normal file
50
src/pxtall2.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 pxtall2.h
|
||||
/// Renderer for double-tall pixels (2x4).
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
void Pixel_tall2 (word x,word y,byte color);
|
||||
byte Read_pixel_tall2 (word x,word y);
|
||||
void Block_tall2 (word start_x,word start_y,word width,word height,byte color);
|
||||
void Pixel_preview_normal_tall2 (word x,word y,byte color);
|
||||
void Pixel_preview_magnifier_tall2 (word x,word y,byte color);
|
||||
void Horizontal_XOR_line_tall2 (word x_pos,word y_pos,word width);
|
||||
void Vertical_XOR_line_tall2 (word x_pos,word y_pos,word height);
|
||||
void Display_brush_color_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
void Display_brush_mono_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
|
||||
void Clear_brush_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
|
||||
void Remap_screen_tall2 (word x_pos,word y_pos,word width,word height,byte * conversion_table);
|
||||
void Display_part_of_screen_tall2 (word width,word height,word image_width);
|
||||
void Display_line_on_screen_tall2 (word x_pos,word y_pos,word width,byte * line);
|
||||
void Read_line_screen_tall2 (word x_pos,word y_pos,word width,byte * line);
|
||||
void Display_part_of_screen_scaled_tall2(word width,word height,word image_width,byte * buffer);
|
||||
void Display_brush_color_zoom_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
|
||||
void Display_brush_mono_zoom_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
|
||||
void Clear_brush_scaled_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
|
||||
void Display_brush_tall2 (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
|
||||
void Display_line_on_screen_fast_tall2 (word x_pos,word y_pos,word width,byte * line);
|
||||
533
src/pxtriple.c
Normal file
533
src/pxtriple.c
Normal file
@@ -0,0 +1,533 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <SDL.h>
|
||||
#include "global.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "misc.h"
|
||||
#include "graph.h"
|
||||
#include "pxtriple.h"
|
||||
|
||||
#define ZOOMX 3
|
||||
#define ZOOMY 3
|
||||
|
||||
#ifdef __VBCC__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
void Pixel_triple (word x,word y,byte color)
|
||||
/* Affiche un pixel de la color aux coords x;y à l'écran */
|
||||
{
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 2)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 1)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 2)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 1)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 2)=color;
|
||||
}
|
||||
|
||||
byte Read_pixel_triple (word x,word y)
|
||||
/* On retourne la couleur du pixel aux coords données */
|
||||
{
|
||||
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
|
||||
}
|
||||
|
||||
void Block_triple (word start_x,word start_y,word width,word height,byte color)
|
||||
/* On affiche un rectangle de la couleur donnée */
|
||||
{
|
||||
SDL_Rect rectangle;
|
||||
rectangle.x=start_x*ZOOMX;
|
||||
rectangle.y=start_y*ZOOMY;
|
||||
rectangle.w=width*ZOOMX;
|
||||
rectangle.h=height*ZOOMY;
|
||||
SDL_FillRect(Screen_SDL,&rectangle,color);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_triple (word width,word height,word image_width)
|
||||
/* Afficher une partie de l'image telle quelle sur l'écran */
|
||||
{
|
||||
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
int dy;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
// On fait une copie de la ligne
|
||||
for (dy=width;dy>0;dy--)
|
||||
{
|
||||
*(dest+2)=*(dest+1)=*dest=*src;
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
// On double la ligne qu'on vient de copier
|
||||
memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
|
||||
// On la triple
|
||||
memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
}
|
||||
//Update_rect(0,0,width,height);
|
||||
}
|
||||
|
||||
void Pixel_preview_normal_triple (word x,word y,byte color)
|
||||
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
|
||||
* dans l'écran, en mode normal (pas en mode loupe)
|
||||
* Note: si on modifie cette procédure, il faudra penser à faire également
|
||||
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */
|
||||
{
|
||||
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
|
||||
Pixel_triple(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
}
|
||||
|
||||
void Pixel_preview_magnifier_triple (word x,word y,byte color)
|
||||
{
|
||||
// Affiche le pixel dans la partie non zoomée
|
||||
Pixel_triple(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
|
||||
// Regarde si on doit aussi l'afficher dans la partie zoomée
|
||||
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
|
||||
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
|
||||
{
|
||||
// On est dedans
|
||||
int height;
|
||||
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
|
||||
|
||||
if (Menu_Y - y_zoom < Main_magnifier_factor)
|
||||
// On ne doit dessiner qu'un morceau du pixel
|
||||
// sinon on dépasse sur le menu
|
||||
height = Menu_Y - y_zoom;
|
||||
else
|
||||
height = Main_magnifier_factor;
|
||||
|
||||
Block_triple(
|
||||
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
|
||||
y_zoom, Main_magnifier_factor, height, color
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void Horizontal_XOR_line_triple(word x_pos,word y_pos,word width)
|
||||
{
|
||||
//On calcule la valeur initiale de dest:
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
|
||||
|
||||
int x;
|
||||
|
||||
for (x=0;x<width*ZOOMX;x+=ZOOMX)
|
||||
*(dest+x+2*VIDEO_LINE_WIDTH+2)=*(dest+x+2*VIDEO_LINE_WIDTH+1)=*(dest+x+2*VIDEO_LINE_WIDTH)=*(dest+x+VIDEO_LINE_WIDTH+2)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+2)=*(dest+x+1)=*(dest+x)=~*(dest+x);
|
||||
}
|
||||
|
||||
void Vertical_XOR_line_triple(word x_pos,word y_pos,word height)
|
||||
{
|
||||
int i;
|
||||
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
|
||||
for (i=height;i>0;i--)
|
||||
{
|
||||
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=~*dest;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY;
|
||||
}
|
||||
}
|
||||
|
||||
void Display_brush_color_triple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
// src = Position dans la brosse
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*(dest+2*VIDEO_LINE_WIDTH+2) = *(dest+2*VIDEO_LINE_WIDTH+1) = *(dest+2*VIDEO_LINE_WIDTH) = *(dest+VIDEO_LINE_WIDTH+2) = *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+2) = *(dest+1) = *dest = *src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_brush_mono_triple(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset, word width, word height,
|
||||
byte transp_color, byte color, word brush_width)
|
||||
/* On affiche la brosse en monochrome */
|
||||
{
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à
|
||||
// l'écran
|
||||
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
|
||||
// la brosse
|
||||
int x,y;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
//Pour chaque ligne
|
||||
{
|
||||
for(x=width;x!=0;x--)
|
||||
//Pour chaque pixel
|
||||
{
|
||||
if (*src!=transp_color)
|
||||
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=color;
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=brush_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Clear_brush_triple(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
|
||||
{
|
||||
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
int x;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
for(x=width;x!=0;x--)
|
||||
//Pour chaque pixel
|
||||
{
|
||||
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*src;
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
// Affiche une brosse (arbitraire) à l'écran
|
||||
void Display_brush_triple(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
// src = Position dans la brosse
|
||||
byte* src = brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++; dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
}
|
||||
|
||||
void Remap_screen_triple(word x_pos,word y_pos,word width,word height,byte * conversion_table)
|
||||
{
|
||||
// dest = coords a l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
int x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y=height;y>0;y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=
|
||||
conversion_table[*dest];
|
||||
dest +=ZOOMX;
|
||||
}
|
||||
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
}
|
||||
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_fast_triple(word x_pos,word y_pos,word width,byte * line)
|
||||
/* On affiche toute une ligne de pixels telle quelle. */
|
||||
/* Utilisée si le buffer contient déja des pixel doublés. */
|
||||
{
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+2)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_triple(word x_pos,word y_pos,word width,byte * line)
|
||||
/* On affiche une ligne de pixels en les doublant. */
|
||||
{
|
||||
int x;
|
||||
byte *dest;
|
||||
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*line;
|
||||
dest+=ZOOMX;
|
||||
line++;
|
||||
}
|
||||
}
|
||||
void Display_transparent_mono_line_on_screen_triple(
|
||||
word x_pos, word y_pos, word width, byte* line,
|
||||
byte transp_color, byte color)
|
||||
// Affiche une ligne à l'écran avec une couleur + transparence.
|
||||
// Utilisé par les brosses en mode zoom
|
||||
{
|
||||
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
|
||||
int x;
|
||||
// Pour chaque pixel
|
||||
for(x=0;x<width;x++)
|
||||
{
|
||||
if (transp_color!=*line)
|
||||
{
|
||||
*(dest+2)=*(dest+1)=*dest=color;
|
||||
}
|
||||
line ++; // Pixel suivant
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
}
|
||||
|
||||
void Read_line_screen_triple(word x_pos,word y_pos,word width,byte * line)
|
||||
{
|
||||
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_scaled_triple(
|
||||
word width, // width non zoomée
|
||||
word height, // height zoomée
|
||||
word image_width,byte * buffer)
|
||||
{
|
||||
byte* src = Main_screen + Main_magnifier_offset_Y * image_width
|
||||
+ Main_magnifier_offset_X;
|
||||
int y = 0; // Ligne en cours de traitement
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1)
|
||||
{
|
||||
int x;
|
||||
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
|
||||
// On l'affiche Facteur fois, sur des lignes consécutives
|
||||
x = Main_magnifier_factor/**ZOOMY*/;
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
// On affiche la ligne zoomée
|
||||
Display_line_on_screen_fast_triple(
|
||||
Main_X_zoom, y, width*Main_magnifier_factor,
|
||||
buffer
|
||||
);
|
||||
// On passe à la suivante
|
||||
y++;
|
||||
if(y==height/**ZOOMY*/)
|
||||
{
|
||||
Redraw_grid(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
Update_rect(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
return;
|
||||
}
|
||||
x--;
|
||||
}while (x > 0);
|
||||
src += image_width;
|
||||
}
|
||||
// ATTENTION on n'arrive jamais ici !
|
||||
}
|
||||
|
||||
// Affiche une partie de la brosse couleur zoomée
|
||||
void Display_brush_color_zoom_triple(word x_pos,word y_pos,
|
||||
word x_offset,word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,byte transp_color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer)
|
||||
{
|
||||
byte* src = Brush+y_offset*brush_width + x_offset;
|
||||
word y = y_pos;
|
||||
byte bx;
|
||||
|
||||
// Pour chaque ligne
|
||||
while(1)
|
||||
{
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
// On affiche facteur fois la ligne zoomée
|
||||
for(bx=Main_magnifier_factor;bx>0;bx--)
|
||||
{
|
||||
byte* line_src = buffer;
|
||||
byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
word x;
|
||||
// Pour chaque pixel de la ligne
|
||||
for(x = width*Main_magnifier_factor;x > 0;x--)
|
||||
{
|
||||
if(*line_src!=transp_color)
|
||||
{
|
||||
*(dest+2)=*(dest+1)=*dest = *line_src;
|
||||
}
|
||||
line_src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
// Double the line
|
||||
memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
|
||||
// Triple the line
|
||||
memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
src += brush_width;
|
||||
}
|
||||
// ATTENTION zone jamais atteinte
|
||||
}
|
||||
|
||||
void Display_brush_mono_zoom_triple(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,
|
||||
byte transp_color, byte color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer
|
||||
)
|
||||
|
||||
{
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
int y=y_pos*ZOOMY;
|
||||
|
||||
//Pour chaque ligne à zoomer :
|
||||
while(1)
|
||||
{
|
||||
int bx;
|
||||
// src = Ligne originale
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
|
||||
// On affiche la ligne Facteur fois à l'écran (sur des
|
||||
// lignes consécutives)
|
||||
bx = Main_magnifier_factor*ZOOMY;
|
||||
|
||||
// Pour chaque ligne écran
|
||||
do
|
||||
{
|
||||
// On affiche la ligne zoomée
|
||||
Display_transparent_mono_line_on_screen_triple(
|
||||
x_pos, y, width * Main_magnifier_factor,
|
||||
buffer, transp_color, color
|
||||
);
|
||||
// On passe à la ligne suivante
|
||||
y++;
|
||||
// On vérifie qu'on est pas à la ligne finale
|
||||
if(y == end_y_pos*ZOOMY)
|
||||
{
|
||||
Redraw_grid( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
Update_rect( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
return;
|
||||
}
|
||||
bx --;
|
||||
}
|
||||
while (bx > 0);
|
||||
|
||||
// Passage à la ligne suivante dans la brosse aussi
|
||||
src+=brush_width;
|
||||
}
|
||||
}
|
||||
|
||||
void Clear_brush_scaled_triple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
|
||||
{
|
||||
|
||||
// En fait on va recopier l'image non zoomée dans la partie zoomée !
|
||||
byte* src = Main_screen + y_offset * image_width + x_offset;
|
||||
int y = y_pos;
|
||||
int bx;
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1){
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
|
||||
|
||||
bx=Main_magnifier_factor;
|
||||
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
// TODO a verifier
|
||||
Display_line_on_screen_fast_triple(x_pos,y,
|
||||
width * Main_magnifier_factor,buffer);
|
||||
|
||||
// Ligne suivante
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
Redraw_grid(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
Update_rect(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
return;
|
||||
}
|
||||
bx--;
|
||||
}while(bx!=0);
|
||||
|
||||
src+= image_width;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
50
src/pxtriple.h
Normal file
50
src/pxtriple.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 pxtriple.h
|
||||
/// Renderer for triple pixels (3x3).
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
void Pixel_triple (word x,word y,byte color);
|
||||
byte Read_pixel_triple (word x,word y);
|
||||
void Block_triple (word start_x,word start_y,word width,word height,byte color);
|
||||
void Pixel_preview_normal_triple (word x,word y,byte color);
|
||||
void Pixel_preview_magnifier_triple (word x,word y,byte color);
|
||||
void Horizontal_XOR_line_triple (word x_pos,word y_pos,word width);
|
||||
void Vertical_XOR_line_triple (word x_pos,word y_pos,word height);
|
||||
void Display_brush_color_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
void Display_brush_mono_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
|
||||
void Clear_brush_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
|
||||
void Remap_screen_triple (word x_pos,word y_pos,word width,word height,byte * conversion_table);
|
||||
void Display_part_of_screen_triple (word width,word height,word image_width);
|
||||
void Display_line_on_screen_triple (word x_pos,word y_pos,word width,byte * line);
|
||||
void Read_line_screen_triple (word x_pos,word y_pos,word width,byte * line);
|
||||
void Display_part_of_screen_scaled_triple(word width,word height,word image_width,byte * buffer);
|
||||
void Display_brush_color_zoom_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
|
||||
void Display_brush_mono_zoom_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
|
||||
void Clear_brush_scaled_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
|
||||
void Display_brush_triple (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
|
||||
void Display_line_on_screen_fast_triple (word x_pos,word y_pos,word width,byte * line);
|
||||
519
src/pxwide.c
Normal file
519
src/pxwide.c
Normal file
@@ -0,0 +1,519 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <SDL.h>
|
||||
#include "global.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "misc.h"
|
||||
#include "graph.h"
|
||||
#include "pxwide.h"
|
||||
|
||||
#define ZOOMX 2
|
||||
#define ZOOMY 1
|
||||
|
||||
#ifdef __VBCC__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
void Pixel_wide (word x,word y,byte color)
|
||||
/* Affiche un pixel de la color aux coords x;y à l'écran */
|
||||
{
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
|
||||
}
|
||||
|
||||
byte Read_pixel_wide (word x,word y)
|
||||
/* On retourne la couleur du pixel aux coords données */
|
||||
{
|
||||
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
|
||||
}
|
||||
|
||||
void Block_wide (word start_x,word start_y,word width,word height,byte color)
|
||||
/* On affiche un rectangle de la couleur donnée */
|
||||
{
|
||||
SDL_Rect rectangle;
|
||||
rectangle.x=start_x*ZOOMX;
|
||||
rectangle.y=start_y*ZOOMY;
|
||||
rectangle.w=width*ZOOMX;
|
||||
rectangle.h=height*ZOOMY;
|
||||
SDL_FillRect(Screen_SDL,&rectangle,color);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_wide (word width,word height,word image_width)
|
||||
/* Afficher une partie de l'image telle quelle sur l'écran */
|
||||
{
|
||||
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
int dy;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
// On fait une copie de la ligne
|
||||
for (dy=width;dy>0;dy--)
|
||||
{
|
||||
*(dest+1)=*dest=*src;
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
}
|
||||
//Update_rect(0,0,width,height);
|
||||
}
|
||||
|
||||
void Pixel_preview_normal_wide (word x,word y,byte color)
|
||||
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
|
||||
* dans l'écran, en mode normal (pas en mode loupe)
|
||||
* Note: si on modifie cette procédure, il faudra penser à faire également
|
||||
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */
|
||||
{
|
||||
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
|
||||
Pixel_wide(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
}
|
||||
|
||||
void Pixel_preview_magnifier_wide (word x,word y,byte color)
|
||||
{
|
||||
// Affiche le pixel dans la partie non zoomée
|
||||
Pixel_wide(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
|
||||
// Regarde si on doit aussi l'afficher dans la partie zoomée
|
||||
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
|
||||
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
|
||||
{
|
||||
// On est dedans
|
||||
int height;
|
||||
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
|
||||
|
||||
if (Menu_Y - y_zoom < Main_magnifier_factor)
|
||||
// On ne doit dessiner qu'un morceau du pixel
|
||||
// sinon on dépasse sur le menu
|
||||
height = Menu_Y - y_zoom;
|
||||
else
|
||||
height = Main_magnifier_factor;
|
||||
|
||||
Block_wide(
|
||||
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
|
||||
y_zoom, Main_magnifier_factor, height, color
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void Horizontal_XOR_line_wide(word x_pos,word y_pos,word width)
|
||||
{
|
||||
//On calcule la valeur initiale de dest:
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
|
||||
|
||||
int x;
|
||||
|
||||
for (x=0;x<width*ZOOMX;x+=ZOOMX)
|
||||
*(dest+x+1)=*(dest+x)=~*(dest+x);
|
||||
}
|
||||
|
||||
void Vertical_XOR_line_wide(word x_pos,word y_pos,word height)
|
||||
{
|
||||
int i;
|
||||
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
|
||||
for (i=height;i>0;i--)
|
||||
{
|
||||
*dest=*(dest+1)=~*dest;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY;
|
||||
}
|
||||
}
|
||||
|
||||
void Display_brush_color_wide(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
// src = Position dans la brosse
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*(dest+1) = *dest = *src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_brush_mono_wide(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset, word width, word height,
|
||||
byte transp_color, byte color, word brush_width)
|
||||
/* On affiche la brosse en monochrome */
|
||||
{
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à
|
||||
// l'écran
|
||||
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
|
||||
// la brosse
|
||||
int x,y;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
//Pour chaque ligne
|
||||
{
|
||||
for(x=width;x!=0;x--)
|
||||
//Pour chaque pixel
|
||||
{
|
||||
if (*src!=transp_color)
|
||||
*(dest+1)=*dest=color;
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=brush_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Clear_brush_wide(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
|
||||
{
|
||||
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
int x;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
for(x=width;x!=0;x--)
|
||||
//Pour chaque pixel
|
||||
{
|
||||
*(dest+1)=*dest=*src;
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
// Affiche une brosse (arbitraire) à l'écran
|
||||
void Display_brush_wide(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
// src = Position dans la brosse
|
||||
byte* src = brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*(dest+1) = *dest = *src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++; dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
}
|
||||
|
||||
void Remap_screen_wide(word x_pos,word y_pos,word width,word height,byte * conversion_table)
|
||||
{
|
||||
// dest = coords a l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
int x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y=height;y>0;y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*(dest+1) = *dest = conversion_table[*dest];
|
||||
dest +=ZOOMX;
|
||||
}
|
||||
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
}
|
||||
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_fast_wide(word x_pos,word y_pos,word width,byte * line)
|
||||
/* On affiche toute une ligne de pixels telle quelle. */
|
||||
/* Utilisée si le buffer contient déja des pixel doublés. */
|
||||
{
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_wide(word x_pos,word y_pos,word width,byte * line)
|
||||
/* On affiche une ligne de pixels en les doublant. */
|
||||
{
|
||||
int x;
|
||||
byte *dest;
|
||||
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*(dest+1)=*dest=*line;
|
||||
dest+=ZOOMX;
|
||||
line++;
|
||||
}
|
||||
}
|
||||
void Display_transparent_mono_line_on_screen_wide(
|
||||
word x_pos, word y_pos, word width, byte* line,
|
||||
byte transp_color, byte color)
|
||||
// Affiche une ligne à l'écran avec une couleur + transparence.
|
||||
// Utilisé par les brosses en mode zoom
|
||||
{
|
||||
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
|
||||
int x;
|
||||
// Pour chaque pixel
|
||||
for(x=0;x<width;x++)
|
||||
{
|
||||
if (transp_color!=*line)
|
||||
{
|
||||
*(dest+1)=*dest=color;
|
||||
}
|
||||
line ++; // Pixel suivant
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
}
|
||||
|
||||
void Read_line_screen_wide(word x_pos,word y_pos,word width,byte * line)
|
||||
{
|
||||
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_scaled_wide(
|
||||
word width, // width non zoomée
|
||||
word height, // height zoomée
|
||||
word image_width,byte * buffer)
|
||||
{
|
||||
byte* src = Main_screen + Main_magnifier_offset_Y * image_width
|
||||
+ Main_magnifier_offset_X;
|
||||
int y = 0; // Ligne en cours de traitement
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1)
|
||||
{
|
||||
int x;
|
||||
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
|
||||
// On l'affiche Facteur fois, sur des lignes consécutives
|
||||
x = Main_magnifier_factor;
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
// On affiche la ligne zoomée
|
||||
Display_line_on_screen_fast_wide(
|
||||
Main_X_zoom, y, width*Main_magnifier_factor,
|
||||
buffer
|
||||
);
|
||||
// On passe à la suivante
|
||||
y++;
|
||||
if(y==height)
|
||||
{
|
||||
Redraw_grid(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
Update_rect(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
return;
|
||||
}
|
||||
x--;
|
||||
}while (x > 0);
|
||||
src += image_width;
|
||||
}
|
||||
// ATTENTION on n'arrive jamais ici !
|
||||
}
|
||||
|
||||
void Display_transparent_line_on_screen_wide(word x_pos,word y_pos,word width,byte* line,byte transp_color)
|
||||
{
|
||||
byte* src = line;
|
||||
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
|
||||
word x;
|
||||
|
||||
// Pour chaque pixel de la ligne
|
||||
for(x = width;x > 0;x--)
|
||||
{
|
||||
if(*src!=transp_color)
|
||||
{
|
||||
*(dest+1) = *dest = *src;
|
||||
}
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
}
|
||||
|
||||
// Affiche une partie de la brosse couleur zoomée
|
||||
void Display_brush_color_zoom_wide(word x_pos,word y_pos,
|
||||
word x_offset,word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,byte transp_color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer)
|
||||
{
|
||||
byte* src = Brush+y_offset*brush_width + x_offset;
|
||||
word y = y_pos;
|
||||
byte bx;
|
||||
|
||||
// Pour chaque ligne
|
||||
while(1)
|
||||
{
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
// On affiche facteur fois la ligne zoomée
|
||||
for(bx=Main_magnifier_factor;bx>0;bx--)
|
||||
{
|
||||
Display_transparent_line_on_screen_wide(x_pos,y*ZOOMY,width*Main_magnifier_factor,buffer,transp_color);
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
src += brush_width;
|
||||
}
|
||||
// ATTENTION zone jamais atteinte
|
||||
}
|
||||
|
||||
void Display_brush_mono_zoom_wide(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,
|
||||
byte transp_color, byte color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer
|
||||
)
|
||||
|
||||
{
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
int y=y_pos*ZOOMY;
|
||||
|
||||
//Pour chaque ligne à zoomer :
|
||||
while(1)
|
||||
{
|
||||
int bx;
|
||||
// src = Ligne originale
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
|
||||
// On affiche la ligne Facteur fois à l'écran (sur des
|
||||
// lignes consécutives)
|
||||
bx = Main_magnifier_factor*ZOOMY;
|
||||
|
||||
// Pour chaque ligne écran
|
||||
do
|
||||
{
|
||||
// On affiche la ligne zoomée
|
||||
Display_transparent_mono_line_on_screen_wide(
|
||||
x_pos, y, width * Main_magnifier_factor,
|
||||
buffer, transp_color, color
|
||||
);
|
||||
// On passe à la ligne suivante
|
||||
y++;
|
||||
// On vérifie qu'on est pas à la ligne finale
|
||||
if(y == end_y_pos*ZOOMY)
|
||||
{
|
||||
Redraw_grid( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
Update_rect( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
return;
|
||||
}
|
||||
bx --;
|
||||
}
|
||||
while (bx > 0);
|
||||
|
||||
// Passage à la ligne suivante dans la brosse aussi
|
||||
src+=brush_width;
|
||||
}
|
||||
}
|
||||
|
||||
void Clear_brush_scaled_wide(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
|
||||
{
|
||||
// En fait on va recopier l'image non zoomée dans la partie zoomée !
|
||||
byte* src = Main_screen + y_offset * image_width + x_offset;
|
||||
int y = y_pos;
|
||||
int bx;
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1){
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
|
||||
|
||||
bx=Main_magnifier_factor;
|
||||
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
Display_line_on_screen_fast_wide(x_pos,y,
|
||||
width * Main_magnifier_factor,buffer);
|
||||
|
||||
// Ligne suivante
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
Redraw_grid(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
Update_rect(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
return;
|
||||
}
|
||||
bx--;
|
||||
}while(bx!=0);
|
||||
|
||||
src+= image_width;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
51
src/pxwide.h
Normal file
51
src/pxwide.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 pxwide.h
|
||||
/// Renderer for wide pixels (2x1).
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
void Pixel_wide (word x,word y,byte color);
|
||||
byte Read_pixel_wide (word x,word y);
|
||||
void Block_wide (word start_x,word start_y,word width,word height,byte color);
|
||||
void Pixel_preview_normal_wide (word x,word y,byte color);
|
||||
void Pixel_preview_magnifier_wide (word x,word y,byte color);
|
||||
void Horizontal_XOR_line_wide (word x_pos,word y_pos,word width);
|
||||
void Vertical_XOR_line_wide (word x_pos,word y_pos,word height);
|
||||
void Display_brush_color_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
void Display_brush_mono_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
|
||||
void Clear_brush_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
|
||||
void Remap_screen_wide (word x_pos,word y_pos,word width,word height,byte * conversion_table);
|
||||
void Display_part_of_screen_wide (word width,word height,word image_width);
|
||||
void Display_line_on_screen_wide (word x_pos,word y_pos,word width,byte * line);
|
||||
void Read_line_screen_wide (word x_pos,word y_pos,word width,byte * line);
|
||||
void Display_part_of_screen_scaled_wide(word width,word height,word image_width,byte * buffer);
|
||||
void Display_brush_color_zoom_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
|
||||
void Display_brush_mono_zoom_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
|
||||
void Clear_brush_scaled_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
|
||||
void Display_brush_wide (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
|
||||
void Display_line_on_screen_fast_wide (word x_pos,word y_pos,word width,byte * line);
|
||||
void Display_transparent_line_on_screen_wide(word x_pos,word y_pos,word width,byte* line,byte transp_color);
|
||||
527
src/pxwide2.c
Normal file
527
src/pxwide2.c
Normal file
@@ -0,0 +1,527 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <SDL.h>
|
||||
#include "global.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "misc.h"
|
||||
#include "graph.h"
|
||||
#include "pxwide2.h"
|
||||
|
||||
#define ZOOMX 4
|
||||
#define ZOOMY 2
|
||||
|
||||
#ifdef __VBCC__
|
||||
#define __attribute__(w)
|
||||
#endif
|
||||
|
||||
void Pixel_wide2 (word x,word y,byte color)
|
||||
/* Affiche un pixel de la color aux coords x;y à l'écran */
|
||||
{
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 2)=color;
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 3)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 1)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 2)=color;
|
||||
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 3)=color;
|
||||
}
|
||||
|
||||
byte Read_pixel_wide2 (word x,word y)
|
||||
/* On retourne la couleur du pixel aux coords données */
|
||||
{
|
||||
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
|
||||
}
|
||||
|
||||
void Block_wide2 (word start_x,word start_y,word width,word height,byte color)
|
||||
/* On affiche un rectangle de la couleur donnée */
|
||||
{
|
||||
SDL_Rect rectangle;
|
||||
rectangle.x=start_x*ZOOMX;
|
||||
rectangle.y=start_y*ZOOMY;
|
||||
rectangle.w=width*ZOOMX;
|
||||
rectangle.h=height*ZOOMY;
|
||||
SDL_FillRect(Screen_SDL,&rectangle,color);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_wide2 (word width,word height,word image_width)
|
||||
/* Afficher une partie de l'image telle quelle sur l'écran */
|
||||
{
|
||||
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
int dy;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
// On fait une copie de la ligne
|
||||
for (dy=width;dy>0;dy--)
|
||||
{
|
||||
*(dest+3)=*(dest+2)=*(dest+1)=*dest=*src;
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
// On double la ligne qu'on vient de copier
|
||||
memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
}
|
||||
//Update_rect(0,0,width,height);
|
||||
}
|
||||
|
||||
void Pixel_preview_normal_wide2 (word x,word y,byte color)
|
||||
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
|
||||
* dans l'écran, en mode normal (pas en mode loupe)
|
||||
* Note: si on modifie cette procédure, il faudra penser à faire également
|
||||
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */
|
||||
{
|
||||
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
|
||||
Pixel_wide2(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
}
|
||||
|
||||
void Pixel_preview_magnifier_wide2 (word x,word y,byte color)
|
||||
{
|
||||
// Affiche le pixel dans la partie non zoomée
|
||||
Pixel_wide2(x-Main_offset_X,y-Main_offset_Y,color);
|
||||
|
||||
// Regarde si on doit aussi l'afficher dans la partie zoomée
|
||||
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
|
||||
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
|
||||
{
|
||||
// On est dedans
|
||||
int height;
|
||||
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
|
||||
|
||||
if (Menu_Y - y_zoom < Main_magnifier_factor)
|
||||
// On ne doit dessiner qu'un morceau du pixel
|
||||
// sinon on dépasse sur le menu
|
||||
height = Menu_Y - y_zoom;
|
||||
else
|
||||
height = Main_magnifier_factor;
|
||||
|
||||
Block_wide2(
|
||||
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
|
||||
y_zoom, Main_magnifier_factor, height, color
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void Horizontal_XOR_line_wide2(word x_pos,word y_pos,word width)
|
||||
{
|
||||
//On calcule la valeur initiale de dest:
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
|
||||
|
||||
int x;
|
||||
|
||||
for (x=0;x<width*ZOOMX;x+=ZOOMX)
|
||||
*(dest+x+VIDEO_LINE_WIDTH+3)=*(dest+x+VIDEO_LINE_WIDTH+2)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+3)=*(dest+x+2)=*(dest+x+1)=*(dest+x)=~*(dest+x);
|
||||
}
|
||||
|
||||
void Vertical_XOR_line_wide2(word x_pos,word y_pos,word height)
|
||||
{
|
||||
int i;
|
||||
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
|
||||
for (i=height;i>0;i--)
|
||||
{
|
||||
*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*(dest)=~*(dest);
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY;
|
||||
}
|
||||
}
|
||||
|
||||
void Display_brush_color_wide2(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
// src = Position dans la brosse
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*(dest+VIDEO_LINE_WIDTH+3) = *(dest+VIDEO_LINE_WIDTH+2) = *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = *src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_brush_mono_wide2(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset, word width, word height,
|
||||
byte transp_color, byte color, word brush_width)
|
||||
/* On affiche la brosse en monochrome */
|
||||
{
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à
|
||||
// l'écran
|
||||
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
|
||||
// la brosse
|
||||
int x,y;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
//Pour chaque ligne
|
||||
{
|
||||
for(x=width;x!=0;x--)
|
||||
//Pour chaque pixel
|
||||
{
|
||||
if (*src!=transp_color)
|
||||
*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=color;
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=brush_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Clear_brush_wide2(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
|
||||
{
|
||||
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
int x;
|
||||
|
||||
for(y=height;y!=0;y--)
|
||||
// Pour chaque ligne
|
||||
{
|
||||
for(x=width;x!=0;x--)
|
||||
//Pour chaque pixel
|
||||
{
|
||||
*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*src;
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width-width;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
// Affiche une brosse (arbitraire) à l'écran
|
||||
void Display_brush_wide2(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
// src = Position dans la brosse
|
||||
byte* src = brush + y_offset * brush_width + x_offset;
|
||||
|
||||
word x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y = height;y > 0; y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x = width;x > 0; x--)
|
||||
{
|
||||
// On vérifie que ce n'est pas la transparence
|
||||
if(*src != transp_color)
|
||||
{
|
||||
*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*src;
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++; dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
}
|
||||
|
||||
void Remap_screen_wide2(word x_pos,word y_pos,word width,word height,byte * conversion_table)
|
||||
{
|
||||
// dest = coords a l'écran
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
int x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
for(y=height;y>0;y--)
|
||||
{
|
||||
// Pour chaque pixel
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=
|
||||
conversion_table[*dest];
|
||||
dest +=ZOOMX;
|
||||
}
|
||||
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
}
|
||||
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_fast_wide2(word x_pos,word y_pos,word width,byte * line)
|
||||
/* On affiche toute une ligne de pixels telle quelle. */
|
||||
/* Utilisée si le buffer contient déja des pixel doublés. */
|
||||
{
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_wide2(word x_pos,word y_pos,word width,byte * line)
|
||||
/* On affiche une ligne de pixels en les doublant. */
|
||||
{
|
||||
int x;
|
||||
byte *dest;
|
||||
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*line;
|
||||
dest+=ZOOMX;
|
||||
line++;
|
||||
}
|
||||
}
|
||||
void Display_transparent_mono_line_on_screen_wide2(
|
||||
word x_pos, word y_pos, word width, byte* line,
|
||||
byte transp_color, byte color)
|
||||
// Affiche une ligne à l'écran avec une couleur + transparence.
|
||||
// Utilisé par les brosses en mode zoom
|
||||
{
|
||||
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
|
||||
int x;
|
||||
// Pour chaque pixel
|
||||
for(x=0;x<width;x++)
|
||||
{
|
||||
if (transp_color!=*line)
|
||||
{
|
||||
*(dest+3)=*(dest+2)=*(dest+1)=*dest=color;
|
||||
}
|
||||
line ++; // Pixel suivant
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
}
|
||||
|
||||
void Read_line_screen_wide2(word x_pos,word y_pos,word width,byte * line)
|
||||
{
|
||||
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_scaled_wide2(
|
||||
word width, // width non zoomée
|
||||
word height, // height zoomée
|
||||
word image_width,byte * buffer)
|
||||
{
|
||||
byte* src = Main_screen + Main_magnifier_offset_Y * image_width
|
||||
+ Main_magnifier_offset_X;
|
||||
int y = 0; // Ligne en cours de traitement
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1)
|
||||
{
|
||||
int x;
|
||||
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
|
||||
// On l'affiche Facteur fois, sur des lignes consécutives
|
||||
x = Main_magnifier_factor/**ZOOMY*/;
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
// On affiche la ligne zoomée
|
||||
Display_line_on_screen_fast_wide2(
|
||||
Main_X_zoom, y, width*Main_magnifier_factor,
|
||||
buffer
|
||||
);
|
||||
// On passe à la suivante
|
||||
y++;
|
||||
if(y==height/**ZOOMY*/)
|
||||
{
|
||||
Redraw_grid(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
Update_rect(Main_X_zoom,0,
|
||||
width*Main_magnifier_factor,height);
|
||||
return;
|
||||
}
|
||||
x--;
|
||||
}while (x > 0);
|
||||
src += image_width;
|
||||
}
|
||||
// ATTENTION on n'arrive jamais ici !
|
||||
}
|
||||
|
||||
// Affiche une partie de la brosse couleur zoomée
|
||||
void Display_brush_color_zoom_wide2(word x_pos,word y_pos,
|
||||
word x_offset,word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,byte transp_color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer)
|
||||
{
|
||||
byte* src = Brush+y_offset*brush_width + x_offset;
|
||||
word y = y_pos;
|
||||
byte bx;
|
||||
|
||||
// Pour chaque ligne
|
||||
while(1)
|
||||
{
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
// On affiche facteur fois la ligne zoomée
|
||||
for(bx=Main_magnifier_factor;bx>0;bx--)
|
||||
{
|
||||
byte* line_src = buffer;
|
||||
byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
word x;
|
||||
// Pour chaque pixel de la ligne
|
||||
for(x = width*Main_magnifier_factor;x > 0;x--)
|
||||
{
|
||||
if(*line_src!=transp_color)
|
||||
{
|
||||
*(dest+3)=*(dest+2)=*(dest+1)=*dest = *line_src;
|
||||
}
|
||||
line_src++;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
// Double the line
|
||||
memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
src += brush_width;
|
||||
}
|
||||
// ATTENTION zone jamais atteinte
|
||||
}
|
||||
|
||||
void Display_brush_mono_zoom_wide2(word x_pos, word y_pos,
|
||||
word x_offset, word y_offset,
|
||||
word width, // width non zoomée
|
||||
word end_y_pos,
|
||||
byte transp_color, byte color,
|
||||
word brush_width, // width réelle de la brosse
|
||||
byte * buffer
|
||||
)
|
||||
|
||||
{
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
int y=y_pos*ZOOMY;
|
||||
|
||||
//Pour chaque ligne à zoomer :
|
||||
while(1)
|
||||
{
|
||||
int bx;
|
||||
// src = Ligne originale
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
|
||||
|
||||
// On affiche la ligne Facteur fois à l'écran (sur des
|
||||
// lignes consécutives)
|
||||
bx = Main_magnifier_factor*ZOOMY;
|
||||
|
||||
// Pour chaque ligne écran
|
||||
do
|
||||
{
|
||||
// On affiche la ligne zoomée
|
||||
Display_transparent_mono_line_on_screen_wide2(
|
||||
x_pos, y, width * Main_magnifier_factor,
|
||||
buffer, transp_color, color
|
||||
);
|
||||
// On passe à la ligne suivante
|
||||
y++;
|
||||
// On vérifie qu'on est pas à la ligne finale
|
||||
if(y == end_y_pos*ZOOMY)
|
||||
{
|
||||
Redraw_grid( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
Update_rect( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
return;
|
||||
}
|
||||
bx --;
|
||||
}
|
||||
while (bx > 0);
|
||||
|
||||
// Passage à la ligne suivante dans la brosse aussi
|
||||
src+=brush_width;
|
||||
}
|
||||
}
|
||||
|
||||
void Clear_brush_scaled_wide2(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
|
||||
{
|
||||
|
||||
// En fait on va recopier l'image non zoomée dans la partie zoomée !
|
||||
byte* src = Main_screen + y_offset * image_width + x_offset;
|
||||
int y = y_pos;
|
||||
int bx;
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1){
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
|
||||
|
||||
bx=Main_magnifier_factor;
|
||||
|
||||
// Pour chaque ligne
|
||||
do{
|
||||
// TODO a verifier
|
||||
Display_line_on_screen_fast_wide2(x_pos,y,
|
||||
width * Main_magnifier_factor,buffer);
|
||||
|
||||
// Ligne suivante
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
Redraw_grid(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
Update_rect(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
return;
|
||||
}
|
||||
bx--;
|
||||
}while(bx!=0);
|
||||
|
||||
src+= image_width;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
50
src/pxwide2.h
Normal file
50
src/pxwide2.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 pxwide2.h
|
||||
/// Renderer for double-wide pixels (4x2).
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
void Pixel_wide2 (word x,word y,byte color);
|
||||
byte Read_pixel_wide2 (word x,word y);
|
||||
void Block_wide2 (word start_x,word start_y,word width,word height,byte color);
|
||||
void Pixel_preview_normal_wide2 (word x,word y,byte color);
|
||||
void Pixel_preview_magnifier_wide2 (word x,word y,byte color);
|
||||
void Horizontal_XOR_line_wide2 (word x_pos,word y_pos,word width);
|
||||
void Vertical_XOR_line_wide2 (word x_pos,word y_pos,word height);
|
||||
void Display_brush_color_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
void Display_brush_mono_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
|
||||
void Clear_brush_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
|
||||
void Remap_screen_wide2 (word x_pos,word y_pos,word width,word height,byte * conversion_table);
|
||||
void Display_part_of_screen_wide2 (word width,word height,word image_width);
|
||||
void Display_line_on_screen_wide2 (word x_pos,word y_pos,word width,byte * line);
|
||||
void Read_line_screen_wide2 (word x_pos,word y_pos,word width,byte * line);
|
||||
void Display_part_of_screen_scaled_wide2(word width,word height,word image_width,byte * buffer);
|
||||
void Display_brush_color_zoom_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
|
||||
void Display_brush_mono_zoom_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
|
||||
void Clear_brush_scaled_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
|
||||
void Display_brush_wide2 (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
|
||||
|
||||
void Display_line_on_screen_fast_wide2 (word x_pos,word y_pos,word width,byte * line);
|
||||
918
src/readini.c
Normal file
918
src/readini.c
Normal file
@@ -0,0 +1,918 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Peter Gordon
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
#define _XOPEN_SOURCE 500
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "const.h"
|
||||
#include "errors.h"
|
||||
#include "global.h"
|
||||
#include "misc.h"
|
||||
#include "readini.h"
|
||||
|
||||
void Load_INI_clear_string(char * str, byte keep_comments)
|
||||
{
|
||||
int index;
|
||||
int equal_found=0;
|
||||
|
||||
for (index=0;str[index]!='\0';)
|
||||
{
|
||||
if ((str[index]=='='))
|
||||
{
|
||||
equal_found=1;
|
||||
index++;
|
||||
// On enleve les espaces après le '='
|
||||
while (str[index]==' ' || str[index]=='\t')
|
||||
memmove(str+index,str+index+1,strlen(str+index));
|
||||
}
|
||||
else if ((str[index]==' ' && !equal_found) || (str[index]=='\t'))
|
||||
{
|
||||
// Suppression d'un espace ou d'un tab:
|
||||
memmove(str+index,str+index+1,strlen(str+index));
|
||||
}
|
||||
else
|
||||
if (!keep_comments && ((str[index]==';') || (str[index]=='#')))
|
||||
{
|
||||
// Comment
|
||||
str[index]='\0';
|
||||
}
|
||||
else if ((str[index]=='\r') || (str[index]=='\n'))
|
||||
{
|
||||
// Line break
|
||||
str[index]='\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!equal_found)
|
||||
{
|
||||
// Passage en majuscule d'un caractère:
|
||||
|
||||
str[index]=toupper((int)str[index]);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
// On enlève les espaces avant la fin de chaine
|
||||
while (index>0 && (str[index-1]==' ' || str[index-1]=='\t'))
|
||||
{
|
||||
index--;
|
||||
str[index]='\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Load_INI_seek_pattern(char * buffer,char * pattern)
|
||||
{
|
||||
int buffer_index;
|
||||
int pattern_index;
|
||||
|
||||
// A partir de chaque lettre de la chaîne buffer
|
||||
for (buffer_index=0;buffer[buffer_index]!='\0';buffer_index++)
|
||||
{
|
||||
// On regarde si la chaîne pattern est équivalente à la position courante
|
||||
// de la chaîne buffer:
|
||||
for (pattern_index=0;(pattern[pattern_index]!='\0') && (buffer[buffer_index+pattern_index]==pattern[pattern_index]);pattern_index++);
|
||||
|
||||
// Si on a trouvé la chaîne pattern dans la chaîne buffer, on renvoie la
|
||||
// position à laquelle on l'a trouvée (+1 pour que si on la trouve au
|
||||
// début ça ne renvoie pas la même chose que si on ne l'avait pas
|
||||
// trouvée):
|
||||
if (pattern[pattern_index]=='\0')
|
||||
return (buffer_index+1);
|
||||
}
|
||||
|
||||
// Si on ne l'a pas trouvée, on renvoie 0:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Load_INI_reach_group(FILE * file,char * buffer,char * group)
|
||||
{
|
||||
int stop_seek;
|
||||
char * group_upper;
|
||||
char * upper_buffer;
|
||||
|
||||
// On alloue les zones de mémoire:
|
||||
group_upper=(char *)malloc(1024);
|
||||
upper_buffer=(char *)malloc(1024);
|
||||
|
||||
// On commence par se faire une version majuscule du groupe à rechercher:
|
||||
strcpy(group_upper,group);
|
||||
Load_INI_clear_string(group_upper, 0);
|
||||
|
||||
stop_seek=0;
|
||||
do
|
||||
{
|
||||
// On lit une ligne dans le fichier:
|
||||
if (fgets(buffer,1024,file)==0)
|
||||
{
|
||||
free(upper_buffer);
|
||||
free(group_upper);
|
||||
return ERROR_INI_CORRUPTED;
|
||||
}
|
||||
|
||||
Line_number_in_INI_file++;
|
||||
|
||||
// On s'en fait une version en majuscule:
|
||||
strcpy(upper_buffer,buffer);
|
||||
Load_INI_clear_string(upper_buffer, 0);
|
||||
|
||||
// On compare la chaîne avec le groupe recherché:
|
||||
stop_seek=Load_INI_seek_pattern(upper_buffer,group_upper);
|
||||
}
|
||||
while (!stop_seek);
|
||||
|
||||
free(upper_buffer);
|
||||
free(group_upper);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
///
|
||||
/// Find the next string in the .INI file.
|
||||
/// @param file INI file currently opened
|
||||
/// @param buffer Current text buffer, preserved from one call to the next
|
||||
/// @param option_name string to search
|
||||
/// @param return_code the found value will be copied there. (must be allocaed)
|
||||
/// @param raw_text Boolean: true to return the raw value (up to end-of-line), false to strip comments.
|
||||
int Load_INI_get_string(FILE * file,char * buffer,char * option_name,char * return_code, byte raw_text)
|
||||
{
|
||||
int stop_seek;
|
||||
char * option_upper;
|
||||
char * upper_buffer;
|
||||
int buffer_index;
|
||||
|
||||
// On alloue les zones de mémoire:
|
||||
option_upper=(char *)malloc(1024);
|
||||
upper_buffer=(char *)malloc(1024);
|
||||
|
||||
// On commence par se faire une version majuscule de l'option à rechercher:
|
||||
strcpy(option_upper,option_name);
|
||||
Load_INI_clear_string(option_upper, 0);
|
||||
|
||||
stop_seek=0;
|
||||
do
|
||||
{
|
||||
// On lit une ligne dans le fichier:
|
||||
if (fgets(buffer,1024,file)==NULL)
|
||||
{
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
return ERROR_INI_CORRUPTED;
|
||||
}
|
||||
|
||||
Line_number_in_INI_file++;
|
||||
|
||||
// On s'en fait une version en majuscule:
|
||||
strcpy(upper_buffer,buffer);
|
||||
Load_INI_clear_string(upper_buffer, raw_text);
|
||||
|
||||
// On compare la chaîne avec l'option recherchée:
|
||||
stop_seek=Load_INI_seek_pattern(upper_buffer,option_upper);
|
||||
|
||||
// Si on l'a trouvée:
|
||||
if (stop_seek)
|
||||
{
|
||||
// On se positionne juste après la chaîne "="
|
||||
buffer_index=Load_INI_seek_pattern(upper_buffer,"=");
|
||||
|
||||
strcpy(return_code, upper_buffer + buffer_index);
|
||||
}
|
||||
}
|
||||
while (!stop_seek);
|
||||
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Load_INI_get_value(char * str,int * index,int * value)
|
||||
{
|
||||
int negative = 0;
|
||||
|
||||
// On teste si la valeur actuelle est YES (ou Y):
|
||||
|
||||
if (Load_INI_seek_pattern(str+(*index),"yes,")==1)
|
||||
{
|
||||
(*value)=1;
|
||||
(*index)+=4;
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(str+(*index),"yes")==0)
|
||||
{
|
||||
(*value)=1;
|
||||
(*index)+=3;
|
||||
return 0;
|
||||
}
|
||||
if (Load_INI_seek_pattern(str+(*index),"y,")==1)
|
||||
{
|
||||
(*value)=1;
|
||||
(*index)+=2;
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(str+(*index),"y")==0)
|
||||
{
|
||||
(*value)=1;
|
||||
(*index)+=1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// On teste si la valeur actuelle est NO (ou N):
|
||||
|
||||
if (Load_INI_seek_pattern(str+(*index),"no,")==1)
|
||||
{
|
||||
(*value)=0;
|
||||
(*index)+=3;
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(str+(*index),"no")==0)
|
||||
{
|
||||
(*value)=0;
|
||||
(*index)+=2;
|
||||
return 0;
|
||||
}
|
||||
if (Load_INI_seek_pattern(str+(*index),"n,")==1)
|
||||
{
|
||||
(*value)=0;
|
||||
(*index)+=2;
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(str+(*index),"n")==0)
|
||||
{
|
||||
(*value)=0;
|
||||
(*index)+=1;
|
||||
return 0;
|
||||
}
|
||||
if (str[*index]=='$')
|
||||
{
|
||||
(*value)=0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
(*index)++;
|
||||
|
||||
if ((str[*index]>='0') && (str[*index]<='9'))
|
||||
(*value)=((*value)*16)+str[*index]-'0';
|
||||
else
|
||||
if ((str[*index]>='A') && (str[*index]<='F'))
|
||||
(*value)=((*value)*16)+str[*index]-'A'+10;
|
||||
else
|
||||
if (str[*index]==',')
|
||||
{
|
||||
(*index)++;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if (str[*index]=='\0')
|
||||
return 0;
|
||||
else
|
||||
return ERROR_INI_CORRUPTED;
|
||||
}
|
||||
}
|
||||
if (str[*index]=='-')
|
||||
{
|
||||
negative = 1;
|
||||
// next character
|
||||
(*index)++;
|
||||
// Fall thru
|
||||
}
|
||||
if ((str[*index]>='0') && (str[*index]<='9'))
|
||||
{
|
||||
(*value)=0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if ((str[*index]>='0') && (str[*index]<='9'))
|
||||
{
|
||||
(*value)=((*value)*10)+str[*index]-'0';
|
||||
if (negative)
|
||||
{
|
||||
(*value)*= -1;
|
||||
// This is to do it once per number.
|
||||
negative = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (str[*index]==',')
|
||||
{
|
||||
(*index)++;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if (str[*index]=='\0')
|
||||
return 0;
|
||||
else
|
||||
return ERROR_INI_CORRUPTED;
|
||||
|
||||
(*index)++;
|
||||
}
|
||||
}
|
||||
else
|
||||
return ERROR_INI_CORRUPTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Load_INI_get_values(FILE * file,char * buffer,char * option_name,int nb_expected_values,int * values)
|
||||
{
|
||||
int stop_seek;
|
||||
char * option_upper;
|
||||
char * upper_buffer;
|
||||
int buffer_index;
|
||||
int nb_values;
|
||||
|
||||
// On alloue les zones de mémoire:
|
||||
option_upper=(char *)malloc(1024);
|
||||
upper_buffer=(char *)malloc(1024);
|
||||
|
||||
// On commence par se faire une version majuscule de l'option à rechercher:
|
||||
strcpy(option_upper,option_name);
|
||||
Load_INI_clear_string(option_upper, 0);
|
||||
|
||||
stop_seek=0;
|
||||
do
|
||||
{
|
||||
// On lit une ligne dans le fichier:
|
||||
if (fgets(buffer,1024,file)==0)
|
||||
{
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
return ERROR_INI_CORRUPTED;
|
||||
}
|
||||
|
||||
Line_number_in_INI_file++;
|
||||
|
||||
// On s'en fait une version en majuscule:
|
||||
strcpy(upper_buffer,buffer);
|
||||
Load_INI_clear_string(upper_buffer, 0);
|
||||
|
||||
// On compare la chaîne avec l'option recherchée:
|
||||
stop_seek=Load_INI_seek_pattern(upper_buffer,option_upper);
|
||||
|
||||
// Si on l'a trouvée:
|
||||
if (stop_seek)
|
||||
{
|
||||
nb_values=0;
|
||||
|
||||
// On se positionne juste après la chaîne "="
|
||||
buffer_index=Load_INI_seek_pattern(upper_buffer,"=");
|
||||
|
||||
// Tant qu'on a pas atteint la fin de la ligne
|
||||
while (upper_buffer[buffer_index]!='\0')
|
||||
{
|
||||
if (Load_INI_get_value(upper_buffer,&buffer_index,values+nb_values))
|
||||
{
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
return ERROR_INI_CORRUPTED;
|
||||
}
|
||||
|
||||
if ( ((++nb_values) == nb_expected_values) &&
|
||||
(upper_buffer[buffer_index]!='\0') )
|
||||
{
|
||||
// Too many values !
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
return ERROR_INI_CORRUPTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (nb_values<nb_expected_values)
|
||||
{
|
||||
// Not enough values !
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
return ERROR_INI_CORRUPTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!stop_seek);
|
||||
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int Load_INI(T_Config * conf)
|
||||
{
|
||||
FILE * file;
|
||||
char * buffer;
|
||||
int values[3];
|
||||
int index;
|
||||
char * filename;
|
||||
int return_code;
|
||||
char value_label[1024];
|
||||
|
||||
Line_number_in_INI_file=0;
|
||||
|
||||
// On alloue les zones de mémoire:
|
||||
buffer=(char *)malloc(1024);
|
||||
filename=(char *)malloc(256);
|
||||
|
||||
// On calcule le nom du fichier qu'on manipule:
|
||||
strcpy(filename,Config_directory);
|
||||
strcat(filename,"gfx2.ini");
|
||||
|
||||
file=fopen(filename,"r");
|
||||
if (file==0)
|
||||
{
|
||||
// Si le fichier ini est absent on le relit depuis gfx2def.ini
|
||||
strcpy(filename,Data_directory);
|
||||
strcat(filename,"gfx2def.ini");
|
||||
file=fopen(filename,"r");
|
||||
if (file == 0)
|
||||
{
|
||||
free(filename);
|
||||
free(buffer);
|
||||
return ERROR_INI_MISSING;
|
||||
}
|
||||
}
|
||||
|
||||
if ((return_code=Load_INI_reach_group(file,buffer,"[MOUSE]")))
|
||||
goto Erreur_Retour;
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"X_sensitivity",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<1) || (values[0]>4))
|
||||
conf->Mouse_sensitivity_index_x=1;
|
||||
else
|
||||
conf->Mouse_sensitivity_index_x=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Y_sensitivity",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<1) || (values[0]>4))
|
||||
conf->Mouse_sensitivity_index_y=1;
|
||||
else
|
||||
conf->Mouse_sensitivity_index_y=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"X_correction_factor",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>4))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
// Deprecated setting, unused
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Y_correction_factor",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>4))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
// Deprecated setting, unused
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Cursor_aspect",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<1) || (values[0]>3))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Cursor=values[0]-1;
|
||||
|
||||
if ((return_code=Load_INI_reach_group(file,buffer,"[MENU]")))
|
||||
goto Erreur_Retour;
|
||||
|
||||
conf->Fav_menu_colors[0].R=0;
|
||||
conf->Fav_menu_colors[0].G=0;
|
||||
conf->Fav_menu_colors[0].B=0;
|
||||
conf->Fav_menu_colors[3].R=255;
|
||||
conf->Fav_menu_colors[3].G=255;
|
||||
conf->Fav_menu_colors[3].B=255;
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Light_color",3,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>63))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
if ((values[1]<0) || (values[1]>63))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
if ((values[2]<0) || (values[2]>63))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Fav_menu_colors[2].R=(values[0]<<2)|(values[0]>>4);
|
||||
conf->Fav_menu_colors[2].G=(values[1]<<2)|(values[1]>>4);
|
||||
conf->Fav_menu_colors[2].B=(values[2]<<2)|(values[2]>>4);
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Dark_color",3,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>63))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
if ((values[1]<0) || (values[1]>63))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
if ((values[2]<0) || (values[2]>63))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Fav_menu_colors[1].R=(values[0]<<2)|(values[0]>>4);
|
||||
conf->Fav_menu_colors[1].G=(values[1]<<2)|(values[1]>>4);
|
||||
conf->Fav_menu_colors[1].B=(values[2]<<2)|(values[2]>>4);
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Menu_ratio",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<-4) || (values[0]>2))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Ratio=values[0];
|
||||
|
||||
if ((return_code=Load_INI_reach_group(file,buffer,"[FILE_SELECTOR]")))
|
||||
goto Erreur_Retour;
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Show_hidden_files",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Show_hidden_files=values[0]?-1:0;
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Show_hidden_directories",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Show_hidden_directories=values[0]?-1:0;
|
||||
|
||||
/* if ((return_code=Load_INI_get_values (file,buffer,"Show_system_directories",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Show_system_directories=values[0]?-1:0;
|
||||
*/
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Preview_delay",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<1) || (values[0]>256))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Timer_delay=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Maximize_preview",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Maximize_preview=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Find_file_fast",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>2))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Find_file_fast=values[0];
|
||||
|
||||
|
||||
if ((return_code=Load_INI_reach_group(file,buffer,"[LOADING]")))
|
||||
goto Erreur_Retour;
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Auto_set_resolution",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Auto_set_res=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Set_resolution_according_to",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<1) || (values[0]>2))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Set_resolution_according_to=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Clear_palette",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Clear_palette=values[0];
|
||||
|
||||
|
||||
if ((return_code=Load_INI_reach_group(file,buffer,"[MISCELLANEOUS]")))
|
||||
goto Erreur_Retour;
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Draw_limits",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Display_image_limits=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Adjust_brush_pick",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Adjust_brush_pick=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Coordinates",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<1) || (values[0]>2))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Coords_rel=2-values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Backup",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Backup=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Undo_pages",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<1) || (values[0]>99))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Max_undo_pages=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Gauges_scrolling_speed_Left",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<1) || (values[0]>255))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Delay_left_click_on_slider=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Gauges_scrolling_speed_Right",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<1) || (values[0]>255))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Delay_right_click_on_slider=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Auto_save",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Auto_save=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Vertices_per_polygon",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<2) || (values[0]>16384))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Nb_max_vertices_per_polygon=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Fast_zoom",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Fast_zoom=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Separate_colors",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Separate_colors=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"FX_feedback",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->FX_Feedback=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Safety_colors",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Safety_colors=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Opening_message",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Opening_message=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Clear_with_stencil",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Clear_with_stencil=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Auto_discontinuous",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Auto_discontinuous=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Save_screen_size_in_GIF",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Screen_size_in_GIF=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Auto_nb_colors_used",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Auto_nb_used=values[0];
|
||||
|
||||
// Optionnel, le mode video par défaut (à partir de beta 97.0%)
|
||||
conf->Default_resolution=0;
|
||||
if (!Load_INI_get_string (file,buffer,"Default_video_mode",value_label, 0))
|
||||
{
|
||||
int mode = Convert_videomode_arg(value_label);
|
||||
if (mode>=0)
|
||||
conf->Default_resolution=mode;
|
||||
}
|
||||
|
||||
// Optionnel, les dimensions de la fenêtre (à partir de beta 97.0%)
|
||||
// Do that only if the first mode is actually windowed (not the case on gp2x for example)
|
||||
if(Video_mode[0].Fullscreen==0)
|
||||
{
|
||||
Video_mode[0].Width = 640;
|
||||
Video_mode[0].Height = 480;
|
||||
if (!Load_INI_get_values (file,buffer,"Default_window_size",2,values))
|
||||
{
|
||||
if ((values[0]>=320))
|
||||
Video_mode[0].Width = values[0];
|
||||
if ((values[1]>=200))
|
||||
Video_mode[0].Height = values[1];
|
||||
}
|
||||
}
|
||||
|
||||
conf->Mouse_merge_movement=100;
|
||||
// Optionnel, paramètre pour grouper les mouvements souris (>98.0%)
|
||||
if (!Load_INI_get_values (file,buffer,"Merge_movement",1,values))
|
||||
{
|
||||
if ((values[0]<0) || (values[0]>1000))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Mouse_merge_movement=values[0];
|
||||
}
|
||||
|
||||
conf->Palette_cells_X=8;
|
||||
// Optionnel, nombre de colonnes dans la palette (>98.0%)
|
||||
if (!Load_INI_get_values (file,buffer,"Palette_cells_X",1,values))
|
||||
{
|
||||
if ((values[0]<1) || (values[0]>256))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Palette_cells_X=values[0];
|
||||
}
|
||||
conf->Palette_cells_Y=8;
|
||||
// Optionnel, nombre de lignes dans la palette (>98.0%)
|
||||
if (!Load_INI_get_values (file,buffer,"Palette_cells_Y",1,values))
|
||||
{
|
||||
if (values[0]<1 || values[0]>16)
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Palette_cells_Y=values[0];
|
||||
}
|
||||
// Optionnel, bookmarks (>98.0%)
|
||||
for (index=0;index<NB_BOOKMARKS;index++)
|
||||
{
|
||||
conf->Bookmark_directory[index]=NULL;
|
||||
conf->Bookmark_label[index][0]='\0';
|
||||
}
|
||||
for (index=0;index<NB_BOOKMARKS;index++)
|
||||
{
|
||||
if (!Load_INI_get_string (file,buffer,"Bookmark_label",value_label, 1))
|
||||
{
|
||||
int size=strlen(value_label);
|
||||
if (size!=0)
|
||||
{
|
||||
if (size>8)
|
||||
{
|
||||
value_label[7]=ELLIPSIS_CHARACTER;
|
||||
value_label[8]='\0';
|
||||
}
|
||||
strcpy(conf->Bookmark_label[index],value_label);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
if (!Load_INI_get_string (file,buffer,"Bookmark_directory",value_label, 1))
|
||||
{
|
||||
int size=strlen(value_label);
|
||||
if (size!=0)
|
||||
{
|
||||
conf->Bookmark_directory[index]=(char *)malloc(size+1);
|
||||
strcpy(conf->Bookmark_directory[index],value_label);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
conf->Palette_vertical=0;
|
||||
// Optional, vertical palette option (>98.0%)
|
||||
if (!Load_INI_get_values (file,buffer,"Palette_vertical",1,values))
|
||||
{
|
||||
if ((values[0]<0) || (values[0]>1))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Palette_vertical=values[0];
|
||||
}
|
||||
|
||||
// Optional, the window position (>98.0%)
|
||||
conf->Window_pos_x=9999;
|
||||
conf->Window_pos_y=9999;
|
||||
if (!Load_INI_get_values (file,buffer,"Window_position",2,values))
|
||||
{
|
||||
conf->Window_pos_x = values[0];
|
||||
conf->Window_pos_y = values[1];
|
||||
}
|
||||
|
||||
conf->Double_click_speed=500;
|
||||
// Optional, speed of double-click (>2.0)
|
||||
if (!Load_INI_get_values (file,buffer,"Double_click_speed",1,values))
|
||||
{
|
||||
if ((values[0]>0) || (values[0]<=2000))
|
||||
conf->Double_click_speed=values[0];
|
||||
}
|
||||
|
||||
conf->Double_key_speed=500;
|
||||
// Optional, speed of double-keypress (>2.0)
|
||||
if (!Load_INI_get_values (file,buffer,"Double_key_speed",1,values))
|
||||
{
|
||||
if ((values[0]>0) || (values[0]<=2000))
|
||||
conf->Double_key_speed=values[0];
|
||||
}
|
||||
|
||||
// Optional, name of skin file. (>2.0)
|
||||
if(!Load_INI_get_string(file,buffer,"Skin_file",value_label,1))
|
||||
{
|
||||
conf->Skin_file = strdup(value_label);
|
||||
}
|
||||
else
|
||||
conf->Skin_file = strdup("skin_modern.png");
|
||||
|
||||
// Optional, name of font file. (>2.0)
|
||||
if(!Load_INI_get_string(file,buffer,"Font_file",value_label,1))
|
||||
conf->Font_file = strdup(value_label);
|
||||
else
|
||||
conf->Font_file = strdup("font_Classic.png");
|
||||
|
||||
conf->Grid_XOR_color=255;
|
||||
// Optional, XOR color for grid overlay (>2.0)
|
||||
if (!Load_INI_get_values (file,buffer,"Grid_XOR_color",1,values))
|
||||
{
|
||||
if ((values[0]>0) && (values[0]<=255))
|
||||
conf->Grid_XOR_color=values[0];
|
||||
}
|
||||
|
||||
// Optional, "fake hardware zoom" factor (>2.1)
|
||||
if (!Load_INI_get_values (file, buffer,"Pixel_ratio",1,values))
|
||||
{
|
||||
Pixel_ratio = values[0];
|
||||
switch(Pixel_ratio) {
|
||||
case PIXEL_WIDE:
|
||||
if(Video_mode[0].Width < 640)
|
||||
Pixel_ratio = PIXEL_SIMPLE;
|
||||
break;
|
||||
case PIXEL_TALL:
|
||||
if(Video_mode[0].Height < 400)
|
||||
Pixel_ratio = PIXEL_SIMPLE;
|
||||
break;
|
||||
case PIXEL_DOUBLE:
|
||||
if(Video_mode[0].Width < 640 || Video_mode[0].Height < 400)
|
||||
Pixel_ratio = PIXEL_SIMPLE;
|
||||
break;
|
||||
case PIXEL_TRIPLE:
|
||||
if(Video_mode[0].Width < 3*320 || Video_mode[0].Height < 3*200)
|
||||
Pixel_ratio = PIXEL_SIMPLE;
|
||||
break;
|
||||
case PIXEL_WIDE2:
|
||||
if(Video_mode[0].Width < 4*320 || Video_mode[0].Height < 2*200)
|
||||
Pixel_ratio = PIXEL_SIMPLE;
|
||||
break;
|
||||
case PIXEL_TALL2:
|
||||
if(Video_mode[0].Width < 2*320 || Video_mode[0].Height < 4*200)
|
||||
Pixel_ratio = PIXEL_SIMPLE;
|
||||
break;
|
||||
case PIXEL_QUAD:
|
||||
if(Video_mode[0].Width < 4*320 || Video_mode[0].Height < 4*200)
|
||||
Pixel_ratio = PIXEL_SIMPLE;
|
||||
break;
|
||||
default:
|
||||
// Convert back unknown values to PIXEL_SIMPLE
|
||||
Pixel_ratio = PIXEL_SIMPLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Optional, Menu bars visibility (> 2.1)
|
||||
if (!Load_INI_get_values (file, buffer,"Menubars_visible",1,values))
|
||||
{
|
||||
int index;
|
||||
for (index=MENUBAR_STATUS+1; index<MENUBAR_COUNT;index++)
|
||||
{
|
||||
// Note that I skip the status bar, always enabled.
|
||||
Menu_bars[index].Visible = (values[0] & (1<<index)) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
free(filename);
|
||||
free(buffer);
|
||||
return 0;
|
||||
|
||||
// Gestion des erreurs:
|
||||
|
||||
Erreur_Retour:
|
||||
fclose(file);
|
||||
free(filename);
|
||||
free(buffer);
|
||||
return return_code;
|
||||
|
||||
Erreur_ERREUR_INI_CORROMPU:
|
||||
|
||||
fclose(file);
|
||||
free(filename);
|
||||
free(buffer);
|
||||
return ERROR_INI_CORRUPTED;
|
||||
}
|
||||
29
src/readini.h
Normal file
29
src/readini.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 readini.h
|
||||
/// Reading settings in gfx2.ini
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int Load_INI(T_Config * conf);
|
||||
int Load_INI_seek_pattern(char * buffer,char * pattern);
|
||||
void Load_INI_clear_string(char * str, byte keep_comments);
|
||||
434
src/readline.c
Normal file
434
src/readline.c
Normal file
@@ -0,0 +1,434 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
/************************************************************************
|
||||
* *
|
||||
* READLINE (procédure permettant de saisir une chaîne de caractères) *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "const.h"
|
||||
#include "struct.h"
|
||||
#include "global.h"
|
||||
#include "misc.h"
|
||||
#include "errors.h"
|
||||
#include "const.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "readline.h"
|
||||
#include "windows.h"
|
||||
#include "input.h"
|
||||
|
||||
#define TEXT_COLOR MC_Black
|
||||
#define BACKGROUND_COLOR MC_Light
|
||||
#define CURSOR_COLOR MC_Black
|
||||
#define CURSOR_BACKGROUND_COLOR MC_Dark
|
||||
|
||||
// Suppresion d'un caractère à une certaine POSITION dans une CHAINE.
|
||||
void Remove_character(char * str, byte position)
|
||||
{
|
||||
for (;str[position]!='\0';position++)
|
||||
str[position]=str[position+1];
|
||||
}
|
||||
|
||||
|
||||
void Insert_character(char * str, char letter, byte position)
|
||||
// Insertion d'une LETTRE à une certaine POSITION
|
||||
// dans une CHAINE d'une certaine TAILLE.
|
||||
{
|
||||
char temp_char;
|
||||
|
||||
for (;letter!='\0';position++)
|
||||
{
|
||||
// On mémorise le caractère qui se trouve en "position"
|
||||
temp_char=str[position];
|
||||
// On splotch la lettre à insérer
|
||||
str[position]=letter;
|
||||
// On place le caractère mémorisé dans "letter" comme nouvelle lettre à insérer
|
||||
letter=temp_char;
|
||||
}
|
||||
// On termine la chaine
|
||||
str[position]='\0';
|
||||
}
|
||||
|
||||
int Valid_character(int c)
|
||||
{
|
||||
// Sous Linux: Seul le / est strictement interdit, mais beaucoup
|
||||
// d'autres poseront des problèmes au shell, alors on évite.
|
||||
// Sous Windows : c'est moins grave car le fopen() échouerait de toutes façons.
|
||||
// AmigaOS4: Pas de ':' car utilisé pour les volumes.
|
||||
#if defined(__WIN32__)
|
||||
char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':', '\\'};
|
||||
#elif defined (__amigaos4__)
|
||||
char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':'};
|
||||
#else
|
||||
char forbidden_char[] = {'/', '|', '?', '*', '<', '>'};
|
||||
#endif
|
||||
int position;
|
||||
|
||||
if (c < ' ' || c > 255)
|
||||
return 0;
|
||||
|
||||
for (position=0; position<(long)sizeof(forbidden_char); position++)
|
||||
if (c == forbidden_char[position])
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Display_whole_string(word x_pos,word y_pos,char * str,byte position)
|
||||
{
|
||||
Print_in_window(x_pos,y_pos,str,TEXT_COLOR,BACKGROUND_COLOR);
|
||||
Print_char_in_window(x_pos+(position<<3),y_pos,str[position],CURSOR_COLOR,CURSOR_BACKGROUND_COLOR);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Enhanced super scanf deluxe pro plus giga mieux :-) *
|
||||
****************************************************************************/
|
||||
byte Readline(word x_pos,word y_pos,char * str,byte visible_size,byte input_type)
|
||||
// Paramètres:
|
||||
// x_pos, y_pos : Coordonnées de la saisie dans la fenêtre
|
||||
// str : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale)
|
||||
// max_size : Nombre de caractères logeant dans la zone de saisie
|
||||
// input_type : 0=Chaîne, 1=Nombre, 2=Nom de fichier
|
||||
// Sortie:
|
||||
// 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return)
|
||||
{
|
||||
byte max_size;
|
||||
// Grosse astuce pour les noms de fichiers: La taille affichée est différente
|
||||
// de la taille maximum gérée.
|
||||
if (input_type == 2)
|
||||
max_size = 255;
|
||||
else
|
||||
max_size = visible_size;
|
||||
return Readline_ex(x_pos,y_pos,str,visible_size,max_size,input_type,0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Enhanced super scanf deluxe pro plus giga mieux :-) *
|
||||
****************************************************************************/
|
||||
byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_size, byte input_type, byte decimal_places)
|
||||
// Paramètres:
|
||||
// x_pos, y_pos : Coordonnées de la saisie dans la fenêtre
|
||||
// str : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale)
|
||||
// max_size : Nombre de caractères logeant dans la zone de saisie
|
||||
// input_type : 0=String, 1=Unsigned int, 2=Filename 3=Signed Double
|
||||
// decimal_places: Number of decimal places for a double
|
||||
// Sortie:
|
||||
// 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return)
|
||||
{
|
||||
char initial_string[256];
|
||||
char display_string[256];
|
||||
byte position;
|
||||
byte size;
|
||||
word input_key=0;
|
||||
byte is_authorized;
|
||||
|
||||
byte offset=0; // index du premier caractère affiché
|
||||
|
||||
// Si on a commencé à editer par un clic-droit, on vide la chaine.
|
||||
if (Mouse_K==RIGHT_SIDE)
|
||||
str[0]='\0';
|
||||
else if (input_type==1)
|
||||
snprintf(str,10,"%d",atoi(str)); // On tasse la chaine à gauche
|
||||
else if (input_type==3)
|
||||
{
|
||||
// Nothing. The caller should have used Sprint_double, with min_positions
|
||||
// at zero, so there's no spaces on the left and no useless 0s on the right.
|
||||
}
|
||||
|
||||
Wait_end_of_click();
|
||||
Keyboard_click_allowed = 0;
|
||||
Hide_cursor();
|
||||
|
||||
// Effacement de la chaîne
|
||||
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
|
||||
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
|
||||
Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
|
||||
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
|
||||
|
||||
// Mise à jour des variables se rapportant à la chaîne en fonction de la chaîne initiale
|
||||
strcpy(initial_string,str);
|
||||
|
||||
size=strlen(str);
|
||||
position=(size<max_size)? size:size-1;
|
||||
if (position-offset>=visible_size)
|
||||
offset=position-visible_size+1;
|
||||
// Formatage d'une partie de la chaine (si trop longue pour tenir)
|
||||
strncpy(display_string, str + offset, visible_size);
|
||||
display_string[visible_size]='\0';
|
||||
if (offset>0)
|
||||
display_string[0]=LEFT_TRIANGLE_CHARACTER;
|
||||
if (visible_size + offset + 1 < size )
|
||||
display_string[visible_size-1]=RIGHT_TRIANGLE_CHARACTER;
|
||||
|
||||
Display_whole_string(x_pos,y_pos,display_string,position - offset);
|
||||
Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
|
||||
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
|
||||
Flush_update();
|
||||
|
||||
while ((input_key!=SDLK_RETURN) && (input_key!=KEY_ESC) && Mouse_K == 0)
|
||||
{
|
||||
Display_cursor();
|
||||
do
|
||||
{
|
||||
if(!Get_input()) SDL_Delay(20);
|
||||
input_key=Key_ANSI;
|
||||
} while(input_key==0 && Mouse_K == 0);
|
||||
Hide_cursor();
|
||||
switch (input_key)
|
||||
{
|
||||
case SDLK_DELETE : // Suppr.
|
||||
if (position<size)
|
||||
{
|
||||
Remove_character(str,position);
|
||||
size--;
|
||||
|
||||
// Effacement de la chaîne
|
||||
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
|
||||
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
|
||||
goto affichage;
|
||||
}
|
||||
break;
|
||||
case SDLK_LEFT : // Gauche
|
||||
if (position>0)
|
||||
{
|
||||
// Effacement de la chaîne
|
||||
if (position==size)
|
||||
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
|
||||
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
|
||||
position--;
|
||||
if (offset > 0 && (position == 0 || position < (offset + 1)))
|
||||
offset--;
|
||||
goto affichage;
|
||||
}
|
||||
break;
|
||||
case SDLK_RIGHT : // Droite
|
||||
if ((position<size) && (position<max_size-1))
|
||||
{
|
||||
position++;
|
||||
//if (position > visible_size + offset - 2)
|
||||
//if (offset + visible_size < max_size && (position == size || (position > visible_size + offset - 2)))
|
||||
if (display_string[position-offset]==RIGHT_TRIANGLE_CHARACTER || position-offset>=visible_size)
|
||||
offset++;
|
||||
goto affichage;
|
||||
}
|
||||
break;
|
||||
case SDLK_HOME : // Home
|
||||
if (position)
|
||||
{
|
||||
// Effacement de la chaîne
|
||||
if (position==size)
|
||||
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
|
||||
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
|
||||
position = 0;
|
||||
offset = 0;
|
||||
goto affichage;
|
||||
}
|
||||
break;
|
||||
case SDLK_END : // End
|
||||
if ((position<size) && (position<max_size-1))
|
||||
{
|
||||
position=(size<max_size)?size:size-1;
|
||||
if (position-offset>=visible_size)
|
||||
offset=position-visible_size+1;
|
||||
goto affichage;
|
||||
}
|
||||
break;
|
||||
case SDLK_BACKSPACE : // Backspace : combinaison de gauche + suppr
|
||||
|
||||
if (position)
|
||||
{
|
||||
position--;
|
||||
if (offset > 0 && (position == 0 || position < (offset + 1)))
|
||||
offset--;
|
||||
Remove_character(str,position);
|
||||
size--;
|
||||
// Effacement de la chaîne
|
||||
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
|
||||
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
|
||||
goto affichage;
|
||||
}
|
||||
break;
|
||||
case SDLK_RETURN :
|
||||
break;
|
||||
|
||||
case KEY_ESC :
|
||||
// On restaure la chaine initiale
|
||||
strcpy(str,initial_string);
|
||||
size=strlen(str);
|
||||
break;
|
||||
default :
|
||||
if (size<max_size)
|
||||
{
|
||||
// On va regarder si l'utilisateur le droit de se servir de cette touche
|
||||
is_authorized=0; // On commence par supposer qu'elle est interdite
|
||||
switch(input_type)
|
||||
{
|
||||
case 0 : // N'importe quelle chaîne:
|
||||
if (input_key>=' ' && input_key<= 255)
|
||||
is_authorized=1;
|
||||
break;
|
||||
case 1 : // Nombre
|
||||
if ( (input_key>='0') && (input_key<='9') )
|
||||
is_authorized=1;
|
||||
break;
|
||||
case 3: // Decimal number
|
||||
if ( (input_key>='0') && (input_key<='9') )
|
||||
is_authorized=1;
|
||||
else if (input_key=='-' && position==0 && str[0]!='-')
|
||||
is_authorized=1;
|
||||
else if (input_key=='.')
|
||||
is_authorized=1;
|
||||
break;
|
||||
default : // Nom de fichier
|
||||
// On regarde si la touche est autorisée
|
||||
if ( Valid_character(input_key))
|
||||
is_authorized=1;
|
||||
} // End du "switch(input_type)"
|
||||
|
||||
// Si la touche était autorisée...
|
||||
if (is_authorized)
|
||||
{
|
||||
// ... alors on l'insère ...
|
||||
Insert_character(str,input_key,position/*,size*/);
|
||||
// ce qui augmente la taille de la chaine
|
||||
size++;
|
||||
// et qui risque de déplacer le curseur vers la droite
|
||||
if (size<max_size)
|
||||
{
|
||||
position++;
|
||||
if (display_string[position-offset]==RIGHT_TRIANGLE_CHARACTER || position-offset>=visible_size)
|
||||
offset++;
|
||||
}
|
||||
// Enfin, on raffiche la chaine
|
||||
goto affichage;
|
||||
} // End du test d'autorisation de touche
|
||||
} // End du test de place libre
|
||||
break;
|
||||
|
||||
affichage:
|
||||
size=strlen(str);
|
||||
// Formatage d'une partie de la chaine (si trop longue pour tenir)
|
||||
strncpy(display_string, str + offset, visible_size);
|
||||
display_string[visible_size]='\0';
|
||||
if (offset>0)
|
||||
display_string[0]=LEFT_TRIANGLE_CHARACTER;
|
||||
if (visible_size + offset + 0 < size )
|
||||
display_string[visible_size-1]=RIGHT_TRIANGLE_CHARACTER;
|
||||
|
||||
Display_whole_string(x_pos,y_pos,display_string,position - offset);
|
||||
Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
|
||||
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
|
||||
} // End du "switch(input_key)"
|
||||
Flush_update();
|
||||
|
||||
} // End du "while"
|
||||
Keyboard_click_allowed = 1;
|
||||
|
||||
// Effacement de la chaîne
|
||||
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
|
||||
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
|
||||
// On raffiche la chaine correctement
|
||||
if (input_type==1)
|
||||
{
|
||||
if (str[0]=='\0')
|
||||
{
|
||||
strcpy(str,"0");
|
||||
size=1;
|
||||
}
|
||||
Print_in_window(x_pos+((max_size-size)<<3),y_pos,str,TEXT_COLOR,BACKGROUND_COLOR);
|
||||
}
|
||||
else if (input_type==3)
|
||||
{
|
||||
double value;
|
||||
// Discard extra digits
|
||||
value = Fround(atof(str), decimal_places);
|
||||
Sprint_double(str,value,decimal_places,visible_size);
|
||||
// Recompute updated size
|
||||
size = strlen(str);
|
||||
|
||||
if (size<=visible_size)
|
||||
Print_in_window(x_pos+((visible_size-size)<<3),y_pos,str,TEXT_COLOR,BACKGROUND_COLOR);
|
||||
else
|
||||
Print_in_window_limited(x_pos,y_pos,str,visible_size,TEXT_COLOR,BACKGROUND_COLOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
Print_in_window_limited(x_pos,y_pos,str,visible_size,TEXT_COLOR,BACKGROUND_COLOR);
|
||||
}
|
||||
Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
|
||||
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
|
||||
|
||||
return (input_key==SDLK_RETURN || Mouse_K != 0);
|
||||
}
|
||||
|
||||
void Sprint_double(char *str, double value, byte decimal_places, byte min_positions)
|
||||
{
|
||||
int i;
|
||||
int length;
|
||||
|
||||
sprintf(str,"%.*f",decimal_places, value);
|
||||
length=strlen(str);
|
||||
|
||||
for (i=0; i<length; i++)
|
||||
{
|
||||
if (str[i]=='.')
|
||||
{
|
||||
// Remove extraneous zeroes
|
||||
char * decimals = str+i+1;
|
||||
int j;
|
||||
|
||||
for (j=strlen(decimals)-1; j >= 0 && decimals[j]=='0'; j--)
|
||||
{
|
||||
decimals[j] = '\0';
|
||||
}
|
||||
// If all decimals were removed, remove the dot too
|
||||
if (str[i+1]=='\0')
|
||||
str[i]='\0';
|
||||
|
||||
// Update string length
|
||||
length=strlen(str);
|
||||
|
||||
// Ends the parent loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Now try add spaces at beginning
|
||||
if (length<min_positions)
|
||||
{
|
||||
int offset = min_positions - length;
|
||||
|
||||
// Move the string to the right
|
||||
for (i=0; i<=length; i++)
|
||||
{
|
||||
str[length+offset-i] = str[length-i];
|
||||
}
|
||||
// Replace the N first characters by spaces
|
||||
for (i=0; i<offset; i++)
|
||||
{
|
||||
str[i] = ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
55
src/readline.h
Normal file
55
src/readline.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 readline.h
|
||||
/// Text input functions.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///
|
||||
/// Lets the user input a line of text, exit by Esc or Return.
|
||||
/// @param x_pos Coordinates of input, in window coordinates before scaling.
|
||||
/// @param y_pos Coordinates of input, in window coordinates before scaling.
|
||||
/// @param str The original string value (will be modified, unless user cancels.
|
||||
/// @param visible_size Number of characters visible and editable.
|
||||
/// @param input_type 0=string, 1=number, 2=filename (255 editable characters)
|
||||
/// @return 0 if user cancelled (esc), 1 if accepted (return)
|
||||
byte Readline(word x_pos,word y_pos,char * str,byte visible_size,byte input_type);
|
||||
|
||||
///
|
||||
/// Lets the user input a line of text, exit by Esc or Return.
|
||||
/// @param x_pos Coordinates of input, in window coordinates before scaling.
|
||||
/// @param y_pos Coordinates of input, in window coordinates before scaling.
|
||||
/// @param str The original string value (will be modified, unless user cancels.
|
||||
/// @param visible_size Number of characters visible.
|
||||
/// @param max_size Number of characters editable.
|
||||
/// @param input_type 0=string, 1=integer, 2=filename (255 editable characters) 3=decimal
|
||||
/// @param decimal_places Number of decimal places (used only with decimal type)
|
||||
/// @return 0 if user cancelled (esc), 1 if accepted (return)
|
||||
byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_size, byte input_type, byte decimal_places);
|
||||
|
||||
///
|
||||
/// Converts a double to string.
|
||||
/// @param str Target string, should be pre-allocated and at least 40 characters, to be safe.
|
||||
/// @param value The number to convert
|
||||
/// @param decimal_places Number of decimal places to keep. 15 seems the maximum.
|
||||
/// @param min_positions Minimum number of characters: Will pad spaces on the left to meet this minimum.
|
||||
void Sprint_double(char *str, double value, byte decimal_places, byte min_positions);
|
||||
118
src/realpath.c
Normal file
118
src/realpath.c
Normal file
@@ -0,0 +1,118 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
#define _XOPEN_SOURCE 500
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(__AROS__) || defined(__BEOS__) || defined(__MORPHOS__) || defined(__GP2X__) || defined(__amigaos__)
|
||||
// These platforms don't have realpath().
|
||||
// We use the following implementation, found in:
|
||||
// http://amiga.sourceforge.net/amigadevhelp/FUNCTIONS/GeekGadgets/realpath/ex02_realpath.c
|
||||
//
|
||||
// When tested on Debian, this piece of code doesn't resolve
|
||||
// symbolic link in the filename itself, only on the directories in
|
||||
// the path. So this implementation is limited, it's really better to
|
||||
// use realpath() if your platform has it.
|
||||
|
||||
#if defined(__GP2X__)
|
||||
// This is a random default value ...
|
||||
#define PATH_MAX 32768
|
||||
#endif
|
||||
|
||||
static char *sep(char *path)
|
||||
{
|
||||
char *tmp, c;
|
||||
|
||||
tmp = strrchr(path, '/');
|
||||
if(tmp) {
|
||||
c = tmp[1];
|
||||
tmp[1] = 0;
|
||||
if (chdir(path)) {
|
||||
return NULL;
|
||||
}
|
||||
tmp[1] = c;
|
||||
|
||||
return tmp + 1;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
char *Realpath(const char *_path, char *resolved_path)
|
||||
{
|
||||
int fd = open(".", O_RDONLY), l;
|
||||
char current_dir_path[PATH_MAX];
|
||||
char path[PATH_MAX], lnk[PATH_MAX], *tmp = (char *)"";
|
||||
|
||||
if (fd < 0) {
|
||||
return NULL;
|
||||
}
|
||||
getcwd(current_dir_path,PATH_MAX);
|
||||
strncpy(path, _path, PATH_MAX);
|
||||
|
||||
if (chdir(path)) {
|
||||
if (errno == ENOTDIR) {
|
||||
#if defined(__WIN32__) || defined(__MORPHOS__) || defined(__amigaos__)
|
||||
// No symbolic links and no readlink()
|
||||
l = -1;
|
||||
#else
|
||||
l = readlink(path, lnk, PATH_MAX);
|
||||
#endif
|
||||
if (!(tmp = sep(path))) {
|
||||
resolved_path = NULL;
|
||||
goto abort;
|
||||
}
|
||||
if (l < 0) {
|
||||
if (errno != EINVAL) {
|
||||
resolved_path = NULL;
|
||||
goto abort;
|
||||
}
|
||||
} else {
|
||||
lnk[l] = 0;
|
||||
if (!(tmp = sep(lnk))) {
|
||||
resolved_path = NULL;
|
||||
goto abort;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
resolved_path = NULL;
|
||||
goto abort;
|
||||
}
|
||||
}
|
||||
|
||||
if(resolved_path==NULL) // if we called realpath with null as a 2nd arg
|
||||
resolved_path = (char*) malloc( PATH_MAX );
|
||||
|
||||
if (!getcwd(resolved_path, PATH_MAX)) {
|
||||
resolved_path = NULL;
|
||||
goto abort;
|
||||
}
|
||||
|
||||
if(strcmp(resolved_path, "/") && *tmp) {
|
||||
strcat(resolved_path, "/");
|
||||
}
|
||||
|
||||
strcat(resolved_path, tmp);
|
||||
abort:
|
||||
chdir(current_dir_path);
|
||||
close(fd);
|
||||
return resolved_path;
|
||||
}
|
||||
|
||||
#elif defined (__WIN32__)
|
||||
// Mingw has a working equivalent. It only has reversed arguments.
|
||||
char *Realpath(const char *_path, char *resolved_path)
|
||||
{
|
||||
return _fullpath(resolved_path,_path,260);
|
||||
}
|
||||
#else
|
||||
// Use the stdlib function.
|
||||
char *Realpath(const char *_path, char *resolved_path)
|
||||
{
|
||||
return realpath(_path, resolved_path);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
36
src/realpath.h
Normal file
36
src/realpath.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 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 realpath.h
|
||||
/// Implementation of realpath() that is portable on all our platforms.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _REALPATH_H
|
||||
#define _REALPATH_H
|
||||
|
||||
///
|
||||
/// Makes an absolute filename, resolving symbolic links etc.
|
||||
/// @param _path Input path
|
||||
/// @param resolved_path Output path, allocated by caller
|
||||
/// @return (points to resolved_path)
|
||||
char *Realpath(const char *_path, char *resolved_path);
|
||||
|
||||
#endif
|
||||
701
src/saveini.c
Normal file
701
src/saveini.c
Normal file
@@ -0,0 +1,701 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Peter Gordon
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "const.h"
|
||||
#include "global.h"
|
||||
#include "readini.h"
|
||||
#include "io.h"
|
||||
#include "errors.h"
|
||||
#include "misc.h"
|
||||
#include "saveini.h"
|
||||
|
||||
int Save_INI_reach_group(FILE * old_file,FILE * new_file,char * buffer,char * group)
|
||||
{
|
||||
int stop_seek;
|
||||
char * group_upper;
|
||||
char * upper_buffer;
|
||||
|
||||
// On alloue les zones de mémoire:
|
||||
group_upper =(char *)malloc(1024);
|
||||
upper_buffer=(char *)malloc(1024);
|
||||
|
||||
// On commence par se faire une version majuscule du groupe à rechercher:
|
||||
strcpy(group_upper,group);
|
||||
Load_INI_clear_string(group_upper, 0);
|
||||
|
||||
stop_seek=0;
|
||||
do
|
||||
{
|
||||
// On lit une ligne dans le fichier:
|
||||
if (fgets(buffer,1024,old_file)==0)
|
||||
{
|
||||
free(upper_buffer);
|
||||
free(group_upper);
|
||||
return ERROR_INI_CORRUPTED;
|
||||
}
|
||||
|
||||
// On s'en fait une version en majuscule:
|
||||
strcpy(upper_buffer,buffer);
|
||||
Load_INI_clear_string(upper_buffer, 0);
|
||||
|
||||
// On compare la chaîne avec le groupe recherché:
|
||||
stop_seek=Load_INI_seek_pattern(upper_buffer,group_upper);
|
||||
if (fprintf(new_file,"%s",buffer)<0)
|
||||
{
|
||||
free(upper_buffer);
|
||||
free(group_upper);
|
||||
return ERROR_SAVING_INI;
|
||||
}
|
||||
}
|
||||
while (stop_seek==0);
|
||||
|
||||
free(upper_buffer);
|
||||
free(group_upper);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Save_INI_char_in_value_alphabet(char c)
|
||||
{
|
||||
if (
|
||||
( // Digit
|
||||
(c>='0') &&
|
||||
(c<='9')
|
||||
) ||
|
||||
( // Uppercase letter
|
||||
(c>='A') &&
|
||||
(c<='Z')
|
||||
) ||
|
||||
( // Lowerchase letter
|
||||
(c>='a') &&
|
||||
(c<='z')
|
||||
) ||
|
||||
(c == '$') || // Hexa prefix
|
||||
(c == '-') || // Minus sign
|
||||
(c== '.') // Dot (in filenames)
|
||||
)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Save_INI_set_value(char * dest,char * source,int nb_values_to_set,int * values,int litteral)
|
||||
{
|
||||
int dest_index;
|
||||
int source_index;
|
||||
int value_index;
|
||||
|
||||
// On commence par recopier tout jusqu'au symbole '=':
|
||||
for (source_index=0;source[source_index]!='=';source_index++)
|
||||
dest[source_index]=source[source_index];
|
||||
|
||||
// Puis on recopie le symbole '=':
|
||||
dest[source_index]=source[source_index];
|
||||
source_index++;
|
||||
|
||||
// Puis on recopie tous les espaces qui suivent:
|
||||
for (;source[source_index]==' ';source_index++)
|
||||
dest[source_index]=source[source_index];
|
||||
|
||||
// Pour l'instant, la source et la destination en sont au même point:
|
||||
dest_index=source_index;
|
||||
|
||||
// Puis pour chaque valeur à recopier:
|
||||
for (value_index=0;value_index<nb_values_to_set;value_index++)
|
||||
{
|
||||
// Dans la destination, on écrit la valeur:
|
||||
if (litteral)
|
||||
{
|
||||
// La valeur doit être écrite sous la forme Yes/No
|
||||
|
||||
if (values[value_index])
|
||||
{
|
||||
// La valeur <=> Yes
|
||||
|
||||
memcpy(dest+dest_index,"yes",3);
|
||||
dest_index+=3;
|
||||
}
|
||||
else
|
||||
{
|
||||
// La valeur <=> No
|
||||
|
||||
memcpy(dest+dest_index,"no",2);
|
||||
dest_index+=2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// La valeur doit être écrite sous forme numérique
|
||||
|
||||
if (source[source_index]=='$')
|
||||
{
|
||||
// On va écrire la valeur sous forme hexadécimale:
|
||||
|
||||
// On commence par inscrire le symbole '$':
|
||||
dest[dest_index]='$';
|
||||
|
||||
// Puis on y concatène la valeur:
|
||||
sprintf(dest+dest_index+1,"%x",values[value_index]);
|
||||
dest_index+=strlen(dest+dest_index);
|
||||
}
|
||||
else
|
||||
{
|
||||
// On va écrire la valeur sous forme décimale:
|
||||
|
||||
sprintf(dest+dest_index,"%d",values[value_index]);
|
||||
dest_index+=strlen(dest+dest_index);
|
||||
}
|
||||
}
|
||||
|
||||
// Dans la source, on saute la valeur:
|
||||
for (;Save_INI_char_in_value_alphabet(source[source_index]) && (source[source_index]!='\0');source_index++);
|
||||
|
||||
if (value_index!=(nb_values_to_set-1))
|
||||
{
|
||||
// Il reste d'autres valeurs à écrire
|
||||
|
||||
// On recopie tous les caractères de la source jusqu'au suivant qui
|
||||
// désigne une valeur:
|
||||
for (;(!Save_INI_char_in_value_alphabet(source[source_index])) && (source[source_index]!='\0');source_index++,dest_index++)
|
||||
dest[dest_index]=source[source_index];
|
||||
}
|
||||
else
|
||||
{
|
||||
// C'est la dernière valeur à initialiser
|
||||
|
||||
// On recopie toute la fin de la ligne:
|
||||
for (;source[source_index]!='\0';source_index++,dest_index++)
|
||||
dest[dest_index]=source[source_index];
|
||||
|
||||
// Et on n'oublie pas d'y mettre l''\0':
|
||||
dest[dest_index]='\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Save_INI_set_string(char * dest,char * source,char * value)
|
||||
{
|
||||
int dest_index;
|
||||
int source_index;
|
||||
|
||||
// On commence par recopier tout jusqu'au symbole '=':
|
||||
for (source_index=0;source[source_index]!='=';source_index++)
|
||||
dest[source_index]=source[source_index];
|
||||
|
||||
// Puis on recopie le symbole '=':
|
||||
dest[source_index]=source[source_index];
|
||||
source_index++;
|
||||
|
||||
// Puis on recopie tous les espaces qui suivent:
|
||||
for (;source[source_index]==' ';source_index++)
|
||||
dest[source_index]=source[source_index];
|
||||
|
||||
// Pour l'instant, la source et la destination en sont au même point:
|
||||
dest_index=source_index;
|
||||
|
||||
// Dans la destination, on écrit la valeur:
|
||||
strcpy(dest+dest_index,value);
|
||||
dest_index+=strlen(value);
|
||||
|
||||
// Dans la source, on saute la valeur:
|
||||
for (;Save_INI_char_in_value_alphabet(source[source_index]) && (source[source_index]!='\0');source_index++);
|
||||
|
||||
// On recopie toute la fin de la ligne:
|
||||
for (;source[source_index]!='\0';source_index++,dest_index++)
|
||||
dest[dest_index]=source[source_index];
|
||||
|
||||
// Et on n'oublie pas d'y mettre l''\0':
|
||||
dest[dest_index]='\0';
|
||||
}
|
||||
|
||||
int Save_INI_set_strings(FILE * old_file,FILE * new_file,char * buffer,char * option_name,char * value)
|
||||
{
|
||||
int stop_seek;
|
||||
char * option_upper;
|
||||
char * upper_buffer;
|
||||
char * result_buffer;
|
||||
//int buffer_index;
|
||||
|
||||
// On alloue les zones de mémoire:
|
||||
option_upper=(char *)malloc(1024);
|
||||
upper_buffer=(char *)malloc(1024);
|
||||
result_buffer=(char *)malloc(1024);
|
||||
|
||||
// On convertit un eventuel argument NULL en chaine vide.
|
||||
if (value == NULL)
|
||||
value="";
|
||||
|
||||
// On commence par se faire une version majuscule de l'option à rechercher:
|
||||
strcpy(option_upper,option_name);
|
||||
Load_INI_clear_string(option_upper, 0);
|
||||
|
||||
stop_seek=0;
|
||||
do
|
||||
{
|
||||
// On lit une ligne dans le fichier:
|
||||
if (fgets(buffer,1024,old_file)==0)
|
||||
{
|
||||
free(result_buffer);
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
return ERROR_INI_CORRUPTED;
|
||||
}
|
||||
|
||||
// On s'en fait une version en majuscule:
|
||||
strcpy(upper_buffer,buffer);
|
||||
Load_INI_clear_string(upper_buffer, 0);
|
||||
|
||||
// On compare la chaîne avec l'option recherchée:
|
||||
stop_seek=Load_INI_seek_pattern(upper_buffer,option_upper);
|
||||
|
||||
if (stop_seek)
|
||||
{
|
||||
// On l'a trouvée:
|
||||
|
||||
Save_INI_set_string(result_buffer,buffer,value);
|
||||
if (fprintf(new_file,"%s",result_buffer)<0)
|
||||
{
|
||||
free(result_buffer);
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
return ERROR_SAVING_INI;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// On l'a pas trouvée:
|
||||
|
||||
if (fprintf(new_file,"%s",buffer)<0)
|
||||
{
|
||||
free(result_buffer);
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
return ERROR_SAVING_INI;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (stop_seek==0);
|
||||
|
||||
free(result_buffer);
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Save_INI_set_values(FILE * old_file,FILE * new_file,char * buffer,char * option_name,int nb_values_to_set,int * values,int litteral)
|
||||
{
|
||||
int stop_seek;
|
||||
char * option_upper;
|
||||
char * upper_buffer;
|
||||
char * result_buffer;
|
||||
//int buffer_index;
|
||||
|
||||
// On alloue les zones de mémoire:
|
||||
option_upper=(char *)malloc(1024);
|
||||
upper_buffer=(char *)malloc(1024);
|
||||
result_buffer=(char *)malloc(1024);
|
||||
|
||||
// On commence par se faire une version majuscule de l'option à rechercher:
|
||||
strcpy(option_upper,option_name);
|
||||
Load_INI_clear_string(option_upper, 0);
|
||||
|
||||
stop_seek=0;
|
||||
do
|
||||
{
|
||||
// On lit une ligne dans le fichier:
|
||||
if (fgets(buffer,1024,old_file)==0)
|
||||
{
|
||||
free(result_buffer);
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
DEBUG("END OF FILE",0);
|
||||
return ERROR_INI_CORRUPTED;
|
||||
}
|
||||
|
||||
// On s'en fait une version en majuscule:
|
||||
strcpy(upper_buffer,buffer);
|
||||
Load_INI_clear_string(upper_buffer, 0);
|
||||
|
||||
// On compare la chaîne avec l'option recherchée:
|
||||
stop_seek=Load_INI_seek_pattern(upper_buffer,option_upper);
|
||||
|
||||
if (stop_seek)
|
||||
{
|
||||
// On l'a trouvée:
|
||||
|
||||
Save_INI_set_value(result_buffer,buffer,nb_values_to_set,values,litteral);
|
||||
if (fprintf(new_file,"%s",result_buffer)<0)
|
||||
{
|
||||
free(result_buffer);
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
return ERROR_SAVING_INI;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// On l'a pas trouvée:
|
||||
|
||||
if (fprintf(new_file,"%s",buffer)<0)
|
||||
{
|
||||
free(result_buffer);
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
return ERROR_SAVING_INI;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (stop_seek==0);
|
||||
|
||||
free(result_buffer);
|
||||
free(upper_buffer);
|
||||
free(option_upper);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Save_INI_flush(FILE * old_file,FILE * new_file,char * buffer)
|
||||
{
|
||||
while (fgets(buffer,1024,old_file)!=0)
|
||||
fprintf(new_file,"%s",buffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Save_INI(T_Config * conf)
|
||||
{
|
||||
FILE * Ancien_fichier;
|
||||
FILE * Nouveau_fichier;
|
||||
char * buffer;
|
||||
int values[3];
|
||||
char filename[MAX_PATH_CHARACTERS];
|
||||
char temp_filename[MAX_PATH_CHARACTERS];
|
||||
int return_code;
|
||||
char ref_ini_file[MAX_PATH_CHARACTERS];
|
||||
int ini_file_exists;
|
||||
int index;
|
||||
|
||||
// On alloue les zones de mémoire:
|
||||
buffer=(char *)malloc(1024);
|
||||
|
||||
// On calcule les noms des fichiers qu'on manipule:
|
||||
strcpy(filename,Config_directory);
|
||||
strcat(filename,"gfx2.ini");
|
||||
|
||||
// On vérifie si le fichier INI existe
|
||||
if ((ini_file_exists = File_exists(filename)))
|
||||
{
|
||||
strcpy(temp_filename,Config_directory);
|
||||
strcat(temp_filename,"gfx2.$$$");
|
||||
|
||||
// On renome l'ancienne version du fichier INI vers un fichier temporaire:
|
||||
if (rename(filename,temp_filename)!=0)
|
||||
{
|
||||
goto Erreur_ERREUR_SAUVEGARDE_INI;
|
||||
}
|
||||
}
|
||||
// On récupère un fichier INI "propre" à partir de gfx2def.ini
|
||||
strcpy(ref_ini_file,Data_directory);
|
||||
strcat(ref_ini_file,"gfx2def.ini");
|
||||
Ancien_fichier=fopen(ref_ini_file,"rb");
|
||||
if (Ancien_fichier==0)
|
||||
{
|
||||
fclose(Ancien_fichier);
|
||||
free(buffer);
|
||||
return ERROR_INI_MISSING;
|
||||
}
|
||||
Nouveau_fichier=fopen(filename,"wb");
|
||||
if (Nouveau_fichier==0)
|
||||
{
|
||||
free(buffer);
|
||||
return ERROR_SAVING_INI;
|
||||
}
|
||||
if ((return_code=Save_INI_reach_group(Ancien_fichier,Nouveau_fichier,buffer,"[MOUSE]")))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Mouse_sensitivity_index_x;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"X_sensitivity",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Mouse_sensitivity_index_y;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Y_sensitivity",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=0;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"X_correction_factor",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=0;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Y_correction_factor",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=(conf->Cursor)+1;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Cursor_aspect",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
if ((return_code=Save_INI_reach_group(Ancien_fichier,Nouveau_fichier,buffer,"[MENU]")))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Fav_menu_colors[2].R>>2;
|
||||
values[1]=conf->Fav_menu_colors[2].G>>2;
|
||||
values[2]=conf->Fav_menu_colors[2].B>>2;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Light_color",3,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Fav_menu_colors[1].R>>2;
|
||||
values[1]=conf->Fav_menu_colors[1].G>>2;
|
||||
values[2]=conf->Fav_menu_colors[1].B>>2;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Dark_color",3,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Ratio;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Menu_ratio",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
if ((return_code=Save_INI_reach_group(Ancien_fichier,Nouveau_fichier,buffer,"[FILE_SELECTOR]")))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Show_hidden_files?1:0;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Show_hidden_files",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Show_hidden_directories?1:0;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Show_hidden_directories",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
/* values[0]=conf->Show_system_directories?1:0;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Show_system_directories",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
*/
|
||||
values[0]=conf->Timer_delay;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Preview_delay",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Maximize_preview;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Maximize_preview",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Find_file_fast;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Find_file_fast",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
|
||||
if ((return_code=Save_INI_reach_group(Ancien_fichier,Nouveau_fichier,buffer,"[LOADING]")))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Auto_set_res;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Auto_set_resolution",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Set_resolution_according_to;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Set_resolution_according_to",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Clear_palette;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Clear_palette",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
|
||||
if ((return_code=Save_INI_reach_group(Ancien_fichier,Nouveau_fichier,buffer,"[MISCELLANEOUS]")))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Display_image_limits;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Draw_limits",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Adjust_brush_pick;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Adjust_brush_pick",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=2-conf->Coords_rel;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Coordinates",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Backup;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Backup",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Max_undo_pages;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Undo_pages",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Delay_left_click_on_slider;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Gauges_scrolling_speed_Left",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Delay_right_click_on_slider;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Gauges_scrolling_speed_Right",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Auto_save;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Auto_save",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Nb_max_vertices_per_polygon;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Vertices_per_polygon",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Fast_zoom;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Fast_zoom",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Separate_colors;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Separate_colors",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->FX_Feedback;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"FX_feedback",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Safety_colors;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Safety_colors",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Opening_message;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Opening_message",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Clear_with_stencil;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Clear_with_stencil",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Auto_discontinuous;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Auto_discontinuous",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Screen_size_in_GIF;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Save_screen_size_in_GIF",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Auto_nb_used;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Auto_nb_colors_used",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
if ((return_code=Save_INI_set_strings (Ancien_fichier,Nouveau_fichier,buffer,"Default_video_mode",Mode_label(conf->Default_resolution))))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=Video_mode[0].Width;
|
||||
values[1]=Video_mode[0].Height;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Default_window_size",2,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=(conf->Mouse_merge_movement);
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Merge_movement",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=(conf->Palette_cells_X);
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Palette_cells_X",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=(conf->Palette_cells_Y);
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Palette_cells_Y",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
for (index=0;index<NB_BOOKMARKS;index++)
|
||||
{
|
||||
if ((return_code=Save_INI_set_strings (Ancien_fichier,Nouveau_fichier,buffer,"Bookmark_label",conf->Bookmark_label[index])))
|
||||
goto Erreur_Retour;
|
||||
if ((return_code=Save_INI_set_strings (Ancien_fichier,Nouveau_fichier,buffer,"Bookmark_directory",conf->Bookmark_directory[index])))
|
||||
goto Erreur_Retour;
|
||||
}
|
||||
values[0]=(conf->Palette_vertical);
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Palette_vertical",1,values,1)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=conf->Window_pos_x;
|
||||
values[1]=conf->Window_pos_y;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Window_position",2,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=(conf->Double_click_speed);
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Double_click_speed",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=(conf->Double_key_speed);
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Double_key_speed",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
if ((return_code=Save_INI_set_strings (Ancien_fichier,Nouveau_fichier,buffer,"Skin_file",conf->Skin_file)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
if ((return_code=Save_INI_set_strings (Ancien_fichier,Nouveau_fichier,buffer,"Font_file",conf->Font_file)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=(conf->Grid_XOR_color);
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Grid_XOR_color",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=(Pixel_ratio);
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Pixel_ratio",1,values,0))) {
|
||||
DEBUG("saving pixel ratio",return_code);
|
||||
goto Erreur_Retour;
|
||||
}
|
||||
|
||||
values[0]=0;
|
||||
for (index=0; index<MENUBAR_COUNT;index++)
|
||||
{
|
||||
values[0] |= Menu_bars[index].Visible ? (1<<index) : 0;
|
||||
}
|
||||
// Fill out the remaining bits. When new toolbars get implemented, they will
|
||||
// be visible by default.
|
||||
for (; index<8;index++)
|
||||
values[0] |= (1<<index);
|
||||
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Menubars_visible",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
|
||||
Save_INI_flush(Ancien_fichier,Nouveau_fichier,buffer);
|
||||
|
||||
fclose(Nouveau_fichier);
|
||||
fclose(Ancien_fichier);
|
||||
|
||||
// On efface le fichier temporaire <=> Ancienne version du .INI
|
||||
if (ini_file_exists)
|
||||
remove(temp_filename);
|
||||
free(buffer);
|
||||
return 0;
|
||||
|
||||
// Gestion des erreurs:
|
||||
|
||||
Erreur_Retour:
|
||||
|
||||
fclose(Nouveau_fichier);
|
||||
fclose(Ancien_fichier);
|
||||
free(buffer);
|
||||
return return_code;
|
||||
|
||||
Erreur_ERREUR_SAUVEGARDE_INI:
|
||||
|
||||
free(buffer);
|
||||
return ERROR_SAVING_INI;
|
||||
}
|
||||
27
src/saveini.h
Normal file
27
src/saveini.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 saveini.h
|
||||
/// Saving settings in gfx2.ini
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int Save_INI(T_Config * conf);
|
||||
259
src/sdlscreen.c
Normal file
259
src/sdlscreen.c
Normal file
@@ -0,0 +1,259 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <SDL.h>
|
||||
#include "global.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "errors.h"
|
||||
#include "misc.h"
|
||||
|
||||
// Update method that does a large number of small rectangles, aiming
|
||||
// for a minimum number of total pixels updated.
|
||||
#define UPDATE_METHOD_MULTI_RECTANGLE 1
|
||||
// Intermediate update method, does only one update with the smallest
|
||||
// rectangle that includes all modified pixels.
|
||||
#define UPDATE_METHOD_CUMULATED 2
|
||||
// Total screen update, for platforms that impose a Vsync on each SDL update.
|
||||
#define UPDATE_METHOD_FULL_PAGE 3
|
||||
|
||||
// UPDATE_METHOD can be set from makefile, otherwise it's selected here
|
||||
// depending on the platform :
|
||||
#ifndef UPDATE_METHOD
|
||||
#if defined(__macosx__)
|
||||
#define UPDATE_METHOD UPDATE_METHOD_FULL_PAGE
|
||||
#else
|
||||
#define UPDATE_METHOD UPDATE_METHOD_CUMULATED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/// Sets the new screen/window dimensions.
|
||||
void Set_mode_SDL(int *width, int *height, int fullscreen)
|
||||
{
|
||||
Screen_SDL=SDL_SetVideoMode(*width,*height,8,(fullscreen?SDL_FULLSCREEN:0)|SDL_RESIZABLE);
|
||||
if(Screen_SDL != NULL)
|
||||
{
|
||||
// Check the mode we got, in case it was different from the one we requested.
|
||||
if (Screen_SDL->w != *width || Screen_SDL->h != *height)
|
||||
{
|
||||
DEBUG("Error: Got a different video mode than the requested one!",0);
|
||||
*width = Screen_SDL->w;
|
||||
*height = Screen_SDL->h;
|
||||
}
|
||||
Screen_pixels=Screen_SDL->pixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG("Error: Unable to change video mode!",0);
|
||||
}
|
||||
SDL_ShowCursor(0); // Hide the SDL mouse cursor, we use our own
|
||||
}
|
||||
|
||||
#if (UPDATE_METHOD == UPDATE_METHOD_CUMULATED)
|
||||
short Min_X=0;
|
||||
short Min_Y=0;
|
||||
short Max_X=10000;
|
||||
short Max_Y=10000;
|
||||
#endif
|
||||
|
||||
#if (UPDATE_METHOD == UPDATE_METHOD_FULL_PAGE)
|
||||
int update_is_required=0;
|
||||
#endif
|
||||
|
||||
void Flush_update(void)
|
||||
{
|
||||
#if (UPDATE_METHOD == UPDATE_METHOD_FULL_PAGE)
|
||||
// Do a full screen update
|
||||
if (update_is_required)
|
||||
{
|
||||
SDL_UpdateRect(Screen_SDL, 0, 0, 0, 0);
|
||||
update_is_required=0;
|
||||
}
|
||||
#endif
|
||||
#if (UPDATE_METHOD == UPDATE_METHOD_CUMULATED)
|
||||
if (Min_X>=Max_X || Min_Y>=Max_Y)
|
||||
{
|
||||
; // Nothing to do
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Min_X<0)
|
||||
Min_X=0;
|
||||
if (Min_Y<0)
|
||||
Min_Y=0;
|
||||
SDL_UpdateRect(Screen_SDL, Min_X*Pixel_width, Min_Y*Pixel_height, Min(Screen_width-Min_X, Max_X-Min_X)*Pixel_width, Min(Screen_height-Min_Y, Max_Y-Min_Y)*Pixel_height);
|
||||
|
||||
Min_X=Min_Y=10000;
|
||||
Max_X=Max_Y=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void Update_rect(short x, short y, unsigned short width, unsigned short height)
|
||||
{
|
||||
#if (UPDATE_METHOD == UPDATE_METHOD_MULTI_RECTANGLE)
|
||||
SDL_UpdateRect(Screen_SDL, x*Pixel_width, y*Pixel_height, width*Pixel_width, height*Pixel_height);
|
||||
#endif
|
||||
|
||||
#if (UPDATE_METHOD == UPDATE_METHOD_CUMULATED)
|
||||
if (width==0 || height==0)
|
||||
{
|
||||
Min_X=Min_Y=0;
|
||||
Max_X=Max_Y=10000;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x < Min_X)
|
||||
Min_X = x;
|
||||
if (y < Min_Y)
|
||||
Min_Y = y;
|
||||
if (x+width>Max_X)
|
||||
Max_X=x+width;
|
||||
if (y+height>Max_Y)
|
||||
Max_Y=y+height;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (UPDATE_METHOD == UPDATE_METHOD_FULL_PAGE)
|
||||
update_is_required=1;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
///
|
||||
/// Converts a SDL_Surface (indexed colors or RGB) into an array of bytes
|
||||
/// (indexed colors).
|
||||
/// If dest is NULL, it's allocated by malloc(). Otherwise, be sure to
|
||||
/// pass a buffer of the right dimensions.
|
||||
byte * Surface_to_bytefield(SDL_Surface *source, byte * dest)
|
||||
{
|
||||
byte *src;
|
||||
byte *dest_ptr;
|
||||
int y;
|
||||
int remainder;
|
||||
|
||||
// Support seulement des images 256 couleurs
|
||||
if (source->format->BytesPerPixel != 1)
|
||||
return NULL;
|
||||
|
||||
if (source->w & 3)
|
||||
remainder=4-(source->w&3);
|
||||
else
|
||||
remainder=0;
|
||||
|
||||
if (dest==NULL)
|
||||
dest=(byte *)malloc(source->w*source->h);
|
||||
|
||||
dest_ptr=dest;
|
||||
src=(byte *)(source->pixels);
|
||||
for(y=0; y < source->h; y++)
|
||||
{
|
||||
memcpy(dest_ptr, src,source->w);
|
||||
dest_ptr += source->w;
|
||||
src += source->w + remainder;
|
||||
}
|
||||
return dest;
|
||||
|
||||
}
|
||||
|
||||
/// Gets the RGB 24-bit color currently associated with a palette index.
|
||||
SDL_Color Color_to_SDL_color(byte index)
|
||||
{
|
||||
SDL_Color color;
|
||||
color.r = Main_palette[index].R;
|
||||
color.g = Main_palette[index].G;
|
||||
color.b = Main_palette[index].B;
|
||||
color.unused = 255;
|
||||
return color;
|
||||
}
|
||||
|
||||
/// Reads a pixel in a 8-bit SDL surface.
|
||||
byte Get_SDL_pixel_8(SDL_Surface *bmp, int x, int y)
|
||||
{
|
||||
return ((byte *)(bmp->pixels))[(y*bmp->pitch+x)];
|
||||
}
|
||||
|
||||
/// Reads a pixel in a multi-byte SDL surface.
|
||||
dword Get_SDL_pixel_hicolor(SDL_Surface *bmp, int x, int y)
|
||||
{
|
||||
switch(bmp->format->BytesPerPixel)
|
||||
{
|
||||
case 4:
|
||||
default:
|
||||
return *((dword *)((byte *)bmp->pixels+(y*bmp->pitch+x*4)));
|
||||
case 3:
|
||||
return *(((dword *)((byte *)bmp->pixels+(y*bmp->pitch+x*3)))) & 0xFFFFFF;
|
||||
case 2:
|
||||
return *((word *)((byte *)bmp->pixels+(y*bmp->pitch+x*2)));
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert a SDL Palette to a grafx2 palette
|
||||
void Get_SDL_Palette(const SDL_Palette * sdl_palette, T_Palette palette)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<256; i++)
|
||||
{
|
||||
palette[i].R=sdl_palette->colors[i].r;
|
||||
palette[i].G=sdl_palette->colors[i].g;
|
||||
palette[i].B=sdl_palette->colors[i].b;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Clear_border(byte color)
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
|
||||
// This function can be called before the graphics mode is set.
|
||||
// Nothing to do then.
|
||||
if (!Screen_SDL)
|
||||
return;
|
||||
|
||||
width = Screen_SDL->w - Screen_width*Pixel_width;
|
||||
height = Screen_SDL->h - Screen_height*Pixel_height;
|
||||
if (width)
|
||||
{
|
||||
SDL_Rect r;
|
||||
r.x=Screen_SDL->w - width;
|
||||
r.y=0;
|
||||
r.h=Screen_SDL->h;
|
||||
r.w=width;
|
||||
SDL_FillRect(Screen_SDL,&r,color);
|
||||
SDL_UpdateRect(Screen_SDL, r.x, r.y, r.w, r.h);
|
||||
}
|
||||
if (height)
|
||||
{
|
||||
SDL_Rect r;
|
||||
r.x=0;
|
||||
r.y=Screen_SDL->h - height;
|
||||
r.h=height;
|
||||
r.w=Screen_SDL->w - height;
|
||||
SDL_FillRect(Screen_SDL,&r,color);
|
||||
SDL_UpdateRect(Screen_SDL, r.x, r.y, r.w, r.h);
|
||||
}
|
||||
}
|
||||
|
||||
68
src/sdlscreen.h
Normal file
68
src/sdlscreen.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 sdlscreen.h
|
||||
/// Screen update (refresh) system, and some SDL-specific graphic functions.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDLSCREEN_H_INCLUDED
|
||||
#define SDLSCREEN_H_INCLUDED
|
||||
|
||||
#include <SDL.h>
|
||||
#include "struct.h"
|
||||
|
||||
///
|
||||
/// This is the number of bytes in a video line for the current mode.
|
||||
/// On many platforms it will be the video mode's width (in pixels), rounded up
|
||||
/// to be a multiple of 4.
|
||||
#define VIDEO_LINE_WIDTH (Screen_SDL->pitch)
|
||||
|
||||
void Set_mode_SDL(int *,int *,int);
|
||||
|
||||
SDL_Rect ** List_SDL_video_modes;
|
||||
byte* Screen_pixels;
|
||||
|
||||
void Update_rect(short x, short y, unsigned short width, unsigned short height);
|
||||
void Flush_update(void);
|
||||
///
|
||||
/// Converts a SDL_Surface (indexed colors or RGB) into an array of bytes
|
||||
/// (indexed colors).
|
||||
/// If dest is NULL, it's allocated by malloc(). Otherwise, be sure to
|
||||
/// pass a buffer of the right dimensions.
|
||||
byte * Surface_to_bytefield(SDL_Surface *source, byte * dest);
|
||||
/// Gets the RGB 24-bit color currently associated with a palette index.
|
||||
SDL_Color Color_to_SDL_color(byte);
|
||||
/// Reads a pixel in a 8-bit SDL surface.
|
||||
byte Get_SDL_pixel_8(SDL_Surface *bmp, int x, int y);
|
||||
/// Reads a pixel in a multi-byte SDL surface.
|
||||
dword Get_SDL_pixel_hicolor(SDL_Surface *bmp, int x, int y);
|
||||
/// Convert a SDL Palette to a grafx2 palette
|
||||
void Get_SDL_Palette(const SDL_Palette * sdl_palette, T_Palette palette);
|
||||
|
||||
///
|
||||
/// Clears the parts of screen that are outside of the editing area.
|
||||
/// There is such area only if the screen mode is not a multiple of the pixel
|
||||
/// size, eg: 3x3 pixels in 1024x768 leaves 1 column on the right, 0 rows on bottom.
|
||||
void Clear_border(byte color);
|
||||
|
||||
#endif // SDLSCREEN_H_INCLUDED
|
||||
197
src/setup.c
Normal file
197
src/setup.c
Normal file
@@ -0,0 +1,197 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Peter Gordon
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#if defined(__WIN32__)
|
||||
#include <windows.h>
|
||||
#include <io.h> // Mingw's _mkdir()
|
||||
#elif defined(__macosx__)
|
||||
#import <corefoundation/corefoundation.h>
|
||||
#import <sys/param.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#import <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include "struct.h"
|
||||
#include "io.h"
|
||||
#include "setup.h"
|
||||
|
||||
int Create_ConfigDirectory(char * config_dir)
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
// Mingw's mkdir has a weird name and only one argument
|
||||
return _mkdir(config_dir);
|
||||
#else
|
||||
return mkdir(config_dir,S_IRUSR|S_IWUSR|S_IXUSR);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__macosx__) || defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) && !defined(__VBCC__)
|
||||
#define ARG_UNUSED __attribute__((unused))
|
||||
#else
|
||||
#define ARG_UNUSED
|
||||
#endif
|
||||
// Determine which directory contains the executable.
|
||||
// IN: Main's argv[0], some platforms need it, some don't.
|
||||
// OUT: Write into program_dir. Trailing / or \ is kept.
|
||||
// Note : in fact this is only used to check for the datafiles and fonts in
|
||||
// this same directory.
|
||||
void Set_program_directory(ARG_UNUSED const char * argv0,char * program_dir)
|
||||
{
|
||||
#undef ARG_UNUSED
|
||||
|
||||
// MacOSX
|
||||
#if defined(__macosx__)
|
||||
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||
CFURLGetFileSystemRepresentation(url,true,(UInt8*)program_dir,MAXPATHLEN);
|
||||
CFRelease(url);
|
||||
// Append trailing slash
|
||||
strcat(program_dir ,"/");
|
||||
|
||||
// AmigaOS and alike: hard-coded volume name.
|
||||
#elif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
|
||||
strcpy(program_dir,"PROGDIR:");
|
||||
|
||||
// Others: The part of argv[0] before the executable name.
|
||||
// Keep the last \ or /.
|
||||
// Note that on Unix, once installed, the executable is called from a shell
|
||||
// script sitting in /usr/local/bin/, this allows argv[0] to contain the full
|
||||
// path. On Windows, Mingw32 already provides the full path in all cases.
|
||||
#else
|
||||
Extract_path(program_dir, argv0);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Determine which directory contains the read-only data.
|
||||
// IN: The directory containing the executable
|
||||
// OUT: Write into data_dir. Trailing / or \ is kept.
|
||||
void Set_data_directory(const char * program_dir, char * data_dir)
|
||||
{
|
||||
// On all platforms, data is relative to the executable's directory
|
||||
strcpy(data_dir,program_dir);
|
||||
// On MacOSX, it is stored in a special folder:
|
||||
#if defined(__macosx__)
|
||||
strcat(data_dir,"Contents/Resources/");
|
||||
// On GP2X, executable is not in bin/
|
||||
#elif defined (__gp2x__)
|
||||
strcat(data_dir,"share/grafx2/");
|
||||
// All other targets, program is in a "bin" subdirectory
|
||||
#else
|
||||
strcat(data_dir,"../share/grafx2/");
|
||||
#endif
|
||||
}
|
||||
|
||||
// Determine which directory should store the user's configuration.
|
||||
//
|
||||
// For most Unix and Windows platforms:
|
||||
// If a config file already exists in program_dir, it will return it in priority
|
||||
// (Useful for development, and possibly for upgrading from DOS version)
|
||||
// If the standard directory doesn't exist yet, this function will attempt
|
||||
// to create it ($(HOME)/.grafx2, or %APPDATA%\GrafX2)
|
||||
// If it cannot be created, this function will return the executable's
|
||||
// own directory.
|
||||
// IN: The directory containing the executable
|
||||
// OUT: Write into config_dir. Trailing / or \ is kept.
|
||||
void Set_config_directory(const char * program_dir, char * config_dir)
|
||||
{
|
||||
// AmigaOS4
|
||||
#if defined(__amigaos4__) || defined(__AROS__)
|
||||
strcpy(config_dir,"PROGDIR:");
|
||||
// GP2X
|
||||
#elif defined(__GP2X__)
|
||||
// On the GP2X, the program is installed to the sdcard, and we don't want to mess with the system tree which is
|
||||
// on an internal flash chip. So, keep these settings locals.
|
||||
strcpy(config_dir,program_dir);
|
||||
#else
|
||||
char filename[MAX_PATH_CHARACTERS];
|
||||
|
||||
// In priority: check root directory
|
||||
strcpy(config_dir, program_dir);
|
||||
// On all these targets except OSX and GP2X, the executable is in ./bin
|
||||
#if !defined(__macosx__) && !defined(__gp2x__)
|
||||
strcat(config_dir, "../");
|
||||
#endif
|
||||
strcpy(filename, config_dir);
|
||||
strcat(filename, "gfx2.cfg");
|
||||
|
||||
if (!File_exists(filename))
|
||||
{
|
||||
char *config_parent_dir;
|
||||
#if defined(__WIN32__)
|
||||
// "%APPDATA%\GrafX2"
|
||||
const char* Config_SubDir = "GrafX2";
|
||||
config_parent_dir = getenv("APPDATA");
|
||||
#elif defined(__BEOS__) || defined(__HAIKU__)
|
||||
// "~/.grafx2", the BeOS way
|
||||
const char* Config_SubDir = ".grafx2";
|
||||
config_parent_dir = getenv("$HOME");
|
||||
#elif defined(__macosx__)
|
||||
// "~/Library/Preferences/com.googlecode.grafx2"
|
||||
const char* Config_SubDir = "Library/Preferences/com.googlecode.grafx2";
|
||||
config_parent_dir = getenv("HOME");
|
||||
#else
|
||||
// "~/.grafx2"
|
||||
const char* Config_SubDir = ".grafx2";
|
||||
config_parent_dir = getenv("HOME");
|
||||
#endif
|
||||
|
||||
if (config_parent_dir && config_parent_dir[0]!='\0')
|
||||
{
|
||||
int size = strlen(config_parent_dir);
|
||||
strcpy(config_dir, config_parent_dir);
|
||||
if (config_parent_dir[size-1] != '\\' && config_parent_dir[size-1] != '/')
|
||||
{
|
||||
strcat(config_dir,PATH_SEPARATOR);
|
||||
}
|
||||
strcat(config_dir,Config_SubDir);
|
||||
if (Directory_exists(config_dir))
|
||||
{
|
||||
// Répertoire trouvé, ok
|
||||
strcat(config_dir,PATH_SEPARATOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Tentative de création
|
||||
if (!Create_ConfigDirectory(config_dir))
|
||||
{
|
||||
// Réussi
|
||||
strcat(config_dir,PATH_SEPARATOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Echec: on se rabat sur le repertoire de l'executable.
|
||||
strcpy(config_dir,program_dir);
|
||||
#if !defined(__macosx__) && !defined(__gp2x__)
|
||||
strcat(config_dir, "../");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
56
src/setup.h
Normal file
56
src/setup.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Peter Gordon
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 setup.h
|
||||
/// Functions that determine where grafx2 is running, finds its data, and
|
||||
/// reads and writes configuration files.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///
|
||||
/// Determine which directory contains the executable.
|
||||
/// - IN: Main's argv[0], some platforms need it, some don't.
|
||||
/// - OUT: Write into program_dir. Trailing / or \ is kept.
|
||||
/// Note : in fact this is only used to check for the datafiles and fonts in this same directory.
|
||||
void Set_program_directory(const char * argv0,char * program_dir);
|
||||
|
||||
///
|
||||
/// Determine which directory contains the read-only data.
|
||||
/// IN: The directory containing the executable
|
||||
/// OUT: Write into data_dir. Trailing / or \ is kept.
|
||||
void Set_data_directory(const char * program_dir, char * data_dir);
|
||||
|
||||
///
|
||||
/// Determine which directory should store the user's configuration.
|
||||
/// For most Unix and Windows platforms:
|
||||
/// If a config file already exists in program_dir, it will return it in priority
|
||||
/// (Useful for development, and possibly for upgrading from DOS version)
|
||||
/// If the standard directory doesn't exist yet, this function will attempt
|
||||
/// to create it ($(HOME)/.grafx2, or %APPDATA%\\GrafX2)
|
||||
/// If it cannot be created, this function will return the executable's
|
||||
/// own directory.
|
||||
/// IN: The directory containing the executable
|
||||
/// OUT: Write into config_dir. Trailing / or \ is kept.
|
||||
void Set_config_directory(const char * program_dir, char * config_dir);
|
||||
|
||||
1132
src/shade.c
Normal file
1132
src/shade.c
Normal file
File diff suppressed because it is too large
Load Diff
34
src/shade.h
Normal file
34
src/shade.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 shade.h
|
||||
/// Screens for Shade and Quick-shade settings.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef SHADE_H_INCLUDED
|
||||
#define SHADE_H_INCLUDED
|
||||
|
||||
void Button_Quick_shade_menu(void);
|
||||
|
||||
int Shade_settings_menu(void);
|
||||
|
||||
#endif // SHADE_H_INCLUDED
|
||||
472
src/special.c
Normal file
472
src/special.c
Normal file
@@ -0,0 +1,472 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "const.h"
|
||||
#include "struct.h"
|
||||
#include "global.h"
|
||||
#include "graph.h"
|
||||
#include "engine.h"
|
||||
#include "windows.h"
|
||||
#include "special.h"
|
||||
#include "pages.h"
|
||||
#include "misc.h"
|
||||
#include "buttons.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------- Modifier le pinceau spécial -------------------------
|
||||
|
||||
int Circle_squared_diameter(int diameter)
|
||||
{
|
||||
int result = diameter*diameter;
|
||||
// Trick to make some circles rounder, even though
|
||||
// mathematically incorrect.
|
||||
if (diameter==3 || diameter==9)
|
||||
return result-2;
|
||||
if (diameter==11)
|
||||
return result-6;
|
||||
if (diameter==14)
|
||||
return result-4;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Set_paintbrush_size(int width, int height)
|
||||
{
|
||||
int x_pos,y_pos;
|
||||
int x,y;
|
||||
int radius2;
|
||||
|
||||
if (width<1) width=1;
|
||||
if (height<1) height=1;
|
||||
if (width>MAX_PAINTBRUSH_SIZE) width=MAX_PAINTBRUSH_SIZE;
|
||||
if (height>MAX_PAINTBRUSH_SIZE) height=MAX_PAINTBRUSH_SIZE;
|
||||
Paintbrush_width=width;
|
||||
Paintbrush_height=height;
|
||||
Paintbrush_offset_X=Paintbrush_width>>1;
|
||||
Paintbrush_offset_Y=Paintbrush_height>>1;
|
||||
switch (Paintbrush_shape)
|
||||
{
|
||||
case PAINTBRUSH_SHAPE_ROUND :
|
||||
radius2=Circle_squared_diameter(Paintbrush_width);
|
||||
|
||||
for (y_pos=0, y=1-Paintbrush_height; y_pos<Paintbrush_height; y_pos++,y+=2)
|
||||
for (x_pos=0, x=1-Paintbrush_width; x_pos<Paintbrush_width; x_pos++,x+=2)
|
||||
{
|
||||
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( ((x*x)+(y*y)) <= radius2 );
|
||||
}
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_SQUARE :
|
||||
for (x_pos=0,y_pos=0; x_pos<Paintbrush_height; x_pos++,y_pos+=MAX_PAINTBRUSH_SIZE)
|
||||
memset(Paintbrush_sprite+y_pos,1,Paintbrush_width);
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_SIEVE_ROUND :
|
||||
{
|
||||
int reminder=0;
|
||||
if (Paintbrush_width==1)
|
||||
reminder = 1;
|
||||
|
||||
radius2=Circle_squared_diameter(Paintbrush_width);
|
||||
|
||||
for (y_pos=0, y=1-Paintbrush_height; y_pos<Paintbrush_height; y_pos++,y+=2)
|
||||
for (x_pos=0, x=1-Paintbrush_width; x_pos<Paintbrush_width; x_pos++,x+=2)
|
||||
{
|
||||
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( ((x_pos+y_pos+reminder)&1) && (((x*x)+(y*y)) < radius2));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PAINTBRUSH_SHAPE_SIEVE_SQUARE:
|
||||
for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
|
||||
for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
|
||||
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=!((x_pos+y_pos)&1);
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_PLUS:
|
||||
x=Paintbrush_width>>1;
|
||||
for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
|
||||
for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
|
||||
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=((x_pos==x) || (y_pos==x));
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_SLASH:
|
||||
x=Paintbrush_width>>1;
|
||||
for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
|
||||
for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
|
||||
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(x_pos==(Paintbrush_width-(y_pos+1)));
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_ANTISLASH:
|
||||
x=Paintbrush_width>>1;
|
||||
for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
|
||||
for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
|
||||
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(x_pos==y_pos);
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
|
||||
memset(Paintbrush_sprite,1,Paintbrush_width);
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_VERTICAL_BAR:
|
||||
for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
|
||||
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)]=1;
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_CROSS:
|
||||
x=Paintbrush_width>>1;
|
||||
for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
|
||||
for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
|
||||
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (x_pos==y_pos) || (x_pos==(Paintbrush_height-(y_pos+1))) );
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_DIAMOND:
|
||||
x=Paintbrush_width>>1;
|
||||
for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
|
||||
for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
|
||||
{
|
||||
if (x_pos<=x)
|
||||
y=x-x_pos;
|
||||
else
|
||||
y=x_pos-x;
|
||||
if (y_pos<=x)
|
||||
y+=x-y_pos;
|
||||
else
|
||||
y+=y_pos-x;
|
||||
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(y<=x);
|
||||
}
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_RANDOM:
|
||||
// Init with blank
|
||||
for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
|
||||
memset(Paintbrush_sprite+y_pos*MAX_PAINTBRUSH_SIZE,0,Paintbrush_width);
|
||||
|
||||
radius2=Circle_squared_diameter(Paintbrush_width);
|
||||
|
||||
for (y_pos=0, y=1-Paintbrush_height; y_pos<Paintbrush_height; y_pos++,y+=2)
|
||||
for (x_pos=0, x=1-Paintbrush_width; x_pos<Paintbrush_width; x_pos++,x+=2)
|
||||
{
|
||||
if ((x*x)+(y*y) < radius2 && !(rand()&7))
|
||||
{
|
||||
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=1;
|
||||
// This prevents having a pixels that touch each other.
|
||||
if (x_pos>0)
|
||||
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos-1]=0;
|
||||
if (y_pos>0)
|
||||
Paintbrush_sprite[((y_pos-1)*MAX_PAINTBRUSH_SIZE)+x_pos]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Smaller_paintbrush(void)
|
||||
{
|
||||
if ( (Paintbrush_shape<PAINTBRUSH_SHAPE_MISC)
|
||||
&& ( (Paintbrush_width>1)
|
||||
|| (Paintbrush_height>1) ) )
|
||||
{
|
||||
Hide_cursor();
|
||||
switch (Paintbrush_shape)
|
||||
{
|
||||
case PAINTBRUSH_SHAPE_CROSS:
|
||||
case PAINTBRUSH_SHAPE_PLUS:
|
||||
case PAINTBRUSH_SHAPE_DIAMOND:
|
||||
if (Paintbrush_width&1)
|
||||
Set_paintbrush_size(Paintbrush_width-2,Paintbrush_height-2);
|
||||
else
|
||||
Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1);
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_SQUARE:
|
||||
case PAINTBRUSH_SHAPE_SLASH:
|
||||
case PAINTBRUSH_SHAPE_ANTISLASH:
|
||||
case PAINTBRUSH_SHAPE_SIEVE_SQUARE:
|
||||
case PAINTBRUSH_SHAPE_ROUND:
|
||||
case PAINTBRUSH_SHAPE_SIEVE_ROUND:
|
||||
case PAINTBRUSH_SHAPE_RANDOM:
|
||||
Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1);
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
|
||||
Set_paintbrush_size(Paintbrush_width-1,1);
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_VERTICAL_BAR:
|
||||
Set_paintbrush_size(1,Paintbrush_height-1);
|
||||
}
|
||||
Display_paintbrush_in_menu();
|
||||
Display_cursor();
|
||||
}
|
||||
}
|
||||
|
||||
void Bigger_paintbrush(void)
|
||||
{
|
||||
if ( (Paintbrush_shape<PAINTBRUSH_SHAPE_MISC)
|
||||
&& ( (Paintbrush_width<MAX_PAINTBRUSH_SIZE)
|
||||
|| (Paintbrush_height<MAX_PAINTBRUSH_SIZE) ) )
|
||||
{
|
||||
Hide_cursor();
|
||||
switch (Paintbrush_shape)
|
||||
{
|
||||
case PAINTBRUSH_SHAPE_CROSS:
|
||||
case PAINTBRUSH_SHAPE_PLUS:
|
||||
case PAINTBRUSH_SHAPE_DIAMOND:
|
||||
if (Paintbrush_width&1)
|
||||
Set_paintbrush_size(Paintbrush_width+2,Paintbrush_height+2);
|
||||
else
|
||||
Set_paintbrush_size(Paintbrush_width+1,Paintbrush_height+1);
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_SQUARE:
|
||||
case PAINTBRUSH_SHAPE_SLASH:
|
||||
case PAINTBRUSH_SHAPE_ANTISLASH:
|
||||
case PAINTBRUSH_SHAPE_SIEVE_SQUARE:
|
||||
case PAINTBRUSH_SHAPE_ROUND:
|
||||
case PAINTBRUSH_SHAPE_SIEVE_ROUND:
|
||||
case PAINTBRUSH_SHAPE_RANDOM:
|
||||
Set_paintbrush_size(Paintbrush_width+1,Paintbrush_height+1);
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
|
||||
Set_paintbrush_size(Paintbrush_width+1,1);
|
||||
break;
|
||||
case PAINTBRUSH_SHAPE_VERTICAL_BAR:
|
||||
Set_paintbrush_size(1,Paintbrush_height+1);
|
||||
}
|
||||
Display_paintbrush_in_menu();
|
||||
Display_cursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------- Increase the ForeColor -----------------------
|
||||
void Special_next_forecolor(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
Set_fore_color(Fore_color+1);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
//--------------------- Decrease the ForeColor -----------------------
|
||||
void Special_previous_forecolor(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
Set_fore_color(Fore_color-1);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
//--------------------- Increase the BackColor -----------------------
|
||||
void Special_next_backcolor(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
Set_back_color(Back_color+1);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
//--------------------- Decrease the BackColor -----------------------
|
||||
void Special_previous_backcolor(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
Set_back_color(Back_color-1);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
/// Picks the next foreground color, according to current shade table
|
||||
void Special_next_user_forecolor(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
Set_fore_color(Shade_table_left[Fore_color]);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
/// Picks the previous foreground color, according to current shade table
|
||||
void Special_previous_user_forecolor(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
Set_fore_color(Shade_table_right[Fore_color]);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
/// Picks the next background color, according to current shade table
|
||||
void Special_next_user_backcolor(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
Set_back_color(Shade_table_left[Back_color]);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
/// Picks the previous background color, according to current shade table
|
||||
void Special_previous_user_backcolor(void)
|
||||
{
|
||||
Hide_cursor();
|
||||
Set_back_color(Shade_table_right[Back_color]);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
// ------------------- Scroller l'écran (pas en mode loupe) ------------------
|
||||
void Scroll_screen(short delta_x,short delta_y)
|
||||
{
|
||||
short temp_x_offset;
|
||||
short temp_y_offset;
|
||||
|
||||
temp_x_offset=Main_offset_X+delta_x;
|
||||
temp_y_offset=Main_offset_Y+delta_y;
|
||||
|
||||
if (temp_x_offset+Screen_width>Main_image_width)
|
||||
temp_x_offset=Main_image_width-Screen_width;
|
||||
if (temp_y_offset+Menu_Y>Main_image_height)
|
||||
temp_y_offset=Main_image_height-Menu_Y;
|
||||
if (temp_x_offset<0)
|
||||
temp_x_offset=0;
|
||||
if (temp_y_offset<0)
|
||||
temp_y_offset=0;
|
||||
|
||||
if ( (Main_offset_X!=temp_x_offset) ||
|
||||
(Main_offset_Y!=temp_y_offset) )
|
||||
{
|
||||
Hide_cursor();
|
||||
Main_offset_X=temp_x_offset;
|
||||
Main_offset_Y=temp_y_offset;
|
||||
|
||||
Compute_limits();
|
||||
Compute_paintbrush_coordinates();
|
||||
|
||||
Display_all_screen(); // <=> Display_screen + Display_image_limits
|
||||
Display_cursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------- Scroller la fenêtre de la loupe --------------------
|
||||
void Scroll_magnifier(short delta_x,short delta_y)
|
||||
{
|
||||
short temp_x_offset;
|
||||
short temp_y_offset;
|
||||
|
||||
temp_x_offset=Main_magnifier_offset_X+delta_x;
|
||||
temp_y_offset=Main_magnifier_offset_Y+delta_y;
|
||||
|
||||
if (temp_x_offset+Main_magnifier_width>Main_image_width)
|
||||
temp_x_offset=Main_image_width-Main_magnifier_width;
|
||||
if (temp_y_offset+Main_magnifier_height>Main_image_height)
|
||||
temp_y_offset=Main_image_height-Main_magnifier_height;
|
||||
if (temp_x_offset<0)
|
||||
temp_x_offset=0;
|
||||
if (temp_y_offset<0)
|
||||
temp_y_offset=0;
|
||||
|
||||
if ( (Main_magnifier_offset_X!=temp_x_offset) ||
|
||||
(Main_magnifier_offset_Y!=temp_y_offset) )
|
||||
{
|
||||
Hide_cursor();
|
||||
Main_magnifier_offset_X=temp_x_offset;
|
||||
Main_magnifier_offset_Y=temp_y_offset;
|
||||
|
||||
Position_screen_according_to_zoom();
|
||||
|
||||
Compute_limits();
|
||||
Compute_paintbrush_coordinates();
|
||||
|
||||
Display_all_screen();
|
||||
Display_cursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -------------- Changer le Zoom (grâce aux touches [+] et [-]) -------------
|
||||
void Zoom(short delta)
|
||||
{
|
||||
short index;
|
||||
for (index=0; ZOOM_FACTOR[index]!=Main_magnifier_factor; index++);
|
||||
index+=delta;
|
||||
|
||||
if ( (index>=0) && (index<NB_ZOOM_FACTORS) )
|
||||
{
|
||||
Hide_cursor();
|
||||
Change_magnifier_factor(index,1);
|
||||
if (Main_magnifier_mode)
|
||||
Display_all_screen();
|
||||
Display_cursor();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Set zoom value. Negative value means no zoom.
|
||||
*/
|
||||
void Zoom_set(int index)
|
||||
{
|
||||
Hide_cursor();
|
||||
if (index<0)
|
||||
{
|
||||
/* Zoom 1:1 */
|
||||
if (Main_magnifier_mode)
|
||||
Unselect_button(BUTTON_MAGNIFIER);
|
||||
}
|
||||
else
|
||||
{
|
||||
Change_magnifier_factor(index,1);
|
||||
if (!Main_magnifier_mode)
|
||||
Select_button(BUTTON_MAGNIFIER,1);
|
||||
Display_all_screen();
|
||||
}
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
void Transparency_set(byte amount)
|
||||
{
|
||||
const int doubleclick_delay = Config.Double_key_speed;
|
||||
static long time_click = 0;
|
||||
long time_previous;
|
||||
|
||||
if (!Colorize_mode)
|
||||
{
|
||||
// Activate mode
|
||||
switch(Colorize_current_mode)
|
||||
{
|
||||
case 0 :
|
||||
Effect_function=Effect_interpolated_colorize;
|
||||
break;
|
||||
case 1 :
|
||||
Effect_function=Effect_additive_colorize;
|
||||
break;
|
||||
case 2 :
|
||||
Effect_function=Effect_substractive_colorize;
|
||||
}
|
||||
Shade_mode=0;
|
||||
Quick_shade_mode=0;
|
||||
Smooth_mode=0;
|
||||
Tiling_mode=0;
|
||||
|
||||
Colorize_mode=1;
|
||||
}
|
||||
|
||||
time_previous = time_click;
|
||||
time_click = SDL_GetTicks();
|
||||
|
||||
// Check if it's a quick re-press
|
||||
if (time_click - time_previous < doubleclick_delay)
|
||||
{
|
||||
// Use the typed amount as units, keep the tens.
|
||||
Colorize_opacity = ((Colorize_opacity%100) /10 *10) + amount;
|
||||
if (Colorize_opacity == 0)
|
||||
Colorize_opacity = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use 10% units: "1"=10%, ... "0"=100%
|
||||
if (amount == 0)
|
||||
Colorize_opacity = 100;
|
||||
else
|
||||
Colorize_opacity = amount*10;
|
||||
}
|
||||
Compute_colorize_table();
|
||||
}
|
||||
|
||||
|
||||
58
src/special.h
Normal file
58
src/special.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
#include "struct.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///@file special.h
|
||||
/// Editor functions that can be hooked to a keyboard shortcut, but don't have
|
||||
/// a menu button associated to them.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Set_paintbrush_size(int width, int height);
|
||||
void Smaller_paintbrush(void);
|
||||
void Bigger_paintbrush(void);
|
||||
|
||||
void Special_next_forecolor(void);
|
||||
void Special_previous_forecolor(void);
|
||||
void Special_next_backcolor(void);
|
||||
void Special_previous_backcolor(void);
|
||||
|
||||
void Special_next_user_forecolor(void);
|
||||
void Special_previous_user_forecolor(void);
|
||||
void Special_next_user_backcolor(void);
|
||||
void Special_previous_user_backcolor(void);
|
||||
|
||||
void Scroll_screen(short delta_x,short delta_y);
|
||||
void Scroll_magnifier(short delta_x,short delta_y);
|
||||
|
||||
void Zoom(short delta);
|
||||
void Zoom_set(int index);
|
||||
|
||||
void Display_stored_brush_in_window(word x,word y,int number);
|
||||
void Store_brush(int index);
|
||||
byte Restore_brush(int index);
|
||||
|
||||
/*!
|
||||
Command that sets the transparency level.
|
||||
*/
|
||||
void Transparency_set(byte amount);
|
||||
|
||||
488
src/struct.h
Normal file
488
src/struct.h
Normal file
@@ -0,0 +1,488 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 struct.h
|
||||
/// Structures that can be used in the whole program.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef _STRUCT_H_
|
||||
#define _STRUCT_H_
|
||||
|
||||
#if defined(__BEOS__) || defined(__TRU64__)
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include "const.h"
|
||||
|
||||
|
||||
// POSIX calls it strcasecmp, Windows uses stricmp... no ANSI standard.
|
||||
#ifdef WIN32
|
||||
#define strcasecmp stricmp
|
||||
#endif
|
||||
|
||||
// Definition of the base data types
|
||||
/// 8bit unsigned integer
|
||||
#define byte uint8_t
|
||||
/// 16bit unsigned integer
|
||||
#define word uint16_t
|
||||
/// 32bit unsigned integer
|
||||
#define dword uint32_t
|
||||
/// 64bit unsigned integer
|
||||
#define qword uint64_t
|
||||
|
||||
// Named function prototypes
|
||||
// GrafX2 use a lot of function pointer to do the drawing depending in the "fake hardware zoom" and the magnifier status.
|
||||
typedef void (* Func_action) (void); ///< An action. Used when you click a menu button or trigger a keyboard shortcut.
|
||||
typedef void (* Func_pixel) (word,word,byte); ///< Set pixel at position (x,y) to color c. Used in load screen to write the data to brush, picture, or preview area.
|
||||
typedef byte (* Func_read) (word,word); ///< Read a pixel at position (x,y) on something. Used for example in save to tell if the data is a brush or a picture
|
||||
typedef void (* Func_clear) (byte);
|
||||
typedef void (* Func_display) (word,word,word);
|
||||
typedef byte (* Func_effect) (word,word,byte); ///< Called by all drawing tools to draw with a special effect (smooth, transparency, shade, ...)
|
||||
typedef void (* Func_block) (word,word,word,word,byte);
|
||||
typedef void (* Func_line_XOR) (word,word,word); ///< Draw an XOR line on the picture view of the screen. Use a different function when in magnify mode.
|
||||
typedef void (* Func_display_brush_color) (word,word,word,word,word,word,byte,word);
|
||||
typedef void (* Func_display_brush_mono) (word,word,word,word,word,word,byte,byte,word);
|
||||
typedef void (* Func_gradient) (long,short,short);
|
||||
typedef void (* Func_remap) (word,word,word,word,byte *);
|
||||
typedef void (* Func_procsline) (word,word,word,byte *);
|
||||
typedef void (* Func_display_zoom) (word,word,word,byte *);
|
||||
typedef void (* Func_display_brush_color_zoom) (word,word,word,word,word,word,byte,word,byte *);
|
||||
typedef void (* Func_display_brush_mono_zoom) (word,word,word,word,word,word,byte,byte,word,byte *);
|
||||
typedef void (* Func_draw_brush) (byte *,word,word,word,word,word,word,byte,word);
|
||||
typedef void (* Func_draw_list_item) (word,word,word,byte); ///< Draw an item inside a list button. This is done with a callback so it is possible to draw anything, as the list itself doesn't handle the content
|
||||
|
||||
/// A set of RGB values.
|
||||
#pragma pack(1)
|
||||
typedef struct
|
||||
{
|
||||
byte R; ///< Red
|
||||
byte G; ///< Green
|
||||
byte B; ///< Blue
|
||||
} T_Components, T_Palette[256]; ///< A complete 256-entry RGB palette (768 bytes).
|
||||
#pragma pack()
|
||||
|
||||
/// A normal rectangular button in windows and menus.
|
||||
typedef struct T_Normal_button
|
||||
{
|
||||
short Number; ///< Unique identifier for all controls
|
||||
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
|
||||
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
|
||||
word Width; ///< Width before scaling
|
||||
word Height; ///< Height before scaling
|
||||
byte Clickable; ///< Boolean, unused.
|
||||
byte Repeatable; ///< Boolean, true if the button activates repeatedly until you release the mouse button. Used for "+" buttons, for example.
|
||||
word Shortcut; ///< Keyboard shortcut that will emulate a click on this button.
|
||||
struct T_Normal_button * Next;///< Pointer to the next normal button of current window.
|
||||
} T_Normal_button;
|
||||
|
||||
/// A window control that shows a complete 256-color palette
|
||||
typedef struct T_Palette_button
|
||||
{
|
||||
short Number; ///< Unique identifier for all controls
|
||||
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
|
||||
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
|
||||
struct T_Palette_button * Next;///< Pointer to the next palette of current window.
|
||||
} T_Palette_button;
|
||||
|
||||
/// A window control that represents a vertical scrollbar, with a slider, and two arrow buttons.
|
||||
typedef struct T_Scroller_button
|
||||
{
|
||||
short Number; ///< Unique identifier for all controls
|
||||
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
|
||||
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
|
||||
word Height; ///< Height before scaling.
|
||||
word Nb_elements; ///< Number of distinct values it can take.
|
||||
word Nb_visibles; ///< If this slider is meant to show several elements of a collection, this is their number (otherwise, it's 1).
|
||||
word Position; ///< Current position of the slider: which item it's pointing.
|
||||
word Cursor_height; ///< Vertical dimension of the slider, in pixels before scaling.
|
||||
struct T_Scroller_button * Next;///< Pointer to the next scroller of current window.
|
||||
} T_Scroller_button;
|
||||
|
||||
/// Special invisible button
|
||||
/// A window control that only has a rectangular "active" area which catches mouse clicks,
|
||||
// but no visible shape. It's used for custom controls where the drawing is done on
|
||||
// a case by case basis.
|
||||
typedef struct T_Special_button
|
||||
{
|
||||
short Number; ///< Unique identifier for all controls
|
||||
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
|
||||
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
|
||||
word Width; ///< Width before scaling
|
||||
word Height; ///< Height before scaling
|
||||
struct T_Special_button * Next;///< Pointer to the next special button of current window.
|
||||
} T_Special_button;
|
||||
|
||||
/// Data for a dropdown item, ie. one proposed choice.
|
||||
typedef struct T_Dropdown_choice
|
||||
{
|
||||
short Number; ///< Value that identifies the choice (for this dropdown only)
|
||||
const char * Label; ///< String to display in the dropdown panel
|
||||
struct T_Dropdown_choice * Next;///< Pointer to the next choice for this dropdown.
|
||||
} T_Dropdown_choice;
|
||||
|
||||
/// A window control that behaves like a dropdown button.
|
||||
typedef struct T_Dropdown_button
|
||||
{
|
||||
short Number; ///< Unique identifier for all controls
|
||||
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
|
||||
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
|
||||
word Width; ///< Width before scaling
|
||||
word Height; ///< Height before scaling
|
||||
byte Display_choice; ///< Boolean, true if the engine should print the selected item's label in the dropdown area when the user chooses it.
|
||||
byte Display_centered; ///< Boolean, true to center the labels (otherwise, align left)
|
||||
byte Display_arrow; ///< Boolean, true to display a "down" arrow box in top right
|
||||
byte Bottom_up; ///< Boolean, true to make the dropdown panel go above its button instead of below it
|
||||
byte Active_button; ///< Determines which mouse button(s) cause the dropdown panel to open: LEFT_SIDE || RIGHT_SIDE || (LEFT_SIDE|RIGHT_SIDE)
|
||||
word Dropdown_width; ///< Width of the dropdown panel when it's open. Use 0 for "same as the dropdown button"
|
||||
T_Dropdown_choice * First_item; ///< Linked list with the choices available for this dropdown.
|
||||
struct T_Dropdown_button * Next;///< Pointer to the next dropdown button of current window.
|
||||
} T_Dropdown_button;
|
||||
|
||||
/// Data for one item (file, directory) in a fileselector.
|
||||
typedef struct T_Fileselector_item
|
||||
{
|
||||
char Short_name[19]; ///< Name to display.
|
||||
char Full_name[256]; ///< Filesystem value.
|
||||
byte Type; ///< Type of item: 0 = File, 1 = Directory, 2 = Drive
|
||||
|
||||
struct T_Fileselector_item * Next; ///< Pointer to next item of the current fileselector.
|
||||
struct T_Fileselector_item * Previous;///< Pointer to previous item of the current fileselector.
|
||||
} T_Fileselector_item;
|
||||
|
||||
/// Data for a fileselector
|
||||
typedef struct T_Fileselector
|
||||
{
|
||||
/// Number of elements in the current fileselector's ::Filelist
|
||||
short Nb_elements;
|
||||
/// Number of files in the current fileselector's ::Filelist
|
||||
short Nb_files;
|
||||
/// Number of directories in the current fileselector's ::Filelist
|
||||
short Nb_directories;
|
||||
/// Head of the linked list for the fileselector.
|
||||
T_Fileselector_item * First;
|
||||
/// Index for direct access to element number N
|
||||
T_Fileselector_item ** Index;
|
||||
} T_Fileselector;
|
||||
|
||||
/// "List" button as used in the font selection, skin selection, and brush factory screens. It's like a limited filelist.
|
||||
/// The screenmode selection and load/save screen were written before this existed so they use their own code. It would be nice if they were updated to use this one.
|
||||
typedef struct T_List_button
|
||||
{
|
||||
short Number; ///< Unique identifier for all controls
|
||||
short List_start; ///< Index of the font to appear as first line
|
||||
short Cursor_position; ///< Index of the selected line (0=top)
|
||||
|
||||
T_Special_button * Entry_button; ///< Pointer to the associated selection control.
|
||||
T_Scroller_button * Scroller; ///< Pointer to the associated scroller
|
||||
|
||||
Func_draw_list_item Draw_list_item; ///<
|
||||
|
||||
struct T_List_button * Next; ///< Pointer to the next list button of current window.
|
||||
} T_List_button;
|
||||
|
||||
/// Data for one line of the "Help" screens.
|
||||
typedef struct {
|
||||
char Line_type; ///< Kind of line: 'N' for normal line, 'S' for a bold line, 'K' for a line with keyboard shortcut, 'T' and '-' for upper and lower titles.
|
||||
char * Text; ///< Displayed string.
|
||||
int Line_parameter; ///< Generic parameter depending on line type. For 'K' lines: a shortcut identifier. For others: unused.
|
||||
} T_Help_table;
|
||||
|
||||
/// Data for one section of the "Help" screens, ie a page.
|
||||
typedef struct
|
||||
{
|
||||
const T_Help_table* Help_table; ///< Pointer to the array of ::T_Help_table that contains the lines
|
||||
word Length; ///< Size of the array of lines
|
||||
} T_Help_section;
|
||||
|
||||
/// Data for one setting of gradients. Warning, this one is saved/loaded as binary.
|
||||
typedef struct
|
||||
{
|
||||
byte Start; ///< First color
|
||||
byte End; ///< Last color
|
||||
dword Inverse; ///< Boolean, true if the gradient goes in descending order
|
||||
dword Mix; ///< Amount of randomness to add to the mix (0-255)
|
||||
dword Technique;///< Gradient technique: 0 (no pattern) 1 (dithering), or 2 (big dithering)
|
||||
} T_Gradient_array;
|
||||
|
||||
/// Data for one setting of shade. Warning, this one is saved/loaded as binary.
|
||||
typedef struct
|
||||
{
|
||||
word List[512]; ///< List of entries, each one is either a color (0-255) or -1 for empty.
|
||||
byte Step; ///< Step to increment/decrement on left-clicks.
|
||||
byte Mode; ///< Shade mode: Normal, Loop, or No-saturation see ::SHADE_MODES
|
||||
} T_Shade;
|
||||
|
||||
#pragma pack(1) // is it useful ?
|
||||
/// Data for one fullscreen video mode in configuration file. Warning, this one is saved/loaded as binary.
|
||||
typedef struct
|
||||
{
|
||||
byte State; ///< How good is the mode supported. 0:Good (white) 1:OK (light) 2:So-so (dark) 4:User-disabled (black); +128 => System doesn't support it at all.
|
||||
word Width; ///< Videomode width in pixels.
|
||||
word Height;///< Videomode height in pixels.
|
||||
} T_Config_video_mode;
|
||||
|
||||
|
||||
/// Header for gfx2.cfg. Warning, this one is saved/loaded as binary.
|
||||
typedef struct
|
||||
{
|
||||
char Signature[3]; ///< Signature for the file format. "CFG".
|
||||
byte Version1; ///< Major version number (ex: 2)
|
||||
byte Version2; ///< Minor version number (ex: 0)
|
||||
byte Beta1; ///< Major beta version number (ex: 96)
|
||||
byte Beta2; ///< Major beta version number (ex: 5)
|
||||
} T_Config_header;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/// Header for a config chunk in for gfx2.cfg. Warning, this one is saved/loaded as binary.
|
||||
typedef struct
|
||||
{
|
||||
byte Number; ///< Section identfier. Possible values are in enum ::CHUNKS_CFG
|
||||
word Size; ///< Size of the configuration block that follows, in bytes.
|
||||
} T_Config_chunk;
|
||||
|
||||
#pragma pack(1)
|
||||
/// Configuration for one keyboard shortcut in gfx2.cfg. Warning, this one is saved/loaded as binary.
|
||||
typedef struct
|
||||
{
|
||||
word Number; ///< Indicates the shortcut action. This is a number starting from 0, which matches ::T_Key_config.Number
|
||||
word Key; ///< Keyboard shortcut: SDLK_something, or -1 for none
|
||||
word Key2; ///< Alternate keyboard shortcut: SDLK_something, or -1 for none
|
||||
} T_Config_shortcut_info;
|
||||
#pragma pack()
|
||||
|
||||
/// This structure holds all the settings saved and loaded as gfx2.ini.
|
||||
typedef struct
|
||||
{
|
||||
char *Font_file; ///< Name of the font used in the menus. Matches file skins/font_*.png (Case-sensitive on some filesystems)
|
||||
char *Skin_file; ///< String, name of the file where all the graphic data is stored
|
||||
int Show_hidden_files; ///< Boolean, true to show hidden files in fileselectors.
|
||||
int Show_hidden_directories; ///< Boolean, true to show hidden directories in fileselectors.
|
||||
// int Show_system_directories; ///< (removed when converted from DOS)
|
||||
byte Display_image_limits; ///< Boolean, true to display a dotted line at the borders of the image if it's smaller than screen.
|
||||
byte Cursor; ///< Mouse cursor aspect: 1 Solid, 2 Transparent, 3 Thin
|
||||
byte Maximize_preview; ///< Boolean, true to make previews in fileselector fit the whole rectangle.
|
||||
byte Auto_set_res; ///< Boolean, true to make grafx2 switch to a new resolution whenever you load an image.
|
||||
byte Coords_rel; ///< Boolean, true to display coordinates as relative (instead of absolute)
|
||||
byte Backup; ///< Boolean, true to backup the original file whenever you save an image.
|
||||
byte Adjust_brush_pick; ///< Boolean, true to omit the right and bottom edges when grabbing a brush in Grid mode.
|
||||
byte Auto_save; ///< Boolean, true to save configuration when exiting program.
|
||||
byte Max_undo_pages; ///< Number of steps to memorize for Undo/Redo.
|
||||
byte Mouse_sensitivity_index_x; ///< Mouse sensitivity in X axis
|
||||
byte Mouse_sensitivity_index_y; ///< Mouse sensitivity in Y axis
|
||||
byte Mouse_merge_movement; ///< Number of SDL mouse events that are merged into a single change of mouse coordinates.
|
||||
byte Delay_left_click_on_slider; ///< Delay (in 1/100s) between two activations of a repeatable button when you hold left-click.
|
||||
byte Delay_right_click_on_slider; ///< Delay (in 1/100s) between two activations of a repeatable button when you hold left-click.
|
||||
long Timer_delay; ///< Delay (in 1/55s) before showing a preview in a fileselector.
|
||||
T_Components Fav_menu_colors[4]; ///< Favorite colors to use for the menu.
|
||||
int Nb_max_vertices_per_polygon; ///< Limit for the number of vertices in polygon tools.
|
||||
byte Clear_palette; ///< Boolean, true to reset the palette (to black) before loading an image.
|
||||
byte Set_resolution_according_to; ///< When Auto_set_res is on, this determines if the mode should be chosen according to the "original screen" information in the file (1) or the picture dimensons (2)
|
||||
int8_t Ratio; ///< Determines the scaling of menu and windows: 0 no scaling, 1 scaling, 2 slight scaling, negative= opposite of max scaling
|
||||
byte Fast_zoom; ///< Boolean, true if the magnifier shortcut should automatically view the mouse area.
|
||||
byte Find_file_fast; ///< In fileselectors, this determines which entries should be sought when typing letters: 0 all, 1 files only, 2 directories only.
|
||||
byte Separate_colors; ///< Boolean, true if the menu palette should separate color cells with a black outline.
|
||||
word Palette_cells_X; ///< Number of colors to show in a row of the menu palette.
|
||||
word Palette_cells_Y; ///< Number of colors to show in a column of the menu palette.
|
||||
byte Palette_vertical; ///< Boolean, true if the menu palette should go top to bottom instead of left to right
|
||||
byte FX_Feedback; ///< Boolean, true if drawing effects should read the image being modified (instead of the image before clicking)
|
||||
byte Safety_colors; ///< Boolean, true to make the palette automatically re-create menu colors if needed after a "Zap" or color reduction.
|
||||
byte Opening_message; ///< Boolean, true to display the splash screen on strtup.
|
||||
byte Clear_with_stencil; ///< Boolean, true to take the stencil into effect (if active) when using the Clear function.
|
||||
byte Auto_discontinuous; ///< Boolean, true to automatically switch to the discontinuous freehand draw after grabbing a brush.
|
||||
byte Screen_size_in_GIF; ///< Boolean, true to store current resolution in GIF files.
|
||||
byte Auto_nb_used; ///< Boolean, true to count colors in Palette screen.
|
||||
byte Default_resolution; ///< Default video mode to use on startup. Index in ::Video_mode.
|
||||
char *Bookmark_directory[NB_BOOKMARKS];///< Bookmarked directories in fileselectors: This is the full dierctory name.
|
||||
char Bookmark_label[NB_BOOKMARKS][8+1];///< Bookmarked directories in fileselectors: This is the displayed name.
|
||||
int Window_pos_x; ///< Last window x position (9999 if unsupportd/irrelevant for the platform)
|
||||
int Window_pos_y; ///< Last window y position (9999 if unsupportd/irrelevant for the platform)
|
||||
word Double_click_speed; ///< Maximum delay for double-click, in ms.
|
||||
word Double_key_speed; ///< Maximum delay for double-keypress, in ms.
|
||||
byte Grid_XOR_color; ///< XOR value to apply for grid color.
|
||||
} T_Config;
|
||||
|
||||
// Structures utilisées pour les descriptions de pages et de liste de pages.
|
||||
// Lorsqu'on gèrera les animations, il faudra aussi des listes de listes de
|
||||
// pages.
|
||||
|
||||
// Ces structures sont manipulées à travers des fonctions de gestion du
|
||||
// backup dans "graph.c".
|
||||
|
||||
/// This is the data for one step of Undo/Redo, for one image.
|
||||
/// This structure is resized dynamically to hold pointers to all of the layers in the picture.
|
||||
/// The pointed layers are just byte* holding the raw pixel data. But at Image[0]-1 you will find a short that is used as a reference counter for each layer.
|
||||
/// This way we can use the same pixel data in many undo pages when the user edit only one of the layers (which is what they usually do).
|
||||
typedef struct T_Page
|
||||
{
|
||||
int Width; ///< Image width in pixels.
|
||||
int Height; ///< Image height in pixels.
|
||||
T_Palette Palette; ///< Image palette.
|
||||
|
||||
char Comment[COMMENT_SIZE+1]; ///< Comment to store in the image file.
|
||||
|
||||
char File_directory[MAX_PATH_CHARACTERS];///< Directory that contains the file.
|
||||
char Filename[MAX_PATH_CHARACTERS]; ///< Filename without directory.
|
||||
byte File_format; ///< File format, in enum ::FILE_FORMATS
|
||||
struct T_Page *Next; ///< Pointer to the next backup
|
||||
struct T_Page *Prev; ///< Pointer to the previous backup
|
||||
byte Background_transparent; ///< Boolean, true if Layer 0 should have transparent pixels
|
||||
byte Transparent_color; ///< Index of transparent color. 0 to 255.
|
||||
byte Nb_layers; ///< Number of layers
|
||||
byte * Image[]; ///< Pixel data for the (first layer of) image.
|
||||
// Define as Image[0] if you have an old gcc which is not C99.
|
||||
// No field after Image[] ! Dynamic layer allocation for Image[1], [2] etc.
|
||||
} T_Page;
|
||||
|
||||
/// Collection of undo/redo steps.
|
||||
typedef struct
|
||||
{
|
||||
int List_size; ///< Number of ::T_Page in the vector "Pages".
|
||||
T_Page * Pages; ///< Head of a linked list of pages, each one being a undo/redo step.
|
||||
} T_List_of_pages;
|
||||
|
||||
/// A single image bitmap
|
||||
/// This struct is used to store a flattened view of the current picture.
|
||||
typedef struct
|
||||
{
|
||||
int Width; ///< Image width in pixels.
|
||||
int Height; ///< Image height in pixels.
|
||||
byte * Image; ///< Pixel data for the image.
|
||||
} T_Bitmap;
|
||||
|
||||
/// A single memorized brush from the Brush Container
|
||||
typedef struct
|
||||
{
|
||||
byte Paintbrush_shape; ///< Kind of brush
|
||||
byte Thumbnail[BRUSH_CONTAINER_PREVIEW_WIDTH][BRUSH_CONTAINER_PREVIEW_HEIGHT];
|
||||
// Data for color brush
|
||||
word Width;
|
||||
word Height;
|
||||
byte * Brush; /// < Color brush (if any)
|
||||
T_Palette Palette;
|
||||
byte Transp_color;
|
||||
} T_Brush_template;
|
||||
|
||||
/// GUI skin data
|
||||
typedef struct
|
||||
{
|
||||
// Mouse
|
||||
|
||||
/// X coordinate of the mouse cursor's "hot spot". It is < ::CURSOR_SPRITE_WIDTH
|
||||
word Cursor_offset_X[NB_CURSOR_SPRITES];
|
||||
/// Y coordinate of the mouse cursor's "hot spot". It is < ::CURSOR_SPRITE_HEIGHT
|
||||
word Cursor_offset_Y[NB_CURSOR_SPRITES];
|
||||
/// Graphic resources for the mouse cursor.
|
||||
byte Cursor_sprite[NB_CURSOR_SPRITES][CURSOR_SPRITE_HEIGHT][CURSOR_SPRITE_WIDTH];
|
||||
|
||||
// Preset paintbrushes
|
||||
|
||||
/// Graphic resources for the preset paintbrushes.
|
||||
byte Paintbrush_sprite [NB_PAINTBRUSH_SPRITES][PAINTBRUSH_HEIGHT][PAINTBRUSH_WIDTH];
|
||||
/// Width of the preset paintbrushes.
|
||||
word Preset_paintbrush_width[NB_PAINTBRUSH_SPRITES];
|
||||
/// Height of the preset paintbrushes.
|
||||
word Preset_paintbrush_height[NB_PAINTBRUSH_SPRITES];
|
||||
/// Type of the preset paintbrush: index in enum PAINTBRUSH_SHAPES
|
||||
byte Paintbrush_type[NB_PAINTBRUSH_SPRITES];
|
||||
/// Brush handle for the preset brushes. Generally ::Preset_paintbrush_width[]/2
|
||||
word Preset_paintbrush_offset_X[NB_PAINTBRUSH_SPRITES];
|
||||
/// Brush handle for the preset brushes. Generally ::Preset_paintbrush_height[]/2
|
||||
word Preset_paintbrush_offset_Y[NB_PAINTBRUSH_SPRITES];
|
||||
|
||||
// Sieve patterns
|
||||
|
||||
/// Preset sieve patterns, stored as binary (one word per line)
|
||||
word Sieve_pattern[12][16];
|
||||
|
||||
// Menu and other graphics
|
||||
|
||||
/// Bitmap data for the menu, a single rectangle.
|
||||
byte Menu_block[35][MENU_WIDTH];
|
||||
byte Layerbar_block[10][144];
|
||||
byte Statusbar_block[9][20];
|
||||
/// Bitmap data for the icons that are displayed over the menu.
|
||||
byte Menu_sprite[NB_MENU_SPRITES][MENU_SPRITE_HEIGHT][MENU_SPRITE_WIDTH];
|
||||
/// Bitmap data for the different "effects" icons.
|
||||
byte Effect_sprite[NB_EFFECTS_SPRITES][MENU_SPRITE_HEIGHT][MENU_SPRITE_WIDTH];
|
||||
/// Bitmap data for the different Layer icons.
|
||||
byte Layer_sprite[3][16][LAYER_SPRITE_HEIGHT][LAYER_SPRITE_WIDTH];
|
||||
/// Bitmap data for the Grafx2 logo that appears on splash screen. All 256 colors allowed.
|
||||
byte Logo_grafx2[231*56];
|
||||
/// Bitmap data for the 6x8 font used in help screens.
|
||||
byte Help_font_norm [256][6][8];
|
||||
/// Bitmap data for the 6x8 font used in help screens ("bold" verstion).
|
||||
byte Bold_font [256][6][8];
|
||||
// 12
|
||||
// 34
|
||||
/// Bitmap data for the title font used in help screens. Top-left quarter.
|
||||
byte Help_font_t1 [64][6][8];
|
||||
/// Bitmap data for the title font used in help screens. Top-right quarter.
|
||||
byte Help_font_t2 [64][6][8];
|
||||
/// Bitmap data for the title font used in help screens. Bottom-left quarter.
|
||||
byte Help_font_t3 [64][6][8];
|
||||
/// Bitmap data for the title font used in help screens. Bottom-right quarter.
|
||||
byte Help_font_t4 [64][6][8];
|
||||
/// Bitmap data for the small 8x8 icons.
|
||||
byte Icon_sprite[NB_ICON_SPRITES][ICON_SPRITE_HEIGHT][ICON_SPRITE_WIDTH];
|
||||
|
||||
/// A default 256-color 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;
|
||||
|
||||
// A menubar.
|
||||
typedef struct {
|
||||
word Width;
|
||||
word Height;
|
||||
byte Visible;
|
||||
word Top; ///< Relative to the top line of the menu, hidden bars don't count.
|
||||
byte* Skin;
|
||||
word Skin_width;
|
||||
byte Last_button_index;
|
||||
} T_Menu_Bar;
|
||||
|
||||
typedef enum {
|
||||
MENUBAR_STATUS = 0, // MUST be 0
|
||||
MENUBAR_LAYERS,
|
||||
MENUBAR_TOOLS,
|
||||
MENUBAR_COUNT
|
||||
} T_Menubars;
|
||||
|
||||
#endif
|
||||
552
src/text.c
Normal file
552
src/text.c
Normal file
@@ -0,0 +1,552 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Franck Charlet
|
||||
Copyright 2008 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
// Pour désactiver le support TrueType, définir NOTTF
|
||||
// To disable TrueType support, define NOTTF
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h> // tolower()
|
||||
|
||||
// TrueType
|
||||
#ifndef NOTTF
|
||||
#if defined(__macosx__)
|
||||
#include <SDL_ttf/SDL_ttf.h>
|
||||
#else
|
||||
#include <SDL_ttf.h>
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#if defined(__macosx__)
|
||||
#include <Carbon/Carbon.h>
|
||||
#import <corefoundation/corefoundation.h>
|
||||
#import <sys/param.h>
|
||||
#else
|
||||
#include <X11/Xlib.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <SDL_image.h>
|
||||
// SFont
|
||||
#include "SFont.h"
|
||||
|
||||
#include "struct.h"
|
||||
#include "global.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "io.h"
|
||||
#include "errors.h"
|
||||
|
||||
typedef struct T_Font
|
||||
{
|
||||
char * Name;
|
||||
int Is_truetype;
|
||||
int Is_bitmap;
|
||||
char Label[22];
|
||||
|
||||
// Liste chainée simple
|
||||
struct T_Font * Next;
|
||||
struct T_Font * Previous;
|
||||
} T_Font;
|
||||
// Liste chainée des polices de texte
|
||||
T_Font * font_list_start;
|
||||
int Nb_fonts;
|
||||
|
||||
// Inspiré par Allegro
|
||||
#define EXTID(a,b,c) ((((a)&255)<<16) | (((b)&255)<<8) | (((c)&255)))
|
||||
#define EXTID4(a,b,c,d) ((((a)&255)<<24) | (((b)&255)<<16) | (((c)&255)<<8) | (((d)&255)))
|
||||
|
||||
int Compare_fonts(T_Font * font_1, T_Font * font_2)
|
||||
{
|
||||
if (font_1->Is_bitmap && !font_2->Is_bitmap)
|
||||
return -1;
|
||||
if (font_2->Is_bitmap && !font_1->Is_bitmap)
|
||||
return 1;
|
||||
return strcmp(font_1->Label, font_2->Label);
|
||||
}
|
||||
|
||||
// Ajout d'une fonte à la liste.
|
||||
void Add_font(const char *name)
|
||||
{
|
||||
char * font_name;
|
||||
T_Font * font;
|
||||
int size=strlen(name)+1;
|
||||
int index;
|
||||
|
||||
// Détermination du type:
|
||||
|
||||
#if defined(__macosx__)
|
||||
|
||||
if (size < 6) return;
|
||||
|
||||
char strFontName[512];
|
||||
CFStringRef CFSFontName;// = CFSTR(name);
|
||||
|
||||
CFSFontName = CFStringCreateWithBytes(NULL, (UInt8 *) name, size - 1, kCFStringEncodingASCII, false);
|
||||
// Fix some funny names
|
||||
CFStringGetCString(CFSFontName, strFontName, 512, kCFStringEncodingASCII);
|
||||
|
||||
// Now we have a printable font name, use it
|
||||
name = strFontName;
|
||||
|
||||
#else
|
||||
if (size<5 ||
|
||||
name[size-5]!='.')
|
||||
return;
|
||||
#endif
|
||||
|
||||
font = (T_Font *)malloc(sizeof(T_Font));
|
||||
|
||||
switch (EXTID(tolower(name[size-4]), tolower(name[size-3]), tolower(name[size-2])))
|
||||
{
|
||||
case EXTID('t','t','f'):
|
||||
case EXTID('f','o','n'):
|
||||
case EXTID('o','t','f'):
|
||||
case EXTID('p','f','b'):
|
||||
font->Is_truetype = 1;
|
||||
font->Is_bitmap = 0;
|
||||
break;
|
||||
case EXTID('b','m','p'):
|
||||
case EXTID('g','i','f'):
|
||||
case EXTID('j','p','g'):
|
||||
case EXTID('l','b','m'):
|
||||
case EXTID('p','c','x'):
|
||||
case EXTID('p','n','g'):
|
||||
case EXTID('t','g','a'):
|
||||
case EXTID('t','i','f'):
|
||||
case EXTID('x','c','f'):
|
||||
case EXTID('x','p','m'):
|
||||
case EXTID('.','x','v'):
|
||||
font->Is_truetype = 0;
|
||||
font->Is_bitmap = 1;
|
||||
break;
|
||||
default:
|
||||
#if defined(__macosx__)
|
||||
if(strcasecmp(&name[size-6], "dfont") == 0)
|
||||
{
|
||||
font->Is_truetype = 1;
|
||||
font->Is_bitmap = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
free(font);
|
||||
return;
|
||||
}
|
||||
#else
|
||||
free(font);
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
font->Name = (char *)malloc(size);
|
||||
strcpy(font->Name, name);
|
||||
// Label
|
||||
strcpy(font->Label, " ");
|
||||
if (font->Is_truetype)
|
||||
font->Label[17]=font->Label[18]='T'; // Logo TT
|
||||
font_name=Find_last_slash(font->Name);
|
||||
if (font_name==NULL)
|
||||
font_name=font->Name;
|
||||
else
|
||||
font_name++;
|
||||
for (index=0; index < 17 && font_name[index]!='\0' && font_name[index]!='.'; index++)
|
||||
font->Label[index]=font_name[index];
|
||||
|
||||
// Gestion Liste
|
||||
font->Next = NULL;
|
||||
font->Previous = NULL;
|
||||
if (font_list_start==NULL)
|
||||
{
|
||||
// Premiere (liste vide)
|
||||
font_list_start = font;
|
||||
Nb_fonts++;
|
||||
}
|
||||
else
|
||||
{
|
||||
int compare;
|
||||
compare = Compare_fonts(font, font_list_start);
|
||||
if (compare<=0)
|
||||
{
|
||||
if (compare==0 && !strcmp(font->Name, font_list_start->Name))
|
||||
{
|
||||
// Doublon
|
||||
free(font->Name);
|
||||
free(font);
|
||||
return;
|
||||
}
|
||||
// Avant la premiere
|
||||
font->Next=font_list_start;
|
||||
font_list_start=font;
|
||||
Nb_fonts++;
|
||||
}
|
||||
else
|
||||
{
|
||||
T_Font *searched_font;
|
||||
searched_font=font_list_start;
|
||||
while (searched_font->Next && (compare=Compare_fonts(font, searched_font->Next))>0)
|
||||
searched_font=searched_font->Next;
|
||||
// Après searched_font
|
||||
if (compare==0 && strcmp(font->Name, searched_font->Next->Name)==0)
|
||||
{
|
||||
// Doublon
|
||||
free(font->Name);
|
||||
free(font);
|
||||
return;
|
||||
}
|
||||
font->Next=searched_font->Next;
|
||||
searched_font->Next=font;
|
||||
Nb_fonts++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Trouve le nom d'une fonte par son numéro
|
||||
char * Font_name(int index)
|
||||
{
|
||||
T_Font *font = font_list_start;
|
||||
if (index<0 ||index>=Nb_fonts)
|
||||
return "";
|
||||
while (index--)
|
||||
font = font->Next;
|
||||
return font->Name;
|
||||
}
|
||||
|
||||
|
||||
// Trouve le libellé d'affichage d'une fonte par son numéro
|
||||
// Renvoie un pointeur sur un buffer statique de 20 caracteres.
|
||||
char * Font_label(int index)
|
||||
{
|
||||
T_Font *font;
|
||||
static char label[20];
|
||||
|
||||
strcpy(label, " ");
|
||||
|
||||
// Recherche de la fonte
|
||||
font = font_list_start;
|
||||
if (index<0 ||index>=Nb_fonts)
|
||||
return label;
|
||||
while (index--)
|
||||
font = font->Next;
|
||||
|
||||
// Libellé
|
||||
strcpy(label, font->Label);
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
// Vérifie si une fonte donnée est TrueType
|
||||
int TrueType_font(int index)
|
||||
{
|
||||
T_Font *font = font_list_start;
|
||||
if (index<0 ||index>=Nb_fonts)
|
||||
return 0;
|
||||
while (index--)
|
||||
font = font->Next;
|
||||
return font->Is_truetype;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Initialisation à faire une fois au début du programme
|
||||
void Init_text(void)
|
||||
{
|
||||
char directory_name[MAX_PATH_CHARACTERS];
|
||||
#ifndef NOTTF
|
||||
// Initialisation de TTF
|
||||
TTF_Init();
|
||||
#endif
|
||||
|
||||
// Initialisation des fontes
|
||||
font_list_start = NULL;
|
||||
Nb_fonts=0;
|
||||
// Parcours du répertoire "fonts"
|
||||
strcpy(directory_name, Data_directory);
|
||||
strcat(directory_name, "fonts");
|
||||
For_each_file(directory_name, Add_font);
|
||||
|
||||
#if defined(__WIN32__)
|
||||
// Parcours du répertoire systeme windows "fonts"
|
||||
#ifndef NOTTF
|
||||
{
|
||||
char * WindowsPath=getenv("windir");
|
||||
if (WindowsPath)
|
||||
{
|
||||
sprintf(directory_name, "%s\\FONTS", WindowsPath);
|
||||
For_each_file(directory_name, Add_font);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#elif defined(__macosx__)
|
||||
// Récupération de la liste des fonts avec fontconfig
|
||||
#ifndef NOTTF
|
||||
|
||||
|
||||
int i,number;
|
||||
char home_dir[MAXPATHLEN];
|
||||
char *font_path_list[3] = {
|
||||
"/System/Library/Fonts",
|
||||
"/Library/Fonts"
|
||||
};
|
||||
number = 3;
|
||||
// Make sure we also search into the user's fonts directory
|
||||
CFURLRef url = (CFURLRef) CFCopyHomeDirectoryURLForUser(NULL);
|
||||
CFURLGetFileSystemRepresentation(url, true, (UInt8 *) home_dir, MAXPATHLEN);
|
||||
strcat(home_dir, "/Library/Fonts");
|
||||
font_path_list[2] = home_dir;
|
||||
|
||||
for(i=0;i<number;i++)
|
||||
For_each_file(*(font_path_list+i),Add_font);
|
||||
|
||||
CFRelease(url);
|
||||
#endif
|
||||
|
||||
#elif defined(__linux__)
|
||||
#ifndef NOTTF
|
||||
#define USE_XLIB
|
||||
|
||||
#ifdef USE_XLIB
|
||||
{
|
||||
int i,number;
|
||||
Display* dpy = XOpenDisplay(NULL);
|
||||
char** font_path_list = XGetFontPath(dpy,&number);
|
||||
XCloseDisplay(dpy);
|
||||
|
||||
for(i=0;i<number;i++)
|
||||
For_each_file(*(font_path_list+i),Add_font);
|
||||
|
||||
XFreeFontPath(font_path_list);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(__amigaos4__) || defined(__amigaos__)
|
||||
#ifndef NOTTF
|
||||
For_each_file( "FONTS:_TrueType", Add_font );
|
||||
#endif
|
||||
#elif defined(__BEOS__) || defined(__HAIKU__)
|
||||
#ifndef NOTTF
|
||||
For_each_file("/etc/fonts/ttfonts", Add_font);
|
||||
#endif
|
||||
|
||||
#elif defined(__SKYOS__)
|
||||
#ifndef NOTTF
|
||||
For_each_file("/boot/system/fonts", Add_font);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
// Informe si texte.c a été compilé avec l'option de support TrueType ou pas.
|
||||
int TrueType_is_supported()
|
||||
{
|
||||
#ifdef NOTTF
|
||||
return 0;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef NOTTF
|
||||
byte *Render_text_TTF(const char *str, int font_number, int size, int antialias, int bold, int italic, int *width, int *height)
|
||||
{
|
||||
TTF_Font *font;
|
||||
SDL_Surface * TexteColore;
|
||||
SDL_Surface * Texte8Bit;
|
||||
byte * new_brush;
|
||||
int index;
|
||||
int style;
|
||||
|
||||
SDL_Color Couleur_Avant;
|
||||
SDL_Color Couleur_Arriere;
|
||||
|
||||
// Chargement de la fonte
|
||||
font=TTF_OpenFont(Font_name(font_number), size);
|
||||
if (!font)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
// Style
|
||||
style=0;
|
||||
if (italic)
|
||||
style|=TTF_STYLE_ITALIC;
|
||||
if (bold)
|
||||
style|=TTF_STYLE_BOLD;
|
||||
TTF_SetFontStyle(font, style);
|
||||
// Couleurs
|
||||
if (antialias)
|
||||
{
|
||||
Couleur_Avant = Color_to_SDL_color(Fore_color);
|
||||
Couleur_Arriere = Color_to_SDL_color(Back_color);
|
||||
}
|
||||
else
|
||||
{
|
||||
Couleur_Avant = Color_to_SDL_color(MC_White);
|
||||
Couleur_Arriere = Color_to_SDL_color(MC_Black);
|
||||
}
|
||||
|
||||
|
||||
// Rendu du texte: crée une surface SDL RGB 24bits
|
||||
if (antialias)
|
||||
TexteColore=TTF_RenderText_Shaded(font, str, Couleur_Avant, Couleur_Arriere );
|
||||
else
|
||||
TexteColore=TTF_RenderText_Solid(font, str, Couleur_Avant);
|
||||
if (!TexteColore)
|
||||
{
|
||||
TTF_CloseFont(font);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Texte8Bit=SDL_DisplayFormat(TexteColore);
|
||||
|
||||
SDL_FreeSurface(TexteColore);
|
||||
|
||||
new_brush=Surface_to_bytefield(Texte8Bit, NULL);
|
||||
if (!new_brush)
|
||||
{
|
||||
SDL_FreeSurface(TexteColore);
|
||||
SDL_FreeSurface(Texte8Bit);
|
||||
TTF_CloseFont(font);
|
||||
return NULL;
|
||||
}
|
||||
if (!antialias)
|
||||
{
|
||||
// Mappage des couleurs
|
||||
for (index=0; index < Texte8Bit->w * Texte8Bit->h; index++)
|
||||
{
|
||||
if (*(new_brush+index) == MC_Black)
|
||||
*(new_brush+index)=Back_color;
|
||||
else if (*(new_brush+index) == MC_White)
|
||||
*(new_brush+index)=Fore_color;
|
||||
}
|
||||
}
|
||||
*width=Texte8Bit->w;
|
||||
*height=Texte8Bit->h;
|
||||
SDL_FreeSurface(Texte8Bit);
|
||||
TTF_CloseFont(font);
|
||||
return new_brush;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
byte *Render_text_SFont(const char *str, int font_number, int *width, int *height)
|
||||
{
|
||||
SFont_Font *font;
|
||||
SDL_Surface * TexteColore;
|
||||
SDL_Surface * Texte8Bit;
|
||||
SDL_Surface *Surface_fonte;
|
||||
byte * new_brush;
|
||||
SDL_Rect rectangle;
|
||||
|
||||
// Chargement de la fonte
|
||||
Surface_fonte=IMG_Load(Font_name(font_number));
|
||||
if (!Surface_fonte)
|
||||
{
|
||||
DEBUG("Font loading failed",0);
|
||||
return NULL;
|
||||
}
|
||||
font=SFont_InitFont(Surface_fonte);
|
||||
if (!font)
|
||||
{
|
||||
DEBUG("Font init failed",1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Calcul des dimensions
|
||||
*height=SFont_TextHeight(font);
|
||||
*width=SFont_TextWidth(font, str);
|
||||
// Allocation d'une surface SDL
|
||||
TexteColore=SDL_CreateRGBSurface(SDL_SWSURFACE, *width, *height, 24, 0, 0, 0, 0);
|
||||
// Fill with backcolor
|
||||
rectangle.x=0;
|
||||
rectangle.y=0;
|
||||
rectangle.w=*width;
|
||||
rectangle.h=*height;
|
||||
SDL_FillRect(TexteColore, &rectangle, SDL_MapRGB(
|
||||
TexteColore->format,
|
||||
Main_palette[Back_color].R,
|
||||
Main_palette[Back_color].G,
|
||||
Main_palette[Back_color].B
|
||||
));
|
||||
// Rendu du texte
|
||||
SFont_Write(TexteColore, font, 0, 0, str);
|
||||
if (!TexteColore)
|
||||
{
|
||||
DEBUG("Rendering failed",2);
|
||||
SFont_FreeFont(font);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Texte8Bit=SDL_DisplayFormat(TexteColore);
|
||||
SDL_FreeSurface(TexteColore);
|
||||
|
||||
new_brush=Surface_to_bytefield(Texte8Bit, NULL);
|
||||
if (!new_brush)
|
||||
{
|
||||
DEBUG("Converting failed",3);
|
||||
SDL_FreeSurface(TexteColore);
|
||||
SDL_FreeSurface(Texte8Bit);
|
||||
SFont_FreeFont(font);
|
||||
return NULL;
|
||||
}
|
||||
SDL_FreeSurface(Texte8Bit);
|
||||
SFont_FreeFont(font);
|
||||
|
||||
return new_brush;
|
||||
}
|
||||
|
||||
#ifdef NOTTF
|
||||
#define TTFONLY __attribute__((unused))
|
||||
#else
|
||||
#define TTFONLY
|
||||
#endif
|
||||
|
||||
// Crée une brosse à partir des paramètres de texte demandés.
|
||||
// Si cela réussit, la fonction place les dimensions dans width et height,
|
||||
// et retourne l'adresse du bloc d'octets.
|
||||
byte *Render_text(const char *str, int font_number, TTFONLY int size, int TTFONLY antialias, TTFONLY int bold, TTFONLY int italic, int *width, int *height)
|
||||
{
|
||||
T_Font *font = font_list_start;
|
||||
int index=font_number;
|
||||
|
||||
// Verification type de la fonte
|
||||
if (font_number<0 ||font_number>=Nb_fonts)
|
||||
return NULL;
|
||||
|
||||
while (index--)
|
||||
font = font->Next;
|
||||
if (font->Is_truetype)
|
||||
{
|
||||
#ifndef NOTTF
|
||||
return Render_text_TTF(str, font_number, size, antialias, bold, italic, width, height);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
return Render_text_SFont(str, font_number, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
56
src/text.h
Normal file
56
src/text.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* vim:expandtab:ts=2 sw=2:
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2008 Adrien Destugues
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
|
||||
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 text.h
|
||||
/// Functions related to rendering text as a brush, using TrueType or SFont.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Initialization of text settings, needs to be called once on program startup.
|
||||
void Init_text(void);
|
||||
/// Returns true if text.c was compiled with TrueType support.
|
||||
int TrueType_is_supported(void);
|
||||
/// Add a new font to the list to propose to the user.
|
||||
void Add_font(const char *name);
|
||||
///
|
||||
/// Creates a brush, from the parameters given:
|
||||
/// @param str The text to render
|
||||
/// @param font_number The index of the font to use. Pass 0 for the first font you declared with ::Add_font(), 1 for the second etc.
|
||||
/// @param size The size in points (unused for bitmap fonts)
|
||||
/// @param antialias Boolean, true to use antialiasing in TrueType
|
||||
/// @param bold Boolean, true to use bold rendering in TrueType
|
||||
/// @param italic Boolean, true to use italic rendering in TrueType
|
||||
/// @param width Returns the width of the created brush, in pixels.
|
||||
/// @param height Returns the height of the created brush, in pixels.
|
||||
/// Returns true on success.
|
||||
byte *Render_text(const char *str, int font_number, int size, int antialias, int bold, int italic, int *width, int *height);
|
||||
|
||||
/// Finds a label to display for a font declared with ::Add_font().
|
||||
char * Font_label(int index);
|
||||
/// Finds the filename of a font declared with ::Add_font().
|
||||
char * Font_name(int index);
|
||||
/// Returns true if the font of this number is TrueType, false if it's a SFont bitmap.
|
||||
char * TrueType_font(int index);
|
||||
///
|
||||
/// Number of fonts declared with a series of ::Add_font(). This is public for
|
||||
/// convenience, but functionaly it is read-only.
|
||||
extern int Nb_fonts;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user