1// MIT License
2
3// Copyright (c) 2017 Vadim Grigoruk @nesbox // grigoruk@gmail.com
4
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11
12// The above copyright notice and this permission notice shall be included in all
13// copies or substantial portions of the Software.
14
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22
23#pragma once
24
25#include "studio/studio.h"
26#include "tilesheet.h"
27
28typedef struct Map Map;
29
30struct Map
31{
32 Studio* studio;
33 tic_mem* tic;
34
35 tic_map* src;
36
37 s32 tickCounter;
38
39 enum
40 {
41 MAP_DRAW_MODE = 0,
42 MAP_DRAG_MODE,
43 MAP_SELECT_MODE,
44 MAP_FILL_MODE,
45 } mode;
46
47 struct
48 {
49 bool grid;
50 bool draw;
51 tic_point start;
52 } canvas;
53
54 struct
55 {
56 bool keep;
57 tic_rect rect;
58 tic_point start;
59 bool drag;
60
61 tic_blit blit;
62 } sheet;
63
64 struct
65 {
66 s32 x;
67 s32 y;
68
69 tic_point start;
70
71 bool active;
72 bool gesture;
73
74 } scroll;
75
76 struct
77 {
78 tic_rect rect;
79 tic_point start;
80 bool drag;
81 } select;
82
83 u8* paste;
84
85 struct History* history;
86
87 struct
88 {
89 struct
90 {
91 s32 sheet;
92 s32 bank;
93 s32 page;
94 } pos;
95
96 Movie* movie;
97
98 Movie idle;
99 Movie show;
100 Movie hide;
101 Movie bank;
102 Movie page;
103
104 } anim;
105
106 void (*tick)(Map*);
107 void (*event)(Map*, StudioEvent);
108 void (*scanline)(tic_mem* tic, s32 row, void* data);
109};
110
111void initMap(Map*, Studio* studio, tic_map* src);
112void freeMap(Map* map);
113