use screen.h instead of sdlscreen.h, etc.

Create grafx2-win32 MSVC++ project
create keycode.h
various fixes
This commit is contained in:
Thomas Bernard
2018-05-31 12:33:26 +02:00
parent d86efa58e4
commit 77005eb780
42 changed files with 746 additions and 64 deletions

View File

@@ -33,7 +33,7 @@
#include "misc.h"
#include "errors.h"
#include "windows.h"
#include "sdlscreen.h"
#include "screen.h"
#include "brush.h"
#include "tiles.h"

View File

@@ -35,7 +35,7 @@
#include "misc.h"
#include "operatio.h"
#include "pages.h"
#include "sdlscreen.h"
#include "screen.h"
#include "windows.h"
#if defined(__VBCC__) || defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__)
@@ -961,8 +961,11 @@ void Rotate_brush_1_5(void)
// On corrige les coordonnées de la ligne si la touche shift est appuyée...
cursor_x = Paintbrush_X;
cursor_y = Paintbrush_Y;
#if defined(USE_SDL) || defined(USE_SDL2)
if(SDL_GetModState() & KMOD_SHIFT)
Clamp_coordinates_regular_angle(Brush_rotation_center_X,Brush_rotation_center_Y,&cursor_x,&cursor_y);
// TODO : portable
#endif
if ( (cursor_x!=old_x) || (cursor_y!=old_y) || (prev_state!=2) )
{
@@ -1032,8 +1035,11 @@ void Rotate_brush_0_5(void)
// On corrige les coordonnées de la ligne si la touche shift est appuyée...
cursor_x = Paintbrush_X;
cursor_y = Paintbrush_Y;
#if defined(USE_SDL) || defined(USE_SDL2)
if(SDL_GetModState() & KMOD_SHIFT)
Clamp_coordinates_regular_angle(Brush_rotation_center_X,Brush_rotation_center_Y,&cursor_x,&cursor_y);
// TODO
#endif
if ((cursor_x!=old_x) || (cursor_y!=old_y) || (prev_state!=3))
{

View File

@@ -71,7 +71,7 @@
#include "io.h"
#include "help.h"
#include "text.h"
#include "sdlscreen.h"
#include "screen.h"
#include "windows.h"
#include "brush.h"
#include "input.h"
@@ -86,7 +86,7 @@
#elif defined(__MINT__)
#include <mint/sysbind.h>
#include <dirent.h>
#elif defined(__WIN32__)
#elif defined(WIN32)
#ifndef _MSC_VER
#include <dirent.h>
#endif

View File

@@ -38,7 +38,7 @@
#include "misc.h"
#include "pages.h"
#include "readline.h"
#include "sdlscreen.h"
#include "screen.h"
#include "struct.h"
#include "windows.h"
#include "tiles.h"

View File

@@ -33,7 +33,7 @@
#include "operatio.h"
#include "shade.h"
#include "errors.h"
#include "sdlscreen.h"
#include "screen.h"
#include "windows.h"
#include "brush.h"
#include "input.h"

View File

@@ -37,7 +37,7 @@
#include "misc.h"
#include "pages.h" // Backup()
#include "readline.h"
#include "sdlscreen.h"
#include "screen.h"
#include "windows.h"
#include "palette.h"
#include "input.h" // Is_shortcut()

View File

@@ -25,7 +25,9 @@
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/
#if defined(USE_SDL) || defined(USE_SDL2)
#include <SDL_syswm.h>
#endif
#if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
#include <proto/dos.h>
@@ -61,7 +63,7 @@
#include "errors.h"
#include "io.h"
#include "windows.h"
#include "sdlscreen.h"
#include "screen.h"
#include "loadsave.h"
#include "mountlist.h"
#include "engine.h"

View File

@@ -36,7 +36,7 @@
#include "buttons.h"
#include "pages.h"
#include "errors.h"
#include "sdlscreen.h"
#include "screen.h"
#include "graph.h"
#include "misc.h"
#include "pxsimple.h"
@@ -52,6 +52,9 @@
#include "input.h"
#include "brush.h"
#include "tiles.h"
#if defined(USE_SDL) || defined(USE_SDL2)
#include "sdlscreen.h"
#endif
#if defined(__VBCC__) || defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__)
#define M_PI 3.141592653589793238462643
@@ -397,7 +400,9 @@ try_again:
if (screen_changed)
{
#if defined(USE_SDL) || defined(USE_SDL2)
Set_mode_SDL(&width, &height,fullscreen);
#endif
}
if (screen_changed || pixels_changed)

View File

@@ -52,7 +52,7 @@
#include "engine.h"
#include "helpfile.h"
#include "help.h"
#include "sdlscreen.h"
#include "screen.h"
#include "text.h"
#include "keyboard.h"
#include "windows.h"
@@ -61,6 +61,7 @@
#include "errors.h"
#include "pages.h"
#include "factory.h"
#include "keycodes.h"
extern const char Program_version[]; // generated in pversion.c
extern const char SVN_revision[]; // generated in version.c

View File

@@ -30,7 +30,7 @@
#include "global.h"
#include "keyboard.h"
#include "sdlscreen.h"
#include "screen.h"
#include "windows.h"
#include "errors.h"
#include "misc.h"

View File

@@ -37,6 +37,9 @@
/// Add 0x4000 for the Alt modifier ::MOD_ALT
/// Add 0x8000 for the "Meta" modifier ::MOD_META (On MacOS X it's the CMD key)
//////////////////////////////////////////////////////////////////////////////
#if defined(USE_SDL)
#include <SDL.h>
#endif
/*!
Convert an SDL keysym to an ANSI/ASCII character.

29
src/keycodes.h Normal file
View File

@@ -0,0 +1,29 @@
/* vim:expandtab:ts=2 sw=2:
*/
/* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2018 Thomas Bernard
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/>
*/
#ifndef KEYCODES_H_INCLUDED
#define KEYCODES_H_INCLUDED
#if defined(USE_SDL) || defined(USE_SDL2)
#include <SDL.h>
#endif
#endif

View File

@@ -19,18 +19,22 @@
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 "windows.h"
#include "engine.h"
#include "pages.h"
#include "sdlscreen.h"
#include "screen.h"
#include "input.h"
#include "help.h"
#include "misc.h"
#include "readline.h"
#include "graph.h"
#include "keycodes.h"
void Layer_activate(int layer, short side)
{
@@ -638,7 +642,7 @@ void Button_Anim_continuous_next(void)
do
{
int target_frame;
Uint32 time_now;
dword time_now;
Get_input(20);
@@ -673,7 +677,7 @@ void Button_Anim_continuous_prev(void)
do
{
int target_frame;
Uint32 time_now;
dword time_now;
Get_input(20);

View File

@@ -61,6 +61,7 @@
#if defined(USE_SDL) || defined(USE_SDL2)
#include "sdlscreen.h"
#endif
#include "screen.h"
#include "struct.h"
#include "windows.h"
#include "engine.h"

View File

@@ -58,7 +58,7 @@
#include "engine.h"
#include "pages.h"
#include "loadsave.h"
#include "sdlscreen.h"
#include "screen.h"
#include "errors.h"
#include "readini.h"
#include "saveini.h"

View File

@@ -39,14 +39,13 @@
#endif
#endif
#include "struct.h"
#include "sdlscreen.h"
#include "global.h"
#include "errors.h"
#include "buttons.h"
#include "engine.h"
#include "misc.h"
#include "keyboard.h"
#include "sdlscreen.h"
#include "screen.h"
#include "windows.h"
#include "palette.h"
#include "input.h"

View File

@@ -27,6 +27,9 @@
#ifndef MISC_H__
#define MISC_H__
/* For sprintf() used in Num2str() and Dec2str(a,b,c) */
#include <stdio.h>
#include "struct.h"
#include "global.h"

View File

@@ -38,7 +38,7 @@
#include "libraw2crtc.h"
#include "loadsave.h"
#include "misc.h"
#include "sdlscreen.h"
#include "screen.h"
#include "struct.h"
#include "windows.h"
#include "oldies.h"

View File

@@ -33,7 +33,7 @@
#include "buttons.h"
#include "pages.h"
#include "errors.h"
#include "sdlscreen.h"
#include "screen.h"
#include "brush.h"
#include "windows.h"
#include "input.h"

View File

@@ -32,7 +32,7 @@
#include "buttons.h"
#include "pages.h"
#include "help.h"
#include "sdlscreen.h"
#include "screen.h"
#include "errors.h"
#include "op_c.h"
#include "windows.h"

View File

@@ -24,7 +24,7 @@
#include <string.h>
#include <stdlib.h>
#include "global.h"
#include "sdlscreen.h"
#include "screen.h"
#include "misc.h"
#include "graph.h"
#include "pxdouble.h"

View File

@@ -24,7 +24,7 @@
#include <string.h>
#include <stdlib.h>
#include "global.h"
#include "sdlscreen.h"
#include "screen.h"
#include "misc.h"
#include "graph.h"
#include "pxquad.h"

View File

@@ -24,7 +24,7 @@
#include <string.h>
#include <stdlib.h>
#include "global.h"
#include "sdlscreen.h"
#include "screen.h"
#include "misc.h"
#include "graph.h"
#include "pxsimple.h"

View File

@@ -24,7 +24,7 @@
#include <string.h>
#include <stdlib.h>
#include "global.h"
#include "sdlscreen.h"
#include "screen.h"
#include "misc.h"
#include "graph.h"
#include "pxtall.h"

View File

@@ -24,7 +24,7 @@
#include <string.h>
#include <stdlib.h>
#include "global.h"
#include "sdlscreen.h"
#include "screen.h"
#include "misc.h"
#include "graph.h"
#include "pxtall2.h"

View File

@@ -24,7 +24,7 @@
#include <string.h>
#include <stdlib.h>
#include "global.h"
#include "sdlscreen.h"
#include "screen.h"
#include "misc.h"
#include "graph.h"
#include "pxtall3.h"

View File

@@ -24,7 +24,7 @@
#include <string.h>
#include <stdlib.h>
#include "global.h"
#include "sdlscreen.h"
#include "screen.h"
#include "misc.h"
#include "graph.h"
#include "pxtriple.h"

View File

@@ -24,7 +24,7 @@
#include <string.h>
#include <stdlib.h>
#include "global.h"
#include "sdlscreen.h"
#include "screen.h"
#include "misc.h"
#include "graph.h"
#include "pxwide.h"

View File

@@ -24,7 +24,7 @@
#include <string.h>
#include <stdlib.h>
#include "global.h"
#include "sdlscreen.h"
#include "screen.h"
#include "misc.h"
#include "graph.h"
#include "pxwide2.h"

View File

@@ -37,16 +37,19 @@
#include "misc.h"
#include "errors.h"
#include "const.h"
#include "sdlscreen.h"
#include "screen.h"
#include "readline.h"
#include "windows.h"
#include "input.h"
#include "engine.h"
#include "unicode.h"
#include "keycodes.h"
#ifdef __WIN32__
#ifdef WIN32
#include <windows.h>
#if defined(USE_SDL)
#include <SDL_syswm.h>
#endif
#elif defined __HAIKU__
#include "haiku.h"

60
src/screen.h Normal file
View File

@@ -0,0 +1,60 @@
/* vim:expandtab:ts=2 sw=2:
*/
/* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2018 Thomas Bernard
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 screen.h
/// Screen update (refresh) system
//////////////////////////////////////////////////////////////////////////////
#ifndef SCREEN_H_INCLUDED
#define SCREEN_H_INCLUDED
#include "struct.h"
#include "global.h"
byte Get_Screen_pixel(int x, int y);
void Set_Screen_pixel(int x, int y, byte value);
byte* Get_Screen_pixel_ptr(int x, int y);
void Screen_FillRect(int x, int y, int w, int h, byte color);
void Update_rect(short x, short y, unsigned short width, unsigned short height);
void Flush_update(void);
void Update_status_line(short char_pos, short width);
int SetPalette(const T_Components * colors, int firstcolor, int ncolors);
///
/// Clears the parts of screen that are outside of the editing area.
/// There is such area only if the screen mode is not a multiple of the pixel
/// size, eg: 3x3 pixels in 1024x768 leaves 1 column on the right, 0 rows on bottom.
void Clear_border(byte color);
extern volatile int Allow_colorcycling;
/// Activates or desactivates file drag-dropping in program window.
void Allow_drag_and_drop(int flag);
#endif // SCREEN_H_INCLUDED

View File

@@ -37,18 +37,6 @@ void Set_mode_SDL(int *,int *,int);
GFX2_GLOBAL SDL_Rect ** List_SDL_video_modes;
byte Get_Screen_pixel(int x, int y);
void Set_Screen_pixel(int x, int y, byte value);
byte* Get_Screen_pixel_ptr(int x, int y);
void Screen_FillRect(int x, int y, int w, int h, byte color);
void Update_rect(short x, short y, unsigned short width, unsigned short height);
void Flush_update(void);
void Update_status_line(short char_pos, short width);
///
/// Converts a SDL_Surface (indexed colors or RGB) into an array of bytes
/// (indexed colors).
@@ -66,17 +54,4 @@ void Set_SDL_pixel_8(SDL_Surface *bmp, int x, int y, byte color);
/// Convert a SDL Palette to a grafx2 palette
void Get_SDL_Palette(const SDL_Palette * sdl_palette, T_Palette palette);
int SetPalette(const T_Components * colors, int firstcolor, int ncolors);
///
/// Clears the parts of screen that are outside of the editing area.
/// There is such area only if the screen mode is not a multiple of the pixel
/// size, eg: 3x3 pixels in 1024x768 leaves 1 column on the right, 0 rows on bottom.
void Clear_border(byte color);
extern volatile int Allow_colorcycling;
/// Activates or desactivates file drag-dropping in program window.
void Allow_drag_and_drop(int flag);
#endif // SDLSCREEN_H_INCLUDED
#endif // SDLSCREEN_H_INCLUDED

View File

@@ -28,10 +28,11 @@
#include "misc.h"
#include "readline.h"
#include "help.h"
#include "sdlscreen.h"
#include "screen.h"
#include "windows.h"
#include "input.h"
#include "shade.h"
#include "keycodes.h"
void Button_Shade_mode(void)
{

View File

@@ -58,12 +58,14 @@
#endif
#endif
#if defined(USE_SDL) || defined(USE_SDL2)
#include <SDL_image.h>
#include "SFont.h"
#include "sdlscreen.h"
#endif
#include "struct.h"
#include "global.h"
#include "sdlscreen.h"
#include "io.h"
#include "errors.h"
#include "windows.h"
@@ -541,7 +543,7 @@ byte *Render_text_TTF(const char *str, int font_number, int size, int antialias,
}
#endif
#if defined(USE_SDL) || defined(USE_SDL2)
byte *Render_text_SFont(const char *str, int font_number, int *width, int *height, T_Palette palette)
{
SFont_Font *font;
@@ -673,6 +675,7 @@ byte *Render_text_SFont(const char *str, int font_number, int *width, int *heigh
return new_brush;
}
#endif
// Crée une brosse à partir des paramètres de texte demandés.
// Si cela réussit, la fonction place les dimensions dans width et height,
@@ -704,8 +707,9 @@ byte *Render_text(const char *str, int font_number, int size, int antialias, int
}
else
{
#if defined(USE_SDL) || defined(USE_SDL2)
return Render_text_SFont(str, font_number, width, height, palette);
#endif
}
}

View File

@@ -19,10 +19,13 @@
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/
#include <stdlib.h>
#include <string.h>
#include "struct.h"
#include "global.h"
#include "graph.h"
#include "sdlscreen.h"
#include "screen.h"
#include "engine.h"
#include "windows.h"
#include "input.h"

View File

@@ -26,7 +26,7 @@
#include "struct.h"
#include "transform.h"
#include "engine.h"
#include "sdlscreen.h"
#include "screen.h"
#include "windows.h"
#include "input.h"
#include "help.h"

View File

@@ -46,9 +46,10 @@
#include "misc.h"
#include "op_c.h"
#include "readline.h"
#include "sdlscreen.h"
#include "screen.h"
#include "palette.h"
#include "unicode.h"
#include "keycodes.h"
T_Toolbar_button Buttons_Pool[NB_BUTTONS];
T_Menu_Bar Menu_bars[MENUBAR_COUNT] =