summaryrefslogtreecommitdiff
path: root/src/editor.h
blob: 0c32cdfa04ac37795e71a033f5195410b50a7c05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef __EDITOR_H__
#define __EDITOR_H__
#include <raylib.h>
#include <stdbool.h>

#include "xd.h"

#define EDITOR_TOOLKIT_WIDTH 400.0f
#define EDITOR_TOOLKIT_HEIGHT GetScreenHeight()
#define EDITOR_TOOLKIT_X GetScreenWidth() - EDITOR_TOOLKIT_WIDTH
#define EDITOR_TOOLKIT_Y 0.0f

#define TEXTURE_WIDTH 16.0f
#define TEXTURE_HEIGHT 16.0f

typedef struct {
  bool isFloor, isWall;
  char *upFilePath, *sideFilePath, *cornerFilePath;
  Texture2D upTexture, sideTexture, cornerTexture;
} EditorCreateBlockState;

typedef struct {
  XdTileData data;
  Texture2D texture;
} EditorTileData;

typedef struct {
  EditorTileData *tile;
  Vector2 position;
} EditorTile;

typedef struct {
  int tileDataSize;
  int tilesCount;
  EditorTileData *tileData[200];
  EditorTile *tiles[];
} EditorCache;

typedef struct {
  int currentLevel, currentLayer, activeMainTab;
  EditorCreateBlockState *createBlockState;
  Rectangle panelView;
  Vector2 panelScroll;
  EditorTileData *selectedTile;
  EditorCache cache;
} EditorState;

typedef struct {
  XdData *data;
  EditorState state;
} Editor;

void SE_DrawEditor(Editor *editor, Camera2D *camera);
void SE_DrawEditorToolkit(Editor *editor);
void SE_RebuildEditorCache(Editor *editor);
#endif