Update the 'release' branch
git-svn-id: svn://pulkomandy.tk/GrafX2/branches/release@1027 416bcca6-2ee7-4201-b75f-2eb2f807beb1
@ -12,6 +12,12 @@
|
||||
002F3A2E09D0888800EBEB88 /* SDLMain.m in Sources */ = {isa = PBXBuildFile; fileRef = 002F3A2C09D0888800EBEB88 /* SDLMain.m */; };
|
||||
002F3A3F09D088BA00EBEB88 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 002F3A3E09D088BA00EBEB88 /* main.c */; };
|
||||
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 */; };
|
||||
@ -52,8 +58,6 @@
|
||||
F5B19BA30EA4BE3E003F4BA4 /* shade.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B8B0EA4BE3E003F4BA4 /* shade.c */; };
|
||||
F5B19BA40EA4BE3E003F4BA4 /* special.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B8C0EA4BE3E003F4BA4 /* special.c */; };
|
||||
F5B19BE10EA4C65A003F4BA4 /* gfx2.cfg in Resources */ = {isa = PBXBuildFile; fileRef = F5B19BDF0EA4C65A003F4BA4 /* gfx2.cfg */; };
|
||||
F5B19BE10EA4C65A003F4BA5 /* base.gif in Copy skins */ = {isa = PBXBuildFile; fileRef = F5B19BDF0EA4C65A003F4BA5 /* base.gif */; };
|
||||
F5B19BE10EA4C65A003F4BA6 /* ilkke.png in Copy skins */ = {isa = PBXBuildFile; fileRef = F5B19BDF0EA4C65A003F4BA6 /* ilkke.png */; };
|
||||
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 */; };
|
||||
@ -104,6 +108,22 @@
|
||||
name = "Copy Frameworks into .app bundle";
|
||||
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;
|
||||
@ -119,18 +139,6 @@
|
||||
name = "Copy fonts";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
F5A33F1D0EC8A26C00F8052E /* Copy skins */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = skins;
|
||||
dstSubfolderSpec = 7;
|
||||
files = (
|
||||
F5B19BE10EA4C65A003F4BA5 /* base.gif in Copy skins */,
|
||||
F5B19BE10EA4C65A003F4BA6 /* ilkke.png in Copy skins */,
|
||||
);
|
||||
name = "Copy skins";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@ -145,6 +153,12 @@
|
||||
32CA4F630368D1EE00C91783 /* Grafx2_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Grafx2_Prefix.pch; sourceTree = "<group>"; };
|
||||
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>"; };
|
||||
@ -186,8 +200,6 @@
|
||||
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>"; };
|
||||
F5B19BDF0EA4C65A003F4BA4 /* gfx2.cfg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gfx2.cfg; sourceTree = "<group>"; };
|
||||
F5B19BDF0EA4C65A003F4BA5 /* base.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = base.gif; path = skins/base.gif; sourceTree = "<group>"; };
|
||||
F5B19BDF0EA4C65A003F4BA6 /* ilkke.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ilkke.png; path = skins/ilkke.png; sourceTree = "<group>"; };
|
||||
F5B19C1C0EA4D71C003F4BA4 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/CoreFoundation.framework; sourceTree = SYSTEM_DEVELOPER_DIR; };
|
||||
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>"; };
|
||||
@ -260,6 +272,12 @@
|
||||
29B97314FDCFA39411CA2CEA /* Grafx2 */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
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 */,
|
||||
@ -294,8 +312,6 @@
|
||||
F5B19C3B0EA4DC91003F4BA4 /* InfoPlist.strings */,
|
||||
F5B19C1C0EA4D71C003F4BA4 /* CoreFoundation.framework */,
|
||||
F5B19BDF0EA4C65A003F4BA4 /* gfx2.cfg */,
|
||||
F5B19BDF0EA4C65A003F4BA5 /* base.gif */,
|
||||
F5B19BDF0EA4C65A003F4BA6 /* ilkke.png */,
|
||||
F5B19B7B0EA4BE3E003F4BA4 /* graph.c */,
|
||||
F5B19B7C0EA4BE3E003F4BA4 /* init.c */,
|
||||
F5B19B7D0EA4BE3E003F4BA4 /* io.c */,
|
||||
@ -366,7 +382,7 @@
|
||||
002F39FD09D0883400EBEB89 /* Copy Frameworks into .app bundle */,
|
||||
002F39FD09D0883400EBEB8A /* Copy Frameworks into .app bundle */,
|
||||
F5A33F1D0EC8A26C00F8052D /* Copy fonts */,
|
||||
F5A33F1D0EC8A26C00F8052E /* Copy skins */,
|
||||
F514264B101F6C5B006CF3C4 /* Copy skins */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
|
||||
@ -18,9 +18,9 @@
|
||||
};
|
||||
002F3A3E09D088BA00EBEB88 /* main.c */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1060, 11476}}";
|
||||
sepNavSelRange = "{0, 0}";
|
||||
sepNavVisRect = "{{0, 0}, {867, 536}}";
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1044, 15086}}";
|
||||
sepNavSelRange = "{19535, 0}";
|
||||
sepNavVisRect = "{{0, 10961}, {867, 536}}";
|
||||
sepNavWindowFrame = "{{14, 76}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
@ -29,7 +29,6 @@
|
||||
activeExecutable = F5B19B5D0EA4BD57003F4BA4 /* Grafx2 */;
|
||||
activeTarget = 8D1107260486CEB800E47090 /* Grafx2 */;
|
||||
addToTargets = (
|
||||
8D1107260486CEB800E47090 /* Grafx2 */,
|
||||
);
|
||||
breakpointsGroup = F5B19B700EA4BDA9003F4BA4 /* XCBreakpointsBucket */;
|
||||
codeSenseManager = F5B19B6A0EA4BD79003F4BA4 /* Code sense */;
|
||||
@ -70,14 +69,15 @@
|
||||
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Built_ColumnID;
|
||||
PBXFileTableDataSourceColumnWidthsKey = (
|
||||
20,
|
||||
229,
|
||||
99,
|
||||
20,
|
||||
48,
|
||||
43,
|
||||
43,
|
||||
20,
|
||||
79,
|
||||
88,
|
||||
264,
|
||||
10,
|
||||
20,
|
||||
);
|
||||
PBXFileTableDataSourceColumnsKey = (
|
||||
PBXFileDataSource_FiletypeID,
|
||||
@ -89,6 +89,7 @@
|
||||
PBXFileDataSource_Target_ColumnID,
|
||||
PBXFileDataSource_Path_ColumnID,
|
||||
PBXFileDataSource_Comments_ColumnID,
|
||||
PBXFileDataSource_SCM_ColumnID,
|
||||
);
|
||||
};
|
||||
PBXConfiguration.PBXFileTableDataSource3.PBXFindDataSource = {
|
||||
@ -165,8 +166,8 @@
|
||||
PBXFileDataSource_Warnings_ColumnID,
|
||||
);
|
||||
};
|
||||
PBXPerProjectTemplateStateSaveDate = 266433807;
|
||||
PBXWorkspaceStateSaveDate = 266433807;
|
||||
PBXPerProjectTemplateStateSaveDate = 270495112;
|
||||
PBXWorkspaceStateSaveDate = 270495112;
|
||||
};
|
||||
sourceControlManager = F5B19B690EA4BD79003F4BA4 /* Source Control */;
|
||||
userBuildSettings = {
|
||||
@ -187,6 +188,11 @@
|
||||
F5B19B5D0EA4BD57003F4BA4 /* Grafx2 */,
|
||||
);
|
||||
};
|
||||
F51CBD2B0EC8A3E1005C06AC /* 5pxtinyfont.png */ = {
|
||||
uiCtxt = {
|
||||
sepNavWindowFrame = "{{15, 25}, {971, 716}}";
|
||||
};
|
||||
};
|
||||
F5A33E690EC893F800F8052D /* 8pxfont.png */ = {
|
||||
uiCtxt = {
|
||||
sepNavWindowFrame = "{{15, 76}, {906, 665}}";
|
||||
@ -256,10 +262,10 @@
|
||||
};
|
||||
F5B19B7B0EA4BE3E003F4BA4 /* graph.c */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1620, 118579}}";
|
||||
sepNavSelRange = "{16112, 36}";
|
||||
sepNavVisRect = "{{0, 9964}, {867, 536}}";
|
||||
sepNavWindowFrame = "{{15, 76}, {906, 665}}";
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1140, 52782}}";
|
||||
sepNavSelRange = "{6769, 0}";
|
||||
sepNavVisRect = "{{0, 0}, {867, 536}}";
|
||||
sepNavWindowFrame = "{{14, 76}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
F5B19B7C0EA4BE3E003F4BA4 /* init.c */ = {
|
||||
@ -296,10 +302,10 @@
|
||||
};
|
||||
F5B19B890EA4BE3E003F4BA4 /* sdlscreen.c */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1580, 11571}}";
|
||||
sepNavSelRange = "{0, 0}";
|
||||
sepNavVisRect = "{{0, 0}, {867, 536}}";
|
||||
sepNavWindowFrame = "{{61, 34}, {906, 665}}";
|
||||
sepNavIntBoundsRect = "{{0, 0}, {1396, 4351}}";
|
||||
sepNavSelRange = "{2375, 0}";
|
||||
sepNavVisRect = "{{0, 1072}, {867, 536}}";
|
||||
sepNavWindowFrame = "{{35, 15}, {906, 665}}";
|
||||
};
|
||||
};
|
||||
F5B19C3C0EA4DC91003F4BA4 /* English */ = {
|
||||
|
||||
@ -188,9 +188,9 @@
|
||||
<array/>
|
||||
<key>PerspectiveWidths</key>
|
||||
<array>
|
||||
<integer>970</integer>
|
||||
<integer>970</integer>
|
||||
<integer>970</integer>
|
||||
<integer>971</integer>
|
||||
<integer>971</integer>
|
||||
<integer>971</integer>
|
||||
</array>
|
||||
<key>Perspectives</key>
|
||||
<array>
|
||||
@ -247,7 +247,7 @@
|
||||
<dict>
|
||||
<key>PBXSmartGroupTreeModuleColumnWidthsKey</key>
|
||||
<array>
|
||||
<real>305</real>
|
||||
<real>345</real>
|
||||
</array>
|
||||
<key>PBXSmartGroupTreeModuleColumnsKey_v4</key>
|
||||
<array>
|
||||
@ -259,7 +259,10 @@
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateExpansionKey</key>
|
||||
<array>
|
||||
<string>29B97314FDCFA39411CA2CEA</string>
|
||||
<string>29B97317FDCFA39411CA2CEA</string>
|
||||
<string>1C37FBAC04509CD000000102</string>
|
||||
<string>F56B73F7101F6D9500B6D9A4</string>
|
||||
<string>F56B7443101FA1C600B6D9A4</string>
|
||||
</array>
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||
<array>
|
||||
@ -268,7 +271,7 @@
|
||||
</array>
|
||||
</array>
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
||||
<string>{{0, 124}, {305, 575}}</string>
|
||||
<string>{{0, 0}, {345, 600}}</string>
|
||||
</dict>
|
||||
<key>PBXTopSmartGroupGIDs</key>
|
||||
<array/>
|
||||
@ -278,17 +281,17 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {322, 593}}</string>
|
||||
<string>{{0, 0}, {362, 618}}</string>
|
||||
<key>GroupTreeTableConfiguration</key>
|
||||
<array>
|
||||
<string>MainColumn</string>
|
||||
<real>305</real>
|
||||
<real>345</real>
|
||||
</array>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXSmartGroupTreeModule</string>
|
||||
<key>Proportion</key>
|
||||
<string>322pt</string>
|
||||
<string>362pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Dock</key>
|
||||
@ -299,7 +302,7 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>F5A33EBD0EC89C3000F8052D</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>asm pthread_mutex_lock 0x90001a38</string>
|
||||
<string></string>
|
||||
<key>PBXSplitModuleInNavigatorKey</key>
|
||||
<dict>
|
||||
<key>Split0</key>
|
||||
@ -307,7 +310,7 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>F5A33EBE0EC89C3000F8052D</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>asm pthread_mutex_lock 0x90001a38</string>
|
||||
<string></string>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
<string>1</string>
|
||||
@ -320,7 +323,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {643, 0}}</string>
|
||||
<string>{{0, 0}, {604, 0}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXNavigatorGroup</string>
|
||||
@ -329,7 +332,7 @@
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Proportion</key>
|
||||
<string>588pt</string>
|
||||
<string>613pt</string>
|
||||
<key>Tabs</key>
|
||||
<array>
|
||||
<dict>
|
||||
@ -343,7 +346,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {643, 561}}</string>
|
||||
<string>{{10, 27}, {604, 586}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>XCDetailModule</string>
|
||||
@ -359,7 +362,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {650, 590}}</string>
|
||||
<string>{{10, 27}, {644, 586}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXProjectFindModule</string>
|
||||
@ -375,7 +378,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 31}, {603, 297}}</string>
|
||||
<string>{{10, 27}, {644, 586}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXCVSModule</string>
|
||||
@ -384,7 +387,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>Proportion</key>
|
||||
<string>643pt</string>
|
||||
<string>604pt</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Name</key>
|
||||
@ -402,11 +405,11 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>F5D646000F487ECB007E515F</string>
|
||||
<string>F56B7444101FA1C600B6D9A4</string>
|
||||
<string>1CA23ED40692098700951B8B</string>
|
||||
<string>F5D646010F487ECB007E515F</string>
|
||||
<string>F56B7445101FA1C600B6D9A4</string>
|
||||
<string>F5A33EBD0EC89C3000F8052D</string>
|
||||
<string>F5D646020F487ECB007E515F</string>
|
||||
<string>F56B7446101FA1C600B6D9A4</string>
|
||||
<string>1CA23EDF0692099D00951B8B</string>
|
||||
<string>1CA23EE00692099D00951B8B</string>
|
||||
<string>1CA23EE10692099D00951B8B</string>
|
||||
@ -468,18 +471,24 @@
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateExpansionKey</key>
|
||||
<array>
|
||||
<string>29B97314FDCFA39411CA2CEA</string>
|
||||
<string>F5B19C3B0EA4DC91003F4BA4</string>
|
||||
<string>080E96DDFE201D6D7F000001</string>
|
||||
<string>29B97315FDCFA39411CA2CEA</string>
|
||||
<string>29B97317FDCFA39411CA2CEA</string>
|
||||
<string>29B97323FDCFA39411CA2CEA</string>
|
||||
<string>1058C7A0FEA54F0111CA2CBB</string>
|
||||
<string>1058C7A2FEA54F0111CA2CBB</string>
|
||||
<string>19C28FACFE9D520D11CA2CBB</string>
|
||||
</array>
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||
<array>
|
||||
<array>
|
||||
<integer>42</integer>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
</array>
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
||||
<string>{{0, 0}, {275, 583}}</string>
|
||||
<string>{{0, 475}, {275, 600}}</string>
|
||||
</dict>
|
||||
<key>PBXTopSmartGroupGIDs</key>
|
||||
<array/>
|
||||
@ -489,14 +498,14 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {292, 601}}</string>
|
||||
<string>{{0, 0}, {292, 618}}</string>
|
||||
<key>GroupTreeTableConfiguration</key>
|
||||
<array>
|
||||
<string>MainColumn</string>
|
||||
<real>275</real>
|
||||
</array>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>65 75 944 642 0 0 1024 746 </string>
|
||||
<string>151 75 971 659 0 0 1024 746 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXSmartGroupTreeModule</string>
|
||||
@ -533,9 +542,9 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {647, 0}}</string>
|
||||
<string>{{0, 0}, {674, 0}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>65 75 944 642 0 0 1024 746 </string>
|
||||
<string>151 75 971 659 0 0 1024 746 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXNavigatorGroup</string>
|
||||
@ -544,14 +553,14 @@
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Proportion</key>
|
||||
<string>596pt</string>
|
||||
<string>613pt</string>
|
||||
<key>Tabs</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>ContentConfiguration</key>
|
||||
<dict>
|
||||
<key>PBXBuildLogShowsTranscriptDefaultKey</key>
|
||||
<string>{{0, 5}, {647, 564}}</string>
|
||||
<string>{{0, 5}, {674, 581}}</string>
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>XCMainBuildResultsModuleGUID</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
@ -564,9 +573,9 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {647, 569}}</string>
|
||||
<string>{{10, 27}, {674, 586}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>65 75 944 642 0 0 1024 746 </string>
|
||||
<string>151 75 971 659 0 0 1024 746 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXBuildResultsModule</string>
|
||||
@ -628,7 +637,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>Proportion</key>
|
||||
<string>647pt</string>
|
||||
<string>674pt</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Name</key>
|
||||
@ -646,14 +655,14 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>F53931560FE170BC003CB103</string>
|
||||
<string>F56B7447101FA1C600B6D9A4</string>
|
||||
<string>1CA23EE50692099D00951B8B</string>
|
||||
<string>F53931570FE170BC003CB103</string>
|
||||
<string>F56B7448101FA1C600B6D9A4</string>
|
||||
<string>F5A33EC20EC89C3000F8052D</string>
|
||||
<string>F53931580FE170BC003CB103</string>
|
||||
<string>F56B7449101FA1C600B6D9A4</string>
|
||||
<string>XCMainBuildResultsModuleGUID</string>
|
||||
<string>1CA23EE80692099D00951B8B</string>
|
||||
<string>F53931590FE170BC003CB103</string>
|
||||
<string>F56B744A101FA1C600B6D9A4</string>
|
||||
</array>
|
||||
<key>ToolbarConfiguration</key>
|
||||
<string>xcode.toolbar.config.buildAndRun</string>
|
||||
@ -697,7 +706,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {1323, 0}}</string>
|
||||
<string>{{0, 0}, {971, 0}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXDebugCLIModule</string>
|
||||
@ -721,8 +730,8 @@
|
||||
<string>yes</string>
|
||||
<key>sizes</key>
|
||||
<array>
|
||||
<string>{{0, 0}, {641, 197}}</string>
|
||||
<string>{{641, 0}, {682, 197}}</string>
|
||||
<string>{{0, 0}, {470, 295}}</string>
|
||||
<string>{{470, 0}, {501, 295}}</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>VerticalSplitView</key>
|
||||
@ -737,8 +746,8 @@
|
||||
<string>yes</string>
|
||||
<key>sizes</key>
|
||||
<array>
|
||||
<string>{{0, 0}, {1323, 197}}</string>
|
||||
<string>{{0, 197}, {1323, 211}}</string>
|
||||
<string>{{0, 0}, {971, 295}}</string>
|
||||
<string>{{0, 295}, {971, 318}}</string>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
@ -760,12 +769,12 @@
|
||||
<key>DebugSTDIOWindowFrame</key>
|
||||
<string>{{200, 200}, {500, 300}}</string>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 5}, {1323, 408}}</string>
|
||||
<string>{{0, 5}, {971, 613}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXDebugSessionModule</string>
|
||||
<key>Proportion</key>
|
||||
<string>408pt</string>
|
||||
<string>613pt</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Name</key>
|
||||
@ -784,15 +793,15 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>F5AED0700F1999130090A93F</string>
|
||||
<string>F56B744B101FA1C600B6D9A4</string>
|
||||
<string>1CCC7628064C1048000F2A68</string>
|
||||
<string>1CCC7629064C1048000F2A68</string>
|
||||
<string>F5AED0710F1999130090A93F</string>
|
||||
<string>F5AED0720F1999130090A93F</string>
|
||||
<string>F5AED0730F1999130090A93F</string>
|
||||
<string>F5AED0740F1999130090A93F</string>
|
||||
<string>F5AED0410F1989EC0090A93F</string>
|
||||
<string>F5AED0750F1999130090A93F</string>
|
||||
<string>F56B744C101FA1C600B6D9A4</string>
|
||||
<string>F56B744D101FA1C600B6D9A4</string>
|
||||
<string>F56B744E101FA1C600B6D9A4</string>
|
||||
<string>F56B744F101FA1C600B6D9A4</string>
|
||||
<string>F56B7409101F6DEB00B6D9A4</string>
|
||||
<string>F56B7450101FA1C600B6D9A4</string>
|
||||
</array>
|
||||
<key>ToolbarConfiguration</key>
|
||||
<string>xcode.toolbar.config.debug</string>
|
||||
@ -801,7 +810,7 @@
|
||||
<key>PerspectivesBarVisible</key>
|
||||
<true/>
|
||||
<key>PinnedNavigatorIdentifier</key>
|
||||
<string>F539315B0FE170D5003CB103</string>
|
||||
<string>F56B743E101F7E4F00B6D9A4</string>
|
||||
<key>ShelfIsVisible</key>
|
||||
<false/>
|
||||
<key>SourceDescription</key>
|
||||
@ -824,10 +833,11 @@
|
||||
<integer>5</integer>
|
||||
<key>WindowOrderList</key>
|
||||
<array>
|
||||
<string>F56B7450101FA1C600B6D9A4</string>
|
||||
<string>/Users/xx/Grafx2/Grafx2.xcodeproj</string>
|
||||
</array>
|
||||
<key>WindowString</key>
|
||||
<string>65 75 944 642 0 0 1024 746 </string>
|
||||
<string>151 75 971 659 0 0 1024 746 </string>
|
||||
<key>WindowTools</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<string>Grafx2</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>http://grafx2.googlecode.com/</string>
|
||||
<string>com.googlecode.grafx2</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<string>Grafx2</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
|
||||
89
Makefile
@ -1,5 +1,6 @@
|
||||
# Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
#
|
||||
# Copyright 2009 Per Olofsson
|
||||
# Copyright 2008 Peter Gordon
|
||||
# Copyright 2008 Yves Rizoud
|
||||
# Copyright 2007 Adrien Destugues
|
||||
@ -31,6 +32,8 @@
|
||||
|
||||
### 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
|
||||
@ -45,8 +48,7 @@ ifdef COMSPEC
|
||||
OBJDIR = obj/win32
|
||||
# Resources (icon)
|
||||
WINDRES = windres.exe
|
||||
OBJRES = $(OBJDIR)/winres.o
|
||||
CFGOBJRES = $(OBJDIR)/wincfgres.o
|
||||
PLATFORMOBJ = $(OBJDIR)/winres.o
|
||||
PLATFORM = win32
|
||||
PLATFORMFILES = SDL.dll SDL_image.dll libpng13.dll zlib1.dll gfx2.ico $(TTFLIBS) #some misc files we have to add to the release archive under windows.
|
||||
ZIP = zip
|
||||
@ -62,13 +64,36 @@ else
|
||||
RMDIR = rmdir
|
||||
CP = cp
|
||||
BIN = grafx2
|
||||
COPT = -Wall -c -gstabs -mcrt=newlib `sdl-config --cflags` -D__USE_INLINE__ $(TTFCOPT)
|
||||
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)
|
||||
#Mac OS X specific
|
||||
DELCOMMAND = rm -rf
|
||||
MKDIR = mkdir -p
|
||||
RMDIR = rmdir
|
||||
CP = cp
|
||||
ZIP = zip
|
||||
PLATFORMFILES = gfx2.png
|
||||
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)
|
||||
#AROS specific
|
||||
DELCOMMAND = rm -rf
|
||||
@ -185,7 +210,7 @@ else
|
||||
|
||||
# Compiles a regular linux exectutable for the native platform
|
||||
BIN = grafx2
|
||||
COPT = -W -Wall -Wdeclaration-after-statement -pedantic -std=c99 -c -g `sdl-config --cflags` $(TTFCOPT)
|
||||
COPT = -W -Wall -Wdeclaration-after-statement -std=c99 -c -g `sdl-config --cflags` $(TTFCOPT)
|
||||
LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) -lpng
|
||||
# Use gcc for compiling. Use ncc to build a callgraph and analyze the code.
|
||||
CC = gcc
|
||||
@ -225,9 +250,30 @@ endif
|
||||
.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
|
||||
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 $(PLATFORMOBJ)
|
||||
|
||||
SKIN_FILES = skins/skin_classic.png skins/skin_modern.png skins/font_Classic.png 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 gfx2.cfg 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)
|
||||
|
||||
@ -237,17 +283,22 @@ release : version $(BIN)
|
||||
|
||||
# Create a zip archive ready for upload to the website, including binaries and sourcecode
|
||||
ziprelease: version $(BIN) release
|
||||
tar cvzf src-svn`svnversion | sed 's/:/-/'`.tgz --transform 's,^,src/,g' *.c *.h Makefile Makefile.dep gfx2.ico
|
||||
$(ZIP) $(ZIPOPT) grafx2-svn`svnversion | sed 's/:/-/'`$(TTFLABEL)-$(PLATFORM).$(ZIP) $(BIN) gfx2def.ini skins/base.gif gfx2.gif doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt fonts/8pxfont.png doc/README-zlib1.txt doc/README-SDL.txt doc/README-SDL_image.txt doc/README-SDL_ttf.txt fonts/Tuffy.ttf src-svn`svnversion | sed 's/:/-/'`.tgz $(PLATFORMFILES)
|
||||
$(DELCOMMAND) src-svn`svnversion | sed 's/:/-/'`.tgz
|
||||
tar cvzf grafx2-svn`svnversion | sed 's/:/-/'`$(TTFLABEL)-src.tgz --transform 's,^,grafx2/,g' *.c *.h Makefile Makefile.dep gfx2def.ini skins/base.gif gfx2.ico gfx2.gif doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt misc/grafx2.1 misc/grafx2.xpm misc/grafx2.desktop fonts/8pxfont.png fonts/Tuffy.ttf
|
||||
echo `sed "s/.*=\"\(.*\)\";/\1/" pversion.c`.`svnversion` | tr " :" "_-" | sed -e s/\\(wip\\)\\\\./\\1/I > $(OBJDIR)/versiontag
|
||||
|
||||
$(BIN) : $(OBJ) $(OBJRES)
|
||||
$(CC) $(OBJ) $(OBJRES) -o $(BIN) $(LOPT)
|
||||
tar cvzf "src-`cat $(OBJDIR)/versiontag`.tgz" --transform 's,^,src/,g' *.c *.h Makefile Makefile.dep gfx2.ico
|
||||
$(ZIP) $(ZIPOPT) "grafx2-`cat $(OBJDIR)/versiontag`$(TTFLABEL)-$(PLATFORM).$(ZIP)" $(BIN) gfx2def.ini $(SKIN_FILES) gfx2.gif doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt fonts/8pxfont.png doc/README-zlib1.txt doc/README-SDL.txt doc/README-SDL_image.txt doc/README-SDL_ttf.txt fonts/Tuffy.ttf src-`cat $(OBJDIR)/versiontag`.tgz $(PLATFORMFILES)
|
||||
$(DELCOMMAND) "src-`cat $(OBJDIR)/versiontag`.tgz"
|
||||
tar cvzf "grafx2-`cat $(OBJDIR)/versiontag`$(TTFLABEL)-src.tgz" --transform 's,^,grafx2/,g' *.c *.h Makefile Makefile.dep gfx2def.ini $(SKIN_FILES) gfx2.ico gfx2.gif doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt misc/grafx2.1 misc/grafx2.xpm misc/grafx2.desktop fonts/8pxfont.png fonts/Tuffy.ttf
|
||||
$(DELCOMMAND) "$(OBJDIR)/versiontag"
|
||||
|
||||
testsed :
|
||||
|
||||
$(BIN) : $(OBJ)
|
||||
$(CC) $(OBJ) -o $(BIN) $(LOPT)
|
||||
|
||||
# SVN revision number
|
||||
version.c :
|
||||
echo "char SVN_revision[]=\"`svnversion`\";" > version.c
|
||||
echo "char SVN_revision[]=\"`svnversion .`\";" > version.c
|
||||
ifeq ($(LABEL),)
|
||||
else
|
||||
echo "char Program_version[]=\"$(LABEL)\";" > pversion.c
|
||||
@ -265,10 +316,14 @@ else
|
||||
$(DELCOMMAND) pversion.c
|
||||
endif
|
||||
|
||||
$(OBJDIR)/%.o :
|
||||
$(OBJDIR)/%.o : %.c
|
||||
$(if $(wildcard $(OBJDIR)),,$(MKDIR) $(OBJDIR))
|
||||
$(CC) $(COPT) -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
|
||||
|
||||
@ -277,7 +332,7 @@ $(OBJDIR)/winres.o : gfx2.ico
|
||||
echo "1 ICON \"gfx2.ico\"" | $(WINDRES) -o $(OBJDIR)/winres.o
|
||||
|
||||
clean :
|
||||
$(DELCOMMAND) $(OBJ) $(OBJDIR)/version.o $(OBJRES)
|
||||
$(DELCOMMAND) $(OBJ)
|
||||
$(DELCOMMAND) $(BIN)
|
||||
|
||||
# Linux installation of the program
|
||||
@ -298,7 +353,7 @@ install : $(BIN)
|
||||
$(CP) gfx2def.ini $(DESTDIR)$(datadir)/grafx2/
|
||||
$(CP) gfx2.gif $(DESTDIR)$(datadir)/grafx2/
|
||||
$(CP) fonts/* $(DESTDIR)$(datadir)/grafx2/fonts/
|
||||
$(CP) skins/base.gif $(DESTDIR)$(datadir)/grafx2/skins/
|
||||
$(CP) $(SKIN_FILES) $(DESTDIR)$(datadir)/grafx2/skins/
|
||||
# Icon and desktop file for debian
|
||||
$(CP) misc/grafx2.desktop $(DESTDIR)$(datadir)/applications/
|
||||
$(CP) misc/grafx2.xpm $(DESTDIR)$(datadir)/icons/
|
||||
@ -312,7 +367,9 @@ uninstall :
|
||||
$(DELCOMMAND) $(DESTDIR)$(datadir)/grafx2/gfx2.gif
|
||||
$(DELCOMMAND) $(DESTDIR)$(datadir)/grafx2/fonts/*
|
||||
$(if $(wildcard $(DESTDIR)$(datadir)/grafx2/fonts),,$(RMDIR) $(DESTDIR)$(datadir)/grafx2/fonts)
|
||||
$(DELCOMMAND) $(DESTDIR)$(datadir)/grafx2/skins/base.gif
|
||||
cd $(DESTDIR)$(datadir)/grafx2
|
||||
$(DELCOMMAND) $(SKIN_FILES)
|
||||
cd ..
|
||||
$(if $(wildcard $(DESTDIR)$(datadir)/grafx2/skins),,$(RMDIR) $(DESTDIR)$(datadir)/grafx2/skins)
|
||||
# Icon and desktop file for debian
|
||||
$(DELCOMMAND) $(DESTDIR)$(datadir)/applications/grafx2.desktop
|
||||
|
||||
205
brush.c
@ -123,7 +123,8 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
||||
int position;
|
||||
byte * temp;
|
||||
|
||||
if (!(is_preview && Mouse_K)) // Si bouton enfoncé & preview > pas de dessin
|
||||
if (is_preview==0 || Mouse_K==0) // pas de curseur si on est en preview et
|
||||
// en train de cliquer
|
||||
switch (Paintbrush_shape)
|
||||
{
|
||||
case PAINTBRUSH_SHAPE_POINT : // !!! TOUJOURS EN PREVIEW !!!
|
||||
@ -151,7 +152,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
||||
end_counter_x=start_x_counter+width;
|
||||
end_counter_y=start_y_counter+height;
|
||||
|
||||
if (is_preview)
|
||||
if (is_preview != 0)
|
||||
{
|
||||
if ( (width>0) && (height>0) )
|
||||
Display_brush_color(
|
||||
@ -165,7 +166,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
||||
Brush_width
|
||||
);
|
||||
|
||||
if (Main_magnifier_mode)
|
||||
if (Main_magnifier_mode != 0)
|
||||
{
|
||||
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,
|
||||
&height
|
||||
@ -196,9 +197,9 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((Smear_mode) && (Shade_table==Shade_table_left))
|
||||
if ((Smear_mode != 0) && (Shade_table==Shade_table_left))
|
||||
{
|
||||
if (Smear_start)
|
||||
if (Smear_start != 0)
|
||||
{
|
||||
if ((width>0) && (height>0))
|
||||
{
|
||||
@ -275,7 +276,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
||||
start_y_counter=start_y-(y-Brush_offset_Y);
|
||||
end_counter_x=start_x_counter+width;
|
||||
end_counter_y=start_y_counter+height;
|
||||
if (is_preview)
|
||||
if (is_preview != 0)
|
||||
{
|
||||
if ( (width>0) && (height>0) )
|
||||
Display_brush_mono(start_x-Main_offset_X,
|
||||
@ -285,7 +286,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
||||
Back_color,Fore_color,
|
||||
Brush_width);
|
||||
|
||||
if (Main_magnifier_mode)
|
||||
if (Main_magnifier_mode != 0)
|
||||
{
|
||||
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
|
||||
start_x_counter=start_x-(x-Brush_offset_X);
|
||||
@ -314,9 +315,9 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((Smear_mode) && (Shade_table==Shade_table_left))
|
||||
if ((Smear_mode != 0) && (Shade_table==Shade_table_left))
|
||||
{
|
||||
if (Smear_start)
|
||||
if (Smear_start != 0)
|
||||
{
|
||||
if ((width>0) && (height>0))
|
||||
{
|
||||
@ -377,7 +378,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
||||
start_y_counter=start_y-(y-Paintbrush_offset_Y);
|
||||
end_counter_x=start_x_counter+width;
|
||||
end_counter_y=start_y_counter+height;
|
||||
if (is_preview)
|
||||
if (is_preview != 0)
|
||||
{
|
||||
temp=Brush;
|
||||
Brush=Paintbrush_sprite;
|
||||
@ -390,7 +391,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
||||
0,Fore_color,
|
||||
MAX_PAINTBRUSH_SIZE);
|
||||
|
||||
if (Main_magnifier_mode)
|
||||
if (Main_magnifier_mode != 0)
|
||||
{
|
||||
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
|
||||
start_x_counter=start_x-(x-Paintbrush_offset_X);
|
||||
@ -419,9 +420,9 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((Smear_mode) && (Shade_table==Shade_table_left))
|
||||
if ((Smear_mode != 0) && (Shade_table==Shade_table_left))
|
||||
{
|
||||
if (Smear_start)
|
||||
if (Smear_start != 0)
|
||||
{
|
||||
if ((width>0) && (height>0))
|
||||
{
|
||||
@ -444,10 +445,13 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
||||
{
|
||||
temp_color=Read_pixel_from_current_screen(x_pos,y_pos);
|
||||
position=(counter_y*Smear_brush_width)+counter_x;
|
||||
if ( (Paintbrush_sprite[(MAX_PAINTBRUSH_SIZE*counter_y)+counter_x]) // Le pinceau sert de masque pour dire quels pixels on doit traiter dans le rectangle
|
||||
&& (counter_y<Smear_max_Y) && (counter_x<Smear_max_X) // On clippe l'effet smear entre Smear_Min et Smear_Max
|
||||
&& (counter_y>=Smear_min_Y) && (counter_x>=Smear_min_X) )
|
||||
Display_pixel(x_pos,y_pos,Smear_brush[position]);
|
||||
if ( (Paintbrush_sprite[(MAX_PAINTBRUSH_SIZE*counter_y)+counter_x] != 0)
|
||||
// Le pinceau sert de masque pour dire quels pixels on doit traiter dans le rectangle
|
||||
&& (counter_y<Smear_max_Y) && (counter_x<Smear_max_X)
|
||||
&& (counter_y>=Smear_min_Y) && (counter_x>=Smear_min_X)
|
||||
// On clippe l'effet smear entre Smear_Min et Smear_Max
|
||||
)
|
||||
Display_pixel(x_pos,y_pos,Smear_brush[position]);
|
||||
Smear_brush[position]=temp_color;
|
||||
}
|
||||
Update_part_of_screen(start_x, start_y, width, height);
|
||||
@ -464,7 +468,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
||||
for (y_pos=start_y,counter_y=start_y_counter;counter_y<end_counter_y;y_pos++,counter_y++)
|
||||
for (x_pos=start_x,counter_x=start_x_counter;counter_x<end_counter_x;x_pos++,counter_x++)
|
||||
{
|
||||
if (Paintbrush_sprite[(MAX_PAINTBRUSH_SIZE*counter_y)+counter_x])
|
||||
if (Paintbrush_sprite[(MAX_PAINTBRUSH_SIZE*counter_y)+counter_x] != 0)
|
||||
Display_pixel(x_pos,y_pos,color);
|
||||
}
|
||||
Update_part_of_screen(start_x,start_y,width,height);
|
||||
@ -473,6 +477,69 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Changes the Brush size, discarding its previous content.
|
||||
/// @return 0 OK, 1 Failed
|
||||
byte Realloc_brush(word new_brush_width, word new_brush_height)
|
||||
{
|
||||
byte return_code=0;
|
||||
|
||||
if ( (((long)Brush_height)*Brush_width) !=
|
||||
(((long)new_brush_height)*new_brush_width) )
|
||||
{
|
||||
free(Brush);
|
||||
Brush=(byte *)malloc(((long)new_brush_height)*new_brush_width);
|
||||
if (Brush == NULL)
|
||||
{
|
||||
Error(0);
|
||||
return_code=1;
|
||||
|
||||
Brush=(byte *)malloc(1*1);
|
||||
if(Brush == NULL)
|
||||
{
|
||||
Error(ERROR_MEMORY);
|
||||
exit(ERROR_MEMORY);
|
||||
}
|
||||
new_brush_height=new_brush_width=1;
|
||||
*Brush=Fore_color;
|
||||
}
|
||||
}
|
||||
Brush_width=new_brush_width;
|
||||
Brush_height=new_brush_height;
|
||||
|
||||
free(Smear_brush);
|
||||
Smear_brush_width=(Brush_width>MAX_PAINTBRUSH_SIZE)?Brush_width:MAX_PAINTBRUSH_SIZE;
|
||||
Smear_brush_height=(Brush_height>MAX_PAINTBRUSH_SIZE)?Brush_height:MAX_PAINTBRUSH_SIZE;
|
||||
Smear_brush=(byte *)malloc(((long)Smear_brush_height)*Smear_brush_width);
|
||||
|
||||
if (Smear_brush == NULL) // Failed to allocate the smear brush
|
||||
{
|
||||
Error(0);
|
||||
return_code=1;
|
||||
|
||||
free(Brush);
|
||||
Brush=(byte *)malloc(1*1);
|
||||
if(Brush == NULL)
|
||||
{
|
||||
Error(ERROR_MEMORY);
|
||||
exit(ERROR_MEMORY);
|
||||
}
|
||||
Brush_height=1;
|
||||
Brush_width=1;
|
||||
|
||||
Smear_brush=(byte *)malloc(MAX_PAINTBRUSH_SIZE*MAX_PAINTBRUSH_SIZE);
|
||||
if(Smear_brush == NULL)
|
||||
{
|
||||
Error(ERROR_MEMORY);
|
||||
exit(ERROR_MEMORY);
|
||||
}
|
||||
Smear_brush_height=MAX_PAINTBRUSH_SIZE;
|
||||
Smear_brush_width=MAX_PAINTBRUSH_SIZE;
|
||||
}
|
||||
return return_code;
|
||||
}
|
||||
|
||||
|
||||
// -- Effacer le pinceau -- //
|
||||
//
|
||||
void Hide_paintbrush(short x,short y)
|
||||
@ -495,11 +562,11 @@ void Hide_paintbrush(short x,short y)
|
||||
//short counter_x; // Position X (dans la brosse/pinceau) en cours
|
||||
//d'affichage
|
||||
//short counter_y; // Position Y (dans la brosse/pinceau) en cours d'affichage
|
||||
short end_counter_x; // Position X ou s'arrête l'affichade de la brosse/pinceau
|
||||
short end_counter_y; // Position Y ou s'arrête l'affichade de la brosse/pinceau
|
||||
short end_counter_x; // Position X ou s'arrête l'affichage de la brosse/pinceau
|
||||
short end_counter_y; // Position Y ou s'arrête l'affichage de la brosse/pinceau
|
||||
byte * temp;
|
||||
|
||||
if (!Mouse_K)
|
||||
if (Mouse_K == 0)
|
||||
switch (Paintbrush_shape)
|
||||
{
|
||||
case PAINTBRUSH_SHAPE_POINT :
|
||||
@ -531,7 +598,7 @@ void Hide_paintbrush(short x,short y)
|
||||
width,height,Back_color,
|
||||
Main_image_width);
|
||||
|
||||
if (Main_magnifier_mode)
|
||||
if (Main_magnifier_mode != 0)
|
||||
{
|
||||
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
|
||||
start_x_counter=start_x;
|
||||
@ -577,7 +644,7 @@ void Hide_paintbrush(short x,short y)
|
||||
Main_image_width);
|
||||
}
|
||||
|
||||
if (Main_magnifier_mode)
|
||||
if (Main_magnifier_mode != 0)
|
||||
{
|
||||
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
|
||||
start_x_counter=start_x;
|
||||
@ -651,46 +718,12 @@ void Capture_brush(short start_x,short start_y,short end_x,short end_y,short cle
|
||||
if (start_y+new_brush_height>Main_image_height)
|
||||
new_brush_height=Main_image_height-start_y;
|
||||
|
||||
if ( (((long)Brush_height)*Brush_width) !=
|
||||
(((long)new_brush_height)*new_brush_width) )
|
||||
{
|
||||
free(Brush);
|
||||
Brush=(byte *)malloc(((long)new_brush_height)*new_brush_width);
|
||||
if (!Brush)
|
||||
{
|
||||
Error(0);
|
||||
|
||||
Brush=(byte *)malloc(1*1);
|
||||
new_brush_height=new_brush_width=1;
|
||||
*Brush=Fore_color;
|
||||
}
|
||||
}
|
||||
Brush_width=new_brush_width;
|
||||
Brush_height=new_brush_height;
|
||||
|
||||
free(Smear_brush);
|
||||
Smear_brush_width=(Brush_width>MAX_PAINTBRUSH_SIZE)?Brush_width:MAX_PAINTBRUSH_SIZE;
|
||||
Smear_brush_height=(Brush_height>MAX_PAINTBRUSH_SIZE)?Brush_height:MAX_PAINTBRUSH_SIZE;
|
||||
Smear_brush=(byte *)malloc(((long)Smear_brush_height)*Smear_brush_width);
|
||||
|
||||
if (!Smear_brush) // On ne peut même pas allouer la brosse du smear!
|
||||
{
|
||||
Error(0);
|
||||
|
||||
free(Brush);
|
||||
Brush=(byte *)malloc(1*1);
|
||||
Brush_height=1;
|
||||
Brush_width=1;
|
||||
|
||||
Smear_brush=(byte *)malloc(MAX_PAINTBRUSH_SIZE*MAX_PAINTBRUSH_SIZE);
|
||||
Smear_brush_height=MAX_PAINTBRUSH_SIZE;
|
||||
Smear_brush_width=MAX_PAINTBRUSH_SIZE;
|
||||
}
|
||||
Realloc_brush(new_brush_width, new_brush_height);
|
||||
|
||||
Copy_image_to_brush(start_x,start_y,Brush_width,Brush_height,Main_image_width);
|
||||
|
||||
// On regarde s'il faut effacer quelque chose:
|
||||
if (clear)
|
||||
if (clear != 0)
|
||||
{
|
||||
for (y_pos=start_y;y_pos<start_y+Brush_height;y_pos++)
|
||||
for (x_pos=start_x;x_pos<start_x+Brush_width;x_pos++)
|
||||
@ -716,7 +749,7 @@ void Rotate_90_deg()
|
||||
new_brush=(byte *)malloc(((long)Brush_height)*Brush_width);
|
||||
if (new_brush)
|
||||
{
|
||||
Rotate_90_deg_lowlevel(Brush,new_brush,Brush_width,Brush_height);
|
||||
Rotate_90_deg_lowlevel(Brush,/*@out@*/ new_brush,Brush_width,Brush_height);
|
||||
free(Brush);
|
||||
Brush=new_brush;
|
||||
|
||||
@ -767,7 +800,7 @@ void Remap_brush(void)
|
||||
// conversion puisque elles n'existent pas dans la brosse, donc elles
|
||||
// ne seront pas utilisées par Remap_brush_LOWLEVEL.
|
||||
for (color=0;color<=255;color++)
|
||||
if (used[color])
|
||||
if (used[color] != 0)
|
||||
used[color]=Best_color(Spare_palette[color].R,Spare_palette[color].G,Spare_palette[color].B);
|
||||
|
||||
// Il reste une couleur non calculée dans la table qu'il faut mettre à
|
||||
@ -808,13 +841,9 @@ void Outline_brush(void)
|
||||
|
||||
// On copie la brosse courante dans la nouvelle
|
||||
Copy_part_of_image_to_another(Brush, // source
|
||||
0, 0,
|
||||
Brush_width,
|
||||
Brush_height,
|
||||
Brush_width,
|
||||
new_brush, // Destination
|
||||
1, 1,
|
||||
width);
|
||||
0, 0, Brush_width, Brush_height, Brush_width,
|
||||
new_brush, // Destination
|
||||
1, 1, width);
|
||||
|
||||
// On intervertit la nouvelle et l'ancienne brosse:
|
||||
temp=Brush;
|
||||
@ -835,23 +864,20 @@ void Outline_brush(void)
|
||||
{
|
||||
if (temp[((y_pos-1)*width)+x_pos-1]==Back_color)
|
||||
{
|
||||
if (state)
|
||||
if (state != 0)
|
||||
{
|
||||
Pixel_in_brush(x_pos,y_pos,Fore_color);
|
||||
state=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (state == 0)
|
||||
{
|
||||
if (!state)
|
||||
{
|
||||
Pixel_in_brush(x_pos-1,y_pos,Fore_color);
|
||||
state=1;
|
||||
}
|
||||
Pixel_in_brush(x_pos-1,y_pos,Fore_color);
|
||||
state=1;
|
||||
}
|
||||
}
|
||||
// Cas du dernier pixel à droite de la ligne
|
||||
if (state)
|
||||
if (state != 0)
|
||||
Pixel_in_brush(x_pos,y_pos,Fore_color);
|
||||
}
|
||||
|
||||
@ -863,23 +889,20 @@ void Outline_brush(void)
|
||||
{
|
||||
if (temp[((y_pos-1)*width)+x_pos-1]==Back_color)
|
||||
{
|
||||
if (state)
|
||||
if (state != 0)
|
||||
{
|
||||
Pixel_in_brush(x_pos,y_pos,Fore_color);
|
||||
state=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (state == 0)
|
||||
{
|
||||
if (!state)
|
||||
{
|
||||
Pixel_in_brush(x_pos,y_pos-1,Fore_color);
|
||||
state=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Cas du dernier pixel en bas de la colonne
|
||||
if (state)
|
||||
if (state != 0)
|
||||
Pixel_in_brush(x_pos,y_pos,Fore_color);
|
||||
}
|
||||
}
|
||||
@ -903,7 +926,7 @@ void Outline_brush(void)
|
||||
|
||||
void Nibble_brush(void)
|
||||
{
|
||||
long /*Pos,*/x_pos,y_pos;
|
||||
long x_pos,y_pos;
|
||||
byte state;
|
||||
byte * new_brush;
|
||||
byte * temp;
|
||||
@ -946,7 +969,7 @@ void Nibble_brush(void)
|
||||
{
|
||||
if (temp[((y_pos+1)*width)+x_pos+1]==Back_color)
|
||||
{
|
||||
if (state)
|
||||
if (state != 0)
|
||||
{
|
||||
if (x_pos>0)
|
||||
Pixel_in_brush(x_pos-1,y_pos,Back_color);
|
||||
@ -955,7 +978,7 @@ void Nibble_brush(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!state)
|
||||
if (state == 0)
|
||||
{
|
||||
Pixel_in_brush(x_pos,y_pos,Back_color);
|
||||
state=1;
|
||||
@ -984,7 +1007,7 @@ void Nibble_brush(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!state)
|
||||
if (state == 0)
|
||||
{
|
||||
Pixel_in_brush(x_pos,y_pos,Back_color);
|
||||
state=1;
|
||||
@ -1021,7 +1044,7 @@ void Capture_brush_with_lasso(int vertices, short * points,short clear)
|
||||
short start_y=Limit_bottom+1;
|
||||
short end_x=Limit_left-1;
|
||||
short end_y=Limit_top-1;
|
||||
short temp;
|
||||
unsigned short temp;
|
||||
short x_pos;
|
||||
short y_pos;
|
||||
word new_brush_width;
|
||||
@ -1029,10 +1052,10 @@ void Capture_brush_with_lasso(int vertices, short * points,short clear)
|
||||
|
||||
|
||||
// On recherche les bornes de la brosse:
|
||||
for (temp=0; temp<vertices; temp++)
|
||||
for (temp=0; temp<2*vertices; temp+=2)
|
||||
{
|
||||
x_pos=points[temp<<1];
|
||||
y_pos=points[(temp<<1)+1];
|
||||
x_pos=points[temp];
|
||||
y_pos=points[temp+1];
|
||||
if (x_pos<start_x)
|
||||
start_x=x_pos;
|
||||
if (x_pos>end_x)
|
||||
@ -1079,6 +1102,7 @@ void Capture_brush_with_lasso(int vertices, short * points,short clear)
|
||||
Error(0);
|
||||
|
||||
Brush=(byte *)malloc(1*1);
|
||||
if(Brush==NULL) Error(ERROR_MEMORY);
|
||||
new_brush_height=new_brush_width=1;
|
||||
*Brush=Fore_color;
|
||||
}
|
||||
@ -1097,6 +1121,7 @@ void Capture_brush_with_lasso(int vertices, short * points,short clear)
|
||||
|
||||
free(Brush);
|
||||
Brush=(byte *)malloc(1*1);
|
||||
if(Brush==NULL) Error(ERROR_MEMORY);
|
||||
Brush_height=1;
|
||||
Brush_width=1;
|
||||
|
||||
|
||||
8
brush.h
@ -105,4 +105,12 @@ void Nibble_brush(void);
|
||||
*/
|
||||
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
|
||||
|
||||
25
buttons.h
@ -353,6 +353,11 @@ void Button_Snap_mode(void);
|
||||
*/
|
||||
void Button_Grid_menu(void);
|
||||
|
||||
/*!
|
||||
Callback to toggle the grid visible in the magnified view.
|
||||
*/
|
||||
void Button_Show_grid(void);
|
||||
|
||||
// Mode trame (Sieve)
|
||||
|
||||
/*!
|
||||
@ -425,6 +430,17 @@ void Button_Tiling_mode(void);
|
||||
Displays the tiling setup menu.
|
||||
*/
|
||||
void Button_Tiling_menu(void);
|
||||
|
||||
/*!
|
||||
Callback for the command that turns off all drawaing effects.
|
||||
*/
|
||||
void Effects_off(void);
|
||||
|
||||
/*!
|
||||
Command that sets the transparency level.
|
||||
*/
|
||||
void Transparency_set(byte amount);
|
||||
|
||||
// Menu des effets
|
||||
|
||||
/*!
|
||||
@ -568,6 +584,11 @@ void Button_Autosave(void);
|
||||
*/
|
||||
void Button_Settings(void);
|
||||
|
||||
/*!
|
||||
Display the skin selector window.
|
||||
*/
|
||||
void Button_Skins(void);
|
||||
|
||||
// Annulation de la dernière modification
|
||||
|
||||
/*!
|
||||
@ -621,7 +642,7 @@ 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);
|
||||
void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_cancel, const char *help_section, word close_shortcut );
|
||||
|
||||
|
||||
/*!
|
||||
@ -635,5 +656,7 @@ void Button_Smooth_menu(void);
|
||||
*/
|
||||
void Button_Smear_mode(void);
|
||||
|
||||
void Button_Brush_container(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
56
const.h
@ -33,7 +33,7 @@
|
||||
#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 134 ///< Number of actions that can have a key combination associated to it.
|
||||
#define NB_SHORTCUTS 159 ///< Number of actions that can have a key combination associated to it.
|
||||
#define NB_ZOOM_FACTORS 12 ///< 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.
|
||||
@ -58,13 +58,18 @@
|
||||
#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
|
||||
// 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
|
||||
// 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 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.
|
||||
@ -90,14 +95,14 @@
|
||||
// -- File formats
|
||||
|
||||
#ifndef __no_pnglib__
|
||||
#define NB_KNOWN_FORMATS 13 ///< Total number of known file formats.
|
||||
#define NB_FORMATS_LOAD 13 ///< Number of file formats that grafx2 can load.
|
||||
#define NB_FORMATS_SAVE 13 ///< Number of file formats that grafx2 can save.
|
||||
#define NB_KNOWN_FORMATS 15 ///< Total number of known file formats.
|
||||
#define NB_FORMATS_LOAD 15 ///< Number of file formats that grafx2 can load.
|
||||
#define NB_FORMATS_SAVE 15 ///< Number of file formats that grafx2 can save.
|
||||
#else
|
||||
// Without pnglib
|
||||
#define NB_KNOWN_FORMATS 12 ///< Total number of known file formats.
|
||||
#define NB_FORMATS_LOAD 12 ///< Number of file formats that grafx2 can load.
|
||||
#define NB_FORMATS_SAVE 12 ///< Number of file formats that grafx2 can save.
|
||||
#define NB_KNOWN_FORMATS 14 ///< Total number of known file formats.
|
||||
#define NB_FORMATS_LOAD 14 ///< Number of file formats that grafx2 can load.
|
||||
#define NB_FORMATS_SAVE 14 ///< Number of file formats that grafx2 can save.
|
||||
#endif
|
||||
|
||||
/// List of file formats recognized by grafx2
|
||||
@ -114,8 +119,10 @@ enum FILE_FORMATS
|
||||
FORMAT_PI1,
|
||||
FORMAT_PC1,
|
||||
FORMAT_CEL,
|
||||
FORMAT_NEO,
|
||||
FORMAT_KCF,
|
||||
FORMAT_PAL,
|
||||
FORMAT_C64,
|
||||
FORMAT_PNG
|
||||
};
|
||||
|
||||
@ -209,7 +216,8 @@ enum PAINTBRUSH_SHAPES
|
||||
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_MONO_BRUSH, ///< User's brush, in mono mode
|
||||
PAINTBRUSH_SHAPE_MAX ///< Upper limit.
|
||||
};
|
||||
|
||||
/// Normal resting state for a menu button.
|
||||
@ -241,7 +249,7 @@ enum CHUNKS_CFG
|
||||
CHUNK_MAX
|
||||
};
|
||||
|
||||
/// Identifiers for the 8x8 icons of ::GFX_icon_sprite (these are unused now)
|
||||
/// Identifiers for the 8x8 icons of ::Gfx->Icon_sprite (most are unused now)
|
||||
enum ICON_TYPES
|
||||
{
|
||||
ICON_FLOPPY_3_5=0, ///< 3½" Floppy disk
|
||||
@ -271,7 +279,6 @@ enum BUTTON_NUMBERS
|
||||
BUTTON_CIRCLES,
|
||||
BUTTON_FILLCIRC,
|
||||
BUTTON_GRADRECT,
|
||||
BUTTON_GRADMENU,
|
||||
BUTTON_SPHERES,
|
||||
BUTTON_BRUSH,
|
||||
BUTTON_POLYBRUSH,
|
||||
@ -374,8 +381,33 @@ enum SPECIAL_ACTIONS
|
||||
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,
|
||||
NB_SPECIAL_SHORTCUTS ///< Number of special shortcuts
|
||||
};
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ executable; You can normally find it in a packed archive whose name begins by
|
||||
the Subversion repository:
|
||||
http://grafx2.googlecode.com/svn/trunk/
|
||||
or you can find the latest versions as packed archives:
|
||||
http://code.google.com/p/grafx2/downloads/list
|
||||
http://code.google.com/p/grafx2/wiki/Downloads
|
||||
|
||||
=== COMPILING ===
|
||||
|
||||
@ -76,17 +76,18 @@ Sends greetings and glops to pouet.net : http://pouet.net/prod.php?which=51865
|
||||
=== HISTORY ===
|
||||
|
||||
Short revision history :
|
||||
* 06/2009 2.0 Completed the features planned by Sunset Design.
|
||||
* 04/2009 2.0b99.0% Many new features and critical fixes.
|
||||
* 01/2009 2.0b98.0% Now running Linux, Windows, Mac OS X, BeOS, Haiku,
|
||||
AmigaOS 3.x and 4, MorphOS, SkyOS and gp2x.
|
||||
* 10/2008 2.0b97.0% Our first public beta release.
|
||||
* 07/2008 Our first public alpha release, Windows and Linux only
|
||||
* 04/2007 Start of this project and port to SDL.
|
||||
* 2001 Sunset Design releases the source under the GNU GPL.
|
||||
* 12/1999 2.0b96.5% Last release from Sunset Design.
|
||||
* 11/1996 2.0b90% First public release, at the Wired'96.
|
||||
* 09/1995 Project starts.
|
||||
* 09/2009 2.1 GUI improvements and some new features.
|
||||
* 06/2009 2.0 Completed the features planned by Sunset Design.
|
||||
* 04/2009 2.0b99.0% Many new features and critical fixes.
|
||||
* 01/2009 2.0b98.0% Now running Linux, Windows, Mac OS X, BeOS, Haiku,
|
||||
AmigaOS 3.x and 4, MorphOS, SkyOS and gp2x.
|
||||
* 10/2008 2.0b97.0% Our first public beta release.
|
||||
* 07/2008 Our first public alpha release, Windows and Linux only
|
||||
* 04/2007 Start of this project and port to SDL.
|
||||
* 2001 Sunset Design releases the source under the GNU GPL.
|
||||
* 12/1999 2.0b96.5% Last release from Sunset Design.
|
||||
* 11/1996 2.0b90% First public release, at the Wired'96.
|
||||
* 09/1995 Project starts.
|
||||
|
||||
Check http://code.google.com/p/grafx2/source/list for (very) detailed changelog.
|
||||
Check http://code.google.com/p/grafx2/wiki/History for an overview of the new
|
||||
|
||||
716
engine.c
@ -75,8 +75,7 @@ char * Menu_tooltip[NB_BUTTONS]=
|
||||
"Filled rectangles ",
|
||||
"Empty circles / ellipses",
|
||||
"Filled circles / ellips.",
|
||||
"Grad. rectangles ",
|
||||
"Gradation menu ",
|
||||
"Grad. rect / Grad. menu ",
|
||||
"Grad. spheres / ellipses",
|
||||
"Brush grab. / Restore ",
|
||||
"Lasso / Restore brush ",
|
||||
@ -89,13 +88,13 @@ char * Menu_tooltip[NB_BUTTONS]=
|
||||
"Go / Copy to other page ",
|
||||
"Save as / Save ",
|
||||
"Load / Re-load ",
|
||||
"Settings ",
|
||||
"Settings / Skins ",
|
||||
"Clear / with backcolor ",
|
||||
"Help / Statistics ",
|
||||
"Undo / Redo ",
|
||||
"Kill current page ",
|
||||
"Quit ",
|
||||
"Palette editor ",
|
||||
"Palette editor / setup ",
|
||||
"Scroll pal. bkwd / Fast ",
|
||||
"Scroll pal. fwd / Fast ",
|
||||
"Color #" ,
|
||||
@ -108,6 +107,7 @@ void Save_background(byte **buffer, int x_pos, int y_pos, int width, int height)
|
||||
int index;
|
||||
if(*buffer != NULL) DEBUG("WARNING : buffer already allocated !!!",0);
|
||||
*buffer=(byte *) malloc(width*Menu_factor_X*height*Menu_factor_Y*Pixel_width);
|
||||
if(*buffer==NULL) Error(0);
|
||||
for (index=0; index<(height*Menu_factor_Y); index++)
|
||||
Read_line(x_pos,y_pos+index,width*Menu_factor_X,(*buffer)+((int)index*width*Menu_factor_X*Pixel_width));
|
||||
}
|
||||
@ -119,6 +119,7 @@ void Restore_background(byte *buffer, int x_pos, int y_pos, int width, int heigh
|
||||
for (index=0; index<height*Menu_factor_Y; index++)
|
||||
Display_line_fast(x_pos,y_pos+index,width*Menu_factor_X,buffer+((int)index*width*Menu_factor_X*Pixel_width));
|
||||
free(buffer);
|
||||
buffer = NULL;
|
||||
}
|
||||
|
||||
///Draw a pixel in a saved screen block (when you sort colors in the palette, for example)
|
||||
@ -211,74 +212,74 @@ void Draw_menu_button_frame(byte btn_number,byte pressed)
|
||||
case BUTTON_SHAPE_RECTANGLE :
|
||||
// On colorie le point haut droit
|
||||
Pixel_in_menu(end_x,start_y,color_diagonal);
|
||||
GFX_menu_block[start_y][end_x]=color_diagonal;
|
||||
Gfx->Menu_block[start_y][end_x]=color_diagonal;
|
||||
// On colorie le point bas gauche
|
||||
Pixel_in_menu(start_x,end_y,color_diagonal);
|
||||
GFX_menu_block[end_y][start_x]=color_diagonal;
|
||||
Gfx->Menu_block[end_y][start_x]=color_diagonal;
|
||||
// On colorie la partie haute
|
||||
for (x_pos=start_x;x_pos<=end_x-1;x_pos++)
|
||||
{
|
||||
Pixel_in_menu(x_pos,start_y,color_top_left);
|
||||
GFX_menu_block[start_y][x_pos]=color_top_left;
|
||||
Gfx->Menu_block[start_y][x_pos]=color_top_left;
|
||||
}
|
||||
for (y_pos=start_y+1;y_pos<=end_y-1;y_pos++)
|
||||
{
|
||||
// On colorie la partie gauche
|
||||
Pixel_in_menu(start_x,y_pos,color_top_left);
|
||||
GFX_menu_block[y_pos][start_x]=color_top_left;
|
||||
Gfx->Menu_block[y_pos][start_x]=color_top_left;
|
||||
// On colorie la partie droite
|
||||
Pixel_in_menu(end_x,y_pos,color_bottom_right);
|
||||
GFX_menu_block[y_pos][end_x]=color_bottom_right;
|
||||
Gfx->Menu_block[y_pos][end_x]=color_bottom_right;
|
||||
}
|
||||
// On colorie la partie basse
|
||||
for (x_pos=start_x+1;x_pos<=end_x;x_pos++)
|
||||
{
|
||||
Pixel_in_menu(x_pos,end_y,color_bottom_right);
|
||||
GFX_menu_block[end_y][x_pos]=color_bottom_right;
|
||||
Gfx->Menu_block[end_y][x_pos]=color_bottom_right;
|
||||
}
|
||||
break;
|
||||
case BUTTON_SHAPE_TRIANGLE_TOP_LEFT:
|
||||
// On colorie le point haut droit
|
||||
Pixel_in_menu(end_x,start_y,color_diagonal);
|
||||
GFX_menu_block[start_y][end_x]=color_diagonal;
|
||||
Gfx->Menu_block[start_y][end_x]=color_diagonal;
|
||||
// On colorie le point bas gauche
|
||||
Pixel_in_menu(start_x,end_y,color_diagonal);
|
||||
GFX_menu_block[end_y][start_x]=color_diagonal;
|
||||
Gfx->Menu_block[end_y][start_x]=color_diagonal;
|
||||
// On colorie le coin haut gauche
|
||||
for (x_pos=0;x_pos<Buttons_Pool[btn_number].Width;x_pos++)
|
||||
{
|
||||
Pixel_in_menu(start_x+x_pos,start_y,color_top_left);
|
||||
GFX_menu_block[start_y][start_x+x_pos]=color_top_left;
|
||||
Gfx->Menu_block[start_y][start_x+x_pos]=color_top_left;
|
||||
Pixel_in_menu(start_x,start_y+x_pos,color_top_left);
|
||||
GFX_menu_block[start_y+x_pos][start_x]=color_top_left;
|
||||
Gfx->Menu_block[start_y+x_pos][start_x]=color_top_left;
|
||||
}
|
||||
// On colorie la diagonale
|
||||
for (x_pos=1;x_pos<Buttons_Pool[btn_number].Width;x_pos++)
|
||||
{
|
||||
Pixel_in_menu(start_x+x_pos,end_y-x_pos,color_bottom_right);
|
||||
GFX_menu_block[end_y-x_pos][start_x+x_pos]=color_bottom_right;
|
||||
Gfx->Menu_block[end_y-x_pos][start_x+x_pos]=color_bottom_right;
|
||||
}
|
||||
break;
|
||||
case BUTTON_SHAPE_TRIANGLE_BOTTOM_RIGHT:
|
||||
// On colorie le point haut droit
|
||||
Pixel_in_menu(end_x,start_y,color_diagonal);
|
||||
GFX_menu_block[start_y][end_x]=color_diagonal;
|
||||
Gfx->Menu_block[start_y][end_x]=color_diagonal;
|
||||
// On colorie le point bas gauche
|
||||
Pixel_in_menu(start_x,end_y,color_diagonal);
|
||||
GFX_menu_block[end_y][start_x]=color_diagonal;
|
||||
Gfx->Menu_block[end_y][start_x]=color_diagonal;
|
||||
// On colorie la diagonale
|
||||
for (x_pos=1;x_pos<Buttons_Pool[btn_number].Width;x_pos++)
|
||||
{
|
||||
Pixel_in_menu(start_x+x_pos,end_y-x_pos,color_top_left);
|
||||
GFX_menu_block[end_y-x_pos][start_x+x_pos]=color_top_left;
|
||||
Gfx->Menu_block[end_y-x_pos][start_x+x_pos]=color_top_left;
|
||||
}
|
||||
// On colorie le coin bas droite
|
||||
for (x_pos=0;x_pos<Buttons_Pool[btn_number].Width;x_pos++)
|
||||
{
|
||||
Pixel_in_menu(end_x-x_pos,end_y,color_bottom_right);
|
||||
GFX_menu_block[end_y][end_x-x_pos]=color_bottom_right;
|
||||
Gfx->Menu_block[end_y][end_x-x_pos]=color_bottom_right;
|
||||
Pixel_in_menu(end_x,end_y-x_pos,color_bottom_right);
|
||||
GFX_menu_block[end_y-x_pos][end_x]=color_bottom_right;
|
||||
Gfx->Menu_block[end_y-x_pos][end_x]=color_bottom_right;
|
||||
}
|
||||
}
|
||||
if (Menu_is_visible)
|
||||
@ -372,6 +373,9 @@ void Select_button(int btn_number,byte click)
|
||||
// the unselection of all "Tool" buttons.
|
||||
if (btn_number==BUTTON_ADJUST && click==RIGHT_SIDE)
|
||||
break;
|
||||
// Same case with the Grad. Rectangle button.
|
||||
if (btn_number==BUTTON_GRADRECT && click==RIGHT_SIDE)
|
||||
break;
|
||||
// Pour chaque bouton:
|
||||
for (b=0; b<NB_BUTTONS; b++)
|
||||
// S'il est de la même famille
|
||||
@ -774,7 +778,7 @@ void Main_handler(void)
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_EXCLUDE_COLORS_MENU : // Exclude colors menu
|
||||
Menu_tag_colors("Tag colors to exclude",Exclude_color,&temp,1, NULL);
|
||||
Menu_tag_colors("Tag colors to exclude",Exclude_color,&temp,1, NULL, SPECIAL_EXCLUDE_COLORS_MENU);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_INVERT_SIEVE :
|
||||
@ -821,6 +825,10 @@ void Main_handler(void)
|
||||
Button_Grid_menu();
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_SHOW_GRID :
|
||||
Button_Show_grid();
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_SIEVE_MODE :
|
||||
Button_Sieve_mode();
|
||||
Key=0;
|
||||
@ -857,6 +865,102 @@ void Main_handler(void)
|
||||
Button_Tiling_menu();
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_EFFECTS_OFF :
|
||||
Effects_off();
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_TRANSPARENCY_1 :
|
||||
Transparency_set(1);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_TRANSPARENCY_2 :
|
||||
Transparency_set(2);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_TRANSPARENCY_3 :
|
||||
Transparency_set(3);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_TRANSPARENCY_4 :
|
||||
Transparency_set(4);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_TRANSPARENCY_5 :
|
||||
Transparency_set(5);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_TRANSPARENCY_6 :
|
||||
Transparency_set(6);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_TRANSPARENCY_7 :
|
||||
Transparency_set(7);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_TRANSPARENCY_8 :
|
||||
Transparency_set(8);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_TRANSPARENCY_9 :
|
||||
Transparency_set(9);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_TRANSPARENCY_0 :
|
||||
Transparency_set(0);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_ZOOM_1 :
|
||||
Zoom_set(-1);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_ZOOM_2 :
|
||||
Zoom_set(0);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_ZOOM_3 :
|
||||
Zoom_set(1);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_ZOOM_4 :
|
||||
Zoom_set(2);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_ZOOM_5 :
|
||||
Zoom_set(3);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_ZOOM_6 :
|
||||
Zoom_set(4);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_ZOOM_8 :
|
||||
Zoom_set(5);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_ZOOM_10 :
|
||||
Zoom_set(6);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_ZOOM_12 :
|
||||
Zoom_set(7);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_ZOOM_14 :
|
||||
Zoom_set(8);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_ZOOM_16 :
|
||||
Zoom_set(9);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_ZOOM_18 :
|
||||
Zoom_set(10);
|
||||
Key=0;
|
||||
break;
|
||||
case SPECIAL_ZOOM_20 :
|
||||
Zoom_set(11);
|
||||
Key=0;
|
||||
break;
|
||||
default : // Gestion des touches de raccourci de bouton:
|
||||
// Pour chaque bouton
|
||||
shortcut_button=-1;
|
||||
@ -1132,6 +1236,7 @@ void Close_window(void)
|
||||
T_Scroller_button * temp3;
|
||||
T_Special_button * temp4;
|
||||
T_Dropdown_button * temp5;
|
||||
T_List_button * temp6;
|
||||
|
||||
Hide_cursor();
|
||||
|
||||
@ -1166,6 +1271,12 @@ void Close_window(void)
|
||||
free(Window_dropdown_button_list);
|
||||
Window_dropdown_button_list=temp5;
|
||||
}
|
||||
while (Window_list_button_list)
|
||||
{
|
||||
temp6=Window_list_button_list->Next;
|
||||
free(Window_list_button_list);
|
||||
Window_list_button_list=temp6;
|
||||
}
|
||||
|
||||
if (Windows_open != 1)
|
||||
{
|
||||
@ -1613,6 +1724,42 @@ void Window_dropdown_clear_items(T_Dropdown_button * dropdown)
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------- Create a List control -----------------------
|
||||
// These controls are special. They work over two controls previously created:
|
||||
// - entry_button is the textual area where the list values will be printed.
|
||||
// - scroller is a scroller button attached to it
|
||||
|
||||
T_List_button * Window_set_list_button(T_Special_button * entry_button, T_Scroller_button * scroller, Func_draw_list_item draw_list_item)
|
||||
{
|
||||
T_List_button *temp;
|
||||
|
||||
temp=(T_List_button *)malloc(sizeof(T_List_button));
|
||||
temp->Number =++Window_nb_buttons;
|
||||
temp->List_start = 0;
|
||||
temp->Cursor_position = 0;
|
||||
temp->Entry_button = entry_button;
|
||||
temp->Scroller = scroller;
|
||||
temp->Draw_list_item = draw_list_item;
|
||||
|
||||
temp->Next=Window_list_button_list;
|
||||
Window_list_button_list=temp;
|
||||
return temp;
|
||||
}
|
||||
|
||||
void Window_redraw_list(T_List_button * list)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=Min(list->Scroller->Nb_visibles-1, list->Scroller->Nb_elements-1); i>=0; i--)
|
||||
{
|
||||
list->Draw_list_item(
|
||||
list->Entry_button->Pos_X,
|
||||
list->Entry_button->Pos_Y + i * 8,
|
||||
list->List_start + i,
|
||||
i == list->Cursor_position);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------- Ouverture d'un pop-up -----------------------
|
||||
|
||||
void Open_popup(word x_pos, word y_pos, word width,word height)
|
||||
@ -1676,7 +1823,8 @@ void Close_popup(void)
|
||||
T_Palette_button * temp2;
|
||||
T_Scroller_button * temp3;
|
||||
T_Special_button * temp4;
|
||||
T_Dropdown_button * temp5;
|
||||
T_Dropdown_button * temp5;
|
||||
T_List_button * temp6;
|
||||
|
||||
Hide_cursor();
|
||||
|
||||
@ -1711,7 +1859,13 @@ void Close_popup(void)
|
||||
free(Window_dropdown_button_list);
|
||||
Window_dropdown_button_list=temp5;
|
||||
}
|
||||
|
||||
while (Window_list_button_list)
|
||||
{
|
||||
temp6=Window_list_button_list->Next;
|
||||
free(Window_list_button_list);
|
||||
Window_list_button_list=temp6;
|
||||
}
|
||||
|
||||
if (Windows_open != 1)
|
||||
{
|
||||
// Restore de ce que la fenêtre cachait
|
||||
@ -1843,6 +1997,7 @@ void Get_color_behind_window(byte * color, byte * click)
|
||||
char str[25];
|
||||
byte cursor_was_hidden;
|
||||
|
||||
|
||||
Hide_cursor();
|
||||
|
||||
cursor_was_hidden=Cursor_hidden;
|
||||
@ -1933,15 +2088,15 @@ void Move_window(short dx, short dy)
|
||||
{
|
||||
short new_x=Mouse_X-dx;
|
||||
short new_y=Mouse_Y-dy;
|
||||
short old_x;
|
||||
short old_y;
|
||||
short width=Window_width*Menu_factor_X;
|
||||
short height=Window_height*Menu_factor_Y;
|
||||
short a;
|
||||
byte b;
|
||||
byte *buffer=NULL;
|
||||
short old_x;
|
||||
short old_y;
|
||||
short width=Window_width*Menu_factor_X;
|
||||
short height=Window_height*Menu_factor_Y;
|
||||
short a;
|
||||
byte b;
|
||||
byte *buffer=NULL;
|
||||
|
||||
Hide_cursor();
|
||||
Hide_cursor();
|
||||
|
||||
Horizontal_XOR_line(new_x,new_y,width);
|
||||
Vertical_XOR_line(new_x,new_y+1,height-2);
|
||||
@ -2179,8 +2334,11 @@ short Window_dropdown_on_click(T_Dropdown_button *Button)
|
||||
Window_attribute2=item->Number;
|
||||
if (Button->Display_choice)
|
||||
{
|
||||
// Mettre à jour automatiquement le libellé de la dropdown
|
||||
Print_in_window(Button->Pos_X+2,Button->Pos_Y+(Button->Height-7)/2,item->Label,MC_Black,MC_Light);
|
||||
// Automatically update the label of the dropdown list.
|
||||
int text_length = (Button->Width-4-(Button->Display_arrow?8:0))/8;
|
||||
// Clear original label area
|
||||
Window_rectangle(Button->Pos_X+2,Button->Pos_Y+(Button->Height-7)/2,text_length*8,8,MC_Light);
|
||||
Print_in_window_limited(Button->Pos_X+2,Button->Pos_Y+(Button->Height-7)/2,item->Label,text_length ,MC_Black,MC_Light);
|
||||
}
|
||||
return Button->Number;
|
||||
}
|
||||
@ -2221,7 +2379,7 @@ short Window_normal_button_onclick(word x_pos, word y_pos, word width, word heig
|
||||
}
|
||||
}
|
||||
|
||||
// --- Renvoie le numéro du bouton clicke (-1:hors de la fenêtre, 0:aucun) ---
|
||||
// --- Returns the number of the clicked button (-1:out of the window, 0:none) ---
|
||||
short Window_get_clicked_button(void)
|
||||
{
|
||||
T_Normal_button * temp1;
|
||||
@ -2234,11 +2392,13 @@ short Window_get_clicked_button(void)
|
||||
|
||||
Window_attribute1=Mouse_K;
|
||||
|
||||
// Test du click sur les boutons normaux
|
||||
// Test click on normal buttons
|
||||
for (temp1=Window_normal_button_list; temp1; temp1=temp1->Next)
|
||||
{
|
||||
if (Window_click_in_rectangle(temp1->Pos_X,temp1->Pos_Y,temp1->Pos_X+temp1->Width-1,temp1->Pos_Y+temp1->Height-1))
|
||||
if ((Input_sticky_control == 0 || Input_sticky_control == temp1->Number)
|
||||
&& Window_click_in_rectangle(temp1->Pos_X,temp1->Pos_Y,temp1->Pos_X+temp1->Width-1,temp1->Pos_Y+temp1->Height-1))
|
||||
{
|
||||
Input_sticky_control = temp1->Number;
|
||||
if (temp1->Repeatable)
|
||||
{
|
||||
Hide_cursor();
|
||||
@ -2254,135 +2414,145 @@ short Window_get_clicked_button(void)
|
||||
}
|
||||
}
|
||||
|
||||
// Test du click sur les zones "palette"
|
||||
// Test click on "Palette" buttons
|
||||
for (temp2=Window_palette_button_list; temp2; temp2=temp2->Next)
|
||||
{
|
||||
if (Window_click_in_rectangle(temp2->Pos_X+5,temp2->Pos_Y+3,temp2->Pos_X+160,temp2->Pos_Y+82))
|
||||
if ((Input_sticky_control == 0 || Input_sticky_control == temp2->Number)
|
||||
&& Window_click_in_rectangle(temp2->Pos_X+5,temp2->Pos_Y+3,temp2->Pos_X+160,temp2->Pos_Y+82))
|
||||
{
|
||||
// On stocke dans Attribut2 le numero de couleur cliqué
|
||||
Input_sticky_control = temp2->Number;
|
||||
// We store the clicked color in Attribute2
|
||||
Window_attribute2 = (((Mouse_X-Window_pos_X)/Menu_factor_X)-(temp2->Pos_X+2)) / 10 * 16 +
|
||||
(((Mouse_Y-Window_pos_Y)/Menu_factor_Y)-(temp2->Pos_Y+3)) / 5;
|
||||
return temp2->Number;
|
||||
}
|
||||
}
|
||||
|
||||
// Test du click sur les barres de défilement
|
||||
// Test click oin slider/scroller bars
|
||||
for (temp3=Window_scroller_button_list; temp3; temp3=temp3->Next)
|
||||
{
|
||||
if (Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-1))
|
||||
// Button Up arrow
|
||||
if ((Input_sticky_control == 0 || Input_sticky_control == (temp3->Number|1024))
|
||||
&& Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y,temp3->Pos_X+10,temp3->Pos_Y+10))
|
||||
{
|
||||
// Button flèche Haut
|
||||
if (Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y,temp3->Pos_X+10,temp3->Pos_Y+10))
|
||||
Input_sticky_control = temp3->Number | 1024;
|
||||
Hide_cursor();
|
||||
Window_select_normal_button(temp3->Pos_X,temp3->Pos_Y,11,11);
|
||||
|
||||
if (temp3->Position)
|
||||
{
|
||||
Hide_cursor();
|
||||
Window_select_normal_button(temp3->Pos_X,temp3->Pos_Y,11,11);
|
||||
|
||||
if (temp3->Position)
|
||||
{
|
||||
temp3->Position--;
|
||||
Window_attribute1=1;
|
||||
Window_attribute2=temp3->Position;
|
||||
Window_draw_slider(temp3);
|
||||
}
|
||||
else
|
||||
Window_attribute1=0;
|
||||
|
||||
Display_cursor();
|
||||
|
||||
Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
|
||||
|
||||
Hide_cursor();
|
||||
Window_unselect_normal_button(temp3->Pos_X,temp3->Pos_Y,11,11);
|
||||
Display_cursor();
|
||||
temp3->Position--;
|
||||
Window_attribute1=1;
|
||||
Window_attribute2=temp3->Position;
|
||||
Window_draw_slider(temp3);
|
||||
}
|
||||
else
|
||||
// Button flèche Bas
|
||||
if (Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-1))
|
||||
Window_attribute1=0;
|
||||
|
||||
Display_cursor();
|
||||
|
||||
Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
|
||||
|
||||
Hide_cursor();
|
||||
Window_unselect_normal_button(temp3->Pos_X,temp3->Pos_Y,11,11);
|
||||
Display_cursor();
|
||||
|
||||
return (Window_attribute1)? temp3->Number : 0;
|
||||
}
|
||||
|
||||
// Button Down arrow
|
||||
if ((Input_sticky_control == 0 || Input_sticky_control == (temp3->Number|2048))
|
||||
&& Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-1))
|
||||
{
|
||||
Input_sticky_control = temp3->Number | 2048;
|
||||
Hide_cursor();
|
||||
Window_select_normal_button(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,11,11);
|
||||
|
||||
if (temp3->Position+temp3->Nb_visibles<temp3->Nb_elements)
|
||||
{
|
||||
Hide_cursor();
|
||||
Window_select_normal_button(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,11,11);
|
||||
|
||||
if (temp3->Position+temp3->Nb_visibles<temp3->Nb_elements)
|
||||
{
|
||||
temp3->Position++;
|
||||
Window_attribute1=2;
|
||||
Window_attribute2=temp3->Position;
|
||||
Window_draw_slider(temp3);
|
||||
}
|
||||
else
|
||||
Window_attribute1=0;
|
||||
|
||||
Display_cursor();
|
||||
|
||||
Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
|
||||
|
||||
Hide_cursor();
|
||||
Window_unselect_normal_button(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,11,11);
|
||||
Display_cursor();
|
||||
temp3->Position++;
|
||||
Window_attribute1=2;
|
||||
Window_attribute2=temp3->Position;
|
||||
Window_draw_slider(temp3);
|
||||
}
|
||||
else
|
||||
// Jauge
|
||||
if (Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y+12,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-13))
|
||||
{
|
||||
if (temp3->Nb_elements>temp3->Nb_visibles)
|
||||
{
|
||||
// S'il y a la place de faire scroller le curseur:
|
||||
|
||||
max_slider_height=(temp3->Height-24);
|
||||
|
||||
// Window_attribute2 reçoit la position dans la jauge correspondant au click
|
||||
Window_attribute2 =(Mouse_Y-Window_pos_Y) / Menu_factor_Y;
|
||||
Window_attribute2-=(temp3->Pos_Y+12+((temp3->Cursor_height-1)>>1));
|
||||
Window_attribute2*=(temp3->Nb_elements-temp3->Nb_visibles);
|
||||
|
||||
if (Window_attribute2<0)
|
||||
Window_attribute2=0;
|
||||
else
|
||||
{
|
||||
Window_attribute2 =Round_div(Window_attribute2,max_slider_height-temp3->Cursor_height);
|
||||
if (Window_attribute2+temp3->Nb_visibles>temp3->Nb_elements)
|
||||
Window_attribute2=temp3->Nb_elements-temp3->Nb_visibles;
|
||||
}
|
||||
|
||||
// Si le curseur de la jauge bouge:
|
||||
|
||||
if (temp3->Position!=Window_attribute2)
|
||||
{
|
||||
temp3->Position=Window_attribute2;
|
||||
Window_attribute1=3;
|
||||
Hide_cursor();
|
||||
Window_draw_slider(temp3);
|
||||
Display_cursor();
|
||||
}
|
||||
else
|
||||
// Si le curseur de la jauge ne bouge pas:
|
||||
Window_attribute1=0;
|
||||
}
|
||||
else
|
||||
// S'il n'y a pas la place de bouger le curseur de la jauge:
|
||||
Window_attribute1=0;
|
||||
}
|
||||
else
|
||||
// Le click se situe dans la zone de la jauge mais n'est sur aucune
|
||||
// des 3 parties importantes de la jauge
|
||||
Window_attribute1=0;
|
||||
|
||||
Display_cursor();
|
||||
|
||||
Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
|
||||
|
||||
Hide_cursor();
|
||||
Window_unselect_normal_button(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,11,11);
|
||||
Display_cursor();
|
||||
|
||||
return (Window_attribute1)? temp3->Number : 0;
|
||||
}
|
||||
// Middle slider
|
||||
if ((Input_sticky_control == temp3->Number) || (Input_sticky_control==0 &&
|
||||
Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y+12,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-13)))
|
||||
{
|
||||
Input_sticky_control = temp3->Number;
|
||||
if (temp3->Nb_elements>temp3->Nb_visibles)
|
||||
{
|
||||
// If there is enough room to make the cursor move:
|
||||
|
||||
max_slider_height=(temp3->Height-24);
|
||||
|
||||
// Window_attribute2 receives the position of the cursor.
|
||||
Window_attribute2 =(Mouse_Y-Window_pos_Y) / Menu_factor_Y;
|
||||
Window_attribute2-=(temp3->Pos_Y+12+((temp3->Cursor_height-1)>>1));
|
||||
Window_attribute2*=(temp3->Nb_elements-temp3->Nb_visibles);
|
||||
|
||||
if (Window_attribute2<0)
|
||||
Window_attribute2=0;
|
||||
else
|
||||
{
|
||||
Window_attribute2 =Round_div(Window_attribute2,max_slider_height-temp3->Cursor_height);
|
||||
if (Window_attribute2+temp3->Nb_visibles>temp3->Nb_elements)
|
||||
Window_attribute2=temp3->Nb_elements-temp3->Nb_visibles;
|
||||
}
|
||||
|
||||
// If the cursor moved
|
||||
|
||||
if (temp3->Position!=Window_attribute2)
|
||||
{
|
||||
temp3->Position=Window_attribute2;
|
||||
Window_attribute1=3;
|
||||
Hide_cursor();
|
||||
Window_draw_slider(temp3);
|
||||
Display_cursor();
|
||||
}
|
||||
else
|
||||
// If the cursor moved
|
||||
Window_attribute1=0;
|
||||
}
|
||||
else
|
||||
// If there's not enough room to make the cursor move:
|
||||
Window_attribute1=0;
|
||||
|
||||
return (Window_attribute1)? temp3->Number : 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Test du click sur une zone spéciale
|
||||
// Test click on a special button
|
||||
for (temp4=Window_special_button_list; temp4; temp4=temp4->Next)
|
||||
{
|
||||
if (Window_click_in_rectangle(temp4->Pos_X,temp4->Pos_Y,temp4->Pos_X+temp4->Width-1,temp4->Pos_Y+temp4->Height-1))
|
||||
return temp4->Number;
|
||||
if ((Input_sticky_control == 0 || Input_sticky_control == temp4->Number)
|
||||
&& Window_click_in_rectangle(temp4->Pos_X,temp4->Pos_Y,temp4->Pos_X+temp4->Width-1,temp4->Pos_Y+temp4->Height-1))
|
||||
{
|
||||
Input_sticky_control = temp4->Number;
|
||||
return temp4->Number;
|
||||
}
|
||||
}
|
||||
|
||||
// Test du click sur une dropdown
|
||||
// Test click on a dropdown box
|
||||
for (temp5=Window_dropdown_button_list; temp5; temp5=temp5->Next)
|
||||
{
|
||||
if (Window_click_in_rectangle(temp5->Pos_X,temp5->Pos_Y,temp5->Pos_X+temp5->Width-1,temp5->Pos_Y+temp5->Height-1))
|
||||
if ((Input_sticky_control == 0 || Input_sticky_control == temp5->Number)
|
||||
&& Window_click_in_rectangle(temp5->Pos_X,temp5->Pos_Y,temp5->Pos_X+temp5->Width-1,temp5->Pos_Y+temp5->Height-1))
|
||||
{
|
||||
Input_sticky_control = temp5->Number;
|
||||
if (Mouse_K & temp5->Active_button)
|
||||
return Window_dropdown_on_click(temp5);
|
||||
else
|
||||
@ -2440,7 +2610,25 @@ short Window_get_button_shortcut(void)
|
||||
temp=temp->Next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handle arrow keys, end/home, and mouse wheel that have
|
||||
// a certain behavior if a list control is present.
|
||||
if (Window_list_button_list)
|
||||
{
|
||||
T_List_button *list = Window_list_button_list;
|
||||
// If there's more than one of such control, only capture
|
||||
// events if the mouse cursor is over it.
|
||||
if (list->Next)
|
||||
{
|
||||
// to do
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2450,31 +2638,275 @@ short Window_clicked_button(void)
|
||||
|
||||
if(!Get_input())SDL_Delay(20);
|
||||
|
||||
// Gestion des clicks
|
||||
// Handle clicks
|
||||
if (Mouse_K)
|
||||
{
|
||||
if ((Mouse_X<Window_pos_X) || (Mouse_Y<Window_pos_Y)
|
||||
|| (Mouse_X>=Window_pos_X+(Window_width*Menu_factor_X))
|
||||
|| (Mouse_Y>=Window_pos_Y+(Window_height*Menu_factor_Y)))
|
||||
return -1;
|
||||
{
|
||||
if (Input_sticky_control == 0 || Input_sticky_control == -1)
|
||||
{
|
||||
Input_sticky_control = -1;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Input_sticky_control && Mouse_Y < Window_pos_Y+(12*Menu_factor_Y))
|
||||
{
|
||||
Move_window(Mouse_X-Window_pos_X,Mouse_Y-Window_pos_Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Mouse_Y < Window_pos_Y+(12*Menu_factor_Y))
|
||||
Move_window(Mouse_X-Window_pos_X,Mouse_Y-Window_pos_Y);
|
||||
else
|
||||
return Window_get_clicked_button();
|
||||
short clicked_button;
|
||||
T_List_button * list;
|
||||
|
||||
// Check which controls was clicked (by rectangular area)
|
||||
clicked_button = Window_get_clicked_button();
|
||||
|
||||
// Check if it's part of a list control
|
||||
for (list=Window_list_button_list; list!=NULL; list=list->Next)
|
||||
{
|
||||
if (list->Entry_button->Number == clicked_button)
|
||||
{
|
||||
// Click in the textual part of a list.
|
||||
short clicked_line;
|
||||
clicked_line = (((Mouse_Y-Window_pos_Y)/Menu_factor_Y)-list->Entry_button->Pos_Y)>>3;
|
||||
if (clicked_line == list->Cursor_position || // Same as before
|
||||
clicked_line >= list->Scroller->Nb_elements) // Below last line
|
||||
return 0;
|
||||
|
||||
Hide_cursor();
|
||||
// Redraw one item as disabled
|
||||
if (list->Cursor_position>=0 && list->Cursor_position<list->Scroller->Nb_visibles)
|
||||
list->Draw_list_item(
|
||||
list->Entry_button->Pos_X,
|
||||
list->Entry_button->Pos_Y + list->Cursor_position * 8,
|
||||
list->List_start + list->Cursor_position,
|
||||
0);
|
||||
list->Cursor_position = clicked_line;
|
||||
// Redraw one item as enabled
|
||||
if (list->Cursor_position>=0 && list->Cursor_position<list->Scroller->Nb_visibles)
|
||||
list->Draw_list_item(
|
||||
list->Entry_button->Pos_X,
|
||||
list->Entry_button->Pos_Y + list->Cursor_position * 8,
|
||||
list->List_start + list->Cursor_position,
|
||||
1);
|
||||
Display_cursor();
|
||||
|
||||
// Store the selected value as attribute2
|
||||
Window_attribute2=list->List_start + list->Cursor_position;
|
||||
// Return the control ID of the list.
|
||||
return list->Number;
|
||||
}
|
||||
else if (list->Scroller->Number == clicked_button)
|
||||
{
|
||||
// Click in the scroller part of a list
|
||||
if (list->List_start == list->Scroller->Position)
|
||||
return 0; // Didn't actually move
|
||||
// Update scroller indices
|
||||
list->Cursor_position += list->List_start;
|
||||
list->List_start = list->Scroller->Position;
|
||||
list->Cursor_position -= list->List_start;
|
||||
// Need to redraw all
|
||||
Hide_cursor();
|
||||
Window_redraw_list(list);
|
||||
Display_cursor();
|
||||
}
|
||||
}
|
||||
return clicked_button;
|
||||
}
|
||||
}
|
||||
|
||||
// Gestion des touches
|
||||
// Intercept keys
|
||||
if (Key)
|
||||
{
|
||||
T_List_button * list;
|
||||
|
||||
Button=Window_get_button_shortcut();
|
||||
if (Button)
|
||||
{
|
||||
Key=0;
|
||||
return Button;
|
||||
}
|
||||
// Check if there's a list control and the keys can control it
|
||||
for (list=Window_list_button_list; list!=NULL; list=list->Next)
|
||||
{
|
||||
// FIXME: Make only one list have the keyboard focus.
|
||||
if (1)
|
||||
{
|
||||
if (Key==SDLK_UP && (list->Cursor_position+list->List_start)>0)
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
list->Cursor_position--;
|
||||
if (list->Cursor_position<0)
|
||||
{
|
||||
list->List_start=list->List_start+list->Cursor_position;
|
||||
list->Cursor_position=0;
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
}
|
||||
Window_redraw_list(list);
|
||||
Display_cursor();
|
||||
// Store the selected value as attribute2
|
||||
Window_attribute2=list->List_start + list->Cursor_position;
|
||||
// Return the control ID of the list.
|
||||
return list->Number;
|
||||
}
|
||||
if (Key==SDLK_DOWN && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1))
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
list->Cursor_position++;
|
||||
if (list->Cursor_position>(list->Scroller->Nb_visibles-1))
|
||||
{
|
||||
list->List_start=list->List_start+list->Cursor_position-(list->Scroller->Nb_visibles-1);
|
||||
list->Cursor_position=(list->Scroller->Nb_visibles-1);
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
}
|
||||
Window_redraw_list(list);
|
||||
Display_cursor();
|
||||
// Store the selected value as attribute2
|
||||
Window_attribute2=list->List_start + list->Cursor_position;
|
||||
// Return the control ID of the list.
|
||||
return list->Number;
|
||||
}
|
||||
if (Key==SDLK_HOME && (list->Cursor_position!=0 || list->List_start!=0))
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
list->Cursor_position=0;
|
||||
list->List_start=0;
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
Window_redraw_list(list);
|
||||
Display_cursor();
|
||||
// Store the selected value as attribute2
|
||||
Window_attribute2=list->List_start + list->Cursor_position;
|
||||
// Return the control ID of the list.
|
||||
return list->Number;
|
||||
}
|
||||
if (Key==SDLK_END && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1))
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
list->Cursor_position=(list->Scroller->Nb_elements-1)-list->List_start;
|
||||
if (list->Cursor_position>(list->Scroller->Nb_visibles-1))
|
||||
{
|
||||
list->List_start=list->List_start+list->Cursor_position-(list->Scroller->Nb_visibles-1);
|
||||
list->Cursor_position=(list->Scroller->Nb_visibles-1);
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
}
|
||||
Window_redraw_list(list);
|
||||
Display_cursor();
|
||||
// Store the selected value as attribute2
|
||||
Window_attribute2=list->List_start + list->Cursor_position;
|
||||
// Return the control ID of the list.
|
||||
return list->Number;
|
||||
}
|
||||
if (Key==SDLK_PAGEDOWN && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1))
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
if (list->Scroller->Nb_elements<list->Scroller->Nb_visibles)
|
||||
{
|
||||
list->Cursor_position=list->Scroller->Nb_elements-1;
|
||||
}
|
||||
else if(list->Cursor_position!=list->Scroller->Nb_visibles-1)
|
||||
{
|
||||
list->Cursor_position=list->Scroller->Nb_visibles-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
list->List_start+=list->Scroller->Nb_visibles;
|
||||
if (list->List_start+list->Scroller->Nb_visibles>list->Scroller->Nb_elements)
|
||||
{
|
||||
list->List_start=list->Scroller->Nb_elements-list->Scroller->Nb_visibles;
|
||||
}
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
}
|
||||
Window_redraw_list(list);
|
||||
Display_cursor();
|
||||
// Store the selected value as attribute2
|
||||
Window_attribute2=list->List_start + list->Cursor_position;
|
||||
// Return the control ID of the list.
|
||||
return list->Number;
|
||||
}
|
||||
if (Key==SDLK_PAGEUP && (list->Cursor_position+list->List_start)>0)
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
if(list->Cursor_position!=0)
|
||||
{
|
||||
list->Cursor_position=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
list->List_start-=list->Scroller->Nb_visibles;
|
||||
if (list->List_start<0)
|
||||
{
|
||||
list->List_start=0;
|
||||
}
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
}
|
||||
Window_redraw_list(list);
|
||||
Display_cursor();
|
||||
// Store the selected value as attribute2
|
||||
Window_attribute2=list->List_start + list->Cursor_position;
|
||||
// Return the control ID of the list.
|
||||
return list->Number;
|
||||
}
|
||||
if (Key == KEY_MOUSEWHEELUP && list->List_start>0)
|
||||
{
|
||||
list->Cursor_position+=list->List_start;
|
||||
if (list->List_start>=3)
|
||||
list->List_start-=3;
|
||||
else
|
||||
list->List_start=0;
|
||||
list->Cursor_position-=list->List_start;
|
||||
// On affiche à nouveau la liste
|
||||
Hide_cursor();
|
||||
Window_redraw_list(list);
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
Display_cursor();
|
||||
}
|
||||
if (Key==KEY_MOUSEWHEELDOWN && list->List_start<list->Scroller->Nb_elements-list->Scroller->Nb_visibles)
|
||||
{
|
||||
list->Cursor_position+=list->List_start;
|
||||
list->List_start+=3;
|
||||
if (list->List_start+list->Scroller->Nb_visibles>list->Scroller->Nb_elements)
|
||||
{
|
||||
list->List_start=list->Scroller->Nb_elements-list->Scroller->Nb_visibles;
|
||||
}
|
||||
list->Cursor_position-=list->List_start;
|
||||
// On affiche à nouveau la liste
|
||||
Hide_cursor();
|
||||
Window_redraw_list(list);
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
174
engine.h
@ -1,80 +1,94 @@
|
||||
/* 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.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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, 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);
|
||||
void Window_dropdown_add_item(T_Dropdown_button * dropdown, word btn_number, const char *label);
|
||||
void Window_dropdown_clear_items(T_Dropdown_button * dropdown);
|
||||
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);
|
||||
/* 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, 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);
|
||||
void Window_dropdown_add_item(T_Dropdown_button * dropdown, word btn_number,
|
||||
const char *label);
|
||||
void Window_dropdown_clear_items(T_Dropdown_button * dropdown);
|
||||
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
|
||||
|
||||
346
filesel.c
@ -64,14 +64,58 @@
|
||||
#define SELECTED_DIRECTORY_COLOR MC_Light // color du texte pour une ligne de repértoire sélectionnée
|
||||
#define SELECTED_BACKGROUND_COLOR MC_Dark // color du fond pour une ligne sélectionnée
|
||||
|
||||
// -- Fileselector data
|
||||
|
||||
T_Fileselector Filelist;
|
||||
|
||||
// Conventions:
|
||||
//
|
||||
// * Le fileselect modifie le répertoire courant. Ceci permet de n'avoir
|
||||
// qu'un findfirst dans le répertoire courant à faire:
|
||||
|
||||
void Recount_files(T_Fileselector *list)
|
||||
{
|
||||
T_Fileselector_item *item;
|
||||
|
||||
list->Nb_files=0;
|
||||
list->Nb_directories=0;
|
||||
list->Nb_elements=0;
|
||||
|
||||
for (item = list->First; item != NULL; item = item->Next)
|
||||
{
|
||||
if (item->Type == 0)
|
||||
list->Nb_files ++;
|
||||
else
|
||||
list->Nb_directories ++;
|
||||
list->Nb_elements ++;
|
||||
}
|
||||
|
||||
if (list->Index)
|
||||
{
|
||||
free(list->Index);
|
||||
list->Index = NULL;
|
||||
}
|
||||
|
||||
if (list->Nb_elements>0)
|
||||
{
|
||||
int i;
|
||||
|
||||
list->Index = (T_Fileselector_item **) malloc(list->Nb_elements * sizeof(T_Fileselector_item **));
|
||||
if (list->Index)
|
||||
{
|
||||
// Fill the index
|
||||
for (item = list->First, i=0; item != NULL; item = item->Next, i++)
|
||||
{
|
||||
list->Index[i] = item;
|
||||
}
|
||||
}
|
||||
// If the malloc failed, we're probably in trouble, but I don't know
|
||||
// how to recover from that..I'll just make the index bulletproof.
|
||||
}
|
||||
}
|
||||
|
||||
// -- Déstruction de la liste chaînée ---------------------------------------
|
||||
void Free_fileselector_list(void)
|
||||
// -- Destruction de la liste chaînée ---------------------------------------
|
||||
void Free_fileselector_list(T_Fileselector *list)
|
||||
// Cette procédure détruit la chaine des fichiers. Elle doit être appelée
|
||||
// avant de rappeler la fonction Read_list_of_files, ainsi qu'en fin de
|
||||
// programme.
|
||||
@ -79,23 +123,19 @@ void Free_fileselector_list(void)
|
||||
// Pointeur temporaire de destruction
|
||||
T_Fileselector_item * temp_item;
|
||||
|
||||
while (Filelist!=NULL)
|
||||
while (list->First!=NULL)
|
||||
{
|
||||
// On mémorise l'adresse du premier élément de la liste
|
||||
temp_item =Filelist;
|
||||
temp_item =list->First;
|
||||
// On fait avancer la tête de la liste
|
||||
Filelist=Filelist->Next;
|
||||
list->First=list->First->Next;
|
||||
// Et on efface l'ancien premier élément de la liste
|
||||
free(temp_item);
|
||||
}
|
||||
Recount_files(list);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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(char * fname, int type)
|
||||
char * Format_filename(const char * fname, int type)
|
||||
{
|
||||
static char result[19];
|
||||
int c;
|
||||
@ -148,7 +188,7 @@ char * Format_filename(char * fname, int type)
|
||||
|
||||
|
||||
// -- Rajouter a la liste des elements de la liste un element ---------------
|
||||
void Add_element_to_list(char * fname, int type)
|
||||
void Add_element_to_list(T_Fileselector *list, const char * fname, int type)
|
||||
// Cette procedure ajoute a la liste chainee un fichier passé en argument.
|
||||
{
|
||||
// Pointeur temporaire d'insertion
|
||||
@ -162,12 +202,12 @@ void Add_element_to_list(char * fname, int type)
|
||||
strcpy(temp_item->Full_name,fname);
|
||||
temp_item->Type = type;
|
||||
|
||||
temp_item->Next =Filelist;
|
||||
temp_item->Next =list->First;
|
||||
temp_item->Previous=NULL;
|
||||
|
||||
if (Filelist!=NULL)
|
||||
Filelist->Previous=temp_item;
|
||||
Filelist=temp_item;
|
||||
if (list->First!=NULL)
|
||||
list->First->Previous=temp_item;
|
||||
list->First=temp_item;
|
||||
}
|
||||
|
||||
// -- Vérification si un fichier a l'extension demandée.
|
||||
@ -203,11 +243,11 @@ int Check_extension(const char *filename, char * filter)
|
||||
|
||||
|
||||
// -- Lecture d'une liste de fichiers ---------------------------------------
|
||||
void Read_list_of_files(byte selected_format)
|
||||
void Read_list_of_files(T_Fileselector *list, byte selected_format)
|
||||
// Cette procédure charge dans la liste chainée les fichiers dont l'extension
|
||||
// correspond au format demandé.
|
||||
{
|
||||
DIR* Repertoire_Courant; //Répertoire courant
|
||||
DIR* current_directory; //Répertoire courant
|
||||
struct dirent* entry; // Structure de lecture des éléments
|
||||
char * filter = "*"; // Extension demandée
|
||||
struct stat Infos_enreg;
|
||||
@ -218,15 +258,13 @@ void Read_list_of_files(byte selected_format)
|
||||
filter = File_formats[selected_format-1].Extension;
|
||||
|
||||
// Ensuite, on vide la liste actuelle:
|
||||
Free_fileselector_list();
|
||||
Free_fileselector_list(list);
|
||||
// Après effacement, il ne reste ni fichier ni répertoire dans la liste
|
||||
Filelist_nb_files=0;
|
||||
Filelist_nb_directories=0;
|
||||
|
||||
// On lit tous les répertoires:
|
||||
current_path=getcwd(NULL,0);
|
||||
Repertoire_Courant=opendir(current_path);
|
||||
while ((entry=readdir(Repertoire_Courant)))
|
||||
current_directory=opendir(current_path);
|
||||
while ((entry=readdir(current_directory)))
|
||||
{
|
||||
// On ignore le répertoire courant
|
||||
if ( !strcmp(entry->d_name, "."))
|
||||
@ -243,8 +281,8 @@ void Read_list_of_files(byte selected_format)
|
||||
!isHidden(entry)))
|
||||
{
|
||||
// On rajoute le répertoire à la liste
|
||||
Add_element_to_list(entry->d_name, 1);
|
||||
Filelist_nb_directories++;
|
||||
Add_element_to_list(list, entry->d_name, 1);
|
||||
list->Nb_directories++;
|
||||
}
|
||||
else if (S_ISREG(Infos_enreg.st_mode) && //Il s'agit d'un fichier
|
||||
(Config.Show_hidden_files || //Il n'est pas caché
|
||||
@ -253,21 +291,21 @@ void Read_list_of_files(byte selected_format)
|
||||
if (Check_extension(entry->d_name, filter))
|
||||
{
|
||||
// On rajoute le fichier à la liste
|
||||
Add_element_to_list(entry->d_name, 0);
|
||||
Filelist_nb_files++;
|
||||
Add_element_to_list(list, entry->d_name, 0);
|
||||
list->Nb_files++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__MORPHOS__) || defined(__AROS__) || defined (__amigaos4__) || defined(__amigaos__)
|
||||
Add_element_to_list("/",1); // on amiga systems, / means parent. And there is no ..
|
||||
Filelist_nb_directories ++;
|
||||
Add_element_to_list(list, "/",1); // on amiga systems, / means parent. And there is no ..
|
||||
list->Nb_directories ++;
|
||||
#endif
|
||||
|
||||
closedir(Repertoire_Courant);
|
||||
closedir(current_directory);
|
||||
free(current_path);
|
||||
|
||||
Filelist_nb_elements=Filelist_nb_directories+Filelist_nb_files;
|
||||
Recount_files(list);
|
||||
}
|
||||
|
||||
#if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
|
||||
@ -290,14 +328,14 @@ void bstrtostr( BSTR in, STRPTR out, TEXT max )
|
||||
#endif
|
||||
|
||||
// -- Lecture d'une liste de lecteurs / volumes -----------------------------
|
||||
void Read_list_of_drives(void)
|
||||
void Read_list_of_drives(T_Fileselector *list)
|
||||
{
|
||||
|
||||
// Empty the current content of fileselector:
|
||||
Free_fileselector_list();
|
||||
Free_fileselector_list(list);
|
||||
// Reset number of items
|
||||
Filelist_nb_files=0;
|
||||
Filelist_nb_directories=0;
|
||||
list->Nb_files=0;
|
||||
list->Nb_directories=0;
|
||||
|
||||
#if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
|
||||
{
|
||||
@ -311,8 +349,8 @@ void Read_list_of_drives(void)
|
||||
{
|
||||
bstrtostr( dl->dol_Name, tmp, 254 );
|
||||
strcat( tmp, ":" );
|
||||
Add_element_to_list( tmp, 2 );
|
||||
Filelist_nb_directories++;
|
||||
Add_element_to_list(list, tmp, 2 );
|
||||
list->Nb_directories++;
|
||||
}
|
||||
UnLockDosList( LDF_VOLUMES | LDF_READ );
|
||||
}
|
||||
@ -354,8 +392,8 @@ void Read_list_of_drives(void)
|
||||
break;
|
||||
}
|
||||
drive_name[0]='A'+bit_index;
|
||||
Add_element_to_list(drive_name,2);
|
||||
Filelist_nb_directories++;
|
||||
Add_element_to_list(list, drive_name,2);
|
||||
list->Nb_directories++;
|
||||
drive_index++;
|
||||
}
|
||||
}
|
||||
@ -368,7 +406,7 @@ void Read_list_of_drives(void)
|
||||
|
||||
// Ensuite on utilise read_file_system_list pour compléter
|
||||
|
||||
struct mount_entry* Liste_points_montage;
|
||||
struct mount_entry* mount_points_list;
|
||||
struct mount_entry* next;
|
||||
|
||||
#if defined(__BEOS__) || defined(__HAIKU__)
|
||||
@ -376,42 +414,42 @@ void Read_list_of_drives(void)
|
||||
#else
|
||||
char * home_dir = getenv("HOME");
|
||||
#endif
|
||||
Add_element_to_list("/", 2);
|
||||
Filelist_nb_directories++;
|
||||
Add_element_to_list(list, "/", 2);
|
||||
list->Nb_directories++;
|
||||
if(home_dir)
|
||||
{
|
||||
Add_element_to_list(home_dir, 2);
|
||||
Filelist_nb_directories++;
|
||||
Add_element_to_list(list, home_dir, 2);
|
||||
list->Nb_directories++;
|
||||
}
|
||||
|
||||
Liste_points_montage = read_file_system_list(0);
|
||||
mount_points_list = read_file_system_list(0);
|
||||
|
||||
while(Liste_points_montage != NULL)
|
||||
while(mount_points_list != NULL)
|
||||
{
|
||||
if(Liste_points_montage->me_dummy == 0 && strcmp(Liste_points_montage->me_mountdir,"/") && strcmp(Liste_points_montage->me_mountdir,"/home"))
|
||||
if(mount_points_list->me_dummy == 0 && strcmp(mount_points_list->me_mountdir,"/") && strcmp(mount_points_list->me_mountdir,"/home"))
|
||||
{
|
||||
Add_element_to_list(Liste_points_montage->me_mountdir,2);
|
||||
Filelist_nb_directories++;
|
||||
Add_element_to_list(list, mount_points_list->me_mountdir,2);
|
||||
list->Nb_directories++;
|
||||
}
|
||||
next = Liste_points_montage -> me_next;
|
||||
next = mount_points_list -> me_next;
|
||||
#if !(defined(__macosx__) || defined(__FreeBSD__))
|
||||
free(Liste_points_montage -> me_type);
|
||||
free(mount_points_list -> me_type);
|
||||
#endif
|
||||
free(Liste_points_montage -> me_devname);
|
||||
free(Liste_points_montage -> me_mountdir);
|
||||
free(Liste_points_montage);
|
||||
Liste_points_montage = next;
|
||||
free(mount_points_list -> me_devname);
|
||||
free(mount_points_list -> me_mountdir);
|
||||
free(mount_points_list);
|
||||
mount_points_list = next;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
Filelist_nb_elements=Filelist_nb_directories+Filelist_nb_files;
|
||||
Recount_files(list);
|
||||
}
|
||||
|
||||
|
||||
// -- Tri de la liste des fichiers et répertoires ---------------------------
|
||||
void Sort_list_of_files(void)
|
||||
void Sort_list_of_files(T_Fileselector *list)
|
||||
// Tri la liste chainée existante dans l'ordre suivant:
|
||||
//
|
||||
// * Les répertoires d'abord, dans l'ordre alphabétique de leur nom
|
||||
@ -424,16 +462,15 @@ void Sort_list_of_files(void)
|
||||
T_Fileselector_item * next_item;
|
||||
T_Fileselector_item * next_to_next_item;
|
||||
|
||||
// Avant de trier quoi que ce soit, on vérifie qu'il y ait suffisamment
|
||||
// d'éléments pour qu'il soit possibles qu'ils soient en désordre:
|
||||
if (Filelist_nb_elements>1)
|
||||
// Check there are at least two elements before sorting
|
||||
if (list->First && list->First->Next)
|
||||
{
|
||||
do
|
||||
{
|
||||
// Par défaut, on considère que la liste est triée
|
||||
list_is_sorted=1;
|
||||
|
||||
current_item=Filelist;
|
||||
current_item=list->First;
|
||||
next_item=current_item->Next;
|
||||
|
||||
while ( (current_item!=NULL) && (next_item!=NULL) )
|
||||
@ -478,8 +515,8 @@ void Sort_list_of_files(void)
|
||||
next_to_next_item->Previous=current_item;
|
||||
|
||||
// On fait bien attention à modifier la tête de liste en cas de besoin
|
||||
if (current_item==Filelist)
|
||||
Filelist=next_item;
|
||||
if (current_item==list->First)
|
||||
list->First=next_item;
|
||||
|
||||
// Ensuite, on se prépare à étudier les éléments précédents:
|
||||
current_item=prev_item;
|
||||
@ -499,11 +536,38 @@ void Sort_list_of_files(void)
|
||||
}
|
||||
while (!list_is_sorted);
|
||||
}
|
||||
// Force a recount / re-index
|
||||
Recount_files(list);
|
||||
}
|
||||
|
||||
T_Fileselector_item * Get_item_by_index(T_Fileselector *list, short index)
|
||||
{
|
||||
// Safety
|
||||
if (index >= list->Nb_elements)
|
||||
index=list->Nb_elements-1;
|
||||
|
||||
if (list->Index)
|
||||
{
|
||||
return list->Index[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Index not available.
|
||||
// Can only happen in case of malloc error.
|
||||
// Fall back anyway on iterative search
|
||||
|
||||
T_Fileselector_item * item = list->First;
|
||||
for (;index>0;index--)
|
||||
item = item->Next;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -- Affichage des éléments de la liste de fichier / répertoire ------------
|
||||
void Display_file_list(short offset_first,short selector_offset)
|
||||
void Display_file_list(T_Fileselector *list, short offset_first,short selector_offset)
|
||||
//
|
||||
// offset_first = Décalage entre le premier fichier visible dans le
|
||||
// sélecteur et le premier fichier de la liste
|
||||
@ -519,12 +583,10 @@ void Display_file_list(short offset_first,short selector_offset)
|
||||
|
||||
|
||||
// On vérifie s'il y a au moins 1 fichier dans la liste:
|
||||
if (Filelist_nb_elements>0)
|
||||
if (list->Nb_elements>0)
|
||||
{
|
||||
// On commence par chercher à pointer sur le premier fichier visible:
|
||||
current_item=Filelist;
|
||||
for (;offset_first>0;offset_first--)
|
||||
current_item=current_item->Next;
|
||||
current_item = Get_item_by_index(list, offset_first);
|
||||
|
||||
// Pour chacun des 10 éléments inscriptibles à l'écran
|
||||
for (index=0;index<10;index++)
|
||||
@ -566,7 +628,7 @@ void Display_file_list(short offset_first,short selector_offset)
|
||||
|
||||
|
||||
// -- Récupérer le libellé d'un élément de la liste -------------------------
|
||||
void Get_selected_item(short offset_first,short selector_offset,char * label,int *type)
|
||||
void Get_selected_item(T_Fileselector *list, short offset_first,short selector_offset,char * label,int *type)
|
||||
//
|
||||
// offset_first = Décalage entre le premier fichier visible dans le
|
||||
// sélecteur et le premier fichier de la liste
|
||||
@ -582,13 +644,11 @@ void Get_selected_item(short offset_first,short selector_offset,char * label,int
|
||||
T_Fileselector_item * current_item;
|
||||
|
||||
// On vérifie s'il y a au moins 1 fichier dans la liste:
|
||||
if (Filelist_nb_elements>0)
|
||||
if (list->Nb_elements>0)
|
||||
{
|
||||
int i;
|
||||
|
||||
current_item=Filelist;
|
||||
for (i=0; i<Filelist_nb_elements && i<(offset_first+selector_offset);i++)
|
||||
current_item=current_item->Next;
|
||||
// On commence par chercher à pointer sur le premier fichier visible:
|
||||
// Ensuite, on saute autant d'éléments que le décalage demandé:
|
||||
current_item = Get_item_by_index(list, offset_first + selector_offset);
|
||||
|
||||
// On recopie la chaîne
|
||||
strcpy(label, current_item->Full_name);
|
||||
@ -605,12 +665,12 @@ void Selector_scroll_down(short * offset_first,short * selector_offset)
|
||||
// Fait scroller vers le bas le sélecteur de fichier... (si possible)
|
||||
{
|
||||
if ( ((*selector_offset)<9)
|
||||
&& ( (*selector_offset)+1 < Filelist_nb_elements ) )
|
||||
&& ( (*selector_offset)+1 < Filelist.Nb_elements ) )
|
||||
// Si la sélection peut descendre
|
||||
Display_file_list(*offset_first,++(*selector_offset));
|
||||
Display_file_list(&Filelist, *offset_first,++(*selector_offset));
|
||||
else // Sinon, descendre la fenêtre (si possible)
|
||||
if ((*offset_first)+10<Filelist_nb_elements)
|
||||
Display_file_list(++(*offset_first),*selector_offset);
|
||||
if ((*offset_first)+10<Filelist.Nb_elements)
|
||||
Display_file_list(&Filelist, ++(*offset_first),*selector_offset);
|
||||
}
|
||||
|
||||
|
||||
@ -619,38 +679,38 @@ void Selector_scroll_up(short * offset_first,short * selector_offset)
|
||||
{
|
||||
if ((*selector_offset)>0)
|
||||
// Si la sélection peut monter
|
||||
Display_file_list(*offset_first,--(*selector_offset));
|
||||
Display_file_list(&Filelist, *offset_first,--(*selector_offset));
|
||||
else // Sinon, monter la fenêtre (si possible)
|
||||
if ((*offset_first)>0)
|
||||
Display_file_list(--(*offset_first),*selector_offset);
|
||||
Display_file_list(&Filelist, --(*offset_first),*selector_offset);
|
||||
}
|
||||
|
||||
|
||||
void Selector_page_down(short * offset_first,short * selector_offset, short lines)
|
||||
{
|
||||
if (Filelist_nb_elements-1>*offset_first+*selector_offset)
|
||||
if (Filelist.Nb_elements-1>*offset_first+*selector_offset)
|
||||
{
|
||||
if (*selector_offset<9)
|
||||
{
|
||||
if (Filelist_nb_elements<10)
|
||||
if (Filelist.Nb_elements<10)
|
||||
{
|
||||
*offset_first=0;
|
||||
*selector_offset=Filelist_nb_elements-1;
|
||||
*selector_offset=Filelist.Nb_elements-1;
|
||||
}
|
||||
else *selector_offset=9;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Filelist_nb_elements>*offset_first+18)
|
||||
if (Filelist.Nb_elements>*offset_first+18)
|
||||
*offset_first+=lines;
|
||||
else
|
||||
{
|
||||
*offset_first=Filelist_nb_elements-10;
|
||||
*offset_first=Filelist.Nb_elements-10;
|
||||
*selector_offset=9;
|
||||
}
|
||||
}
|
||||
}
|
||||
Display_file_list(*offset_first,*selector_offset);
|
||||
Display_file_list(&Filelist, *offset_first,*selector_offset);
|
||||
}
|
||||
|
||||
|
||||
@ -668,29 +728,29 @@ void Selector_page_up(short * offset_first,short * selector_offset, short lines)
|
||||
*offset_first=0;
|
||||
}
|
||||
}
|
||||
Display_file_list(*offset_first,*selector_offset);
|
||||
Display_file_list(&Filelist, *offset_first,*selector_offset);
|
||||
}
|
||||
|
||||
|
||||
void Selector_end(short * offset_first,short * selector_offset)
|
||||
{
|
||||
if (Filelist_nb_elements<10)
|
||||
if (Filelist.Nb_elements<10)
|
||||
{
|
||||
*offset_first=0;
|
||||
*selector_offset=Filelist_nb_elements-1;
|
||||
*selector_offset=Filelist.Nb_elements-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*offset_first=Filelist_nb_elements-10;
|
||||
*offset_first=Filelist.Nb_elements-10;
|
||||
*selector_offset=9;
|
||||
}
|
||||
Display_file_list(*offset_first,*selector_offset);
|
||||
Display_file_list(&Filelist, *offset_first,*selector_offset);
|
||||
}
|
||||
|
||||
|
||||
void Selector_home(short * offset_first,short * selector_offset)
|
||||
{
|
||||
Display_file_list((*offset_first)=0,(*selector_offset)=0);
|
||||
Display_file_list(&Filelist, (*offset_first)=0,(*selector_offset)=0);
|
||||
}
|
||||
|
||||
|
||||
@ -705,8 +765,8 @@ short Compute_click_offset_in_fileselector(void)
|
||||
short computed_offset;
|
||||
|
||||
computed_offset=(((Mouse_Y-Window_pos_Y)/Menu_factor_Y)-95)>>3;
|
||||
if (computed_offset>=Filelist_nb_elements)
|
||||
computed_offset=Filelist_nb_elements-1;
|
||||
if (computed_offset>=Filelist.Nb_elements)
|
||||
computed_offset=Filelist.Nb_elements-1;
|
||||
|
||||
return computed_offset;
|
||||
}
|
||||
@ -800,22 +860,21 @@ void Print_filename_in_fileselector(void)
|
||||
int Selected_type; // Utilisé pour mémoriser le type d'entrée choisi
|
||||
// dans le selecteur de fichier.
|
||||
|
||||
void Prepare_and_display_filelist(short Position, short offset,
|
||||
T_Scroller_button * button)
|
||||
void Prepare_and_display_filelist(short Position, short offset, T_Scroller_button * button)
|
||||
{
|
||||
button->Nb_elements=Filelist_nb_elements;
|
||||
button->Nb_elements=Filelist.Nb_elements;
|
||||
button->Position=Position;
|
||||
Compute_slider_cursor_height(button);
|
||||
Window_draw_slider(button);
|
||||
// On efface les anciens noms de fichier:
|
||||
Window_rectangle(8-1,95-1,144+2,80+2,MC_Black);
|
||||
// On affiche les nouveaux:
|
||||
Display_file_list(Position,offset);
|
||||
Display_file_list(&Filelist, Position,offset);
|
||||
|
||||
Update_window_area(8-1,95-1,144+2,80+2);
|
||||
|
||||
// On récupère le nom du schmilblick à "accéder"
|
||||
Get_selected_item(Position,offset,Main_filename,&Selected_type);
|
||||
Get_selected_item(&Filelist, Position,offset,Main_filename,&Selected_type);
|
||||
// On affiche le nouveau nom de fichier
|
||||
Print_filename_in_fileselector();
|
||||
// On affiche le nom du répertoire courant
|
||||
@ -825,8 +884,8 @@ void Prepare_and_display_filelist(short Position, short offset,
|
||||
|
||||
void Reload_list_of_files(byte filter, T_Scroller_button * button)
|
||||
{
|
||||
Read_list_of_files(filter);
|
||||
Sort_list_of_files();
|
||||
Read_list_of_files(&Filelist, filter);
|
||||
Sort_list_of_files(&Filelist);
|
||||
//
|
||||
// Check and fix the fileselector positions, because
|
||||
// the directory content may have changed.
|
||||
@ -834,20 +893,20 @@ void Reload_list_of_files(byte filter, T_Scroller_button * button)
|
||||
// Make the offset absolute
|
||||
Main_fileselector_offset += Main_fileselector_position;
|
||||
// Ensure it's within limits
|
||||
if (Main_fileselector_offset >= Filelist_nb_elements)
|
||||
if (Main_fileselector_offset >= Filelist.Nb_elements)
|
||||
{
|
||||
Main_fileselector_offset = Filelist_nb_elements-1;
|
||||
Main_fileselector_offset = Filelist.Nb_elements-1;
|
||||
}
|
||||
// Ensure the position doesn't show "too many files"
|
||||
if (Main_fileselector_position!=0 && Main_fileselector_position>(Filelist_nb_elements-10))
|
||||
if (Main_fileselector_position!=0 && Main_fileselector_position>(Filelist.Nb_elements-10))
|
||||
{
|
||||
if (Filelist_nb_elements<10)
|
||||
if (Filelist.Nb_elements<10)
|
||||
{
|
||||
Main_fileselector_position=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Main_fileselector_position=Filelist_nb_elements-10;
|
||||
Main_fileselector_position=Filelist.Nb_elements-10;
|
||||
}
|
||||
}
|
||||
// Restore the offset as relative to the position.
|
||||
@ -870,7 +929,7 @@ void Scroll_fileselector(T_Scroller_button * file_scroller)
|
||||
Window_draw_slider(file_scroller);
|
||||
}
|
||||
// On récupére le nom du schmilblick à "accéder"
|
||||
Get_selected_item(Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type);
|
||||
Get_selected_item(&Filelist, Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type);
|
||||
if (strcmp(old_filename,Main_filename))
|
||||
New_preview_is_needed=1;
|
||||
|
||||
@ -880,12 +939,12 @@ void Scroll_fileselector(T_Scroller_button * file_scroller)
|
||||
}
|
||||
|
||||
|
||||
short Find_file_in_fileselector(char * fname)
|
||||
short Find_file_in_fileselector(T_Fileselector *list, char * fname)
|
||||
{
|
||||
T_Fileselector_item * current_item;
|
||||
short index;
|
||||
|
||||
for (index=0, current_item=Filelist;
|
||||
for (index=0, current_item=list->First;
|
||||
((current_item!=NULL) && (strcmp(current_item->Full_name,fname)));
|
||||
index++,current_item=current_item->Next);
|
||||
|
||||
@ -897,18 +956,18 @@ void Highlight_file(char * fname)
|
||||
{
|
||||
short index;
|
||||
|
||||
index=Find_file_in_fileselector(fname);
|
||||
index=Find_file_in_fileselector(&Filelist, fname);
|
||||
|
||||
if ((Filelist_nb_elements<=10) || (index<5))
|
||||
if ((Filelist.Nb_elements<=10) || (index<5))
|
||||
{
|
||||
Main_fileselector_position=0;
|
||||
Main_fileselector_offset=index;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (index>=Filelist_nb_elements-5)
|
||||
if (index>=Filelist.Nb_elements-5)
|
||||
{
|
||||
Main_fileselector_position=Filelist_nb_elements-10;
|
||||
Main_fileselector_position=Filelist.Nb_elements-10;
|
||||
Main_fileselector_offset=index-Main_fileselector_position;
|
||||
}
|
||||
else
|
||||
@ -920,18 +979,16 @@ void Highlight_file(char * fname)
|
||||
}
|
||||
|
||||
|
||||
char FFF_best_name[MAX_PATH_CHARACTERS];
|
||||
char * Find_filename_match(char * fname)
|
||||
char * Find_filename_match(T_Fileselector *list, char * fname)
|
||||
{
|
||||
char * best_name_ptr;
|
||||
T_Fileselector_item * current_item;
|
||||
byte matching_letters=0;
|
||||
byte counter;
|
||||
|
||||
strcpy(FFF_best_name,Main_filename);
|
||||
best_name_ptr=NULL;
|
||||
|
||||
for (current_item=Filelist; current_item!=NULL; current_item=current_item->Next)
|
||||
for (current_item=list->First; current_item!=NULL; current_item=current_item->Next)
|
||||
{
|
||||
if ( (!Config.Find_file_fast)
|
||||
|| (Config.Find_file_fast==(current_item->Type+1)) )
|
||||
@ -941,7 +998,6 @@ char * Find_filename_match(char * fname)
|
||||
if (counter>matching_letters)
|
||||
{
|
||||
matching_letters=counter;
|
||||
strcpy(FFF_best_name,current_item->Full_name);
|
||||
best_name_ptr=current_item->Full_name;
|
||||
}
|
||||
}
|
||||
@ -974,6 +1030,12 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
char quicksearch_filename[MAX_PATH_CHARACTERS]="";
|
||||
char save_filename[MAX_PATH_CHARACTERS];
|
||||
char * most_matching_filename;
|
||||
short window_shortcut;
|
||||
|
||||
if (image)
|
||||
window_shortcut = load?(0x100+BUTTON_LOAD):(0x100+BUTTON_SAVE);
|
||||
else
|
||||
window_shortcut = load?SPECIAL_LOAD_BRUSH:SPECIAL_SAVE_BRUSH;
|
||||
|
||||
initial_palette=(T_Components *)malloc(sizeof(T_Palette));
|
||||
memcpy(initial_palette,Main_palette,sizeof(T_Palette));
|
||||
@ -1140,12 +1202,12 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
break;
|
||||
|
||||
case 3 : // Delete
|
||||
if (Filelist_nb_elements && (*Main_filename!='.') && Selected_type!=2)
|
||||
if (Filelist.Nb_elements && (*Main_filename!='.') && Selected_type!=2)
|
||||
{
|
||||
char * message;
|
||||
Hide_cursor();
|
||||
// On affiche une demande de confirmation
|
||||
if (Main_fileselector_position+Main_fileselector_offset>=Filelist_nb_directories)
|
||||
if (Main_fileselector_position+Main_fileselector_offset>=Filelist.Nb_directories)
|
||||
{
|
||||
message="Delete file ?";
|
||||
}
|
||||
@ -1156,7 +1218,7 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
if (Confirmation_box(message))
|
||||
{
|
||||
// Si c'est un fichier
|
||||
if (Main_fileselector_position+Main_fileselector_offset>=Filelist_nb_directories)
|
||||
if (Main_fileselector_position+Main_fileselector_offset>=Filelist.Nb_directories)
|
||||
// On efface le fichier (si on peut)
|
||||
temp=(!remove(Main_filename));
|
||||
else // Si c'est un repertoire
|
||||
@ -1166,7 +1228,7 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
if (temp) // temp indique si l'effacement s'est bien passé
|
||||
{
|
||||
// On remonte si c'était le dernier élément de la liste
|
||||
if (Main_fileselector_position+Main_fileselector_offset==Filelist_nb_elements-1)
|
||||
if (Main_fileselector_position+Main_fileselector_offset==Filelist.Nb_elements-1)
|
||||
{
|
||||
if (Main_fileselector_position)
|
||||
Main_fileselector_position--;
|
||||
@ -1177,7 +1239,7 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
else // Si ce n'était pas le dernier, il faut faire gaffe à ce
|
||||
{ // que ses copains d'en dessous ne remontent pas trop.
|
||||
if ( (Main_fileselector_position)
|
||||
&& (Main_fileselector_position+10==Filelist_nb_elements) )
|
||||
&& (Main_fileselector_position+10==Filelist.Nb_elements) )
|
||||
{
|
||||
Main_fileselector_position--;
|
||||
Main_fileselector_offset++;
|
||||
@ -1214,11 +1276,11 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
Main_fileselector_offset=temp;
|
||||
|
||||
// On récupére le nom du schmilblick à "accéder"
|
||||
Get_selected_item(Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type);
|
||||
Get_selected_item(&Filelist, Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type);
|
||||
// On affiche le nouveau nom de fichier
|
||||
Print_filename_in_fileselector();
|
||||
// On affiche à nouveau la liste
|
||||
Display_file_list(Main_fileselector_position,Main_fileselector_offset);
|
||||
Display_file_list(&Filelist, Main_fileselector_position,Main_fileselector_offset);
|
||||
|
||||
// On vient de changer de nom de fichier, donc on doit s'appreter
|
||||
// a rafficher une preview
|
||||
@ -1231,8 +1293,8 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
// faut mettre le nom de fichier au nom du répertoire. Sinon, dans
|
||||
// certains cas, on risque de sauvegarder avec le nom du fichier
|
||||
// actuel au lieu de changer de répertoire.
|
||||
if (Main_fileselector_position+Main_fileselector_offset<Filelist_nb_directories)
|
||||
Get_selected_item(Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type);
|
||||
if (Main_fileselector_position+Main_fileselector_offset<Filelist.Nb_directories)
|
||||
Get_selected_item(&Filelist, Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type);
|
||||
|
||||
has_clicked_ok=1;
|
||||
New_preview_is_needed=1;
|
||||
@ -1247,11 +1309,11 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
Hide_cursor();
|
||||
Main_fileselector_position=Window_attribute2;
|
||||
// On récupére le nom du schmilblick à "accéder"
|
||||
Get_selected_item(Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type);
|
||||
Get_selected_item(&Filelist, Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type);
|
||||
// On affiche le nouveau nom de fichier
|
||||
Print_filename_in_fileselector();
|
||||
// On affiche à nouveau la liste
|
||||
Display_file_list(Main_fileselector_position,Main_fileselector_offset);
|
||||
Display_file_list(&Filelist, Main_fileselector_position,Main_fileselector_offset);
|
||||
Display_cursor();
|
||||
New_preview_is_needed=1;
|
||||
*quicksearch_filename=0;
|
||||
@ -1345,8 +1407,8 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
Main_fileselector_position=0;
|
||||
Main_fileselector_offset=0;
|
||||
// Affichage des premiers fichiers visibles:
|
||||
Read_list_of_drives();
|
||||
Sort_list_of_files();
|
||||
Read_list_of_drives(&Filelist);
|
||||
Sort_list_of_files(&Filelist);
|
||||
Prepare_and_display_filelist(Main_fileselector_position,Main_fileselector_offset,file_scroller);
|
||||
Display_cursor();
|
||||
New_preview_is_needed=1;
|
||||
@ -1485,7 +1547,7 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
case SDLK_BACKSPACE : // Backspace
|
||||
*quicksearch_filename=0;
|
||||
// Si le choix ".." est bien en tête des propositions...
|
||||
if (!strcmp(Filelist->Full_name,PARENT_DIR))
|
||||
if (!strcmp(Filelist.First->Full_name,PARENT_DIR))
|
||||
{
|
||||
// On va dans le répertoire parent.
|
||||
strcpy(Main_filename,PARENT_DIR);
|
||||
@ -1494,7 +1556,7 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
}
|
||||
Key=0;
|
||||
break;
|
||||
default: // Autre => On se place sur le nom de fichier qui correspond
|
||||
default:
|
||||
if (clicked_button<=0)
|
||||
{
|
||||
if (Is_shortcut(Key,0x100+BUTTON_HELP))
|
||||
@ -1502,12 +1564,18 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
Window_help(load?BUTTON_LOAD:BUTTON_SAVE, NULL);
|
||||
break;
|
||||
}
|
||||
if (Is_shortcut(Key,window_shortcut))
|
||||
{
|
||||
clicked_button=2;
|
||||
break;
|
||||
}
|
||||
// Autre => On se place sur le nom de fichier qui correspond
|
||||
temp=strlen(quicksearch_filename);
|
||||
if (Key_ANSI>= ' ' && Key_ANSI < 255 && temp<50)
|
||||
{
|
||||
quicksearch_filename[temp]=Key_ANSI;
|
||||
quicksearch_filename[temp+1]='\0';
|
||||
most_matching_filename=Find_filename_match(quicksearch_filename);
|
||||
most_matching_filename=Find_filename_match(&Filelist, quicksearch_filename);
|
||||
if ( (most_matching_filename) )
|
||||
{
|
||||
temp=Main_fileselector_position+Main_fileselector_offset;
|
||||
@ -1552,8 +1620,8 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
getcwd(Main_current_directory,256);
|
||||
|
||||
// On lit le nouveau répertoire
|
||||
Read_list_of_files(Main_format);
|
||||
Sort_list_of_files();
|
||||
Read_list_of_files(&Filelist, Main_format);
|
||||
Sort_list_of_files(&Filelist);
|
||||
// On place la barre de sélection sur le répertoire d'où l'on vient
|
||||
Highlight_file(previous_directory);
|
||||
}
|
||||
@ -1614,7 +1682,7 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
|
||||
if (Timer_state==1) // Il faut afficher la preview
|
||||
{
|
||||
if ( (Main_fileselector_position+Main_fileselector_offset>=Filelist_nb_directories) && (Filelist_nb_elements) )
|
||||
if ( (Main_fileselector_position+Main_fileselector_offset>=Filelist.Nb_directories) && (Filelist.Nb_elements) )
|
||||
{
|
||||
strcpy(Main_file_directory,Main_current_directory);
|
||||
|
||||
@ -1661,7 +1729,7 @@ byte Button_Load_or_Save(byte load, byte image)
|
||||
|
||||
Unselect_button((load)?BUTTON_LOAD:BUTTON_SAVE);
|
||||
Display_cursor();
|
||||
Free_fileselector_list();
|
||||
Free_fileselector_list(&Filelist);
|
||||
|
||||
Pixel_load_function=Pixel_load_in_current_screen;
|
||||
|
||||
|
||||
73
filesel.h
@ -1,25 +1,48 @@
|
||||
/* 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.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
byte Button_Load_or_Save(byte load, byte image);
|
||||
/* 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"
|
||||
|
||||
byte Button_Load_or_Save(byte load, byte image);
|
||||
|
||||
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, char * fname);
|
||||
|
||||
#endif
|
||||
|
||||
54
gfx2def.ini
@ -76,13 +76,6 @@
|
||||
; the menus and tool-bar | des menus et de la barre d'outils
|
||||
Menu_ratio = 1 ; (default 1)
|
||||
|
||||
; Font: | Police de caractères (fonte):
|
||||
; 1: Classic | 1: Classique
|
||||
; 2: Fun | 2: Fun
|
||||
Font = 1 ; (default 1)
|
||||
|
||||
|
||||
|
||||
[FILE_SELECTOR] # [SELECTEUR_DE_FICHIERS]
|
||||
|
||||
; Show hidden files and | Afficher les fichiers et répertoires
|
||||
@ -269,12 +262,15 @@
|
||||
Default_window_size = 640,480 ; (default '640,480')
|
||||
|
||||
; This setting allows you merge successive mouse movements into a single
|
||||
; mouse movement. Ideally you should leave it at zero, but if you have an
|
||||
; extremely fast mouse and you see the mouse cursor lagging WHEN YOU'RE NOT
|
||||
; DRAWING, you may want to set it to 1, 2 or more, so that GrafX2 skips small
|
||||
; steps. A very high value (100) guarantees that Grafx2 merges all the mouse
|
||||
; steps into a single one.
|
||||
Merge_movement = 100 ; (default 100)
|
||||
; mouse movement. You should only use it if you are using a mouse which
|
||||
; reports at 200Hz or more, and you experience lag when using discontinuous
|
||||
; hand-drawing with large brushes (this tool tries to paste the brush and
|
||||
; update the screen on each new mouse position) In this case, set this to 2
|
||||
; or more, to ignore some intermediate mouse reports when a more recent one
|
||||
; is present.
|
||||
; Note that with a value superior to 1, you lose precision with continuous
|
||||
; hand-drawing, as intermediate mouse positions are skipped.
|
||||
Merge_movement = 0 ; (default 0)
|
||||
|
||||
; Number of columns in the palette of the menu bar. Can be any number from
|
||||
; 1 to 256. If there is not enough room, the program will display less
|
||||
@ -312,4 +308,36 @@
|
||||
; OS isn't able to do it by itself. (ie: Windows)
|
||||
Window_position = 9999,9999; (Default 9999,9999 which means: NA)
|
||||
|
||||
; This is the time (in milliseconds) between two clicks for Grafx2 to
|
||||
; recognize a double-click. Double-click is used mostly in the palette
|
||||
; area of the menu: double-click a color to open the palette.
|
||||
Double_click_speed = 500; (Default 500)
|
||||
|
||||
; When you press two digit keys in rapid succession (ex: 3 8), Grafx2
|
||||
; sets transparency to 38% (instead of 30% then 80%). This setting
|
||||
; allows you to set the maximum delay between two keypresses for
|
||||
; GrafX2 to recognize them as a combo.
|
||||
Double_key_speed = 500; (Default 500)
|
||||
|
||||
; Name of the skinfile you want to | Nom du fichier skin que vous voulez
|
||||
; use. | utiliser.
|
||||
; Default : (empty to let the program choose)
|
||||
Skin_file =
|
||||
|
||||
; Name of the font file (8x8) you | Nom du fichier police de caractère
|
||||
; want to use. | 8x8 utilisée dans les menus.
|
||||
; Default : (empty to let the program choose)
|
||||
Font_file =
|
||||
|
||||
; This determines the color value for the grid. Each pixel of
|
||||
; the grid will be displayed by XOR-ing the original color with
|
||||
; the value of this setting.
|
||||
; For example, if you always paint 16-color images, you can set it
|
||||
; to 16 so the color of the grid are 16 for 0, 17 for 1, etc.
|
||||
; Then you can set colors 16-31 as lighter/darker variants
|
||||
; of your original palette, resulting in a pretty grid !
|
||||
;
|
||||
; Valid values are 1 to 255.
|
||||
Grid_XOR_color = 255; (Default 255)
|
||||
|
||||
; end of configuration
|
||||
|
||||
85
global.h
@ -63,9 +63,6 @@ GFX2_GLOBAL T_Video_mode Video_mode[MAX_VIDEO_MODES];
|
||||
/// Actual number of video modes in ::Video_mode.
|
||||
GFX2_GLOBAL int Nb_video_modes;
|
||||
|
||||
/// A default 256-color palette.
|
||||
GFX2_GLOBAL T_Palette Default_palette;
|
||||
|
||||
// -- Menu colors
|
||||
|
||||
GFX2_GLOBAL byte MC_Black; ///< Index of color to use as "black" in the GUI menus.
|
||||
@ -81,6 +78,7 @@ GFX2_GLOBAL T_Components Fav_menu_colors[4];
|
||||
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)))
|
||||
@ -139,14 +137,8 @@ GFX2_GLOBAL byte Cursor_hidden;
|
||||
GFX2_GLOBAL byte Cursor_in_menu;
|
||||
/// Boolean, means the cursor was hovering over a menu GUI element.
|
||||
GFX2_GLOBAL byte Cursor_in_menu_previous;
|
||||
/// X coordinate of the mouse cursor's "hot spot". It is < ::CURSOR_SPRITE_WIDTH
|
||||
GFX2_GLOBAL word Cursor_offset_X[NB_CURSOR_SPRITES];
|
||||
/// Y coordinate of the mouse cursor's "hot spot". It is < ::CURSOR_SPRITE_HEIGHT
|
||||
GFX2_GLOBAL word Cursor_offset_Y[NB_CURSOR_SPRITES];
|
||||
/// Graphic resources for the mouse cursor.
|
||||
GFX2_GLOBAL byte GFX_cursor_sprite[NB_CURSOR_SPRITES][CURSOR_SPRITE_HEIGHT][CURSOR_SPRITE_WIDTH];
|
||||
/// 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];
|
||||
GFX2_GLOBAL byte Cursor_background[CURSOR_SPRITE_HEIGHT][CURSOR_SPRITE_WIDTH];
|
||||
|
||||
// -- Paintbrush data
|
||||
|
||||
@ -164,18 +156,6 @@ GFX2_GLOBAL byte Paintbrush_hidden;
|
||||
GFX2_GLOBAL short Paintbrush_X;
|
||||
/// Cordinate of the preview paintbrush in image space.
|
||||
GFX2_GLOBAL short Paintbrush_Y;
|
||||
/// Graphic resources for the preset paintbrushes.
|
||||
GFX2_GLOBAL byte GFX_paintbrush_sprite [NB_PAINTBRUSH_SPRITES][PAINTBRUSH_HEIGHT][PAINTBRUSH_WIDTH];
|
||||
/// Width of the preset paintbrushes.
|
||||
GFX2_GLOBAL word Preset_paintbrush_width[NB_PAINTBRUSH_SPRITES];
|
||||
/// Height of the preset paintbrushes.
|
||||
GFX2_GLOBAL word Preset_paintbrush_height[NB_PAINTBRUSH_SPRITES];
|
||||
/// Type of the preset paintbrush: index in enum PAINTBRUSH_SHAPES
|
||||
GFX2_GLOBAL byte Paintbrush_type[NB_PAINTBRUSH_SPRITES];
|
||||
/// Brush handle for the preset brushes. Generally ::Preset_paintbrush_width[]/2
|
||||
GFX2_GLOBAL word Preset_paintbrush_offset_X[NB_PAINTBRUSH_SPRITES];
|
||||
/// Brush handle for the preset brushes. Generally ::Preset_paintbrush_height[]/2
|
||||
GFX2_GLOBAL word Preset_paintbrush_offset_Y[NB_PAINTBRUSH_SPRITES];
|
||||
/// Pixel data of the current brush
|
||||
GFX2_GLOBAL byte * Paintbrush_sprite;
|
||||
/// Current paintbrush's width
|
||||
@ -548,6 +528,11 @@ 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];
|
||||
///
|
||||
@ -660,6 +645,8 @@ GFX2_GLOBAL byte Stencil[256];
|
||||
|
||||
/// 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.
|
||||
@ -675,8 +662,6 @@ GFX2_GLOBAL word Snap_offset_Y;
|
||||
GFX2_GLOBAL byte Sieve_mode;
|
||||
/// Sprite of the sieve pattern. It's actually an array of booleans.
|
||||
GFX2_GLOBAL byte Sieve[16][16];
|
||||
/// Preset sieve patterns, stored as binary (one word per line)
|
||||
GFX2_GLOBAL word GFX_sieve_pattern[12][16];
|
||||
/// Width of the sieve pattern, in Sieve mode.
|
||||
GFX2_GLOBAL short Sieve_width;
|
||||
/// Height of the sieve pattern, in Sieve mode.
|
||||
@ -810,40 +795,14 @@ GFX2_GLOBAL byte File_in_command_line;
|
||||
/// 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 skin data
|
||||
// - Graphic
|
||||
|
||||
/// Bitmap data for the menu, a single rectangle.
|
||||
GFX2_GLOBAL byte GFX_menu_block[MENU_HEIGHT][MENU_WIDTH];
|
||||
/// Bitmap data for the icons that are displayed over the menu.
|
||||
GFX2_GLOBAL byte GFX_menu_sprite[NB_MENU_SPRITES][MENU_SPRITE_HEIGHT][MENU_SPRITE_WIDTH];
|
||||
/// Bitmap data for the different "effects" icons.
|
||||
GFX2_GLOBAL byte GFX_effect_sprite[NB_EFFECTS_SPRITES][MENU_SPRITE_HEIGHT][MENU_SPRITE_WIDTH];
|
||||
/// Bitmap data for the Grafx2 logo that appears on splash screen. All 256 colors allowed.
|
||||
GFX2_GLOBAL byte * GFX_logo_grafx2;
|
||||
/// Bitmap data for the classic 8x8 font used in menus etc.
|
||||
GFX2_GLOBAL byte GFX_system_font[256*8*8];
|
||||
/// Bitmap data for the "fun" 8x8 font used in menus etc.
|
||||
GFX2_GLOBAL byte GFX_fun_font [256*8*8];
|
||||
/// Bitmap data for the 6x8 font used in help screens.
|
||||
GFX2_GLOBAL byte GFX_help_font_norm [256][6][8];
|
||||
/// Bitmap data for the 6x8 font used in help screens ("bold" verstion).
|
||||
GFX2_GLOBAL byte GFX_bold_font [256][6][8];
|
||||
// 12
|
||||
// 34
|
||||
/// Bitmap data for the title font used in help screens. Top-left quarter.
|
||||
GFX2_GLOBAL byte GFX_help_font_t1 [64][6][8];
|
||||
/// Bitmap data for the title font used in help screens. Top-right quarter.
|
||||
GFX2_GLOBAL byte GFX_help_font_t2 [64][6][8];
|
||||
/// Bitmap data for the title font used in help screens. Bottom-left quarter.
|
||||
GFX2_GLOBAL byte GFX_help_font_t3 [64][6][8];
|
||||
/// Bitmap data for the title font used in help screens. Bottom-right quarter.
|
||||
GFX2_GLOBAL byte GFX_help_font_t4 [64][6][8];
|
||||
/// Bitmap data for the small 8x8 icons.
|
||||
GFX2_GLOBAL byte GFX_icon_sprite[NB_ICON_SPRITES][ICON_SPRITE_HEIGHT][ICON_SPRITE_WIDTH];
|
||||
|
||||
/// Pointer to the font selected for menus. It's either ::GFX_system_font or ::GFX_fun_font
|
||||
/// 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.
|
||||
@ -873,6 +832,8 @@ GFX2_GLOBAL short Colorpicker_X;
|
||||
/// Position of the colorpicker tool, in image coordinates.
|
||||
GFX2_GLOBAL short Colorpicker_Y;
|
||||
|
||||
/// Brush container
|
||||
GFX2_GLOBAL T_Brush_template Brush_container[BRUSH_CONTAINER_COLUMNS*BRUSH_CONTAINER_ROWS];
|
||||
|
||||
#ifdef GLOBAL_VARIABLES
|
||||
byte CURSOR_FOR_OPERATION[NB_OPERATIONS]=
|
||||
@ -921,21 +882,11 @@ GFX2_GLOBAL short Colorpicker_Y;
|
||||
/// each operation, and for each mouse state (no button,left button,right button)
|
||||
GFX2_GLOBAL struct
|
||||
{
|
||||
byte Hide_cursor; ///< Boolean: Need to hide/unhide cursor during this step
|
||||
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];
|
||||
|
||||
// -- Fileselector data
|
||||
|
||||
/// Number of elements in the current fileselector's ::Filelist
|
||||
GFX2_GLOBAL short Filelist_nb_elements;
|
||||
/// Number of files in the current fileselector's ::Filelist
|
||||
GFX2_GLOBAL short Filelist_nb_files;
|
||||
/// Number of directories in the current fileselector's ::Filelist
|
||||
GFX2_GLOBAL short Filelist_nb_directories;
|
||||
/// Head of the linked list for the fileselector.
|
||||
GFX2_GLOBAL T_Fileselector_item * Filelist;
|
||||
|
||||
// -- misc
|
||||
|
||||
///
|
||||
|
||||
277
graph.c
@ -107,6 +107,7 @@ void Update_part_of_screen(short x, short y, short width, short height)
|
||||
|
||||
if(effective_Y + effective_h > Menu_Y)
|
||||
effective_h = Menu_Y - effective_Y;
|
||||
|
||||
/*
|
||||
SDL_Rect r;
|
||||
r.x=effective_X;
|
||||
@ -136,7 +137,7 @@ void Update_part_of_screen(short x, short y, short width, short height)
|
||||
}
|
||||
else
|
||||
effective_X += Main_separator_position + SEPARATOR_WIDTH*Menu_factor_X;
|
||||
diff = effective_X+effective_w-Screen_width;
|
||||
diff = effective_X+effective_w-Min(Screen_width, Main_X_zoom+(Main_image_width-Main_magnifier_offset_X)*Main_magnifier_factor);
|
||||
if (diff>0)
|
||||
{
|
||||
effective_w -=diff;
|
||||
@ -153,7 +154,7 @@ void Update_part_of_screen(short x, short y, short width, short height)
|
||||
return;
|
||||
effective_Y = 0;
|
||||
}
|
||||
diff = effective_Y+effective_h-Menu_Y;
|
||||
diff = effective_Y+effective_h-Min(Menu_Y, (Main_image_height-Main_magnifier_offset_Y)*Main_magnifier_factor);
|
||||
if (diff>0)
|
||||
{
|
||||
effective_h -=diff;
|
||||
@ -161,6 +162,7 @@ void Update_part_of_screen(short x, short y, short width, short height)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Très utile pour le debug :)
|
||||
/*SDL_Rect r;
|
||||
r.x=effective_X;
|
||||
@ -169,6 +171,7 @@ void Update_part_of_screen(short x, short y, short width, short height)
|
||||
r.w=effective_w;
|
||||
SDL_FillRect(Screen_SDL,&r,3);*/
|
||||
|
||||
Redraw_grid(effective_X,effective_Y,effective_w,effective_h);
|
||||
Update_rect(effective_X,effective_Y,effective_w,effective_h);
|
||||
}
|
||||
}
|
||||
@ -468,7 +471,7 @@ int Init_mode_video(int width, int height, int fullscreen, int pix_ratio)
|
||||
|
||||
Clear_border(MC_Black); // Requires up-to-date Screen_* and Pixel_*
|
||||
|
||||
// Taille des menus
|
||||
// Set menu size (software zoom)
|
||||
if (Screen_width/320 > Screen_height/200)
|
||||
factor=Screen_height/200;
|
||||
else
|
||||
@ -476,28 +479,32 @@ int Init_mode_video(int width, int height, int fullscreen, int pix_ratio)
|
||||
|
||||
switch (Config.Ratio)
|
||||
{
|
||||
case 1: // adapter tout
|
||||
case 1: // Always the biggest possible
|
||||
Menu_factor_X=factor;
|
||||
Menu_factor_Y=factor;
|
||||
break;
|
||||
case 2: // adapter légèrement
|
||||
case 2: // Only keep the aspect ratio
|
||||
Menu_factor_X=factor-1;
|
||||
if (Menu_factor_X<1) Menu_factor_X=1;
|
||||
Menu_factor_Y=factor-1;
|
||||
if (Menu_factor_Y<1) Menu_factor_Y=1;
|
||||
break;
|
||||
default: // ne pas adapter
|
||||
case 0: // Always smallest possible
|
||||
Menu_factor_X=1;
|
||||
Menu_factor_Y=1;
|
||||
break;
|
||||
default: // Stay below some reasonable size
|
||||
Menu_factor_X=Min(factor,abs(Config.Ratio));
|
||||
Menu_factor_Y=Min(factor,abs(Config.Ratio));
|
||||
}
|
||||
if (Pixel_height>Pixel_width && Screen_width>=Menu_factor_X*2*320)
|
||||
Menu_factor_X*=2;
|
||||
else if (Pixel_width>Pixel_height && Screen_height>=Menu_factor_Y*2*200)
|
||||
Menu_factor_Y*=2;
|
||||
|
||||
if (Horizontal_line_buffer)
|
||||
free(Horizontal_line_buffer);
|
||||
Horizontal_line_buffer=(byte *)malloc(Pixel_width*((Screen_width>Main_image_width)?Screen_width:Main_image_width));
|
||||
free(Horizontal_line_buffer);
|
||||
Horizontal_line_buffer=(byte *)malloc(Pixel_width *
|
||||
((Screen_width>Main_image_width)?Screen_width:Main_image_width));
|
||||
|
||||
Set_palette(Main_palette);
|
||||
|
||||
@ -677,6 +684,7 @@ void Get_colors_from_brush(void)
|
||||
Display_all_screen();
|
||||
Display_menu();
|
||||
Display_cursor();
|
||||
End_of_modification();
|
||||
|
||||
Main_image_is_modified=1;
|
||||
}
|
||||
@ -994,7 +1002,18 @@ void Fill_general(byte fill_color)
|
||||
// par l'utilisation de "Display_pixel()", et que les autres... eh bein
|
||||
// on n'y a jamais touché à l'écran les autres: ils sont donc corrects.
|
||||
|
||||
if(Main_magnifier_mode)
|
||||
{
|
||||
short w,h;
|
||||
|
||||
w=Min(Screen_width-Main_X_zoom, (Main_image_width-Main_magnifier_offset_X)*Main_magnifier_factor);
|
||||
h=Min(Menu_Y, (Main_image_height-Main_magnifier_offset_Y)*Main_magnifier_factor);
|
||||
|
||||
Redraw_grid(Main_X_zoom,0,w,h);
|
||||
}
|
||||
|
||||
Update_rect(0,0,0,0);
|
||||
End_of_modification();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1005,11 +1024,32 @@ void Fill_general(byte fill_color)
|
||||
////////////////////////// avec gestion de previews //////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Data used by ::Init_permanent_draw() and ::Pixel_figure_permanent()
|
||||
static Uint32 Permanent_draw_next_refresh=0;
|
||||
static int Permanent_draw_count=0;
|
||||
|
||||
void Init_permanent_draw(void)
|
||||
{
|
||||
Permanent_draw_count = 0;
|
||||
Permanent_draw_next_refresh = SDL_GetTicks() + 100;
|
||||
}
|
||||
|
||||
// Affichage d'un point de façon définitive (utilisation du pinceau)
|
||||
void Pixel_figure_permanent(word x_pos,word y_pos,byte color)
|
||||
{
|
||||
Display_paintbrush(x_pos,y_pos,color,0);
|
||||
Permanent_draw_count ++;
|
||||
|
||||
// Check every 8 pixels
|
||||
if (! (Permanent_draw_count&7))
|
||||
{
|
||||
Uint32 now = SDL_GetTicks();
|
||||
if (now>= Permanent_draw_next_refresh)
|
||||
{
|
||||
Permanent_draw_next_refresh = now+100;
|
||||
Flush_update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Affichage d'un point de façon définitive
|
||||
@ -1151,6 +1191,7 @@ void Draw_empty_circle_general(short center_x,short center_y,short radius,byte c
|
||||
void Draw_empty_circle_permanent(short center_x,short center_y,short radius,byte color)
|
||||
{
|
||||
Pixel_figure=Pixel_figure_permanent;
|
||||
Init_permanent_draw();
|
||||
Draw_empty_circle_general(center_x,center_y,radius,color);
|
||||
Update_part_of_screen(center_x - radius, center_y - radius, 2* radius+1, 2*radius+1);
|
||||
}
|
||||
@ -1293,6 +1334,7 @@ void Draw_empty_ellipse_general(short center_x,short center_y,short horizontal_r
|
||||
void Draw_empty_ellipse_permanent(short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color)
|
||||
{
|
||||
Pixel_figure=Pixel_figure_permanent;
|
||||
Init_permanent_draw();
|
||||
Draw_empty_ellipse_general(center_x,center_y,horizontal_radius,vertical_radius,color);
|
||||
Update_part_of_screen(center_x - horizontal_radius, center_y - vertical_radius, 2* horizontal_radius+1, 2*vertical_radius+1);
|
||||
}
|
||||
@ -1356,46 +1398,132 @@ void Draw_filled_ellipse(short center_x,short center_y,short horizontal_radius,s
|
||||
* TRACÉ DE LIGNES *
|
||||
******************/
|
||||
|
||||
void Clamp_coordinates_45_degrees(short ax, short ay, short* bx, short* by)
|
||||
// Modifie bx et by pour que la ligne AXAY - BXBY soit
|
||||
// - une droite horizontale
|
||||
// - une droite verticale
|
||||
// - une droite avec une pente de 45 degrés
|
||||
/// Alters bx and by so the (AX,AY)-(BX,BY) segment becomes either horizontal,
|
||||
/// vertical, 45degrees, or isometrical for pixelart (ie 2:1 ratio)
|
||||
void Clamp_coordinates_regular_angle(short ax, short ay, short* bx, short* by)
|
||||
{
|
||||
int dx, dy;
|
||||
float tan;
|
||||
int dx, dy;
|
||||
float angle;
|
||||
|
||||
dx = (*bx)-ax;
|
||||
dy = ay- *by; // On prend l'opposée car à l'écran les Y sont positifs en bas, et en maths, positifs en haut
|
||||
dx = *bx-ax;
|
||||
dy = *by-ay;
|
||||
|
||||
if (dx==0) return; // On est en lockx et de toutes façons le X n'a pas bougé, on sort tout de suite pour éviter une méchante division par 0
|
||||
// No mouse move: no need to clamp anything
|
||||
if (dx==0 || dy == 0) return;
|
||||
|
||||
tan = (float)dy/(float)dx;
|
||||
// Determine angle (heading)
|
||||
angle = atan2(dx, dy);
|
||||
|
||||
// Get absolute values, useful from now on:
|
||||
//dx=abs(dx);
|
||||
//dy=abs(dy);
|
||||
|
||||
// Negative Y
|
||||
if (angle < M_PI*(-15.0/16.0) || angle > M_PI*(15.0/16.0))
|
||||
{
|
||||
*bx=ax;
|
||||
*by=ay + dy;
|
||||
}
|
||||
// Iso close to negative Y
|
||||
else if (angle < M_PI*(-13.0/16.0))
|
||||
{
|
||||
dy=dy | 1; // Round up to next odd number
|
||||
*bx=ax + dy/2;
|
||||
*by=ay + dy;
|
||||
}
|
||||
// 45deg
|
||||
else if (angle < M_PI*(-11.0/16.0))
|
||||
{
|
||||
*by = (*by + ay + dx)/2;
|
||||
*bx = ax - ay + *by;
|
||||
}
|
||||
// Iso close to negative X
|
||||
else if (angle < M_PI*(-9.0/16.0))
|
||||
{
|
||||
dx=dx | 1; // Round up to next odd number
|
||||
*bx=ax + dx;
|
||||
*by=ay + dx/2;
|
||||
}
|
||||
// Negative X
|
||||
else if (angle < M_PI*(-7.0/16.0))
|
||||
{
|
||||
*bx=ax + dx;
|
||||
*by=ay;
|
||||
}
|
||||
// Iso close to negative X
|
||||
else if (angle < M_PI*(-5.0/16.0))
|
||||
{
|
||||
dx=dx | 1; // Round up to next odd number
|
||||
*bx=ax + dx;
|
||||
*by=ay - dx/2;
|
||||
}
|
||||
// 45 degrees
|
||||
else if (angle < M_PI*(-3.0/16.0))
|
||||
{
|
||||
*by = (*by + ay - dx)/2;
|
||||
*bx = ax + ay - *by;
|
||||
}
|
||||
// Iso close to positive Y
|
||||
else if (angle < M_PI*(-1.0/16.0))
|
||||
{
|
||||
dy=dy | 1; // Round up to next odd number
|
||||
*bx=ax - dy/2;
|
||||
*by=ay + dy;
|
||||
}
|
||||
// Positive Y
|
||||
else if (angle < M_PI*(1.0/16.0))
|
||||
{
|
||||
*bx=ax;
|
||||
*by=ay + dy;
|
||||
}
|
||||
// Iso close to positive Y
|
||||
else if (angle < M_PI*(3.0/16.0))
|
||||
{
|
||||
dy=dy | 1; // Round up to next odd number
|
||||
*bx=ax + dy/2;
|
||||
*by=ay + dy;
|
||||
}
|
||||
// 45 degrees
|
||||
else if (angle < M_PI*(5.0/16.0))
|
||||
{
|
||||
*by = (*by + ay + dx)/2;
|
||||
*bx = ax - ay + *by;
|
||||
}
|
||||
// Iso close to positive X
|
||||
else if (angle < M_PI*(7.0/16.0))
|
||||
{
|
||||
dx=dx | 1; // Round up to next odd number
|
||||
*bx=ax + dx;
|
||||
*by=ay + dx/2;
|
||||
}
|
||||
// Positive X
|
||||
else if (angle < M_PI*(9.0/16.0))
|
||||
{
|
||||
*bx=ax + dx;
|
||||
*by=ay;
|
||||
}
|
||||
// Iso close to positive X
|
||||
else if (angle < M_PI*(11.0/16.0))
|
||||
{
|
||||
dx=dx | 1; // Round up to next odd number
|
||||
*bx=ax + dx;
|
||||
*by=ay - dx/2;
|
||||
}
|
||||
// 45 degrees
|
||||
else if (angle < M_PI*(13.0/16.0))
|
||||
{
|
||||
*by = (*by + ay - dx)/2;
|
||||
*bx = ax + ay - *by;
|
||||
}
|
||||
// Iso close to negative Y
|
||||
else //if (angle < M_PI*(15.0/16.0))
|
||||
{
|
||||
dy=dy | 1; // Round up to next odd number
|
||||
*bx=ax - dy/2;
|
||||
*by=ay + dy;
|
||||
}
|
||||
|
||||
if (tan <= 0.4142 && tan >= -0.4142)
|
||||
{
|
||||
// Cas 1 : Lock Y
|
||||
*by = ay;
|
||||
}
|
||||
else if ( tan > 0.4142 && tan < 2.4142)
|
||||
{
|
||||
// Cas 2 : dy=dx
|
||||
*by = (*by + ay - dx)/2;
|
||||
*bx = ax + ay - *by;
|
||||
}
|
||||
else if (tan < -0.4142 && tan >= -2.4142)
|
||||
{
|
||||
// Cas 8 : dy = -dx
|
||||
*by = (*by + ay + dx)/2;
|
||||
*bx = ax - ay + *by;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cas 3 : Lock X
|
||||
*bx = ax;
|
||||
}
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
// -- Tracer général d'une ligne ------------------------------------------
|
||||
@ -1406,8 +1534,7 @@ void Draw_line_general(short start_x,short start_y,short end_x,short end_y, byte
|
||||
short incr_x,incr_y;
|
||||
short i,cumul;
|
||||
short delta_x,delta_y;
|
||||
|
||||
|
||||
|
||||
x_pos=start_x;
|
||||
y_pos=start_y;
|
||||
|
||||
@ -1471,11 +1598,12 @@ void Draw_line_general(short start_x,short start_y,short end_x,short end_y, byte
|
||||
|
||||
// -- Tracer définitif d'une ligne --
|
||||
|
||||
void Draw_line_permanet(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)
|
||||
{
|
||||
|
||||
int w = end_x-start_x, h = end_y - start_y;
|
||||
Pixel_figure=Pixel_figure_permanent;
|
||||
Init_permanent_draw();
|
||||
Draw_line_general(start_x,start_y,end_x,end_y,color);
|
||||
Update_part_of_screen((start_x<end_x)?start_x:end_x,(start_y<end_y)?start_y:end_y,abs(w)+1,abs(h)+1);
|
||||
}
|
||||
@ -1555,18 +1683,20 @@ void Draw_empty_rectangle(short start_x,short start_y,short end_x,short end_y,by
|
||||
}
|
||||
|
||||
// On trace le rectangle:
|
||||
|
||||
Init_permanent_draw();
|
||||
|
||||
for (x_pos=start_x;x_pos<=end_x;x_pos++)
|
||||
Display_paintbrush(x_pos,start_y,color,0);
|
||||
{
|
||||
Pixel_figure_permanent(x_pos,start_y,color);
|
||||
Pixel_figure_permanent(x_pos, end_y,color);
|
||||
}
|
||||
|
||||
for (y_pos=start_y+1;y_pos<end_y;y_pos++)
|
||||
{
|
||||
Display_paintbrush(start_x,y_pos,color,0);
|
||||
Display_paintbrush( end_x,y_pos,color,0);
|
||||
Pixel_figure_permanent(start_x,y_pos,color);
|
||||
Pixel_figure_permanent( end_x,y_pos,color);
|
||||
}
|
||||
|
||||
for (x_pos=start_x;x_pos<=end_x;x_pos++)
|
||||
Display_paintbrush(x_pos, end_y,color,0);
|
||||
|
||||
#if defined(__macosx__) || defined(__FreeBSD__)
|
||||
Update_part_of_screen(start_x,end_x,end_x-start_x,end_y-start_y);
|
||||
#endif
|
||||
@ -1670,6 +1800,7 @@ void Draw_curve_permanent(short x1, short y1,
|
||||
byte color)
|
||||
{
|
||||
Pixel_figure=Pixel_figure_permanent;
|
||||
Init_permanent_draw();
|
||||
Draw_curve_general(x1,y1,x2,y2,x3,y3,x4,y4,color);
|
||||
}
|
||||
|
||||
@ -2685,3 +2816,41 @@ byte Effect_smooth(word x,word y,__attribute__((unused)) byte color)
|
||||
Read_pixel_from_current_screen(x,y); // C'est bien l'écran courant et pas
|
||||
// l'écran feedback car il s'agit de ne
|
||||
} // pas modifier l'écran courant.
|
||||
|
||||
void Horizontal_grid_line(word x_pos,word y_pos,word width)
|
||||
{
|
||||
int x;
|
||||
|
||||
for (x=!(x_pos&1);x<width;x+=2)
|
||||
Pixel(x_pos+x, y_pos, *((y_pos-1)*Pixel_height*VIDEO_LINE_WIDTH+x_pos*Pixel_width+Screen_pixels+x*Pixel_width)^Config.Grid_XOR_color);
|
||||
}
|
||||
|
||||
void Vertical_grid_line(word x_pos,word y_pos,word height)
|
||||
{
|
||||
int y;
|
||||
|
||||
for (y=!(y_pos&1);y<height;y+=2)
|
||||
Pixel(x_pos, y_pos+y, *(Screen_pixels+(x_pos*Pixel_width-1)+(y_pos*Pixel_height+y*Pixel_height)*VIDEO_LINE_WIDTH)^Config.Grid_XOR_color);
|
||||
}
|
||||
|
||||
// Tile Grid
|
||||
void Redraw_grid(short x, short y, unsigned short w, unsigned short h)
|
||||
{
|
||||
int row, col;
|
||||
if (!Show_grid)
|
||||
return;
|
||||
|
||||
row=y+((Snap_height*1000-(y-0)/Main_magnifier_factor-Main_magnifier_offset_Y+Snap_offset_Y-1)%Snap_height)*Main_magnifier_factor+Main_magnifier_factor-1;
|
||||
while (row < y+h)
|
||||
{
|
||||
Horizontal_grid_line(x, row, w);
|
||||
row+= Snap_height*Main_magnifier_factor;
|
||||
}
|
||||
|
||||
col=x+((Snap_width*1000-(x-Main_X_zoom)/Main_magnifier_factor-Main_magnifier_offset_X+Snap_offset_X-1)%Snap_width)*Main_magnifier_factor+Main_magnifier_factor-1;
|
||||
while (col < x+w)
|
||||
{
|
||||
Vertical_grid_line(col, y, h);
|
||||
col+= Snap_width*Main_magnifier_factor;
|
||||
}
|
||||
}
|
||||
6
graph.h
@ -66,9 +66,9 @@ void Draw_empty_ellipse_preview (short center_x,short center_y,short horizontal
|
||||
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_45_degrees(short ax, short ay, short* bx, short* by);
|
||||
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_permanet (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);
|
||||
@ -108,3 +108,5 @@ void Remap_picture(void);
|
||||
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);
|
||||
|
||||
43
help.c
@ -119,7 +119,7 @@ void Window_set_shortcut(int action_id)
|
||||
while (Ordering[order_index]!=action_id)
|
||||
{
|
||||
order_index++;
|
||||
if (order_index>=134)
|
||||
if (order_index>=NB_SHORTCUTS)
|
||||
{
|
||||
Error(0);
|
||||
return;
|
||||
@ -130,7 +130,7 @@ void Window_set_shortcut(int action_id)
|
||||
while (ConfigKey[config_index].Number!=order_index)
|
||||
{
|
||||
config_index++;
|
||||
if (config_index>=134)
|
||||
if (config_index>=NB_SHORTCUTS)
|
||||
{
|
||||
Error(0);
|
||||
return;
|
||||
@ -278,7 +278,21 @@ void Display_help(void)
|
||||
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);
|
||||
@ -309,27 +323,27 @@ void Display_help(void)
|
||||
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é
|
||||
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]);
|
||||
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]);
|
||||
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é
|
||||
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]);
|
||||
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]);
|
||||
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]);
|
||||
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]);
|
||||
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
|
||||
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++)
|
||||
@ -571,11 +585,12 @@ void Window_help(int section, const char *sub_section)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (Is_shortcut(Key,0x100+BUTTON_HELP))
|
||||
clicked_button=1;
|
||||
}
|
||||
while ((clicked_button!=1) && (Key!=SDLK_RETURN));
|
||||
|
||||
if(Key==SDLK_RETURN) Key=0;
|
||||
Key=0;
|
||||
Close_window();
|
||||
Unselect_button(BUTTON_HELP);
|
||||
Display_cursor();
|
||||
@ -684,6 +699,8 @@ void Button_Stats(void)
|
||||
do
|
||||
{
|
||||
clicked_button=Window_clicked_button();
|
||||
if (Is_shortcut(Key,0x200+BUTTON_HELP))
|
||||
clicked_button=1;
|
||||
}
|
||||
while ( (clicked_button!=1) && (Key!=SDLK_RETURN) );
|
||||
|
||||
|
||||
96
help.h
@ -1,48 +1,48 @@
|
||||
/* 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
|
||||
|
||||
/* 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
|
||||
|
||||
|
||||
4885
helpfile.h
75
init.h
@ -1,32 +1,43 @@
|
||||
/* 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.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Load_graphics(const char * skin_file);
|
||||
void Init_buttons(void);
|
||||
void Init_operations(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);
|
||||
/* 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 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);
|
||||
|
||||
137
input.c
@ -31,6 +31,15 @@
|
||||
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;
|
||||
@ -39,10 +48,12 @@ 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;
|
||||
short Mouse_count; // Number of mouse movements received in the current Get_input()
|
||||
int Mouse_moved; ///< Boolean, Set to true if any cursor movement occurs.
|
||||
|
||||
word Input_new_mouse_X;
|
||||
word Input_new_mouse_Y;
|
||||
@ -71,7 +82,7 @@ short Joybutton_right_click=0; // Button number that serves as right-click
|
||||
|
||||
int Is_shortcut(word Key, word function)
|
||||
{
|
||||
if (Key == 0)
|
||||
if (Key == 0 || function == 0xFFFF)
|
||||
return 0;
|
||||
|
||||
if (function & 0x100)
|
||||
@ -101,19 +112,20 @@ int Is_shortcut(word Key, word function)
|
||||
int Move_cursor_with_constraints()
|
||||
{
|
||||
int feedback=0;
|
||||
byte bl=0;//BL va indiquer si on doit corriger la position du curseur
|
||||
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;
|
||||
bl=1;
|
||||
mouse_blocked=1;
|
||||
}
|
||||
if (Input_new_mouse_X>=Screen_width)
|
||||
{
|
||||
Input_new_mouse_X=Screen_width-1;
|
||||
bl=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
|
||||
@ -125,7 +137,7 @@ int Move_cursor_with_constraints()
|
||||
if(Menu_Y<=Input_new_mouse_Y)
|
||||
{
|
||||
//On bloque le curseur en fin d'image
|
||||
bl++;
|
||||
mouse_blocked=1;
|
||||
Input_new_mouse_Y=Menu_Y-1; //La ligne !!au-dessus!! du menu
|
||||
}
|
||||
|
||||
@ -135,7 +147,7 @@ int Move_cursor_with_constraints()
|
||||
{
|
||||
if(Input_new_mouse_X>=Main_separator_position)
|
||||
{
|
||||
bl++;
|
||||
mouse_blocked=1;
|
||||
Input_new_mouse_X=Main_separator_position-1;
|
||||
}
|
||||
}
|
||||
@ -143,7 +155,7 @@ int Move_cursor_with_constraints()
|
||||
{
|
||||
if(Input_new_mouse_X<Main_X_zoom)
|
||||
{
|
||||
bl++;
|
||||
mouse_blocked=1;
|
||||
Input_new_mouse_X=Main_X_zoom;
|
||||
}
|
||||
}
|
||||
@ -153,25 +165,36 @@ int Move_cursor_with_constraints()
|
||||
(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;
|
||||
Hide_cursor(); // On efface le curseur AVANT de le déplacer...
|
||||
{
|
||||
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;
|
||||
if (bl)
|
||||
Set_mouse_position();
|
||||
}
|
||||
Mouse_K=Input_new_mouse_K;
|
||||
Compute_paintbrush_coordinates();
|
||||
Display_cursor();
|
||||
|
||||
Mouse_count++;
|
||||
if (Mouse_count>Config.Mouse_merge_movement)
|
||||
feedback=1;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -296,6 +319,7 @@ int Handle_mouse_release(SDL_MouseButtonEvent event)
|
||||
Input_new_mouse_K &= ~2;
|
||||
break;
|
||||
}
|
||||
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
|
||||
@ -327,14 +351,16 @@ int Handle_key_press(SDL_KeyboardEvent event)
|
||||
Directional_right=1;
|
||||
return 0;
|
||||
}
|
||||
else if(Is_shortcut(Key,SPECIAL_CLICK_LEFT))
|
||||
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))
|
||||
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();
|
||||
}
|
||||
|
||||
@ -344,44 +370,60 @@ int Handle_key_press(SDL_KeyboardEvent event)
|
||||
|
||||
int Release_control(int key_code, int modifier)
|
||||
{
|
||||
int need_feedback = 0;
|
||||
|
||||
if(key_code == (Config_Key[SPECIAL_MOUSE_UP][0]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_UP][0]&modifier) ||
|
||||
key_code == (Config_Key[SPECIAL_MOUSE_UP][1]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_UP][1]&modifier))
|
||||
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 == (Config_Key[SPECIAL_MOUSE_DOWN][0]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_DOWN][0]&modifier) ||
|
||||
key_code == (Config_Key[SPECIAL_MOUSE_DOWN][1]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_DOWN][1]&modifier))
|
||||
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 == (Config_Key[SPECIAL_MOUSE_LEFT][0]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_LEFT][0]&modifier) ||
|
||||
key_code == (Config_Key[SPECIAL_MOUSE_LEFT][1]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_LEFT][1]&modifier))
|
||||
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 == (Config_Key[SPECIAL_MOUSE_RIGHT][0]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_RIGHT][0]&modifier) ||
|
||||
key_code == (Config_Key[SPECIAL_MOUSE_RIGHT][1]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_RIGHT][1]&modifier))
|
||||
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 == (Config_Key[SPECIAL_CLICK_LEFT][0]&0x0FFF) || (Config_Key[SPECIAL_CLICK_LEFT][0]&modifier) ||
|
||||
key_code == (Config_Key[SPECIAL_CLICK_LEFT][1]&0x0FFF) || (Config_Key[SPECIAL_CLICK_LEFT][1]&modifier))
|
||||
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))
|
||||
{
|
||||
Input_new_mouse_K &= ~1;
|
||||
return Move_cursor_with_constraints();
|
||||
if (Directional_click & 1)
|
||||
{
|
||||
Directional_click &= ~1;
|
||||
Input_new_mouse_K &= ~1;
|
||||
return Move_cursor_with_constraints() || need_feedback;
|
||||
}
|
||||
}
|
||||
if(key_code == (Config_Key[SPECIAL_CLICK_RIGHT][0]&0x0FFF) || (Config_Key[SPECIAL_CLICK_RIGHT][0]&modifier) ||
|
||||
key_code == (Config_Key[SPECIAL_CLICK_RIGHT][1]&0x0FFF) || (Config_Key[SPECIAL_CLICK_RIGHT][1]&modifier))
|
||||
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))
|
||||
{
|
||||
Input_new_mouse_K &= ~2;
|
||||
return Move_cursor_with_constraints();
|
||||
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 0;
|
||||
return need_feedback;
|
||||
}
|
||||
|
||||
|
||||
@ -614,10 +656,12 @@ 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_count=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
|
||||
@ -734,11 +778,20 @@ int Get_input(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Vidage de toute mise à jour de l'affichage à l'écran qui serait encore en attente.
|
||||
// (c'est fait ici car on est sur que cette function est apellée partout ou on a besoin d'interragir avec l'utilisateur)
|
||||
// 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 user_feedback_required;
|
||||
|
||||
return (Mouse_moved!=0) || user_feedback_required;
|
||||
}
|
||||
|
||||
void Adjust_mouse_sensitivity(word fullscreen)
|
||||
|
||||
14
input.h
@ -40,3 +40,17 @@ int Is_shortcut(word Key, word function);
|
||||
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;
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
;Name and file
|
||||
Name "Grafx2"
|
||||
OutFile "grafx2-2.0-svn853-win32.exe"
|
||||
OutFile "grafx2-2.1.1026.win32.exe"
|
||||
|
||||
;Default installation folder
|
||||
InstallDir "$PROGRAMFILES\Grafx2"
|
||||
@ -60,7 +60,7 @@ Section "Grafx2" SecProgram
|
||||
SetOutPath "$INSTDIR"
|
||||
;ADD YOUR OWN FILES HERE...
|
||||
File ..\grafx2.exe
|
||||
File ..\src-svn853.tgz
|
||||
File ..\src-2.1.1026.tgz
|
||||
File ..\gfx2.gif
|
||||
File ..\gfx2def.ini
|
||||
File ..\SDL_image.dll
|
||||
@ -70,7 +70,10 @@ Section "Grafx2" SecProgram
|
||||
File ..\zlib1.dll
|
||||
File ..\libpng13.dll
|
||||
SetOutPath "$INSTDIR\skins"
|
||||
File ..\skins\base.gif
|
||||
File ..\skins\font_Classic.png
|
||||
File ..\skins\font_Fun.png
|
||||
File ..\skins\skin_classic.png
|
||||
File ..\skins\skin_modern.png
|
||||
SetOutPath "$INSTDIR\doc"
|
||||
File ..\doc\README.txt
|
||||
File ..\doc\COMPILING.txt
|
||||
@ -97,7 +100,7 @@ Section "Grafx2" SecProgram
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Grafx2-SDL" \
|
||||
"URLInfoAbout" "http://grafx2.googlecode.com"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Grafx2-SDL" \
|
||||
"DisplayVersion" "2.0 final"
|
||||
"DisplayVersion" "2.1.1026"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Grafx2-SDL" \
|
||||
"NoModify" 1
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Grafx2-SDL" \
|
||||
@ -139,7 +142,7 @@ Section "un.SecProgram"
|
||||
|
||||
;ADD YOUR OWN FILES HERE...
|
||||
Delete "$INSTDIR\grafx2.exe"
|
||||
Delete "$INSTDIR\src-svn853.tgz"
|
||||
Delete "$INSTDIR\src-2.1.1026.tgz"
|
||||
Delete "$INSTDIR\gfx2.gif"
|
||||
Delete "$INSTDIR\gfx2def.ini"
|
||||
Delete "$INSTDIR\SDL_image.dll"
|
||||
@ -159,7 +162,10 @@ Section "un.SecProgram"
|
||||
Delete "$INSTDIR\fonts\8pxfont.png"
|
||||
Delete "$INSTDIR\fonts\Tuffy.ttf"
|
||||
RMDir "$INSTDIR\fonts"
|
||||
Delete "$INSTDIR\skins\base.gif"
|
||||
Delete "$INSTDIR\skins\font_Classic.png"
|
||||
Delete "$INSTDIR\skins\font_Fun.png"
|
||||
Delete "$INSTDIR\skins\skin_classic.png"
|
||||
Delete "$INSTDIR\skins\skin_modern.png"
|
||||
RMDir "$INSTDIR\skins"
|
||||
|
||||
Delete "$INSTDIR\Uninstall.exe"
|
||||
|
||||
10
io.c
@ -243,16 +243,16 @@ int File_length_file(FILE * file)
|
||||
void For_each_file(const char * directory_name, void Callback(const char *))
|
||||
{
|
||||
// Pour scan de répertoire
|
||||
DIR* Repertoire_Courant; //Répertoire courant
|
||||
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);
|
||||
Repertoire_Courant=opendir(directory_name);
|
||||
if(Repertoire_Courant == NULL) return; // Répertoire invalide ...
|
||||
current_directory=opendir(directory_name);
|
||||
if(current_directory == NULL) return; // Répertoire invalide ...
|
||||
strcat(full_filename, PATH_SEPARATOR);
|
||||
filename_position = strlen(full_filename);
|
||||
while ((entry=readdir(Repertoire_Courant)))
|
||||
while ((entry=readdir(current_directory)))
|
||||
{
|
||||
struct stat Infos_enreg;
|
||||
strcpy(&full_filename[filename_position], entry->d_name);
|
||||
@ -262,6 +262,6 @@ void For_each_file(const char * directory_name, void Callback(const char *))
|
||||
Callback(full_filename);
|
||||
}
|
||||
}
|
||||
closedir(Repertoire_Courant);
|
||||
closedir(current_directory);
|
||||
}
|
||||
|
||||
|
||||
1300
keyboard.c
150
keyboard.h
@ -1,75 +1,75 @@
|
||||
/* 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);
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
1099
loadsave.c
117
loadsave.h
@ -1,57 +1,60 @@
|
||||
/* 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.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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);
|
||||
|
||||
void Get_full_filename(char * filename, byte is_colorix_format);
|
||||
|
||||
///
|
||||
/// High-level picture loading function.
|
||||
/// Handles loading an image or a brush, or previewing only.
|
||||
/// @param image true if the fileselector is the one for loading images (not brush)
|
||||
void Load_image(byte image);
|
||||
///
|
||||
/// High-level picture saving function.
|
||||
/// @param image true if the image should be saved (instead of the brush)
|
||||
void Save_image(byte image);
|
||||
|
||||
/// Data for an image file format.
|
||||
typedef struct {
|
||||
char *Extension; ///< Three-letter file extension
|
||||
Func_action Test; ///< Function which tests if the file is of this format
|
||||
Func_action Load; ///< Function which loads an image of this format
|
||||
Func_action Save; ///< Function which saves an image of this format
|
||||
byte Backup_done; ///< Boolean, true if this format saves all the image, and considers it backed up. Set false for formats which only save the palette.
|
||||
byte Comment; ///< This file format allows a text comment
|
||||
} T_Format;
|
||||
|
||||
/// Array of the known file formats
|
||||
extern T_Format File_formats[NB_KNOWN_FORMATS];
|
||||
|
||||
///
|
||||
/// Function which attempts to save backups of the images (main and spare),
|
||||
/// called in case of SIGSEGV.
|
||||
void Image_emergency_backup(void);
|
||||
/* 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.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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);
|
||||
|
||||
void Get_full_filename(char * filename, byte is_colorix_format);
|
||||
|
||||
///
|
||||
/// High-level picture loading function.
|
||||
/// Handles loading an image or a brush, or previewing only.
|
||||
/// @param image true if the fileselector is the one for loading images (not brush)
|
||||
void Load_image(byte image);
|
||||
///
|
||||
/// High-level picture saving function.
|
||||
/// @param image true if the image should be saved (instead of the brush)
|
||||
void Save_image(byte image);
|
||||
|
||||
/// Data for an image file format.
|
||||
typedef struct {
|
||||
char *Extension; ///< Three-letter file extension
|
||||
Func_action Test; ///< Function which tests if the file is of this format
|
||||
Func_action Load; ///< Function which loads an image of this format
|
||||
Func_action Save; ///< Function which saves an image of this format
|
||||
byte Backup_done; ///< Boolean, true if this format saves all the image, and considers it backed up. Set false for formats which only save the palette.
|
||||
byte Comment; ///< This file format allows a text comment
|
||||
} T_Format;
|
||||
|
||||
/// Array of the known file formats
|
||||
extern T_Format File_formats[NB_KNOWN_FORMATS];
|
||||
|
||||
///
|
||||
/// Function which attempts to save backups of the images (main and spare),
|
||||
/// called in case of SIGSEGV.
|
||||
void Image_emergency_backup(void);
|
||||
|
||||
/// Pixel ratio of last loaded image: one of :PIXEL_SIMPLE, :PIXEL_WIDE or :PIXEL_TALL
|
||||
extern enum PIXEL_RATIO Ratio_of_loaded_image;
|
||||
|
||||
83
main.c
@ -76,7 +76,7 @@
|
||||
#endif
|
||||
|
||||
// filename for the current GUI skin file.
|
||||
static char Gui_skin_file[MAX_PATH_CHARACTERS]= "skins" PATH_SEPARATOR "base.gif";
|
||||
static char Gui_skin_file[MAX_PATH_CHARACTERS];
|
||||
|
||||
//--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles ---
|
||||
void Display_syntax(void)
|
||||
@ -344,6 +344,7 @@ int Init_program(int argc,char * argv[])
|
||||
strcpy(Main_file_directory,Main_current_directory);
|
||||
strcpy(Main_filename,"NO_NAME.GIF");
|
||||
Main_fileformat=DEFAULT_FILEFORMAT;
|
||||
|
||||
// On initialise les données sur le nom de fichier de l'image de brouillon:
|
||||
strcpy(Spare_current_directory,Main_current_directory);
|
||||
strcpy(Spare_file_directory,Main_file_directory);
|
||||
@ -355,7 +356,7 @@ int Init_program(int argc,char * argv[])
|
||||
Brush_fileformat =Main_fileformat;
|
||||
|
||||
// On initialise ce qu'il faut pour que les fileselects ne plantent pas:
|
||||
Filelist=NULL; // Au début, il n'y a pas de fichiers dans la liste
|
||||
|
||||
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=0;
|
||||
@ -398,6 +399,7 @@ int Init_program(int argc,char * argv[])
|
||||
Spare_magnifier_width=0;
|
||||
Spare_magnifier_offset_X=0;
|
||||
Spare_magnifier_offset_Y=0;
|
||||
Keyboard_click_allowed = 0;
|
||||
|
||||
// SDL
|
||||
if(SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0)
|
||||
@ -406,6 +408,7 @@ int Init_program(int argc,char * argv[])
|
||||
printf("Couldn't initialize SDL.\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
Joystick = SDL_JoystickOpen(0);
|
||||
SDL_EnableKeyRepeat(250, 32);
|
||||
SDL_EnableUNICODE(SDL_ENABLE);
|
||||
@ -439,18 +442,18 @@ int Init_program(int argc,char * argv[])
|
||||
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:
|
||||
// Donnée sur la sortie du programme:
|
||||
Quit_is_required=0;
|
||||
Quitting=0;
|
||||
// Données sur l'état du menu:
|
||||
// Données sur l'état du menu:
|
||||
Pixel_in_menu=Pixel_in_toolbar;
|
||||
Menu_is_visible=1;
|
||||
// Données sur les couleurs et la palette:
|
||||
// Données sur les couleurs et la palette:
|
||||
First_color_in_palette=0;
|
||||
// Données sur le curseur:
|
||||
// Données sur le curseur:
|
||||
Cursor_shape=CURSOR_SHAPE_TARGET;
|
||||
Cursor_hidden=0;
|
||||
// Données sur le pinceau:
|
||||
// Données sur le pinceau:
|
||||
Paintbrush_X=0;
|
||||
Paintbrush_Y=0;
|
||||
Paintbrush_shape=PAINTBRUSH_SHAPE_ROUND;
|
||||
@ -510,10 +513,14 @@ int Init_program(int argc,char * argv[])
|
||||
// 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:
|
||||
@ -533,30 +540,41 @@ int Init_program(int argc,char * argv[])
|
||||
|
||||
Analyze_command_line(argc,argv);
|
||||
|
||||
// Charger les sprites et la palette
|
||||
Load_graphics(Gui_skin_file);
|
||||
|
||||
// Load sprites, palette etc.
|
||||
strcpy(Gui_skin_file,Config.Skin_file);
|
||||
Gfx = Load_graphics(Gui_skin_file);
|
||||
if (Gfx == NULL)
|
||||
{
|
||||
Gfx = Load_graphics("skin_modern.png");
|
||||
if (Gfx == NULL)
|
||||
{
|
||||
printf("%s", Gui_loading_error_message);
|
||||
Error(ERROR_GUI_MISSING);
|
||||
}
|
||||
}
|
||||
// Infos sur les trames (Sieve)
|
||||
Sieve_mode=0;
|
||||
Copy_preset_sieve(0);
|
||||
|
||||
// Transfert des valeurs du .INI qui ne changent pas dans des variables
|
||||
// plus accessibles:
|
||||
Default_palette[MC_Black]=Fav_menu_colors[0]=Config.Fav_menu_colors[0];
|
||||
Default_palette[MC_Dark] =Fav_menu_colors[1]=Config.Fav_menu_colors[1];
|
||||
Default_palette[MC_Light]=Fav_menu_colors[2]=Config.Fav_menu_colors[2];
|
||||
Default_palette[MC_White]=Fav_menu_colors[3]=Config.Fav_menu_colors[3];
|
||||
Compute_optimal_menu_colors(Default_palette);
|
||||
Gfx->Default_palette[MC_Black]=Fav_menu_colors[0]=Config.Fav_menu_colors[0];
|
||||
Gfx->Default_palette[MC_Dark] =Fav_menu_colors[1]=Config.Fav_menu_colors[1];
|
||||
Gfx->Default_palette[MC_Light]=Fav_menu_colors[2]=Config.Fav_menu_colors[2];
|
||||
Gfx->Default_palette[MC_White]=Fav_menu_colors[3]=Config.Fav_menu_colors[3];
|
||||
Compute_optimal_menu_colors(Gfx->Default_palette);
|
||||
Fore_color=MC_White;
|
||||
Back_color=MC_Black;
|
||||
|
||||
// Prise en compte de la fonte
|
||||
if (Config.Font)
|
||||
Menu_font=GFX_fun_font;
|
||||
else
|
||||
Menu_font=GFX_system_font;
|
||||
// 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,Default_palette,sizeof(T_Palette));
|
||||
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);
|
||||
@ -571,7 +589,7 @@ int Init_program(int argc,char * argv[])
|
||||
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,
|
||||
@ -672,17 +690,24 @@ void Program_shutdown(void)
|
||||
#endif
|
||||
|
||||
// On libère le buffer de gestion de lignes
|
||||
free(Horizontal_line_buffer);
|
||||
if(Horizontal_line_buffer) free(Horizontal_line_buffer);
|
||||
|
||||
// On libère le pinceau spécial
|
||||
free(Paintbrush_sprite);
|
||||
if (Paintbrush_sprite) free(Paintbrush_sprite);
|
||||
|
||||
// On libère les différents écrans virtuels et brosse:
|
||||
free(Brush);
|
||||
if(Brush) free(Brush);
|
||||
Set_number_of_backups(0);
|
||||
free(Spare_screen);
|
||||
free(Main_screen);
|
||||
if(Spare_screen) free(Spare_screen);
|
||||
if(Main_screen) free(Main_screen);
|
||||
|
||||
// Free the skin (Gui graphics) data
|
||||
if (Gfx)
|
||||
{
|
||||
free(Gfx);
|
||||
Gfx=NULL;
|
||||
}
|
||||
|
||||
// On prend bien soin de passer dans le répertoire initial:
|
||||
if (chdir(Initial_directory)!=-1)
|
||||
{
|
||||
@ -711,9 +736,9 @@ int main(int argc,char * argv[])
|
||||
int phoenix2_found=0;
|
||||
char phoenix_filename1[MAX_PATH_CHARACTERS];
|
||||
char phoenix_filename2[MAX_PATH_CHARACTERS];
|
||||
|
||||
if(!Init_program(argc,argv))
|
||||
{
|
||||
Program_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -733,6 +758,7 @@ int main(int argc,char * argv[])
|
||||
strcpy(Main_file_directory,Config_directory);
|
||||
strcpy(Main_filename,"phoenix2.img");
|
||||
chdir(Main_file_directory);
|
||||
|
||||
Button_Reload();
|
||||
Main_image_is_modified=1;
|
||||
Warning_message("Spare page recovered");
|
||||
@ -756,7 +782,6 @@ int main(int argc,char * argv[])
|
||||
{
|
||||
if (Config.Opening_message && (!File_in_command_line))
|
||||
Button_Message_initial();
|
||||
free(GFX_logo_grafx2); // Pas encore utilisé dans le About
|
||||
|
||||
if (File_in_command_line)
|
||||
{
|
||||
|
||||
301
misc.h
@ -1,150 +1,151 @@
|
||||
/* 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.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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(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 Hide_current_image(byte color);
|
||||
void Hide_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);
|
||||
void Pixel_in_current_screen (word x,word y,byte color);
|
||||
void Pixel_in_brush (word x,word y,byte color);
|
||||
byte Read_pixel_from_current_screen (word x,word y);
|
||||
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);
|
||||
|
||||
void Num2str(dword number,char * str,byte nb_char);
|
||||
|
||||
short Round(float value);
|
||||
short Round_div_max(short numerator,short divisor);
|
||||
|
||||
int Min(int a,int b);
|
||||
int Max(int a,int b);
|
||||
|
||||
char* Mode_label(int mode);
|
||||
int Convert_videomode_arg(const char *argument);
|
||||
/* 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.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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(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 Hide_current_image(byte color);
|
||||
void Hide_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_current_screen (word x,word y,byte color);
|
||||
void Pixel_in_brush (word x,word y,byte color);
|
||||
byte Read_pixel_from_current_screen (word x,word y);
|
||||
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);
|
||||
|
||||
void Num2str(dword number,char * str,byte nb_char);
|
||||
|
||||
short Round(float value);
|
||||
short Round_div_max(short numerator,short divisor);
|
||||
|
||||
int Min(int a,int b);
|
||||
int Max(int a,int b);
|
||||
|
||||
char* Mode_label(int mode);
|
||||
int Convert_videomode_arg(const char *argument);
|
||||
|
||||
1828
mountlist.c
94
mountlist.h
@ -1,47 +1,47 @@
|
||||
/* 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_
|
||||
|
||||
# include <stdbool.h>
|
||||
# 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
|
||||
/* 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_
|
||||
|
||||
# include <stdbool.h>
|
||||
# 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
|
||||
|
||||
428
op_c.h
@ -1,213 +1,215 @@
|
||||
/* 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
|
||||
{
|
||||
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é
|
||||
} 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_analyser(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
|
||||
/* 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
|
||||
|
||||
10285
operatio.c
438
operatio.h
@ -1,219 +1,219 @@
|
||||
/* 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 operations, ie all drawing tools.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// 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);
|
||||
|
||||
//////////////////////////////////////////////////// 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_4(void);
|
||||
void Scroll_0_4(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);
|
||||
|
||||
/* 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 operations, ie all drawing tools.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// 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);
|
||||
|
||||
//////////////////////////////////////////////////// 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_4(void);
|
||||
void Scroll_0_4(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);
|
||||
|
||||
|
||||
122
pages.c
@ -49,21 +49,6 @@ void Init_page(T_Page * page)
|
||||
page->File_directory[0]='\0';
|
||||
page->Filename[0]='\0';
|
||||
page->File_format=DEFAULT_FILEFORMAT;
|
||||
/*
|
||||
page->X_offset=0;
|
||||
page->Y_offset=0;
|
||||
page->old_offset_x=0;
|
||||
page->old_offset_y=0;
|
||||
page->Split=0;
|
||||
page->X_zoom=0;
|
||||
page->Separator_proportion=INITIAL_SEPARATOR_PROPORTION;
|
||||
page->Main_magnifier_mode=0;
|
||||
page->Main_magnifier_factor=DEFAULT_ZOOM_FACTOR;
|
||||
page->Main_magnifier_height=0;
|
||||
page->Main_magnifier_width=0;
|
||||
page->Main_magnifier_offset_X=0;
|
||||
page->Main_magnifier_offset_Y=0;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,35 +71,7 @@ void Download_infos_page_main(T_Page * page)
|
||||
strcpy(Main_file_directory,page->File_directory);
|
||||
strcpy(Main_filename,page->Filename);
|
||||
Main_fileformat=page->File_format;
|
||||
/*
|
||||
Main_offset_X=page->X_offset;
|
||||
Main_offset_Y=page->Y_offset;
|
||||
|
||||
// On corrige les décalages en fonction de la dimension de l'écran
|
||||
if ( (Main_offset_X>0) &&
|
||||
(Main_offset_X+Screen_width>Main_image_width) )
|
||||
Main_offset_X=Max(0,Main_image_width-Screen_width);
|
||||
if ( (Main_offset_Y>0) &&
|
||||
(Main_offset_Y+Menu_Y>Main_image_height) )
|
||||
Main_offset_Y=Max(0,Main_image_height-Menu_Y);
|
||||
|
||||
Old_main_offset_X=page->old_offset_x;
|
||||
Old_main_offset_Y=page->old_offset_y;
|
||||
Main_separator_position=page->Split;
|
||||
Main_X_zoom=page->X_zoom;
|
||||
Main_separator_proportion=page->Separator_proportion;
|
||||
Main_magnifier_mode=page->Main_magnifier_mode;
|
||||
Main_magnifier_factor=page->Main_magnifier_factor;
|
||||
Main_magnifier_height=page->Main_magnifier_height;
|
||||
Main_magnifier_width=page->Main_magnifier_width;
|
||||
Main_magnifier_offset_X=page->Main_magnifier_offset_X;
|
||||
Main_magnifier_offset_Y=page->Main_magnifier_offset_Y;
|
||||
|
||||
// Comme le facteur de zoom a des chances d'avoir changé, on appelle
|
||||
// "Change_magnifier_factor".
|
||||
for (factor_index=0; ZOOM_FACTOR[factor_index]!=Main_magnifier_factor; factor_index++);
|
||||
Change_magnifier_factor(factor_index);
|
||||
*/
|
||||
if (size_is_modified)
|
||||
{
|
||||
Main_magnifier_mode=0;
|
||||
@ -140,21 +97,6 @@ void Upload_infos_page_main(T_Page * page)
|
||||
strcpy(page->File_directory,Main_file_directory);
|
||||
strcpy(page->Filename,Main_filename);
|
||||
page->File_format=Main_fileformat;
|
||||
/*
|
||||
page->X_offset=Main_offset_X;
|
||||
page->Y_offset=Main_offset_Y;
|
||||
page->old_offset_x=Old_main_offset_X;
|
||||
page->old_offset_x=Old_main_offset_Y;
|
||||
page->Split=Main_separator_position;
|
||||
page->X_zoom=Main_X_zoom;
|
||||
page->Separator_proportion=Main_separator_proportion;
|
||||
page->Main_magnifier_mode=Main_magnifier_mode;
|
||||
page->Main_magnifier_factor=Main_magnifier_factor;
|
||||
page->Main_magnifier_height=Main_magnifier_height;
|
||||
page->Main_magnifier_width=Main_magnifier_width;
|
||||
page->Main_magnifier_offset_X=Main_magnifier_offset_X;
|
||||
page->Main_magnifier_offset_Y=Main_magnifier_offset_Y;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,21 +112,6 @@ void Download_infos_page_spare(T_Page * page)
|
||||
strcpy(Spare_file_directory,page->File_directory);
|
||||
strcpy(Spare_filename,page->Filename);
|
||||
Spare_fileformat=page->File_format;
|
||||
/*
|
||||
Spare_offset_X=page->X_offset;
|
||||
Spare_offset_Y=page->Y_offset;
|
||||
Old_spare_offset_X=page->old_offset_x;
|
||||
Old_spare_offset_Y=page->old_offset_y;
|
||||
Spare_separator_position=page->Split;
|
||||
Spare_X_zoom=page->X_zoom;
|
||||
Spare_separator_proportion=page->Separator_proportion;
|
||||
Spare_magnifier_mode=page->Main_magnifier_mode;
|
||||
Spare_magnifier_factor=page->Main_magnifier_factor;
|
||||
Spare_magnifier_height=page->Main_magnifier_height;
|
||||
Spare_magnifier_width=page->Main_magnifier_width;
|
||||
Spare_magnifier_offset_X=page->Main_magnifier_offset_X;
|
||||
Spare_magnifier_offset_Y=page->Main_magnifier_offset_Y;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,21 +127,6 @@ void Upload_infos_page_spare(T_Page * page)
|
||||
strcpy(page->File_directory,Spare_file_directory);
|
||||
strcpy(page->Filename,Spare_filename);
|
||||
page->File_format=Spare_fileformat;
|
||||
/*
|
||||
page->X_offset=Spare_offset_X;
|
||||
page->Y_offset=Spare_offset_Y;
|
||||
page->old_offset_x=Old_spare_offset_X;
|
||||
page->old_offset_y=Old_spare_offset_Y;
|
||||
page->Split=Spare_separator_position;
|
||||
page->X_zoom=Spare_X_zoom;
|
||||
page->Separator_proportion=Spare_separator_proportion;
|
||||
page->Main_magnifier_mode=Spare_magnifier_mode;
|
||||
page->Main_magnifier_factor=Spare_magnifier_factor;
|
||||
page->Main_magnifier_height=Spare_magnifier_height;
|
||||
page->Main_magnifier_width=Spare_magnifier_width;
|
||||
page->Main_magnifier_offset_X=Spare_magnifier_offset_X;
|
||||
page->Main_magnifier_offset_Y=Spare_magnifier_offset_Y;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,14 +238,14 @@ void Backward_in_list_of_pages(T_List_of_pages * list)
|
||||
{
|
||||
// Cette fonction fait l'équivalent d'un "Undo" dans la liste de pages.
|
||||
// Elle effectue une sorte de ROL (Rotation Left) sur la liste:
|
||||
// ÉÍËÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍ» |
|
||||
// º0º1³2³3³4³5³6³7³8³9³Aº |
|
||||
// ÈÍÊÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏͼ | 0=page courante
|
||||
// ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ |_ A=page la plus ancienne
|
||||
// v v v v v v v v v v v | 1=Dernière page (1er backup)
|
||||
// ÉÍËÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍ» |
|
||||
// º1º2³3³4³5³6³7³8³9³A³0º |
|
||||
// ÈÍÊÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏͼ |
|
||||
// +---+-+-+-+-+-+-+-+-+-+ |
|
||||
// ¦0¦1¦2¦3¦4¦5¦6¦7¦8¦9¦A¦ |
|
||||
// +---+-+-+-+-+-+-+-+-+-+ | 0=page courante
|
||||
// ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ |_ A=page la plus ancienne
|
||||
// v v v v v v v v v v v | 1=DerniÞre page (1er backup)
|
||||
// +---+-+-+-+-+-+-+-+-+-+ |
|
||||
// ¦1¦2¦3¦4¦5¦6¦7¦8¦9¦A¦0¦ |
|
||||
// +---+-+-+-+-+-+-+-+-+-+ |
|
||||
|
||||
// Pour simuler un véritable Undo, l'appelant doit mettre la structure
|
||||
// de page courante à jour avant l'appel, puis en réextraire les infos en
|
||||
@ -369,14 +281,14 @@ void Advance_in_list_of_pages(T_List_of_pages * list)
|
||||
{
|
||||
// Cette fonction fait l'équivalent d'un "Redo" dans la liste de pages.
|
||||
// Elle effectue une sorte de ROR (Rotation Right) sur la liste:
|
||||
// ÉÍËÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍ» |
|
||||
// º0º1³2³3³4³5³6³7³8³9³Aº |
|
||||
// ÈÍÊÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏͼ | 0=page courante
|
||||
// ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ |_ A=page la plus ancienne
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+ |
|
||||
// |0|1|2|3|4|5|6|7|8|9|A| |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+ | 0=page courante
|
||||
// | | | | | | | | | | | |_ A=page la plus ancienne
|
||||
// v v v v v v v v v v v | 1=Dernière page (1er backup)
|
||||
// ÉÍËÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍ» |
|
||||
// ºAº0³1³2³3³4³5³6³7³8³9º |
|
||||
// ÈÍÊÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏͼ |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+ |
|
||||
// |A|0|1|2|3|4|5|6|7|8|9| |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+ |
|
||||
|
||||
// Pour simuler un véritable Redo, l'appelant doit mettre la structure
|
||||
// de page courante à jour avant l'appel, puis en réextraire les infos en
|
||||
@ -1018,3 +930,7 @@ void * Borrow_memory_from_page(int size)
|
||||
// Pour que le compilateur ne dise pas qu'il manque une valeur de sortie:
|
||||
return 0;
|
||||
}
|
||||
|
||||
void End_of_modification(void)
|
||||
{
|
||||
}
|
||||
|
||||
189
pages.h
@ -1,93 +1,96 @@
|
||||
/* 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_
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////// GESTION DU BACKUP ////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///
|
||||
/// GESTION DES PAGES
|
||||
///
|
||||
|
||||
void Init_page(T_Page * page);
|
||||
void Download_infos_page_main(T_Page * page);
|
||||
void Upload_infos_page_main(T_Page * page);
|
||||
void Download_infos_page_spare(T_Page * page);
|
||||
void Upload_infos_page_spare(T_Page * page);
|
||||
void Download_infos_backup(T_List_of_pages * list);
|
||||
void Free_a_page(T_Page * page);
|
||||
void Copy_S_page(T_Page * dest,T_Page * source);
|
||||
int Size_of_a_page(T_Page * page);
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// GESTION DES LISTES DE PAGES
|
||||
///
|
||||
|
||||
void Init_list_of_pages(T_List_of_pages * list);
|
||||
int Allocate_list_of_pages(T_List_of_pages * list,int size);
|
||||
void Free_a_list_of_pages(T_List_of_pages * list);
|
||||
int Size_of_a_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);
|
||||
int New_page_is_possible(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list);
|
||||
void Free_last_page_of_list(T_List_of_pages * list);
|
||||
void Create_new_page(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list);
|
||||
void Change_page_number_of_list(T_List_of_pages * list,int number);
|
||||
void Free_page_of_a_list(T_List_of_pages * list);
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// GESTION DES BACKUPS
|
||||
///
|
||||
|
||||
int Init_all_backup_lists(int size,int width,int height);
|
||||
void Set_number_of_backups(int nb_backups);
|
||||
int Backup_with_new_dimensions(int upload,int width,int height);
|
||||
int Backup_and_resize_the_spare(int width,int height);
|
||||
void Backup(void);
|
||||
void Undo(void);
|
||||
void Redo(void);
|
||||
void Free_current_page(void);
|
||||
void Exchange_main_and_spare(void);
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// GESTION DES EMPRUNTS DE MEMOIRE DE PAGE
|
||||
///
|
||||
|
||||
int Can_borrow_memory_from_page(int size);
|
||||
void * Borrow_memory_from_page(int size);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
/* 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_
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////// BACKUP ///////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///
|
||||
/// INDIVIDUAL PAGES
|
||||
///
|
||||
|
||||
void Download_infos_page_main(T_Page * page);
|
||||
void Upload_infos_page_main(T_Page * page);
|
||||
|
||||
// private
|
||||
void Init_page(T_Page * page);
|
||||
void Download_infos_page_spare(T_Page * page);
|
||||
void Upload_infos_page_spare(T_Page * page);
|
||||
void Download_infos_backup(T_List_of_pages * list);
|
||||
void Free_a_page(T_Page * page);
|
||||
void Copy_S_page(T_Page * dest,T_Page * source);
|
||||
int Size_of_a_page(T_Page * page);
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// LISTS OF PAGES
|
||||
///
|
||||
|
||||
void Init_list_of_pages(T_List_of_pages * list);
|
||||
// private
|
||||
int Allocate_list_of_pages(T_List_of_pages * list,int size);
|
||||
void Free_a_list_of_pages(T_List_of_pages * list);
|
||||
int Size_of_a_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);
|
||||
int New_page_is_possible(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list);
|
||||
void Free_last_page_of_list(T_List_of_pages * list);
|
||||
void Create_new_page(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list);
|
||||
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 size,int width,int height);
|
||||
void Set_number_of_backups(int nb_backups);
|
||||
int Backup_with_new_dimensions(int upload,int width,int height);
|
||||
int Backup_and_resize_the_spare(int width,int height);
|
||||
void Backup(void);
|
||||
void Undo(void);
|
||||
void Redo(void);
|
||||
void Free_current_page(void); // 'Kill' button
|
||||
void Exchange_main_and_spare(void);
|
||||
void End_of_modification(void);
|
||||
|
||||
|
||||
///
|
||||
/// BORROWING MEMORY FROM PAGE
|
||||
///
|
||||
|
||||
void * Borrow_memory_from_page(int size);
|
||||
// private
|
||||
int Can_borrow_memory_from_page(int size);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
84
palette.h
@ -1,42 +1,42 @@
|
||||
/* 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);
|
||||
/* 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);
|
||||
|
||||
@ -1 +1 @@
|
||||
char Program_version[]="2.0";
|
||||
char Program_version[]="2.1";
|
||||
|
||||
1001
pxdouble.c
96
pxdouble.h
@ -1,48 +1,48 @@
|
||||
/* 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);
|
||||
/* 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);
|
||||
|
||||
96
pxquad.h
@ -1,48 +1,48 @@
|
||||
/* 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);
|
||||
/* 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);
|
||||
|
||||
945
pxsimple.c
@ -1,470 +1,475 @@
|
||||
/* 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 "pxsimple.h"
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Update_rect(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
return;
|
||||
}
|
||||
bx--;
|
||||
}while(bx!=0);
|
||||
|
||||
src+= image_width;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* 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"
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
102
pxsimple.h
@ -1,51 +1,51 @@
|
||||
/* 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);
|
||||
/* 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);
|
||||
|
||||
913
pxtall.c
@ -1,453 +1,460 @@
|
||||
/* 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 "pxtall.h"
|
||||
#include "pxsimple.h"
|
||||
|
||||
#define ZOOMX 1
|
||||
#define ZOOMY 2
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Update_rect(x_pos,y_pos,
|
||||
width*Main_magnifier_factor,end_y_pos-y_pos);
|
||||
return;
|
||||
}
|
||||
bx--;
|
||||
}while(bx!=0);
|
||||
|
||||
src+= image_width;
|
||||
}
|
||||
}
|
||||
/* 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
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
92
pxtall.h
@ -1,46 +1,46 @@
|
||||
/* 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);
|
||||
/* 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);
|
||||
|
||||
96
pxtall2.h
@ -1,48 +1,48 @@
|
||||
/* 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);
|
||||
/* 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);
|
||||
|
||||
1047
pxtriple.c
96
pxtriple.h
@ -1,48 +1,48 @@
|
||||
/* 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);
|
||||
/* 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);
|
||||
|
||||
98
pxwide.h
@ -1,49 +1,49 @@
|
||||
/* 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);
|
||||
/* 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);
|
||||
|
||||
96
pxwide2.h
@ -1,48 +1,48 @@
|
||||
/* 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);
|
||||
/* 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);
|
||||
|
||||
46
readini.c
@ -519,17 +519,10 @@ int Load_INI(T_Config * conf)
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Menu_ratio",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<0) || (values[0]>2))
|
||||
if (values[0]>2)
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Ratio=values[0];
|
||||
|
||||
if ((return_code=Load_INI_get_values (file,buffer,"Font",1,values)))
|
||||
goto Erreur_Retour;
|
||||
if ((values[0]<1) || (values[0]>2))
|
||||
goto Erreur_ERREUR_INI_CORROMPU;
|
||||
conf->Font=values[0]-1;
|
||||
|
||||
|
||||
if ((return_code=Load_INI_reach_group(file,buffer,"[FILE_SELECTOR]")))
|
||||
goto Erreur_Retour;
|
||||
|
||||
@ -788,7 +781,7 @@ int Load_INI(T_Config * conf)
|
||||
break;
|
||||
}
|
||||
conf->Palette_vertical=0;
|
||||
// Optionnel, vertical palette option (>98.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))
|
||||
@ -804,7 +797,42 @@ int Load_INI(T_Config * conf)
|
||||
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];
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
|
||||
54
readini.h
@ -1,27 +1,27 @@
|
||||
/* 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);
|
||||
/* 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);
|
||||
|
||||
703
readline.c
@ -1,350 +1,353 @@
|
||||
/* 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 "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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* 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)
|
||||
// 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)
|
||||
{
|
||||
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é
|
||||
|
||||
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);
|
||||
|
||||
// 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
|
||||
|
||||
|
||||
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))
|
||||
{
|
||||
Display_cursor();
|
||||
do
|
||||
{
|
||||
if(!Get_input()) SDL_Delay(20);
|
||||
input_key=Key_ANSI;
|
||||
} while(input_key==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;
|
||||
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"
|
||||
|
||||
// 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
|
||||
{
|
||||
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);
|
||||
}
|
||||
/* 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 "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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* 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)
|
||||
// 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)
|
||||
{
|
||||
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
|
||||
|
||||
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;
|
||||
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
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
88
readline.h
@ -1,44 +1,44 @@
|
||||
/* 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=number, 2=filename (255 editable characters)
|
||||
/// @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);
|
||||
/* 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=number, 2=filename (255 editable characters)
|
||||
/// @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);
|
||||
|
||||
23
saveini.c
@ -93,6 +93,7 @@ int Save_INI_char_in_value_alphabet(char c)
|
||||
(c<='z')
|
||||
) ||
|
||||
(c == '$') // Symbole d'hexadécimal
|
||||
|| (c== '.') // Point (dans les noms de fichiers)
|
||||
)
|
||||
return 1;
|
||||
else
|
||||
@ -475,11 +476,6 @@ int Save_INI(T_Config * conf)
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Menu_ratio",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
values[0]=(conf->Font)+1;
|
||||
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Font",1,values,0)))
|
||||
goto Erreur_Retour;
|
||||
|
||||
|
||||
if ((return_code=Save_INI_reach_group(Ancien_fichier,Nouveau_fichier,buffer,"[FILE_SELECTOR]")))
|
||||
goto Erreur_Retour;
|
||||
|
||||
@ -635,6 +631,23 @@ int Save_INI(T_Config * conf)
|
||||
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;
|
||||
|
||||
Save_INI_flush(Ancien_fichier,Nouveau_fichier,buffer);
|
||||
|
||||
|
||||
50
saveini.h
@ -1,25 +1,25 @@
|
||||
/* 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);
|
||||
/* 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);
|
||||
|
||||
@ -61,8 +61,9 @@ void Set_mode_SDL(int *width, int *height, int fullscreen)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
363
setup.c
@ -1,181 +1,182 @@
|
||||
/* 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__)
|
||||
#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 in the executable's directory
|
||||
strcpy(data_dir,program_dir);
|
||||
// Except MacOSX, here it is stored in a special folder:
|
||||
#if defined(__macosx__)
|
||||
strcat(data_dir,"Contents/Resources/");
|
||||
#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)
|
||||
{
|
||||
// MacOSX
|
||||
#if defined(__macosx__)
|
||||
strcpy(config_dir,program_dir);
|
||||
strcat(config_dir,"Contents/Resources/");
|
||||
// AmigaOS4
|
||||
#elif 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 own directory
|
||||
strcpy(config_dir, program_dir);
|
||||
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");
|
||||
#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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* 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__)
|
||||
#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 in the executable's directory
|
||||
strcpy(data_dir,program_dir);
|
||||
// Except MacOSX, here it is stored in a special folder:
|
||||
#if defined(__macosx__)
|
||||
strcat(data_dir,"Contents/Resources/");
|
||||
#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 own directory
|
||||
strcpy(config_dir, program_dir);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
108
setup.h
@ -1,54 +1,54 @@
|
||||
/* 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);
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
4
shade.c
@ -978,6 +978,8 @@ int Menu_shade(void)
|
||||
Key=0;
|
||||
Window_help(BUTTON_EFFECTS, "SHADE");
|
||||
}
|
||||
else if (Is_shortcut(Key,SPECIAL_SHADE_MENU))
|
||||
clicked_button=5;
|
||||
}
|
||||
}
|
||||
while ((clicked_button!=4) && (clicked_button!=5));
|
||||
@ -1097,6 +1099,8 @@ void Button_Quick_shade_menu(void)
|
||||
}
|
||||
if (Is_shortcut(Key,0x100+BUTTON_HELP))
|
||||
Window_help(BUTTON_EFFECTS, "QUICK SHADE");
|
||||
else if (Is_shortcut(Key,SPECIAL_QUICK_SHADE_MENU))
|
||||
clicked_button=1;
|
||||
}
|
||||
while ((clicked_button!=1) && (clicked_button!=2));
|
||||
|
||||
|
||||
64
shade.h
@ -1,32 +1,32 @@
|
||||
/* 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
|
||||
/* 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
|
||||
|
||||
BIN
skins/base.gif
|
Before Width: | Height: | Size: 21 KiB |
BIN
skins/font_Classic.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
skins/font_Fairlight.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
skins/font_Fun.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
skins/font_Melon.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
skins/ilkke.png
|
Before Width: | Height: | Size: 21 KiB |
BIN
skins/skin_classic.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
skins/skin_modern.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
777
special.c
@ -1,364 +1,413 @@
|
||||
/* 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"
|
||||
|
||||
|
||||
|
||||
//---------------------- Modifier le pinceau spécial -------------------------
|
||||
|
||||
void Set_paintbrush_size(int width, int height)
|
||||
{
|
||||
int x_pos,y_pos;
|
||||
int x,y;
|
||||
float 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=Paintbrush_offset_X+0.414213562; // [0.410..0.415[
|
||||
radius2*=radius2;
|
||||
for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
|
||||
for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
|
||||
{
|
||||
x=x_pos-Paintbrush_offset_X;
|
||||
y=y_pos-Paintbrush_offset_Y;
|
||||
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 :
|
||||
radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[
|
||||
radius2*=radius2;
|
||||
for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
|
||||
for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
|
||||
{
|
||||
x=x_pos-Paintbrush_offset_X;
|
||||
y=y_pos-Paintbrush_offset_Y;
|
||||
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (!((x_pos+y_pos)&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:
|
||||
radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[
|
||||
radius2*=radius2;
|
||||
for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
|
||||
for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
|
||||
{
|
||||
x=x_pos-Paintbrush_offset_X;
|
||||
y=y_pos-Paintbrush_offset_Y;
|
||||
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (((x*x)+(y*y)) < radius2) && (!(rand()&7)) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Smaller_paintbrush(void)
|
||||
{
|
||||
if ( (Paintbrush_shape<PAINTBRUSH_SHAPE_MISC)
|
||||
&& ( (Paintbrush_width>1)
|
||||
|| (Paintbrush_height>1) ) )
|
||||
{
|
||||
Hide_cursor();
|
||||
switch (Paintbrush_shape)
|
||||
{
|
||||
case PAINTBRUSH_SHAPE_ROUND:
|
||||
case PAINTBRUSH_SHAPE_SIEVE_ROUND:
|
||||
case PAINTBRUSH_SHAPE_CROSS:
|
||||
case PAINTBRUSH_SHAPE_PLUS:
|
||||
case PAINTBRUSH_SHAPE_DIAMOND:
|
||||
case PAINTBRUSH_SHAPE_RANDOM:
|
||||
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:
|
||||
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_ROUND:
|
||||
case PAINTBRUSH_SHAPE_SIEVE_ROUND:
|
||||
case PAINTBRUSH_SHAPE_RANDOM:
|
||||
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:
|
||||
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);
|
||||
if (Main_magnifier_mode)
|
||||
Display_all_screen();
|
||||
Display_cursor();
|
||||
}
|
||||
}
|
||||
/* 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"
|
||||
|
||||
|
||||
|
||||
//---------------------- 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);
|
||||
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);
|
||||
if (!Main_magnifier_mode)
|
||||
Select_button(BUTTON_MAGNIFIER,1);
|
||||
Display_all_screen();
|
||||
}
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
91
special.h
@ -1,43 +1,48 @@
|
||||
/* 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 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);
|
||||
/* 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 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);
|
||||
731
struct.h
@ -1,307 +1,424 @@
|
||||
/* 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__)
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include "const.h"
|
||||
|
||||
// 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
|
||||
typedef void (* Func_action) (void);
|
||||
typedef void (* Func_pixel) (word,word,byte);
|
||||
typedef byte (* Func_read) (word,word);
|
||||
typedef void (* Func_clear) (byte);
|
||||
typedef void (* Func_display) (word,word,word);
|
||||
typedef byte (* Func_effect) (word,word,byte);
|
||||
typedef void (* Func_block) (word,word,word,word,byte);
|
||||
typedef void (* Func_line_XOR) (word,word,word);
|
||||
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);
|
||||
|
||||
/// A set of RGB values.
|
||||
typedef struct
|
||||
{
|
||||
byte R; ///< Red
|
||||
byte G; ///< Green
|
||||
byte B; ///< Blue
|
||||
}__attribute__ ((__packed__)) T_Components, T_Palette[256]; ///< A complete 256-entry RGB palette (768 bytes).
|
||||
|
||||
/// 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;
|
||||
|
||||
///
|
||||
/// 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 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 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;
|
||||
|
||||
/// 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.
|
||||
} __attribute__((__packed__)) 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)
|
||||
} __attribute__((__packed__)) T_Config_header;
|
||||
|
||||
/// 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;
|
||||
|
||||
/// 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
|
||||
} __attribute__((__packed__)) T_Config_shortcut_info;
|
||||
|
||||
/// This structure holds all the settings which are saved and loaded as gfx2.ini.
|
||||
typedef struct
|
||||
{
|
||||
byte Font; ///< Boolean, true to use the "fun" font in menus, false to use the classic one.
|
||||
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_fix_factor_X; ///< Mouse correction factor in X axis.
|
||||
byte Mouse_fix_factor_Y; ///< Mouse correction factor 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)
|
||||
byte Ratio; ///< Determines the scaling of menu and windows: 0 no scaling, 1 scaling, 2 slight 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)
|
||||
} 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.
|
||||
typedef struct
|
||||
{
|
||||
byte * Image; ///< Pixel data for the image.
|
||||
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
|
||||
|
||||
} T_Page;
|
||||
|
||||
/// Collection of undo/redo steps.
|
||||
typedef struct
|
||||
{
|
||||
int List_size; /// Number of ::T_Page in the vector "Pages".
|
||||
int Nb_pages_allocated;/// Number of ::T_Page used so far in the vector "Pages".
|
||||
T_Page * Pages; /// Vector of Pages, each one being a undo/redo step.
|
||||
} T_List_of_pages;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
/* 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__)
|
||||
#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
|
||||
typedef void (* Func_action) (void);
|
||||
typedef void (* Func_pixel) (word,word,byte);
|
||||
typedef byte (* Func_read) (word,word);
|
||||
typedef void (* Func_clear) (byte);
|
||||
typedef void (* Func_display) (word,word,word);
|
||||
typedef byte (* Func_effect) (word,word,byte);
|
||||
typedef void (* Func_block) (word,word,word,word,byte);
|
||||
typedef void (* Func_line_XOR) (word,word,word);
|
||||
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);
|
||||
|
||||
/// A set of RGB values.
|
||||
typedef struct
|
||||
{
|
||||
byte R; ///< Red
|
||||
byte G; ///< Green
|
||||
byte B; ///< Blue
|
||||
}__attribute__ ((__packed__)) T_Components, T_Palette[256]; ///< A complete 256-entry RGB palette (768 bytes).
|
||||
|
||||
/// 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;
|
||||
|
||||
///
|
||||
/// 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 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;
|
||||
|
||||
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;
|
||||
|
||||
/// 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.
|
||||
} __attribute__((__packed__)) 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)
|
||||
} __attribute__((__packed__)) T_Config_header;
|
||||
|
||||
/// 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;
|
||||
|
||||
/// 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
|
||||
} __attribute__((__packed__)) T_Config_shortcut_info;
|
||||
|
||||
/// 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_fix_factor_X; ///< Mouse correction factor in X axis.
|
||||
byte Mouse_fix_factor_Y; ///< Mouse correction factor 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.
|
||||
typedef struct
|
||||
{
|
||||
byte * Image; ///< Pixel data for the image.
|
||||
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
|
||||
|
||||
} T_Page;
|
||||
|
||||
/// Collection of undo/redo steps.
|
||||
typedef struct
|
||||
{
|
||||
int List_size; ///< Number of ::T_Page in the vector "Pages".
|
||||
int Nb_pages_allocated;///< Number of ::T_Page used so far in the vector "Pages".
|
||||
T_Page * Pages; ///< Vector of Pages, each one being a undo/redo step.
|
||||
} T_List_of_pages;
|
||||
|
||||
/// 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[MENU_HEIGHT][MENU_WIDTH];
|
||||
/// 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 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;
|
||||
|
||||
|
||||
} T_Gui_skin;
|
||||
|
||||
#endif
|
||||
|
||||
108
text.h
@ -1,54 +1,54 @@
|
||||
/* 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;
|
||||
/* 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;
|
||||
|
||||
821
transform.c
@ -1,409 +1,412 @@
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2009 Yves Rizoud
|
||||
Copyright 2009 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 "global.h"
|
||||
#include "struct.h"
|
||||
#include "transform.h"
|
||||
#include "engine.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "windows.h"
|
||||
#include "input.h"
|
||||
#include "help.h"
|
||||
#include "misc.h" // Num2str
|
||||
#include "readline.h"
|
||||
#include "buttons.h" // Message_out_of_memory()
|
||||
#include "pages.h" // Backup_with_new_dimensions()
|
||||
|
||||
/// Reduces a fraction A/B to its smallest representation. ie (40,60) becomes (2/3)
|
||||
void Factorize(short *a, short *b)
|
||||
{
|
||||
// Method: brute-force.
|
||||
short factor;
|
||||
|
||||
factor=2;
|
||||
while (factor<=*a && factor<=*b)
|
||||
{
|
||||
if (((*a % factor) == 0) && ((*b % factor) == 0))
|
||||
{
|
||||
// common factor is found
|
||||
*a/=factor;
|
||||
*b/=factor;
|
||||
// restart
|
||||
factor=2;
|
||||
}
|
||||
else
|
||||
factor++;
|
||||
}
|
||||
}
|
||||
|
||||
/// Multiplies original_size by new_ratio/old_ratio, but keeps result in 1-9999 range.
|
||||
short Compute_dimension(short original_size, short new_ratio, short old_ratio)
|
||||
{
|
||||
long amount;
|
||||
amount = (long)original_size*new_ratio/old_ratio;
|
||||
if (amount>9999)
|
||||
return 9999;
|
||||
else if (amount<1)
|
||||
return 1;
|
||||
else
|
||||
return amount;
|
||||
}
|
||||
|
||||
void Button_Transform_menu(void)
|
||||
{
|
||||
enum RESIZE_UNIT {
|
||||
UNIT_PIXELS = 1,
|
||||
UNIT_PERCENT = 2,
|
||||
UNIT_RATIO = 3
|
||||
};
|
||||
|
||||
char buffer[5];
|
||||
short clicked_button;
|
||||
const char * unit_label[] = {
|
||||
"",
|
||||
"Pixels ",
|
||||
"Percent",
|
||||
"Ratio "};
|
||||
short last_unit_index = -1;
|
||||
short old_ratio_width;
|
||||
short old_ratio_height;
|
||||
short new_ratio_width;
|
||||
short new_ratio_height;
|
||||
short new_width=Main_image_width;
|
||||
short new_height=Main_image_height;
|
||||
byte need_display_size = 0;
|
||||
|
||||
// Persistent data
|
||||
static short unit_index = 1; // 1= Pixels, 2= Percent, 3=Ratio
|
||||
static short ratio_is_locked = 1; // True if X and Y resize should go together
|
||||
|
||||
T_Dropdown_button * unit_button;
|
||||
T_Special_button * input_button[4];
|
||||
short *input_value[4];
|
||||
|
||||
// Set initial ratio
|
||||
if (unit_index == UNIT_PERCENT)
|
||||
new_ratio_width=old_ratio_width=new_ratio_height=old_ratio_height=100;
|
||||
else
|
||||
new_ratio_width=old_ratio_width=new_ratio_height=old_ratio_height=1;
|
||||
|
||||
Open_window(215,165,"Picture transform");
|
||||
|
||||
Window_display_frame( 5, 15,205,91);
|
||||
Window_display_frame( 5,110, 55,49);
|
||||
Window_display_frame(64,110, 85,49);
|
||||
|
||||
Window_set_normal_button(154,140, 54,14,"Cancel",0,1,KEY_ESC); // 1
|
||||
|
||||
Print_in_window( 9,114,"Mirror",MC_Dark,MC_Light);
|
||||
Window_set_normal_button( 17,125, 27,14,"X\035" ,1,1,SDLK_x); // 2
|
||||
Window_set_normal_button( 17,140, 27,14,"Y\022" ,1,1,SDLK_y); // 3
|
||||
|
||||
Print_in_window( 84,114,"Rotate",MC_Dark,MC_Light);
|
||||
Window_set_normal_button( 69,125, 37,14,"-90°" ,0,1,SDLK_LAST); // 4
|
||||
Window_set_normal_button(107,125, 37,14,"+90°" ,0,1,SDLK_LAST); // 5
|
||||
Window_set_normal_button( 69,140, 75,14,"180°" ,0,1,SDLK_LAST); // 6
|
||||
|
||||
Print_in_window( 87, 19,"Resize",MC_Dark,MC_Light);
|
||||
Window_set_normal_button( 80, 86, 60,14,"RESIZE",1,1,SDLK_r); // 7
|
||||
Print_in_window( 51, 34,"New",MC_Dark,MC_Light);
|
||||
Print_in_window( 96, 34,"Old",MC_Dark,MC_Light);
|
||||
Print_in_window( 30, 44,"X:",MC_Dark,MC_Light);
|
||||
Print_in_window( 30, 59,"Y:",MC_Dark,MC_Light);
|
||||
Print_in_window( 80, 44,":",MC_Dark,MC_Light);
|
||||
Print_in_window( 80, 59,":",MC_Dark,MC_Light);
|
||||
Print_in_window( 44, 75,"Lock proportions",MC_Dark,MC_Light);
|
||||
|
||||
Window_set_normal_button( 28, 72, 13,13,ratio_is_locked?"X":" ",0,1,SDLK_l);// 8
|
||||
unit_button = Window_set_dropdown_button(128,50,69,11,69,unit_label[unit_index],1,0,1,LEFT_SIDE|RIGHT_SIDE);// 9
|
||||
Window_dropdown_add_item(unit_button,UNIT_PIXELS,unit_label[UNIT_PIXELS]);
|
||||
Window_dropdown_add_item(unit_button,UNIT_PERCENT,unit_label[UNIT_PERCENT]);
|
||||
Window_dropdown_add_item(unit_button,UNIT_RATIO,unit_label[UNIT_RATIO]);
|
||||
|
||||
input_button[0] = Window_set_input_button(45,43,4); // 10
|
||||
input_button[1] = Window_set_input_button(89,43,4); // 11
|
||||
input_button[2] = Window_set_input_button(45,58,4); // 12
|
||||
input_button[3] = Window_set_input_button(89,58,4); // 13
|
||||
|
||||
Update_window_area(0,0,Window_width, Window_height);
|
||||
|
||||
Display_cursor();
|
||||
|
||||
do
|
||||
{
|
||||
// Display the coordinates with the right unit
|
||||
if (last_unit_index != unit_index)
|
||||
{
|
||||
switch(unit_index)
|
||||
{
|
||||
case UNIT_PIXELS:
|
||||
default:
|
||||
input_value[0]=&new_width;
|
||||
input_value[1]=&Main_image_width; // Don't worry, it's read-only
|
||||
input_value[2]=&new_height;
|
||||
input_value[3]=&Main_image_height; // Don't worry, it's read-only
|
||||
break;
|
||||
case UNIT_PERCENT:
|
||||
case UNIT_RATIO:
|
||||
input_value[0]=&new_ratio_width;
|
||||
input_value[1]=&old_ratio_width;
|
||||
input_value[2]=&new_ratio_height;
|
||||
input_value[3]=&old_ratio_height;
|
||||
break;
|
||||
}
|
||||
need_display_size=1;
|
||||
last_unit_index=unit_index;
|
||||
}
|
||||
if (need_display_size)
|
||||
{
|
||||
short i;
|
||||
Hide_cursor();
|
||||
for (i=0;i<4;i++)
|
||||
{
|
||||
// "Old" values are not editable, unless the unit is "ratio"
|
||||
byte color = ((unit_index!=UNIT_RATIO) && (i==1 || i==3)) ? MC_Dark : MC_Black;
|
||||
Num2str(*(input_value[i]),buffer,4);
|
||||
Print_in_window_limited(input_button[i]->Pos_X+2,input_button[i]->Pos_Y+2,buffer,input_button[i]->Width/8,color,MC_Light);
|
||||
}
|
||||
Display_cursor();
|
||||
need_display_size=0;
|
||||
}
|
||||
|
||||
clicked_button=Window_clicked_button();
|
||||
|
||||
// Contextual help
|
||||
if (Is_shortcut(Key,0x100+BUTTON_HELP))
|
||||
{
|
||||
Key=0;
|
||||
Window_help(BUTTON_ADJUST, "PICTURE TRANSFORM");
|
||||
}
|
||||
else switch(clicked_button)
|
||||
{
|
||||
case 9: // Unit
|
||||
switch(Window_attribute2)
|
||||
{
|
||||
case UNIT_PIXELS:
|
||||
// Do nothing, pixel size was already computed.
|
||||
break;
|
||||
case UNIT_PERCENT:
|
||||
if (unit_index == UNIT_RATIO)
|
||||
{
|
||||
// Approximate from current ratio
|
||||
new_ratio_width = Compute_dimension(new_ratio_width,100,old_ratio_width);
|
||||
new_ratio_height = Compute_dimension(new_ratio_height,100,old_ratio_height);
|
||||
old_ratio_width = 100;
|
||||
old_ratio_height = 100;
|
||||
// Update pixel dimensions, to match percentage exactly
|
||||
new_width=Compute_dimension(Main_image_width, new_ratio_width, old_ratio_width);
|
||||
new_height=Compute_dimension(Main_image_height, new_ratio_height, old_ratio_height);
|
||||
}
|
||||
else // unit_index == UNIT_PIXELS
|
||||
{
|
||||
// Approximate from current pixel size
|
||||
new_ratio_width = new_width*100/Main_image_width;
|
||||
new_ratio_height = new_height*100/Main_image_height;
|
||||
old_ratio_width = 100;
|
||||
old_ratio_height = 100;
|
||||
}
|
||||
break;
|
||||
case UNIT_RATIO:
|
||||
if (unit_index == UNIT_PERCENT)
|
||||
{
|
||||
// Compute simplest ratio from current %
|
||||
Factorize(&new_ratio_width, &old_ratio_width);
|
||||
Factorize(&new_ratio_height, &old_ratio_height);
|
||||
}
|
||||
else // unit_index == UNIT_PIXELS
|
||||
{
|
||||
// Compute simplest ratio from current pixel size
|
||||
new_ratio_width = new_width;
|
||||
new_ratio_height = new_height;
|
||||
old_ratio_width = Main_image_width;
|
||||
old_ratio_height = Main_image_height;
|
||||
Factorize(&new_ratio_width, &old_ratio_width);
|
||||
Factorize(&new_ratio_height, &old_ratio_height);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
unit_index = Window_attribute2;
|
||||
break;
|
||||
|
||||
case 8: // Lock proportions
|
||||
ratio_is_locked = ! ratio_is_locked;
|
||||
Hide_cursor();
|
||||
Print_in_window(31,75,(ratio_is_locked)?"X":" ",MC_Black,MC_Light);
|
||||
Display_cursor();
|
||||
break;
|
||||
|
||||
case 11: // input old width
|
||||
case 13: // input old height
|
||||
// "Old" values are not editable, unless the unit is "ratio"
|
||||
if (unit_index!=UNIT_RATIO)
|
||||
break;
|
||||
case 10: // input new width
|
||||
case 12: // input new height
|
||||
Num2str(*( input_value[clicked_button-10]),buffer,4);
|
||||
Hide_cursor();
|
||||
if (Readline(input_button[clicked_button-10]->Pos_X+2,
|
||||
input_button[clicked_button-10]->Pos_Y+2,
|
||||
buffer,
|
||||
4,
|
||||
1))
|
||||
{
|
||||
// Accept entered value
|
||||
*(input_value[clicked_button-10])=atoi(buffer);
|
||||
// 0 is not acceptable size
|
||||
if (*(input_value[clicked_button-10])==0)
|
||||
{
|
||||
*(input_value[clicked_button-10])=1;
|
||||
}
|
||||
// Adapt the other coordinate if X and Y are locked
|
||||
if (ratio_is_locked)
|
||||
{
|
||||
if (clicked_button == 10 || clicked_button == 11 )
|
||||
{
|
||||
// Get Y value because X changed
|
||||
if (unit_index == UNIT_PIXELS)
|
||||
{
|
||||
new_height=Compute_dimension(Main_image_height, new_width, Main_image_width);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy the whole ratio
|
||||
new_ratio_height=new_ratio_width;
|
||||
old_ratio_height=old_ratio_width;
|
||||
}
|
||||
}
|
||||
else // (clicked_button == 12 || clicked_button == 13)
|
||||
{
|
||||
// Get X value because Y changed
|
||||
if (unit_index == UNIT_PIXELS)
|
||||
{
|
||||
new_width=Compute_dimension(Main_image_width, new_height, Main_image_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy the whole ratio
|
||||
new_ratio_width=new_ratio_height;
|
||||
old_ratio_width=old_ratio_height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Re-compute ratio from size in pixels
|
||||
if (unit_index == UNIT_PIXELS)
|
||||
{
|
||||
//new_width=(long)Main_image_width*new_ratio_width/old_ratio_width;
|
||||
//new_height=(long)Main_image_height*new_ratio_height/old_ratio_height;
|
||||
}
|
||||
else // Re-compute size in pixels from ratio
|
||||
{
|
||||
new_width=Compute_dimension(Main_image_width,new_ratio_width,old_ratio_width);
|
||||
new_height=Compute_dimension(Main_image_height,new_ratio_height,old_ratio_height);
|
||||
}
|
||||
need_display_size=1;
|
||||
}
|
||||
Display_cursor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (clicked_button<=0 || clicked_button>=8);
|
||||
|
||||
Close_window();
|
||||
|
||||
// The Scroll operation uses the same button as transformation menu.
|
||||
if (Current_operation != OPERATION_SCROLL)
|
||||
Unselect_button(BUTTON_ADJUST);
|
||||
|
||||
if (clicked_button != 1) // 1 is Cancel
|
||||
{
|
||||
short old_width;
|
||||
short old_height;
|
||||
|
||||
// Determine new image dimensions
|
||||
switch (clicked_button)
|
||||
{
|
||||
case 7 : // Resize
|
||||
// Keep new_width and new_height as entered.
|
||||
break;
|
||||
case 2 : // Flip X
|
||||
case 3 : // Flip Y
|
||||
case 6 : // 180° Rotation
|
||||
new_width=Main_image_width;
|
||||
new_height=Main_image_height;
|
||||
break;
|
||||
|
||||
case 4 : // -90° Rotation
|
||||
case 5 : // +90° Rotation
|
||||
|
||||
new_width=Main_image_height;
|
||||
new_height=Main_image_width;
|
||||
break;
|
||||
}
|
||||
// Memorize the current dimensions
|
||||
old_width=Main_image_width;
|
||||
old_height=Main_image_height;
|
||||
|
||||
// Allocate a new page
|
||||
if (Backup_with_new_dimensions(1,new_width,new_height))
|
||||
{
|
||||
// The new image is allocated, the new dimensions are already updated.
|
||||
|
||||
Main_image_is_modified=1;
|
||||
|
||||
// Process the transformation:
|
||||
switch(clicked_button)
|
||||
{
|
||||
case 2 : // Flip X
|
||||
memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height);
|
||||
Flip_X_lowlevel(Main_screen, Main_image_width, Main_image_height);
|
||||
break;
|
||||
case 3 : // Flip Y
|
||||
memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height);
|
||||
Flip_Y_lowlevel(Main_screen, Main_image_width, Main_image_height);
|
||||
break;
|
||||
case 4 : // -90° Rotation
|
||||
Rotate_270_deg_lowlevel(Screen_backup, Main_screen, old_width, old_height);
|
||||
break;
|
||||
case 5 : // +90° Rotation
|
||||
Rotate_90_deg_lowlevel(Screen_backup, Main_screen, old_width, old_height);
|
||||
break;
|
||||
case 6 : // 180° Rotation
|
||||
memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height);
|
||||
Rotate_180_deg_lowlevel(Main_screen, Main_image_width, Main_image_height);
|
||||
break;
|
||||
case 7 : // Resize
|
||||
Rescale(Screen_backup, old_width, old_height, Main_screen, Main_image_width, Main_image_height, 0, 0);
|
||||
break;
|
||||
}
|
||||
Display_all_screen();
|
||||
}
|
||||
else
|
||||
{
|
||||
Display_cursor();
|
||||
Message_out_of_memory();
|
||||
Hide_cursor();
|
||||
}
|
||||
}
|
||||
Display_cursor();
|
||||
}
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2009 Yves Rizoud
|
||||
Copyright 2009 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 "global.h"
|
||||
#include "struct.h"
|
||||
#include "transform.h"
|
||||
#include "engine.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "windows.h"
|
||||
#include "input.h"
|
||||
#include "help.h"
|
||||
#include "misc.h" // Num2str
|
||||
#include "readline.h"
|
||||
#include "buttons.h" // Message_out_of_memory()
|
||||
#include "pages.h" // Backup_with_new_dimensions()
|
||||
|
||||
/// Reduces a fraction A/B to its smallest representation. ie (40,60) becomes (2/3)
|
||||
void Factorize(short *a, short *b)
|
||||
{
|
||||
// Method: brute-force.
|
||||
short factor;
|
||||
|
||||
factor=2;
|
||||
while (factor<=*a && factor<=*b)
|
||||
{
|
||||
if (((*a % factor) == 0) && ((*b % factor) == 0))
|
||||
{
|
||||
// common factor is found
|
||||
*a/=factor;
|
||||
*b/=factor;
|
||||
// restart
|
||||
factor=2;
|
||||
}
|
||||
else
|
||||
factor++;
|
||||
}
|
||||
}
|
||||
|
||||
/// Multiplies original_size by new_ratio/old_ratio, but keeps result in 1-9999 range.
|
||||
short Compute_dimension(short original_size, short new_ratio, short old_ratio)
|
||||
{
|
||||
long amount;
|
||||
amount = (long)original_size*new_ratio/old_ratio;
|
||||
if (amount>9999)
|
||||
return 9999;
|
||||
else if (amount<1)
|
||||
return 1;
|
||||
else
|
||||
return amount;
|
||||
}
|
||||
|
||||
void Button_Transform_menu(void)
|
||||
{
|
||||
enum RESIZE_UNIT {
|
||||
UNIT_PIXELS = 1,
|
||||
UNIT_PERCENT = 2,
|
||||
UNIT_RATIO = 3
|
||||
};
|
||||
|
||||
char buffer[5];
|
||||
short clicked_button;
|
||||
const char * unit_label[] = {
|
||||
"",
|
||||
"Pixels ",
|
||||
"Percent",
|
||||
"Ratio "};
|
||||
short last_unit_index = -1;
|
||||
short old_ratio_width;
|
||||
short old_ratio_height;
|
||||
short new_ratio_width;
|
||||
short new_ratio_height;
|
||||
short new_width=Main_image_width;
|
||||
short new_height=Main_image_height;
|
||||
byte need_display_size = 0;
|
||||
|
||||
// Persistent data
|
||||
static short unit_index = 1; // 1= Pixels, 2= Percent, 3=Ratio
|
||||
static short ratio_is_locked = 1; // True if X and Y resize should go together
|
||||
|
||||
T_Dropdown_button * unit_button;
|
||||
T_Special_button * input_button[4];
|
||||
short *input_value[4];
|
||||
|
||||
// Set initial ratio
|
||||
if (unit_index == UNIT_PERCENT)
|
||||
new_ratio_width=old_ratio_width=new_ratio_height=old_ratio_height=100;
|
||||
else
|
||||
new_ratio_width=old_ratio_width=new_ratio_height=old_ratio_height=1;
|
||||
|
||||
Open_window(215,165,"Picture transform");
|
||||
|
||||
Window_display_frame( 5, 15,205,91);
|
||||
Window_display_frame( 5,110, 55,49);
|
||||
Window_display_frame(64,110, 85,49);
|
||||
|
||||
Window_set_normal_button(154,140, 54,14,"Cancel",0,1,KEY_ESC); // 1
|
||||
|
||||
Print_in_window( 9,114,"Mirror",MC_Dark,MC_Light);
|
||||
Window_set_normal_button( 17,125, 27,14,"X\035" ,1,1,SDLK_x); // 2
|
||||
Window_set_normal_button( 17,140, 27,14,"Y\022" ,1,1,SDLK_y); // 3
|
||||
|
||||
Print_in_window( 84,114,"Rotate",MC_Dark,MC_Light);
|
||||
Window_set_normal_button( 69,125, 37,14,"-90°" ,0,1,SDLK_LAST); // 4
|
||||
Window_set_normal_button(107,125, 37,14,"+90°" ,0,1,SDLK_LAST); // 5
|
||||
Window_set_normal_button( 69,140, 75,14,"180°" ,0,1,SDLK_LAST); // 6
|
||||
|
||||
Print_in_window( 87, 19,"Resize",MC_Dark,MC_Light);
|
||||
Window_set_normal_button( 80, 86, 60,14,"RESIZE",1,1,SDLK_r); // 7
|
||||
Print_in_window( 51, 34,"New",MC_Dark,MC_Light);
|
||||
Print_in_window( 96, 34,"Old",MC_Dark,MC_Light);
|
||||
Print_in_window( 30, 44,"X:",MC_Dark,MC_Light);
|
||||
Print_in_window( 30, 59,"Y:",MC_Dark,MC_Light);
|
||||
Print_in_window( 80, 44,":",MC_Dark,MC_Light);
|
||||
Print_in_window( 80, 59,":",MC_Dark,MC_Light);
|
||||
Print_in_window( 44, 75,"Lock proportions",MC_Dark,MC_Light);
|
||||
|
||||
Window_set_normal_button( 28, 72, 13,13,ratio_is_locked?"X":" ",0,1,SDLK_l);// 8
|
||||
unit_button = Window_set_dropdown_button(128,50,69,11,69,unit_label[unit_index],1,0,1,LEFT_SIDE|RIGHT_SIDE);// 9
|
||||
Window_dropdown_add_item(unit_button,UNIT_PIXELS,unit_label[UNIT_PIXELS]);
|
||||
Window_dropdown_add_item(unit_button,UNIT_PERCENT,unit_label[UNIT_PERCENT]);
|
||||
Window_dropdown_add_item(unit_button,UNIT_RATIO,unit_label[UNIT_RATIO]);
|
||||
|
||||
input_button[0] = Window_set_input_button(45,43,4); // 10
|
||||
input_button[1] = Window_set_input_button(89,43,4); // 11
|
||||
input_button[2] = Window_set_input_button(45,58,4); // 12
|
||||
input_button[3] = Window_set_input_button(89,58,4); // 13
|
||||
|
||||
Update_window_area(0,0,Window_width, Window_height);
|
||||
|
||||
Display_cursor();
|
||||
|
||||
do
|
||||
{
|
||||
// Display the coordinates with the right unit
|
||||
if (last_unit_index != unit_index)
|
||||
{
|
||||
switch(unit_index)
|
||||
{
|
||||
case UNIT_PIXELS:
|
||||
default:
|
||||
input_value[0]=&new_width;
|
||||
input_value[1]=&Main_image_width; // Don't worry, it's read-only
|
||||
input_value[2]=&new_height;
|
||||
input_value[3]=&Main_image_height; // Don't worry, it's read-only
|
||||
break;
|
||||
case UNIT_PERCENT:
|
||||
case UNIT_RATIO:
|
||||
input_value[0]=&new_ratio_width;
|
||||
input_value[1]=&old_ratio_width;
|
||||
input_value[2]=&new_ratio_height;
|
||||
input_value[3]=&old_ratio_height;
|
||||
break;
|
||||
}
|
||||
need_display_size=1;
|
||||
last_unit_index=unit_index;
|
||||
}
|
||||
if (need_display_size)
|
||||
{
|
||||
short i;
|
||||
Hide_cursor();
|
||||
for (i=0;i<4;i++)
|
||||
{
|
||||
// "Old" values are not editable, unless the unit is "ratio"
|
||||
byte color = ((unit_index!=UNIT_RATIO) && (i==1 || i==3)) ? MC_Dark : MC_Black;
|
||||
Num2str(*(input_value[i]),buffer,4);
|
||||
Print_in_window_limited(input_button[i]->Pos_X+2,input_button[i]->Pos_Y+2,buffer,input_button[i]->Width/8,color,MC_Light);
|
||||
}
|
||||
Display_cursor();
|
||||
need_display_size=0;
|
||||
}
|
||||
|
||||
clicked_button=Window_clicked_button();
|
||||
|
||||
// Contextual help
|
||||
if (Is_shortcut(Key,0x100+BUTTON_HELP))
|
||||
{
|
||||
Key=0;
|
||||
Window_help(BUTTON_ADJUST, "PICTURE TRANSFORM");
|
||||
}
|
||||
else if (Is_shortcut(Key,0x200+BUTTON_ADJUST))
|
||||
clicked_button=1;
|
||||
|
||||
else switch(clicked_button)
|
||||
{
|
||||
case 9: // Unit
|
||||
switch(Window_attribute2)
|
||||
{
|
||||
case UNIT_PIXELS:
|
||||
// Do nothing, pixel size was already computed.
|
||||
break;
|
||||
case UNIT_PERCENT:
|
||||
if (unit_index == UNIT_RATIO)
|
||||
{
|
||||
// Approximate from current ratio
|
||||
new_ratio_width = Compute_dimension(new_ratio_width,100,old_ratio_width);
|
||||
new_ratio_height = Compute_dimension(new_ratio_height,100,old_ratio_height);
|
||||
old_ratio_width = 100;
|
||||
old_ratio_height = 100;
|
||||
// Update pixel dimensions, to match percentage exactly
|
||||
new_width=Compute_dimension(Main_image_width, new_ratio_width, old_ratio_width);
|
||||
new_height=Compute_dimension(Main_image_height, new_ratio_height, old_ratio_height);
|
||||
}
|
||||
else // unit_index == UNIT_PIXELS
|
||||
{
|
||||
// Approximate from current pixel size
|
||||
new_ratio_width = new_width*100/Main_image_width;
|
||||
new_ratio_height = new_height*100/Main_image_height;
|
||||
old_ratio_width = 100;
|
||||
old_ratio_height = 100;
|
||||
}
|
||||
break;
|
||||
case UNIT_RATIO:
|
||||
if (unit_index == UNIT_PERCENT)
|
||||
{
|
||||
// Compute simplest ratio from current %
|
||||
Factorize(&new_ratio_width, &old_ratio_width);
|
||||
Factorize(&new_ratio_height, &old_ratio_height);
|
||||
}
|
||||
else // unit_index == UNIT_PIXELS
|
||||
{
|
||||
// Compute simplest ratio from current pixel size
|
||||
new_ratio_width = new_width;
|
||||
new_ratio_height = new_height;
|
||||
old_ratio_width = Main_image_width;
|
||||
old_ratio_height = Main_image_height;
|
||||
Factorize(&new_ratio_width, &old_ratio_width);
|
||||
Factorize(&new_ratio_height, &old_ratio_height);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
unit_index = Window_attribute2;
|
||||
break;
|
||||
|
||||
case 8: // Lock proportions
|
||||
ratio_is_locked = ! ratio_is_locked;
|
||||
Hide_cursor();
|
||||
Print_in_window(31,75,(ratio_is_locked)?"X":" ",MC_Black,MC_Light);
|
||||
Display_cursor();
|
||||
break;
|
||||
|
||||
case 11: // input old width
|
||||
case 13: // input old height
|
||||
// "Old" values are not editable, unless the unit is "ratio"
|
||||
if (unit_index!=UNIT_RATIO)
|
||||
break;
|
||||
case 10: // input new width
|
||||
case 12: // input new height
|
||||
Num2str(*( input_value[clicked_button-10]),buffer,4);
|
||||
Hide_cursor();
|
||||
if (Readline(input_button[clicked_button-10]->Pos_X+2,
|
||||
input_button[clicked_button-10]->Pos_Y+2,
|
||||
buffer,
|
||||
4,
|
||||
1))
|
||||
{
|
||||
// Accept entered value
|
||||
*(input_value[clicked_button-10])=atoi(buffer);
|
||||
// 0 is not acceptable size
|
||||
if (*(input_value[clicked_button-10])==0)
|
||||
{
|
||||
*(input_value[clicked_button-10])=1;
|
||||
}
|
||||
// Adapt the other coordinate if X and Y are locked
|
||||
if (ratio_is_locked)
|
||||
{
|
||||
if (clicked_button == 10 || clicked_button == 11 )
|
||||
{
|
||||
// Get Y value because X changed
|
||||
if (unit_index == UNIT_PIXELS)
|
||||
{
|
||||
new_height=Compute_dimension(Main_image_height, new_width, Main_image_width);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy the whole ratio
|
||||
new_ratio_height=new_ratio_width;
|
||||
old_ratio_height=old_ratio_width;
|
||||
}
|
||||
}
|
||||
else // (clicked_button == 12 || clicked_button == 13)
|
||||
{
|
||||
// Get X value because Y changed
|
||||
if (unit_index == UNIT_PIXELS)
|
||||
{
|
||||
new_width=Compute_dimension(Main_image_width, new_height, Main_image_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy the whole ratio
|
||||
new_ratio_width=new_ratio_height;
|
||||
old_ratio_width=old_ratio_height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Re-compute ratio from size in pixels
|
||||
if (unit_index == UNIT_PIXELS)
|
||||
{
|
||||
//new_width=(long)Main_image_width*new_ratio_width/old_ratio_width;
|
||||
//new_height=(long)Main_image_height*new_ratio_height/old_ratio_height;
|
||||
}
|
||||
else // Re-compute size in pixels from ratio
|
||||
{
|
||||
new_width=Compute_dimension(Main_image_width,new_ratio_width,old_ratio_width);
|
||||
new_height=Compute_dimension(Main_image_height,new_ratio_height,old_ratio_height);
|
||||
}
|
||||
need_display_size=1;
|
||||
}
|
||||
Display_cursor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (clicked_button<=0 || clicked_button>=8);
|
||||
|
||||
Close_window();
|
||||
|
||||
// The Scroll operation uses the same button as transformation menu.
|
||||
if (Current_operation != OPERATION_SCROLL)
|
||||
Unselect_button(BUTTON_ADJUST);
|
||||
|
||||
if (clicked_button != 1) // 1 is Cancel
|
||||
{
|
||||
short old_width;
|
||||
short old_height;
|
||||
|
||||
// Determine new image dimensions
|
||||
switch (clicked_button)
|
||||
{
|
||||
case 7 : // Resize
|
||||
// Keep new_width and new_height as entered.
|
||||
break;
|
||||
case 2 : // Flip X
|
||||
case 3 : // Flip Y
|
||||
case 6 : // 180° Rotation
|
||||
new_width=Main_image_width;
|
||||
new_height=Main_image_height;
|
||||
break;
|
||||
|
||||
case 4 : // -90° Rotation
|
||||
case 5 : // +90° Rotation
|
||||
|
||||
new_width=Main_image_height;
|
||||
new_height=Main_image_width;
|
||||
break;
|
||||
}
|
||||
// Memorize the current dimensions
|
||||
old_width=Main_image_width;
|
||||
old_height=Main_image_height;
|
||||
|
||||
// Allocate a new page
|
||||
if (Backup_with_new_dimensions(1,new_width,new_height))
|
||||
{
|
||||
// The new image is allocated, the new dimensions are already updated.
|
||||
|
||||
Main_image_is_modified=1;
|
||||
|
||||
// Process the transformation:
|
||||
switch(clicked_button)
|
||||
{
|
||||
case 2 : // Flip X
|
||||
memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height);
|
||||
Flip_X_lowlevel(Main_screen, Main_image_width, Main_image_height);
|
||||
break;
|
||||
case 3 : // Flip Y
|
||||
memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height);
|
||||
Flip_Y_lowlevel(Main_screen, Main_image_width, Main_image_height);
|
||||
break;
|
||||
case 4 : // -90° Rotation
|
||||
Rotate_270_deg_lowlevel(Screen_backup, Main_screen, old_width, old_height);
|
||||
break;
|
||||
case 5 : // +90° Rotation
|
||||
Rotate_90_deg_lowlevel(Screen_backup, Main_screen, old_width, old_height);
|
||||
break;
|
||||
case 6 : // 180° Rotation
|
||||
memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height);
|
||||
Rotate_180_deg_lowlevel(Main_screen, Main_image_width, Main_image_height);
|
||||
break;
|
||||
case 7 : // Resize
|
||||
Rescale(Screen_backup, old_width, old_height, Main_screen, Main_image_width, Main_image_height, 0, 0);
|
||||
break;
|
||||
}
|
||||
Display_all_screen();
|
||||
}
|
||||
else
|
||||
{
|
||||
Display_cursor();
|
||||
Message_out_of_memory();
|
||||
Hide_cursor();
|
||||
}
|
||||
}
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
54
transform.h
@ -1,27 +1,27 @@
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2009 Yves Rizoud
|
||||
Copyright 2009 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 transform.h
|
||||
/// Screen and functions for picture transform.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Opens and handles the Picture transform screen.
|
||||
void Button_Transform_menu(void);
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2009 Yves Rizoud
|
||||
Copyright 2009 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 transform.h
|
||||
/// Screen and functions for picture transform.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Opens and handles the Picture transform screen.
|
||||
void Button_Transform_menu(void);
|
||||
|
||||
293
windows.c
@ -32,6 +32,7 @@
|
||||
#include "misc.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "errors.h"
|
||||
#include "input.h"
|
||||
|
||||
// L'encapsulation tente une percée...ou un dernier combat.
|
||||
|
||||
@ -409,8 +410,7 @@ int Pick_color_in_palette()
|
||||
return color;
|
||||
}
|
||||
|
||||
// -- Afficher tout le menu --
|
||||
|
||||
/// Display the whole menu
|
||||
void Display_menu(void)
|
||||
{
|
||||
word x_pos;
|
||||
@ -420,17 +420,17 @@ void Display_menu(void)
|
||||
|
||||
if (Menu_is_visible)
|
||||
{
|
||||
// Affichage du sprite du menu
|
||||
// display menu sprite
|
||||
for (y_pos=0;y_pos<MENU_HEIGHT;y_pos++)
|
||||
for (x_pos=0;x_pos<MENU_WIDTH;x_pos++)
|
||||
Pixel_in_menu(x_pos,y_pos,GFX_menu_block[y_pos][x_pos]);
|
||||
// Affichage de la bande grise sous la palette
|
||||
Pixel_in_menu(x_pos,y_pos,Gfx->Menu_block[y_pos][x_pos]);
|
||||
// Grey area for filename below palette
|
||||
Block(MENU_WIDTH*Menu_factor_X,Menu_status_Y-Menu_factor_Y,Screen_width-(MENU_WIDTH*Menu_factor_X),9*Menu_factor_Y,MC_Light);
|
||||
|
||||
// Affichage de la palette
|
||||
// Display palette
|
||||
Display_menu_palette();
|
||||
|
||||
// Affichage des couleurs de travail
|
||||
// Display selected colors
|
||||
Display_foreback();
|
||||
|
||||
|
||||
@ -439,12 +439,14 @@ void Display_menu(void)
|
||||
if ((Mouse_Y<Menu_Y) && // Souris dans l'image
|
||||
( (!Main_magnifier_mode) || (Mouse_X<Main_separator_position) || (Mouse_X>=Main_X_zoom) ))
|
||||
{
|
||||
// Dans ces deux cas, on met dans la barre les XY courant, même s'il y a des chances que ça soit recouvert si la souris est sur un bouton (trop chiant à vérifier)
|
||||
// Prepare display of XY coordinates even if in some cases they will be
|
||||
// erased with some other text
|
||||
if ( (Current_operation!=OPERATION_COLORPICK)
|
||||
&& (Current_operation!=OPERATION_REPLACE) )
|
||||
Print_in_menu("X: Y: ",0);
|
||||
else
|
||||
{
|
||||
// The colorpicker display the color id between the parentheses
|
||||
Print_in_menu("X: Y: ( )",0);
|
||||
Num2str(Colorpicker_color,str,3);
|
||||
Print_in_menu(str,20);
|
||||
@ -454,7 +456,8 @@ void Display_menu(void)
|
||||
}
|
||||
Print_filename();
|
||||
}
|
||||
Update_rect(0,Menu_Y,Screen_width,MENU_HEIGHT*Menu_factor_Y); // on met toute la largur à jour, ça inclut la palette et la zone d'état avec le nom du fichier
|
||||
// Now update the area: menu height and whole screen width (including palette)
|
||||
Update_rect(0,Menu_Y,Screen_width,MENU_HEIGHT*Menu_factor_Y);
|
||||
}
|
||||
}
|
||||
|
||||
@ -834,7 +837,7 @@ byte Confirmation_box(char * message)
|
||||
|
||||
|
||||
|
||||
//---- Fenêtre avertissant de quelque chose et attendant un click sur OK -----
|
||||
/// Window that show a warning message and wait for a click on the OK button
|
||||
void Warning_message(char * message)
|
||||
{
|
||||
short clicked_button;
|
||||
@ -860,6 +863,47 @@ void Warning_message(char * message)
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
/// Window that shows a big message, and waits for a click on OK
|
||||
void Verbose_error_message(char * message)
|
||||
{
|
||||
short clicked_button;
|
||||
int line;
|
||||
int i;
|
||||
char buffer[36]; // 35 characters + \0
|
||||
|
||||
Open_window(300,160,"Error!");
|
||||
|
||||
// Word-wrap the message
|
||||
for (line=0; line < 10; line++)
|
||||
{
|
||||
for (i=0;i<35 && *message!='\0';i++)
|
||||
{
|
||||
if (*message == '\n')
|
||||
{
|
||||
message++;
|
||||
break;
|
||||
}
|
||||
buffer[i]=*message;
|
||||
message++;
|
||||
}
|
||||
buffer[i]='\0';
|
||||
Print_in_window(10,20+line*8,buffer,MC_Black,MC_Light);
|
||||
if (*message=='\0')
|
||||
break;
|
||||
}
|
||||
|
||||
Window_set_normal_button(300/2-20,160-23,40,14,"OK",1,1,SDLK_RETURN); // 1
|
||||
Update_window_area(0,0,Window_width,Window_height);
|
||||
Display_cursor();
|
||||
|
||||
do
|
||||
clicked_button=Window_clicked_button();
|
||||
while ((clicked_button<=0) && (Key!=KEY_ESC) && (Key!=SDLK_o));
|
||||
Key=0;
|
||||
|
||||
Close_window();
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
|
||||
// -- Redessiner le sprite d'un bouton dans le menu --
|
||||
@ -883,9 +927,9 @@ void Display_sprite_in_menu(int btn_number,int sprite_number)
|
||||
for (y_pos=0;y_pos<MENU_SPRITE_HEIGHT;y_pos++)
|
||||
for (x_pos=0;x_pos<MENU_SPRITE_WIDTH;x_pos++)
|
||||
{
|
||||
color=GFX_menu_sprite[sprite_number][y_pos][x_pos];
|
||||
color=Gfx->Menu_sprite[sprite_number][y_pos][x_pos];
|
||||
Pixel_in_menu(menu_x_pos+x_pos,menu_y_pos+y_pos,color);
|
||||
GFX_menu_block[menu_y_pos+y_pos][menu_x_pos+x_pos]=color;
|
||||
Gfx->Menu_block[menu_y_pos+y_pos][menu_x_pos+x_pos]=color;
|
||||
}
|
||||
Update_rect(Menu_factor_X*(Buttons_Pool[btn_number].X_offset+1),
|
||||
(Buttons_Pool[btn_number].Y_offset+1)*Menu_factor_Y+Menu_Y,
|
||||
@ -909,9 +953,9 @@ void Display_paintbrush_in_menu(void)
|
||||
for (menu_y_pos=2,y_pos=0;y_pos<MENU_SPRITE_HEIGHT;menu_y_pos++,y_pos++)
|
||||
for (menu_x_pos=1,x_pos=0;x_pos<MENU_SPRITE_WIDTH;menu_x_pos++,x_pos++)
|
||||
{
|
||||
color=GFX_menu_sprite[4][y_pos][x_pos];
|
||||
color=Gfx->Menu_sprite[4][y_pos][x_pos];
|
||||
Pixel_in_menu(menu_x_pos,menu_y_pos,color);
|
||||
GFX_menu_block[menu_y_pos][menu_x_pos]=color;
|
||||
Gfx->Menu_block[menu_y_pos][menu_x_pos]=color;
|
||||
}
|
||||
break;
|
||||
default : // Pinceau
|
||||
@ -920,7 +964,7 @@ void Display_paintbrush_in_menu(void)
|
||||
for (menu_x_pos=1,x_pos=0;x_pos<MENU_SPRITE_WIDTH;menu_x_pos++,x_pos++)
|
||||
{
|
||||
Pixel_in_menu(menu_x_pos,menu_y_pos,MC_Light);
|
||||
GFX_menu_block[menu_y_pos][menu_x_pos]=MC_Light;
|
||||
Gfx->Menu_block[menu_y_pos][menu_x_pos]=MC_Light;
|
||||
}
|
||||
// On affiche le nouveau
|
||||
menu_start_x=8-Paintbrush_offset_X;
|
||||
@ -946,7 +990,7 @@ void Display_paintbrush_in_menu(void)
|
||||
{
|
||||
color=(Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos])?MC_Black:MC_Light;
|
||||
Pixel_in_menu(menu_x_pos,menu_y_pos,color);
|
||||
GFX_menu_block[menu_y_pos][menu_x_pos]=color;
|
||||
Gfx->Menu_block[menu_y_pos][menu_x_pos]=color;
|
||||
}
|
||||
}
|
||||
Update_rect(0,Menu_Y,MENU_SPRITE_WIDTH*Menu_factor_X+3,MENU_SPRITE_HEIGHT*Menu_factor_Y+3);
|
||||
@ -973,18 +1017,18 @@ void Display_paintbrush_in_window(word x,word y,int number)
|
||||
if (y_size<1)
|
||||
y_size=1;
|
||||
|
||||
origin_x = (x + 8)*Menu_factor_X - (Preset_paintbrush_offset_X[number])*x_size+Window_pos_X;
|
||||
origin_y = (y + 8)*Menu_factor_Y - (Preset_paintbrush_offset_Y[number])*y_size+Window_pos_Y;
|
||||
origin_x = (x + 8)*Menu_factor_X - (Gfx->Preset_paintbrush_offset_X[number])*x_size+Window_pos_X;
|
||||
origin_y = (y + 8)*Menu_factor_Y - (Gfx->Preset_paintbrush_offset_Y[number])*y_size+Window_pos_Y;
|
||||
|
||||
for (window_y_pos=0,y_pos=0; y_pos<Preset_paintbrush_height[number]; window_y_pos++,y_pos++)
|
||||
for (window_x_pos=0,x_pos=0; x_pos<Preset_paintbrush_width[number]; window_x_pos++,x_pos++)
|
||||
Block(origin_x+window_x_pos*x_size,origin_y+window_y_pos*y_size,x_size,y_size,(GFX_paintbrush_sprite[number][y_pos][x_pos])?MC_Black:MC_Light);
|
||||
for (window_y_pos=0,y_pos=0; y_pos<Gfx->Preset_paintbrush_height[number]; window_y_pos++,y_pos++)
|
||||
for (window_x_pos=0,x_pos=0; x_pos<Gfx->Preset_paintbrush_width[number]; window_x_pos++,x_pos++)
|
||||
Block(origin_x+window_x_pos*x_size,origin_y+window_y_pos*y_size,x_size,y_size,(Gfx->Paintbrush_sprite[number][y_pos][x_pos])?MC_Black:MC_Light);
|
||||
// On n'utilise pas Pixel_in_window() car on ne dessine pas
|
||||
// forcément avec la même taille de pixel.
|
||||
|
||||
Update_rect( ToWinX(origin_x), ToWinY(origin_y),
|
||||
ToWinL(Preset_paintbrush_width[number]),
|
||||
ToWinH(Preset_paintbrush_height[number])
|
||||
ToWinL(Gfx->Preset_paintbrush_width[number]),
|
||||
ToWinH(Gfx->Preset_paintbrush_height[number])
|
||||
);
|
||||
}
|
||||
|
||||
@ -1041,7 +1085,7 @@ void Window_display_icon_sprite(word x_pos,word y_pos,byte type)
|
||||
|
||||
for (j=0; j<ICON_SPRITE_HEIGHT; j++)
|
||||
for (i=0; i<ICON_SPRITE_WIDTH; i++)
|
||||
Pixel_in_window(x_pos+i,y_pos+j,GFX_icon_sprite[type][j][i]);
|
||||
Pixel_in_window(x_pos+i,y_pos+j,Gfx->Icon_sprite[type][j][i]);
|
||||
Update_rect(ToWinX(x_pos),ToWinY(y_pos),ToWinL(ICON_SPRITE_WIDTH),ToWinH(ICON_SPRITE_HEIGHT));
|
||||
}
|
||||
|
||||
@ -1234,6 +1278,46 @@ void Compute_paintbrush_coordinates(void)
|
||||
Paintbrush_X=(((Paintbrush_X+(Snap_width>>1)-Snap_offset_X)/Snap_width)*Snap_width)+Snap_offset_X;
|
||||
Paintbrush_Y=(((Paintbrush_Y+(Snap_height>>1)-Snap_offset_Y)/Snap_height)*Snap_height)+Snap_offset_Y;
|
||||
}
|
||||
|
||||
// Handling the snap axis mode, when shift is pressed.
|
||||
switch (Current_operation)
|
||||
{
|
||||
// Operations that don't implement it
|
||||
case OPERATION_LINE:
|
||||
Snap_axis=0;
|
||||
break;
|
||||
// Operations that implement it
|
||||
default:
|
||||
if (Snap_axis==0 && (SDL_GetModState() & KMOD_SHIFT))
|
||||
{
|
||||
// Start "Snap axis" mode
|
||||
Snap_axis=1;
|
||||
Snap_axis_origin_X=Paintbrush_X;
|
||||
Snap_axis_origin_Y=Paintbrush_Y;
|
||||
}
|
||||
}
|
||||
|
||||
if (Snap_axis==1)
|
||||
{
|
||||
// Cursor moved
|
||||
if (Paintbrush_X != Snap_axis_origin_X || Paintbrush_Y != Snap_axis_origin_Y)
|
||||
{
|
||||
if ((Paintbrush_X-Snap_axis_origin_X)*(Paintbrush_X-Snap_axis_origin_X) >
|
||||
(Paintbrush_Y-Snap_axis_origin_Y)*(Paintbrush_Y-Snap_axis_origin_Y))
|
||||
// Displacement was bigger on X axis: lock Y
|
||||
Snap_axis=2;
|
||||
else
|
||||
Snap_axis=3;
|
||||
}
|
||||
}
|
||||
if (Snap_axis==2)
|
||||
{
|
||||
Paintbrush_Y = Snap_axis_origin_Y;
|
||||
}
|
||||
else if (Snap_axis==3)
|
||||
{
|
||||
Paintbrush_X = Snap_axis_origin_X;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1522,7 +1606,7 @@ void Display_cursor(void)
|
||||
short end_y;
|
||||
short x_pos;
|
||||
short y_pos;
|
||||
short counter_x;
|
||||
short counter_x = 0;
|
||||
short counter_y;
|
||||
int temp;
|
||||
byte color;
|
||||
@ -1567,21 +1651,23 @@ void Display_cursor(void)
|
||||
else
|
||||
{
|
||||
temp=(Config.Cursor)?CURSOR_SHAPE_THIN_TARGET:CURSOR_SHAPE_TARGET;
|
||||
start_x=Mouse_X-Cursor_offset_X[temp];
|
||||
start_y=Mouse_Y-Cursor_offset_Y[temp];
|
||||
start_x=Mouse_X-Gfx->Cursor_offset_X[temp];
|
||||
start_y=Mouse_Y-Gfx->Cursor_offset_Y[temp];
|
||||
|
||||
for (x_pos=start_x,counter_x=0;counter_x<15 && x_pos < Screen_width;x_pos++,counter_x++)
|
||||
{
|
||||
if( x_pos < 0 ) continue;
|
||||
for (y_pos=start_y,counter_y=0;counter_y<15 && y_pos < Screen_height;y_pos++,counter_y++)
|
||||
{
|
||||
if( y_pos < 0 || y_pos >= Screen_height) continue;
|
||||
color=GFX_cursor_sprite[temp][counter_y][counter_x];
|
||||
CURSOR_BACKGROUND[counter_y][counter_x]=Read_pixel(x_pos,y_pos);
|
||||
if (color!=MC_Trans)
|
||||
Pixel(x_pos,y_pos,color);
|
||||
for (y_pos=start_y,counter_y=0; counter_y<15 && y_pos < Screen_height;
|
||||
y_pos++,counter_y++)
|
||||
{
|
||||
if( y_pos < 0 ) continue;
|
||||
for (x_pos=start_x,counter_x=0;
|
||||
counter_x<15 && x_pos < Screen_width; x_pos++,counter_x++)
|
||||
{
|
||||
if( x_pos < 0 ) continue;
|
||||
color=Gfx->Cursor_sprite[temp][counter_y][counter_x];
|
||||
Cursor_background[counter_y][counter_x]=Read_pixel(x_pos,y_pos);
|
||||
if (color!=MC_Trans)
|
||||
Pixel(x_pos,y_pos,color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y);
|
||||
}
|
||||
@ -1634,25 +1720,24 @@ void Display_cursor(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG("B",0);
|
||||
temp=(Config.Cursor)?CURSOR_SHAPE_THIN_COLORPICKER:CURSOR_SHAPE_COLORPICKER;
|
||||
start_x=Mouse_X-Cursor_offset_X[temp];
|
||||
start_y=Mouse_Y-Cursor_offset_Y[temp];
|
||||
start_x=Mouse_X-Gfx->Cursor_offset_X[temp];
|
||||
start_y=Mouse_Y-Gfx->Cursor_offset_Y[temp];
|
||||
|
||||
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++)
|
||||
for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++)
|
||||
{
|
||||
if(y_pos<0) continue;
|
||||
if(y_pos>=Screen_height) break;
|
||||
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++)
|
||||
{
|
||||
if(x_pos<0) continue;
|
||||
if(x_pos>=Screen_width) break;
|
||||
for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++)
|
||||
{
|
||||
if(y_pos<0) continue;
|
||||
if(y_pos>=Screen_height) break;
|
||||
color=GFX_cursor_sprite[temp][counter_y][counter_x];
|
||||
// On sauvegarde dans CURSOR_BACKGROUND pour restaurer plus tard
|
||||
CURSOR_BACKGROUND[counter_y][counter_x]=Read_pixel(x_pos,y_pos);
|
||||
if (color!=MC_Trans)
|
||||
Pixel(x_pos,y_pos,color);
|
||||
}
|
||||
color=Gfx->Cursor_sprite[temp][counter_y][counter_x];
|
||||
// On sauvegarde dans Cursor_background pour restaurer plus tard
|
||||
Cursor_background[counter_y][counter_x]=Read_pixel(x_pos,y_pos);
|
||||
if (color!=MC_Trans)
|
||||
Pixel(x_pos,y_pos,color);
|
||||
}
|
||||
}
|
||||
Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y);
|
||||
}
|
||||
@ -1666,20 +1751,20 @@ void Display_cursor(void)
|
||||
|
||||
case CURSOR_SHAPE_ARROW :
|
||||
case CURSOR_SHAPE_HOURGLASS :
|
||||
start_x=Mouse_X-Cursor_offset_X[shape];
|
||||
start_y=Mouse_Y-Cursor_offset_Y[shape];
|
||||
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++)
|
||||
start_x=Mouse_X-Gfx->Cursor_offset_X[shape];
|
||||
start_y=Mouse_Y-Gfx->Cursor_offset_Y[shape];
|
||||
for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++)
|
||||
{
|
||||
if(x_pos<0) continue;
|
||||
if(x_pos>=Screen_width) break;
|
||||
for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++)
|
||||
{
|
||||
if(y_pos<0) continue;
|
||||
if(y_pos>=Screen_height) break;
|
||||
color=GFX_cursor_sprite[shape][counter_y][counter_x];
|
||||
// On sauvegarde dans CURSOR_BACKGROUND pour restaurer plus tard
|
||||
CURSOR_BACKGROUND[counter_y][counter_x]=Read_pixel(x_pos,y_pos);
|
||||
if (color!=MC_Trans)
|
||||
if(y_pos<0) continue;
|
||||
if(y_pos>=Screen_height) break;
|
||||
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++)
|
||||
{
|
||||
if(x_pos<0) continue;
|
||||
if(x_pos>=Screen_width) break;
|
||||
color=Gfx->Cursor_sprite[shape][counter_y][counter_x];
|
||||
// On sauvegarde dans Cursor_background pour restaurer plus tard
|
||||
Cursor_background[counter_y][counter_x]=Read_pixel(x_pos,y_pos);
|
||||
if (color!=MC_Trans)
|
||||
Pixel(x_pos,y_pos,color);
|
||||
}
|
||||
}
|
||||
@ -1826,14 +1911,11 @@ void Hide_cursor(void)
|
||||
int start_y;
|
||||
short end_x;
|
||||
short end_y;
|
||||
int x_pos;
|
||||
int x_pos = 0;
|
||||
int y_pos;
|
||||
short counter_x;
|
||||
short counter_x = 0;
|
||||
short counter_y;
|
||||
//short end_counter_x; // Position X ou s'arrête l'affichage de la brosse/pinceau
|
||||
//short end_counter_y; // Position Y ou s'arrête l'affichage de la brosse/pinceau
|
||||
int temp;
|
||||
//byte color;
|
||||
float cos_a,sin_a;
|
||||
short x1,y1,x2,y2,x3,y3,x4,y4;
|
||||
|
||||
@ -1873,17 +1955,18 @@ void Hide_cursor(void)
|
||||
else
|
||||
{
|
||||
temp=(Config.Cursor)?CURSOR_SHAPE_THIN_TARGET:CURSOR_SHAPE_TARGET;
|
||||
start_x=Mouse_X-Cursor_offset_X[temp];
|
||||
start_y=Mouse_Y-Cursor_offset_Y[temp];
|
||||
start_x=Mouse_X-Gfx->Cursor_offset_X[temp];
|
||||
start_y=Mouse_Y-Gfx->Cursor_offset_Y[temp];
|
||||
|
||||
for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++)
|
||||
{
|
||||
if(y_pos < 0) continue;
|
||||
if(y_pos>=Screen_height) break;
|
||||
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++)
|
||||
{
|
||||
if ( (x_pos<0) || (y_pos < 0)) continue;
|
||||
if(x_pos < 0) continue;
|
||||
else if (x_pos>=Screen_width) break;
|
||||
Pixel(x_pos,y_pos,CURSOR_BACKGROUND[counter_y][counter_x]);
|
||||
Pixel(x_pos,y_pos,Cursor_background[counter_y][counter_x]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1941,21 +2024,21 @@ void Hide_cursor(void)
|
||||
else
|
||||
{
|
||||
temp=(Config.Cursor)?CURSOR_SHAPE_THIN_COLORPICKER:CURSOR_SHAPE_COLORPICKER;
|
||||
start_x=Mouse_X-Cursor_offset_X[temp];
|
||||
start_y=Mouse_Y-Cursor_offset_Y[temp];
|
||||
start_x=Mouse_X-Gfx->Cursor_offset_X[temp];
|
||||
start_y=Mouse_Y-Gfx->Cursor_offset_Y[temp];
|
||||
|
||||
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++)
|
||||
for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++)
|
||||
{
|
||||
if(y_pos<0) continue;
|
||||
if(y_pos>=Screen_height) break;
|
||||
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++)
|
||||
{
|
||||
if(x_pos<0) continue;
|
||||
if(x_pos>=Screen_width) break;
|
||||
for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++)
|
||||
{
|
||||
if(y_pos<0) continue;
|
||||
if(y_pos>=Screen_height) break;
|
||||
Pixel(x_pos,y_pos,CURSOR_BACKGROUND[counter_y][counter_x]);
|
||||
}
|
||||
Pixel(x_pos,y_pos,Cursor_background[counter_y][counter_x]);
|
||||
}
|
||||
Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y);
|
||||
}
|
||||
Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y);
|
||||
}
|
||||
}
|
||||
if (!Paintbrush_hidden)
|
||||
@ -1969,18 +2052,18 @@ void Hide_cursor(void)
|
||||
|
||||
case CURSOR_SHAPE_ARROW :
|
||||
case CURSOR_SHAPE_HOURGLASS :
|
||||
start_x=Mouse_X-Cursor_offset_X[shape];
|
||||
start_y=Mouse_Y-Cursor_offset_Y[shape];
|
||||
start_x=Mouse_X-Gfx->Cursor_offset_X[shape];
|
||||
start_y=Mouse_Y-Gfx->Cursor_offset_Y[shape];
|
||||
|
||||
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++)
|
||||
for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++)
|
||||
{
|
||||
if(x_pos<0) continue;
|
||||
if(x_pos>=Screen_width) break;
|
||||
for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++)
|
||||
{
|
||||
if(y_pos<0) continue;
|
||||
if(y_pos>=Screen_height) break;
|
||||
Pixel(x_pos,y_pos,CURSOR_BACKGROUND[counter_y][counter_x]);
|
||||
if(y_pos<0) continue;
|
||||
if(y_pos>=Screen_height) break;
|
||||
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++)
|
||||
{
|
||||
if(x_pos<0) continue;
|
||||
if(x_pos>=Screen_width) break;
|
||||
Pixel(x_pos,y_pos,Cursor_background[counter_y][counter_x]);
|
||||
}
|
||||
}
|
||||
Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y);
|
||||
@ -2492,52 +2575,52 @@ void Compute_optimal_menu_colors(T_Components * palette)
|
||||
for (k=0; k<NB_CURSOR_SPRITES; k++)
|
||||
for (j=0; j<CURSOR_SPRITE_HEIGHT; j++)
|
||||
for (i=0; i<CURSOR_SPRITE_WIDTH; i++)
|
||||
Remap_pixel(&GFX_cursor_sprite[k][j][i]);
|
||||
Remap_pixel(&Gfx->Cursor_sprite[k][j][i]);
|
||||
// Le menu
|
||||
for (j=0; j<MENU_HEIGHT; j++)
|
||||
for (i=0; i<MENU_WIDTH; i++)
|
||||
Remap_pixel(&GFX_menu_block[j][i]);
|
||||
Remap_pixel(&Gfx->Menu_block[j][i]);
|
||||
// Sprites du menu
|
||||
for (k=0; k<NB_MENU_SPRITES; k++)
|
||||
for (j=0; j<MENU_SPRITE_HEIGHT; j++)
|
||||
for (i=0; i<MENU_SPRITE_WIDTH; i++)
|
||||
Remap_pixel(&GFX_menu_sprite[k][j][i]);
|
||||
Remap_pixel(&Gfx->Menu_sprite[k][j][i]);
|
||||
// Sprites d'effets
|
||||
for (k=0; k<NB_EFFECTS_SPRITES; k++)
|
||||
for (j=0; j<MENU_SPRITE_HEIGHT; j++)
|
||||
for (i=0; i<MENU_SPRITE_WIDTH; i++)
|
||||
Remap_pixel(&GFX_effect_sprite[k][j][i]);
|
||||
Remap_pixel(&Gfx->Effect_sprite[k][j][i]);
|
||||
// Fontes de l'aide
|
||||
for (k=0; k<256; k++)
|
||||
for (j=0; j<8; j++)
|
||||
for (i=0; i<6; i++)
|
||||
Remap_pixel(&GFX_help_font_norm[k][i][j]);
|
||||
Remap_pixel(&Gfx->Help_font_norm[k][i][j]);
|
||||
for (k=0; k<256; k++)
|
||||
for (j=0; j<8; j++)
|
||||
for (i=0; i<6; i++)
|
||||
Remap_pixel(&GFX_bold_font[k][i][j]);
|
||||
Remap_pixel(&Gfx->Bold_font[k][i][j]);
|
||||
for (k=0; k<64; k++)
|
||||
for (j=0; j<8; j++)
|
||||
for (i=0; i<6; i++)
|
||||
Remap_pixel(&GFX_help_font_t1[k][i][j]);
|
||||
Remap_pixel(&Gfx->Help_font_t1[k][i][j]);
|
||||
for (k=0; k<64; k++)
|
||||
for (j=0; j<8; j++)
|
||||
for (i=0; i<6; i++)
|
||||
Remap_pixel(&GFX_help_font_t2[k][i][j]);
|
||||
Remap_pixel(&Gfx->Help_font_t2[k][i][j]);
|
||||
for (k=0; k<64; k++)
|
||||
for (j=0; j<8; j++)
|
||||
for (i=0; i<6; i++)
|
||||
Remap_pixel(&GFX_help_font_t3[k][i][j]);
|
||||
Remap_pixel(&Gfx->Help_font_t3[k][i][j]);
|
||||
for (k=0; k<64; k++)
|
||||
for (j=0; j<8; j++)
|
||||
for (i=0; i<6; i++)
|
||||
Remap_pixel(&GFX_help_font_t4[k][i][j]);
|
||||
Remap_pixel(&Gfx->Help_font_t4[k][i][j]);
|
||||
|
||||
// Sprites de lecteurs (drives)
|
||||
for (k=0; k<NB_ICON_SPRITES; k++)
|
||||
for (j=0; j<ICON_SPRITE_HEIGHT; j++)
|
||||
for (i=0; i<ICON_SPRITE_WIDTH; i++)
|
||||
Remap_pixel(&GFX_icon_sprite[k][j][i]);
|
||||
Remap_pixel(&Gfx->Icon_sprite[k][j][i]);
|
||||
}
|
||||
Clear_border(MC_Black);
|
||||
}
|
||||
|
||||
@ -70,6 +70,7 @@ void Print_counter(short x,short y,const char * str,byte text_color,byte backgro
|
||||
|
||||
byte Confirmation_box(char * message);
|
||||
void Warning_message(char * message);
|
||||
void Verbose_error_message(char * message);
|
||||
|
||||
void Display_image_limits(void);
|
||||
void Display_all_screen(void);
|
||||
|
||||