forked from ComputerNerd/Retro-Graphics-Toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
callbacktilemaps.cpp
81 lines (70 loc) · 3.2 KB
/
callbacktilemaps.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
/*
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-2018)
*/
#include "project.h"
#include "classtilemaps.h"
#include "callbacktilemaps.h"
#include "undo.h"
#include "class_global.h"
#include "gui.h"
void setCurPlaneTilemaps(Fl_Widget*, void*val) {
currentProject->curPlane = (uintptr_t)val;
window->BlocksCBtn->value(currentProject->tms->maps[currentProject->curPlane].isBlock);
currentProject->tms->maps[currentProject->curPlane].toggleBlocks(currentProject->tms->maps[currentProject->curPlane].isBlock);
window->updateTileMapGUI(selTileE_G[0], selTileE_G[1]);
window->curPlaneName->value(currentProject->tms->maps[currentProject->curPlane].planeName.c_str());
window->redraw();
}
void removeTilemapsPlane(Fl_Widget*, void*) {
if (currentProject->tms->maps.size() > 1) {
pushTilemapPlaneDelete(currentProject->curPlane);
currentProject->tms->removePlane(currentProject->curPlane);
if (currentProject->curPlane)
--currentProject->curPlane;
window->planeSelect->value(currentProject->curPlane);
updatePlaneTilemapMenu();
setCurPlaneTilemaps(0, (void*)(uintptr_t)currentProject->curPlane);
} else
fl_alert("This is the improper way to disable planes");
}
void updateNameTilemaps(Fl_Widget*w, void*) {
Fl_Input*wi = (Fl_Input*)w;
currentProject->tms->maps[currentProject->curPlane].planeName.assign(wi->value());
window->planeSelect->replace(currentProject->curPlane, currentProject->tms->maps[currentProject->curPlane].planeName.c_str());
window->redraw();
}
void updatePlaneTilemapMenu(uint32_t id, Fl_Choice*plM) {
if (plM->size())
plM->clear();
size_t sz = projects->at(id).tms->maps.size();
for (uintptr_t i = 0; i < sz; ++i)
plM->add(projects->at(id).tms->maps[i].planeName.c_str(), 0, setCurPlaneTilemaps, (void*)i, 0);
plM->value(projects->at(id).curPlane);
if (projects->at(id).containsData(pjHaveChunks)) {
if (projects->at(id).Chunk->usePlane >= sz)
projects->at(id).Chunk->usePlane = sz - 1;
window->planeSelectChunk->value(projects->at(id).Chunk->usePlane);
}
window->planeSelectChunk->maximum(sz - 1);
}
void updatePlaneTilemapMenu(void) {
updatePlaneTilemapMenu(curProjectID, window->planeSelect);
}
void addPlaneTilemap(Fl_Widget*, void*val) {
pushTilemapPlaneAdd(currentProject->tms->maps.size());
currentProject->tms->setPlaneCnt(currentProject->tms->maps.size() + 1);
uintptr_t i = currentProject->tms->maps.size() - 1;
window->planeSelect->add(currentProject->tms->maps[i].planeName.c_str(), 0, setCurPlaneTilemaps, (void*)i, 0);
window->planeSelectChunk->maximum(i);
window->redraw();
}