GrafX2 2.9.3227
The ultimate 256-color painting program
|
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include "gfx2mem.h"
#include "buttons.h"
#include "const.h"
#include "errors.h"
#include "global.h"
#include "graph.h"
#include "init.h"
#include "io.h"
#include "factory.h"
#include "help.h"
#include "hotkeys.h"
#include "keyboard.h"
#include "loadsave.h"
#include "misc.h"
#include "mountlist.h"
#include "operatio.h"
#include "palette.h"
#include "screen.h"
#include "setup.h"
#include "struct.h"
#include "transform.h"
#include "windows.h"
#include "layers.h"
#include "special.h"
#include "gfx2surface.h"
#include "init_buttons.h"
Macros | |
#define | HIDE_CURSOR 1 |
#define | FAST_MOUSE 1 |
Functions | |
static byte | GUI_seek_down (T_GFX2_Surface *gui, int *start_x, int *start_y, byte neutral_color, char *section) |
static byte | GUI_seek_right (T_GFX2_Surface *gui, int *start_x, int start_y, byte neutral_color, char *section) |
static byte | Read_GUI_block (T_Gui_skin *gfx, T_GFX2_Surface *gui, int start_x, int start_y, void *dest, int width, int height, char *section, int type) |
static byte | Read_GUI_pattern (T_Gui_skin *gfx, T_GFX2_Surface *gui, int start_x, int start_y, word *dest, char *section) |
void | Center_GUI_cursor (T_Gui_skin *gfx, byte *cursor_buffer, int cursor_number) |
static byte | Parse_skin (T_GFX2_Surface *gui, T_Gui_skin *gfx) |
T_Gui_skin * | Load_graphics (const char *skin_file, T_Gradient_array *gradients) |
static byte * | Parse_font (T_GFX2_Surface *image, int is_main) |
byte * | Load_font (const char *font_name, int is_main) |
Loads a 8x8 monochrome font, the kind used in all menus and screens. More... | |
static void | Load_Unicode_font (const char *fullname, const char *filename) |
void | Load_Unicode_fonts (void) |
Load fonts for additional Unicode characters. More... | |
static void | Do_nothing (int btn) |
static void | Init_button (byte btn_number, const char *tooltip, word x_offset, word y_offset, word width, word height, byte shape, Func_btn_action left_action, Func_btn_action right_action, byte left_instant, byte right_instant, Func_btn_action unselect_action, byte family) |
void | Init_buttons (void) |
void | Init_operation (byte operation_number, byte mouse_button, byte stack_index, Func_action action, byte hide_cursor, byte fast_mouse) |
void | Init_operations (void) |
static void | Set_video_mode (short width, short height, byte mode, word fullscreen) |
int | Compare_video_modes (const void *p1, const void *p2) |
void | Set_all_video_modes (void) |
int | Load_CFG (int reload_all) |
int | Save_CFG (void) |
void | Set_config_defaults (void) |
void | Init_sighandler (void) |
void | Init_brush_container (void) |
void | Set_current_skin (const char *skinfile, T_Gui_skin *gfx) |
void | Init_paintbrush (int index, int width, int height, byte shape, const char *bitmap) |
void | Init_paintbrushes (void) |
Variables | |
char | Gui_loading_error_message [256] |
#define HIDE_CURSOR 1 |
#define FAST_MOUSE 1 |
|
static |
References Get_GFX2_Surface_pixel(), and Gui_loading_error_message.
Referenced by Parse_skin().
|
static |
References Get_GFX2_Surface_pixel(), and Gui_loading_error_message.
Referenced by Parse_skin().
|
static |
References T_Gui_skin::Color, T_Gui_skin::Color_trans, Get_GFX2_Surface_pixel(), Gui_loading_error_message, T_GFX2_Surface::h, and T_GFX2_Surface::w.
Referenced by Parse_skin(), and Read_GUI_pattern().
|
static |
References Read_GUI_block().
Referenced by Parse_skin().
void Center_GUI_cursor | ( | T_Gui_skin * | gfx, |
byte * | cursor_buffer, | ||
int | cursor_number | ||
) |
References T_Gui_skin::Color_trans, T_Gui_skin::Cursor_offset_X, T_Gui_skin::Cursor_offset_Y, T_Gui_skin::Cursor_sprite, CURSOR_SPRITE_HEIGHT, and CURSOR_SPRITE_WIDTH.
Referenced by Parse_skin().
|
static |
References T_Gui_skin::Animbar_block, T_Gui_skin::Bold_font, Center_GUI_cursor(), T_Gui_skin::Color, T_Gui_skin::Color_trans, T_Gui_skin::Default_palette, T_Gui_skin::Effect_sprite, EFFECT_SPRITE_HEIGHT, EFFECT_SPRITE_WIDTH, Get_GFX2_Surface_pixel(), Gui_loading_error_message, GUI_seek_down(), GUI_seek_right(), T_GFX2_Surface::h, T_Menu_Bar::Height, T_Gui_skin::Help_font_norm, T_Gui_skin::Help_font_t1, T_Gui_skin::Help_font_t2, T_Gui_skin::Help_font_t3, T_Gui_skin::Help_font_t4, T_Gui_skin::Icon_sprite, ICON_SPRITE_HEIGHT, ICON_SPRITE_WIDTH, T_Gui_skin::Layer_sprite, LAYER_SPRITE_HEIGHT, LAYER_SPRITE_WIDTH, T_Gui_skin::Layerbar_block, T_Gui_skin::Logo_grafx2, Menu_bars, T_Gui_skin::Menu_block, T_Gui_skin::Menu_sprite, MENU_SPRITE_HEIGHT, MENU_SPRITE_WIDTH, MENUBAR_ANIMATION, MENUBAR_LAYERS, MENUBAR_STATUS, MENUBAR_TOOLS, NB_CURSOR_SPRITES, NB_EFFECTS_SPRITES, NB_ICON_SPRITES, NB_MENU_SPRITES, NB_PRESET_SIEVE, T_GFX2_Surface::palette, T_Gui_skin::Preview, Read_GUI_block(), Read_GUI_pattern(), T_Gui_skin::Sieve_pattern, T_Menu_Bar::Skin_width, T_Gui_skin::Statusbar_block, and T_GFX2_Surface::w.
Referenced by Load_graphics().
T_Gui_skin * Load_graphics | ( | const char * | skin_file, |
T_Gradient_array * | gradients | ||
) |
References Data_directory, Free_GFX2_Surface(), GFX2_malloc, Gui_loading_error_message, Load_surface(), NULL, Parse_skin(), and SKINS_SUBDIRECTORY.
Referenced by Button_Skins(), and Init_program().
|
static |
References Get_GFX2_Surface_pixel(), GFX2_malloc, Gui_loading_error_message, T_GFX2_Surface::h, NULL, and T_GFX2_Surface::w.
Referenced by Load_font().
byte * Load_font | ( | const char * | font_name, |
int | is_main | ||
) |
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.
References Data_directory, Free_GFX2_Surface(), GFX2_malloc, Gui_loading_error_message, Load_surface(), NULL, Parse_font(), and SKINS_SUBDIRECTORY.
Referenced by Button_Skins(), Init_program(), and Load_Unicode_font().
|
static |
References T_Unicode_Font::FirstChar, T_Unicode_Font::FontData, GFX2_malloc, T_Unicode_Font::LastChar, Load_font(), T_Unicode_Font::Next, NULL, Unicode_fonts, and Warning_with_format().
Referenced by Load_Unicode_fonts().
void Load_Unicode_fonts | ( | void | ) |
Load fonts for additional Unicode characters.
References Data_directory, Filepath_append_to_dir(), For_each_file(), Load_Unicode_font(), and SKINS_SUBDIRECTORY.
Referenced by Init_program().
|
static |
Referenced by Init_buttons().
|
static |
References Buttons_Pool, T_Toolbar_button::Family, T_Toolbar_button::Height, T_Toolbar_button::Icon, T_Toolbar_button::Left_action, T_Toolbar_button::Left_instant, T_Toolbar_button::Pressed, T_Toolbar_button::Right_action, T_Toolbar_button::Right_instant, T_Toolbar_button::Shape, T_Toolbar_button::Tooltip, T_Toolbar_button::Unselect_action, T_Toolbar_button::Width, T_Toolbar_button::X_offset, and T_Toolbar_button::Y_offset.
Referenced by Init_buttons().
void Init_buttons | ( | void | ) |
References BUTTON_SHAPE_RECTANGLE, Buttons_Pool, Do_nothing(), Init_button(), T_Toolbar_button::Left_shortcut, NB_BUTTONS, and T_Toolbar_button::Right_shortcut.
Referenced by Init_program().
void Init_operation | ( | byte | operation_number, |
byte | mouse_button, | ||
byte | stack_index, | ||
Func_action | action, | ||
byte | hide_cursor, | ||
byte | fast_mouse | ||
) |
References Operation.
Referenced by Init_operations().
void Init_operations | ( | void | ) |
References Airbrush_0_2(), Airbrush_12_2(), Airbrush_1_0(), Airbrush_2_0(), Brush_0_5(), Brush_12_0(), Brush_12_5(), Centered_lines_0_3(), Centered_lines_0_7(), Centered_lines_12_0(), Centered_lines_12_3(), Centered_lines_12_7(), Circle_12_0(), Circle_12_5(), Colorpicker_0_1(), Colorpicker_12_0(), Colorpicker_1_1(), Colorpicker_2_1(), Colorpicker_color, Curve_34_points_1_0(), Curve_34_points_1_5(), Curve_34_points_2_0(), Curve_34_points_2_5(), Curve_3_points_0_11(), Curve_3_points_0_5(), Curve_3_points_12_11(), Curve_4_points_0_5(), Curve_4_points_1_9(), Curve_4_points_2_9(), Distort_brush_0_0(), Distort_brush_0_9(), Distort_brush_1_0(), Distort_brush_1_8(), Distort_brush_1_9(), Distort_brush_2_0(), Distort_brush_2_8(), Ellipse_12_0(), Ellipse_12_5(), Empty_circle_0_5(), Empty_ellipse_0_5(), Empty_rectangle_0_5(), FAST_MOUSE, Fill_1_0(), Fill_2_0(), Filled_circle_0_5(), Filled_contour_0_8(), Filled_ellipse_0_5(), Filled_polyform_0_8(), Filled_polyform_12_0(), Filled_polyform_12_8(), Filled_rectangle_0_5(), Freehand_mode12_0_2(), Freehand_mode1_1_0(), Freehand_mode1_1_2(), Freehand_mode1_2_0(), Freehand_mode1_2_2(), Freehand_mode2_1_0(), Freehand_mode2_1_2(), Freehand_mode2_2_0(), Freehand_mode2_2_2(), Freehand_mode3_0_1(), Freehand_mode3_1_0(), Freehand_Mode3_2_0(), Grad_circle_0_6(), Grad_circle_12_0(), Grad_circle_12_6(), Grad_circle_12_8(), Grad_circle_or_ellipse_0_8(), Grad_ellipse_0_6(), Grad_ellipse_12_0(), Grad_ellipse_12_6(), Grad_ellipse_12_8(), Grad_rectangle_0_5(), Grad_rectangle_0_7(), Grad_rectangle_0_9(), Grad_rectangle_12_0(), Grad_rectangle_12_5(), Grad_rectangle_12_7(), Grad_rectangle_12_9(), HIDE_CURSOR, Init_operation(), K_line_0_6(), K_line_12_0(), K_line_12_6(), K_line_12_7(), Line_0_5(), Line_12_0(), Line_12_5(), Magnifier_12_0(), NB_OPERATIONS, OPERATION_3_POINTS_CURVE, OPERATION_4_POINTS_CURVE, OPERATION_AIRBRUSH, OPERATION_CENTERED_LINES, OPERATION_COLORPICK, OPERATION_CONTINUOUS_DRAW, OPERATION_DISCONTINUOUS_DRAW, OPERATION_DISTORT_BRUSH, OPERATION_EMPTY_CIRCLE_CRN, OPERATION_EMPTY_CIRCLE_CTR, OPERATION_EMPTY_ELLIPSE_CRN, OPERATION_EMPTY_ELLIPSE_CTR, OPERATION_EMPTY_RECTANGLE, OPERATION_FILL, OPERATION_FILLED_CIRCLE_CRN, OPERATION_FILLED_CIRCLE_CTR, OPERATION_FILLED_CONTOUR, OPERATION_FILLED_ELLIPSE_CRN, OPERATION_FILLED_ELLIPSE_CTR, OPERATION_FILLED_POLYFORM, OPERATION_FILLED_RECTANGLE, OPERATION_GRAB_BRUSH, OPERATION_GRAD_CIRCLE_CRN, OPERATION_GRAD_CIRCLE_CTR, OPERATION_GRAD_ELLIPSE_CRN, OPERATION_GRAD_ELLIPSE_CTR, OPERATION_GRAD_RECTANGLE, OPERATION_K_LINE, OPERATION_LINE, OPERATION_MAGNIFY, OPERATION_PAN_VIEW, OPERATION_POINT_DRAW, OPERATION_POLYBRUSH, OPERATION_POLYFILL, OPERATION_POLYFORM, OPERATION_POLYGON, OPERATION_REPLACE, OPERATION_RMB_COLORPICK, OPERATION_ROTATE_BRUSH, OPERATION_SCROLL, OPERATION_STACK_SIZE, OPERATION_STRETCH_BRUSH, Pan_view_0_0(), Pan_view_0_2(), Pan_view_12_0(), Pan_view_12_2(), Polybrush_12_8(), Polyfill_0_8(), Polyfill_12_0(), Polyfill_12_8(), Polyfill_12_9(), Polyform_0_8(), Polyform_12_0(), Polyform_12_8(), Polygon_12_0(), Polygon_12_9(), Print_coordinates(), Rectangle_12_0(), Rectangle_12_5(), Replace_1_0(), Replace_2_0(), Rightclick_colorpick_0_1(), Rotate_brush_0_5(), Rotate_brush_12_0(), Rotate_brush_1_5(), Rotate_brush_2_5(), Scroll_0_5(), Scroll_12_0(), Scroll_12_5(), Stretch_brush_0_7(), Stretch_brush_12_0(), Stretch_brush_1_7(), and Stretch_brush_2_7().
Referenced by Init_program().
References T_Video_mode::Fullscreen, GFX2_ERROR, GFX2_Log(), T_Video_mode::Height, MAX_VIDEO_MODES, T_Video_mode::Mode, mode, Nb_video_modes, T_Video_mode::State, Video_mode, and T_Video_mode::Width.
Referenced by Set_all_video_modes().
int Compare_video_modes | ( | const void * | p1, |
const void * | p2 | ||
) |
References T_Video_mode::Height, and T_Video_mode::Width.
Referenced by Set_all_video_modes().
void Set_all_video_modes | ( | void | ) |
References Compare_video_modes(), T_Video_mode::Fullscreen, GFX2_GetScreenSize(), T_Video_mode::Height, T_Video_mode::Mode, mode, Nb_video_modes, NULL, Set_video_mode(), T_Video_mode::State, Video_mode, and T_Video_mode::Width.
Referenced by Init_program().
int Load_CFG | ( | int | reload_all | ) |
References BETA1, T_Config_header::Beta1, BETA2, T_Config_header::Beta2, Bound_script, Buttons_Pool, CHUNK_BRUSH, CHUNK_EXCLUDE_COLORS, CHUNK_GRADIENTS, CHUNK_GRID, CHUNK_KEYS, CHUNK_MASK, CHUNK_QUICK_SHADE, CHUNK_SCRIPTS, CHUNK_SHADE, CHUNK_SMOOTH, CHUNK_STENCIL, CHUNK_VIDEO_MODES, Config_directory, CONFIG_FILENAME, Config_Key, ConfigKey, ERROR_CFG_CORRUPTED, ERROR_CFG_MISSING, ERROR_CFG_OLD, ERROR_MEMORY, Exclude_color, File_length_file(), Filepath_append_to_dir(), GFX2_DEBUG, GFX2_Log(), GFX2_malloc, T_Video_mode::Height, T_Config_video_mode::Height, T_Paintbrush::Height, T_Config_shortcut_info::Key, T_Config_shortcut_info::Key2, Key_for_scancode(), T_Toolbar_button::Left_shortcut, Mask_table, NB_PAINTBRUSH_SPRITES, NB_SHORTCUTS, Nb_video_modes, NULL, T_Config_chunk::Number, T_Config_shortcut_info::Number, Ordering, Paintbrush, Quick_shade_loop, Quick_shade_step, Read_byte(), Read_bytes(), Read_word_le(), T_Toolbar_button::Right_shortcut, Shade_current, Shade_list, Shade_list_to_lookup_tables(), Shade_table_left, Shade_table_right, T_Config_header::Signature, T_Config_chunk::Size, Smooth_matrix, Snap_height, Snap_offset_X, Snap_offset_Y, Snap_width, T_Paintbrush::Sprite, T_Config_video_mode::State, Stencil, VERSION1, T_Config_header::Version1, VERSION2, T_Config_header::Version2, Video_mode, T_Config_video_mode::Width, and T_Paintbrush::Width.
Referenced by Init_program(), and Settings_load_config().
int Save_CFG | ( | void | ) |
References BETA1, T_Config_header::Beta1, BETA2, T_Config_header::Beta2, Bound_script, Buttons_Pool, CHUNK_BRUSH, CHUNK_EXCLUDE_COLORS, CHUNK_GRID, CHUNK_KEYS, CHUNK_MASK, CHUNK_QUICK_SHADE, CHUNK_SCRIPTS, CHUNK_SHADE, CHUNK_SMOOTH, CHUNK_STENCIL, CHUNK_VIDEO_MODES, Config_directory, CONFIG_FILENAME, Config_Key, ConfigKey, ERROR_SAVING_CFG, Exclude_color, Filepath_append_to_dir(), GFX2_DEBUG, GFX2_ERROR, GFX2_Log(), GFX2_WARNING, T_Video_mode::Height, T_Config_video_mode::Height, T_Paintbrush::Height, T_Config_shortcut_info::Key, T_Config_shortcut_info::Key2, T_Toolbar_button::Left_shortcut, Mask_table, NB_PAINTBRUSH_SPRITES, NB_SHORTCUTS, Nb_video_modes, NULL, T_Key_config::Number, T_Config_chunk::Number, T_Config_shortcut_info::Number, Ordering, Paintbrush, Quick_shade_loop, Quick_shade_step, T_Toolbar_button::Right_shortcut, Shade_current, Shade_list, T_Config_header::Signature, T_Config_chunk::Size, Smooth_matrix, Snap_height, Snap_offset_X, Snap_offset_Y, Snap_width, T_Video_mode::State, T_Config_video_mode::State, Stencil, VERSION1, T_Config_header::Version1, VERSION2, T_Config_header::Version2, Video_mode, T_Video_mode::Width, T_Config_video_mode::Width, T_Paintbrush::Width, Write_byte(), Write_bytes(), and Write_word_le().
Referenced by Program_shutdown(), and Settings_save_config().
void Set_config_defaults | ( | void | ) |
References Buttons_Pool, Config_Key, ConfigKey, Exclude_color, T_Key_config::Key, T_Key_config::Key2, T_Toolbar_button::Left_shortcut, Mask_table, T_Shade::Mode, NB_SHORTCUTS, Ordering, Quick_shade_loop, Quick_shade_step, T_Toolbar_button::Right_shortcut, Shade_current, Shade_list, Shade_list_to_lookup_tables(), Shade_table_left, Shade_table_right, Smooth_matrix, Snap_height, Snap_offset_X, Snap_offset_Y, Snap_width, Stencil, and T_Shade::Step.
Referenced by Init_program().
void Init_sighandler | ( | void | ) |
Referenced by Init_program().
void Init_brush_container | ( | void | ) |
References T_Brush_template::Brush, Brush_container, BRUSH_CONTAINER_COLUMNS, BRUSH_CONTAINER_PREVIEW_HEIGHT, BRUSH_CONTAINER_PREVIEW_WIDTH, BRUSH_CONTAINER_ROWS, T_Brush_template::Height, NULL, T_Brush_template::Paintbrush_shape, PAINTBRUSH_SHAPE_MAX, T_Brush_template::Transp_color, and T_Brush_template::Width.
Referenced by Init_program().
void Set_current_skin | ( | const char * | skinfile, |
T_Gui_skin * | gfx | ||
) |
References T_Gui_skin::Animbar_block, T_Gui_skin::Color, T_Gui_skin::Color_trans, Config, Gfx, T_Gui_skin::Layerbar_block, MC_Black, MC_Dark, MC_Darker, MC_Light, MC_Lighter, MC_OnBlack, MC_Trans, MC_White, MC_Window, Menu_bars, T_Gui_skin::Menu_block, MENUBAR_ANIMATION, MENUBAR_LAYERS, MENUBAR_STATUS, MENUBAR_TOOLS, T_Menu_Bar::Skin, T_Config::Skin_file, and T_Gui_skin::Statusbar_block.
Referenced by Button_Skins(), and Init_program().
void Init_paintbrush | ( | int | index, |
int | width, | ||
int | height, | ||
byte | shape, | ||
const char * | bitmap | ||
) |
void Init_paintbrushes | ( | void | ) |
References T_Paintbrush::Height, Init_paintbrush(), NB_PAINTBRUSH_SPRITES, NULL, T_Paintbrush::Offset_X, T_Paintbrush::Offset_Y, Paintbrush, PAINTBRUSH_SHAPE_ANTISLASH, PAINTBRUSH_SHAPE_CROSS, PAINTBRUSH_SHAPE_DIAMOND, PAINTBRUSH_SHAPE_HORIZONTAL_BAR, PAINTBRUSH_SHAPE_MISC, PAINTBRUSH_SHAPE_PLUS, PAINTBRUSH_SHAPE_RANDOM, PAINTBRUSH_SHAPE_ROUND, PAINTBRUSH_SHAPE_SIEVE_ROUND, PAINTBRUSH_SHAPE_SIEVE_SQUARE, PAINTBRUSH_SHAPE_SLASH, PAINTBRUSH_SHAPE_SQUARE, PAINTBRUSH_SHAPE_VERTICAL_BAR, and T_Paintbrush::Width.
Referenced by Init_program().
char Gui_loading_error_message[256] |
Referenced by Button_Skins(), Error_function(), GUI_seek_down(), GUI_seek_right(), Init_program(), Load_font(), Load_graphics(), Parse_font(), Parse_skin(), and Read_GUI_block().