-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoolButtons.js
157 lines (132 loc) · 3.24 KB
/
toolButtons.js
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
"use strict";
var currentMenu = null;
var prevMenu = null;
// Tab
function tabSwitch(tabName)
{
const l = tabNames.length;
for (let i = 0; i < l; i++)
{
window["tab" + tabNames[i]].style.display = "none";
}
if (loaded && cfgDOM.menuClose.checked)
{
changeMenu();
}
if (tabName !== null)
{ window["tab" + tabName].style.display = "block"; }
}
// Menu
function changeMenu(type)
{
// close previous menu
if (currentMenu !== type && currentMenu !== null)
{
menuClose(currentMenu);
menu[currentMenu].classList.remove("show");
}
masterMenu.classList.remove("show");
if (type === undefined || type === "")
{
currentMenu = null;
return;
}
if (type === "prev")
{
type = (prevMenu === currentMenu) ? "Home" : prevMenu;
}
else
{
prevMenu = currentMenu;
}
if (menu[type] === undefined)
{
return;
}
// toggle view on chosen display
if (menu[type].classList[0] === "show")
{
menu[type].classList.remove("show");
currentMenu = null;
menuClose();
return;
}
else
{
// show menu
if (type === "Home")
{
if (menu[type].classList.contains("show"))
{
menu[type].classList.remove("show");
currentMenu = null;
menuClose();
return;
}
}
currentMenu = type;
masterMenu.offsetHeight; // force DOM reflow
masterMenu.classList.add("show");
menu[type].classList.add("show");
masterMenu.classList[(menu[type].plugin) ? "add" : "remove"]("menuPlug");
masterMenu.style.left = (cfgDOM.layoutCenter.checked) ?
`calc(50% - ${masterMenu.getBoundingClientRect().width / 2}px)` :
0;
}
switch (type)
{
case "New":
newWidth.value = grid.dim[0];
newHeight.value = grid.dim[1];
newBack.value = (tileset.type === "pixel") ? grid.back : tileset.list[grid.back];
newTileset.value = tileset.group;
newWidth.focus();
break;
case "Settings":
cfgStart();
break;
case "ExportFormat":
exportFormat.start();
break;
case "Resize":
resizeWidth.value = grid.dim[0];
resizeHeight.value = grid.dim[1];
break;
}
if (cfgDOM.gridMenuPaint.checked)
{
gridContainer.style.pointerEvents = "none";
}
}
function menuClose(type)
{
switch (type)
{
case "Settings":
//cfgIni.finish();
break;
case "ExportFormat":
exportFormat.set();
break;
}
if (cfgDOM.gridMenuPaint.checked)
{
gridContainer.style.pointerEvents = "all";
}
}
// Make default tabs / buttons through plugin API.
ifMakePlug = false;
plug.addTab("Data", "Manage document data");
plug.addButton("Data", "New", "menu:New", "Create new Tile Layer document");
plug.addButton("Data", "Open", "menu:Import", "Import document data");
plug.addButton("Data", "Export", "menu:Export", "Export document data");
plug.addButton("Data", "Home", "menu:Home");
plug.addTab("Grid", "Grid tools");
plug.addButton("Grid", "Resize", "menu:Resize", "Change width and height of grid");
plug.addButton("Grid", "Change Tileset", "menu:Tileset", "Change document tileset");
plug.addTab("Settings", "Configure Tile Layer. Also includes misc options.");
plug.addButton("Settings", "Settings", "menu:Settings", "Configure Tile Layer");
plug.addButton("Settings", "Keys", "menu:Keys", "View keys");
plug.addButton("Settings", "About", "menu:About", "About Tile Layer");
ifMakePlug = true; tabSwitch("Data");
// lemocha - lemocha7.github.io