-
Notifications
You must be signed in to change notification settings - Fork 9
/
callback_chunk.cpp
135 lines (124 loc) · 4.02 KB
/
callback_chunk.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
This file is part of Retro Graphics Toolkit
Retro Graphics Toolkit 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, either version 3 of the License, or any later version.
Retro Graphics Toolkit 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 Retro Graphics Toolkit. If not, see <http://www.gnu.org/licenses/>.
Copyright Sega16 (or whatever you wish to call me) (2012-2017)
*/
#include <FL/Fl_Value_Slider.H>
#include <FL/fl_ask.H>
#include "project.h"
#include "undo.h"
#include "class_global.h"
#include "gui.h"
uint32_t currentChunk;
unsigned solidBits_G;
bool tileEditModeChunk_G;
unsigned ChunkOff[2] = {DefaultChunkX, DefaultChunkY};
unsigned scrollChunks_G[2];
uint_fast32_t editChunk_G[2];//x,y
void setCurPlaneChunkCB(Fl_Widget*w, void*) {
Fl_Value_Slider*v = (Fl_Value_Slider*)w;
currentProject->Chunk->usePlane = v->value();
window->damage(FL_DAMAGE_USER1);
}
void insertChunkCB(Fl_Widget*, void*) {
pushChunkNew(currentChunk);
currentProject->Chunk->insert(currentChunk);
window->chunk_select->maximum(currentProject->Chunk->amt - 1);
window->redraw();
}
void delChunkAtCB(Fl_Widget*, void*) {
pushChunk(currentChunk, true);
currentProject->Chunk->removeAt(currentChunk);
window->chunk_select->maximum(currentProject->Chunk->amt - 1);
window->redraw();
}
void appendChunkCB(Fl_Widget*, void*) {
pushChunkAppend();
currentProject->Chunk->append();
window->chunk_select->maximum(currentProject->Chunk->amt - 1);
window->redraw();
}
void saveChunkS1CB(Fl_Widget*, void*) {
if (!currentProject->containsData(pjHaveChunks)) {
currentProject->haveMessage(pjHaveChunks);
return;
}
currentProject->Chunk->exportSonic1();
}
void resizeChunkCB(Fl_Widget*, void*) {
int32_t wtmp = SafeTxtInput(window->chunksize[0]);
int32_t htmp = SafeTxtInput(window->chunksize[1]);
pushChunkResize(wtmp, htmp);
currentProject->Chunk->resize(wtmp, htmp);
window->updateChunkSize();
window->redraw();
}
void selBlockCB(Fl_Widget*o, void*) {
Fl_Slider*s = (Fl_Slider*)o;
uint32_t selBlock = (uintptr_t)s->value();
if (tileEditModeChunk_G) {
pushChunkEdit(currentChunk, editChunk_G[0], editChunk_G[1]);
currentProject->Chunk->setBlock(currentChunk, editChunk_G[0], editChunk_G[1], selBlock);
window->redraw();
}
}
void solidCB(Fl_Widget*o, void*) {
Fl_Choice*s = (Fl_Choice*)o;
solidBits_G = (uintptr_t)s->value();
if (tileEditModeChunk_G) {
pushChunkEdit(currentChunk, editChunk_G[0], editChunk_G[1]);
currentProject->Chunk->setSolid(currentChunk, editChunk_G[0], editChunk_G[1], solidBits_G);
window->redraw();
}
}
void ImportS1CBChunks(Fl_Widget*, void*a) {
if (!currentProject->containsData(pjHaveChunks)) {
currentProject->haveMessage(pjHaveChunks);
return;
}
bool append = !!(uintptr_t)a;
currentProject->Chunk->importSonic1(append);
window->chunk_select->maximum(currentProject->Chunk->amt - 1);
window->redraw();
}
void currentChunkCB(Fl_Widget*, void*) {
currentChunk = window->chunk_select->value();
tileEditModeChunk_G = false;
window->redraw();
}
void useBlocksCB(Fl_Widget*o, void*) {
Fl_Check_Button*b = (Fl_Check_Button*)o;
bool use = !!b->value();
if (use) {
if (!(currentProject->tms->maps[currentProject->curPlane].isBlock)) {
fl_alert("You cannot use blocks without blocks");
b->value(0);
window->redraw();
return;
}
}
currentProject->Chunk->useBlocks = use;
window->updateBlockTilesChunk();
updateTileSelectAmt();
window->redraw();
}
void scrollChunkCB(Fl_Widget*, void*) {
currentProject->Chunk->scrollChunks();
window->redraw();
}
void scrollChunkX(Fl_Widget*, void*) {
scrollChunks_G[0] = window->chunkX->value();
window->redraw();
}
void scrollChunkY(Fl_Widget*, void*) {
scrollChunks_G[1] = window->chunkY->value();
window->redraw();
}