timesynk/tile_editor/sdl.h

97 lines
2.7 KiB
C

#ifndef SDL_H
#define SDL_H
#include "elements.h"
int g_fullscreen;
SDL_Surface* screen;
SDL_Surface* menu_area;
SDL_Surface* tile_area;
SDL_Surface* sprite_area;
SDL_Rect tile_area_rect;
SDL_Rect sprite_area_rect;
SDL_Rect update_rect;
SDL_Event event;
struct Font font;
struct Font {
int width;
int height;
SDL_Surface *surface;
};
void loadFont(struct Font *font, unsigned char *memory, unsigned int length, int width, int height);
void drawChar(const struct Font *font, SDL_Surface *surface, int x, int y, const char ch);
void drawString(const struct Font *font, SDL_Surface *surface, int x, int y, const char *string);
struct Spritesheet player_sprites;
struct Spritesheet item_sprites;
struct Spritesheet equip_sprites;
struct Spritesheet shadow_sprites;
struct Spritesheet npc_sprites;
struct Spritesheet door_sprites;
struct Spritesheet floor_sprites;
struct Spritesheet wall_sprites;
struct Spritesheet {
int width;
int height;
int s_width;
int s_height;
int columns;
float scale_x;
float scale_y;
SDL_Surface *spritesheet;
SDL_Surface *s_spritesheet;
};
int loadSpritesheetFromFile(struct Spritesheet *spritesheet, char *file_name, int width, int height, int columns);
void freeSpritesheet(struct Spritesheet *spritesheet);
void drawElement(const struct Element *element);
void drawElements();
void clearElement(const struct Element *element);
void addElement(struct Element *element, SDL_Surface *surface);
void addElementHook(struct ElementList *list, struct Element *element);
void handleMouseDown(const SDL_MouseButtonEvent *event);
void handleMouseUp(const SDL_MouseButtonEvent *event);
void handleMouseMove(const SDL_MouseMotionEvent *event);
void handleKeyDown(const SDL_KeyboardEvent *event);
void handleSpritesheetClick(int x, int y);
int getElementWidth(const struct Element* element);
int getElementHeight(const struct Element* element);
void positionElements();
void loadGraphicsCallback();
void loadDataCallback();
void saveDataCallback();
void setSetCallback();
void setIdCallback();
void changeKeyCallback();
void changeValueCallback();
void deleteElementCallback();
void deleteInventoryElementCallback();
void addPairCallback(struct Element *element);
void addInventoryCallback(struct Element *element);
void addInventoryElementCallback(struct Element *element);
void commitChangesCallback(struct Element *element);
void loadTile(int set, int id);
void showSpritesheet();
void reloadImagePreview();
void printConsole(const char *string);
void Quit();
/* sdl helper */
Uint32 getpixel(SDL_Surface *surface, int x, int y);
void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel);
SDL_Surface *SDL_ScaleSurface(SDL_Surface *surface, float scale_x, float scale_y);
#endif