forked from Lightningreed/PVZ2-Tools-Dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PVZ2GRIDITEMS.html
185 lines (177 loc) · 14.1 KB
/
PVZ2GRIDITEMS.html
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></head><body background="./PVZ2GRIDITEMS_files/bg.png" style="background-repeat: no-repeat;">
<div id="gridDiv"><div style="width: 396px; height: 51px;"><canvas id="0x0" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="1x0" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="2x0" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="3x0" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="4x0" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="5x0" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="6x0" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="7x0" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="8x0" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas></div><div style="width: 396px; height: 51px;"><canvas id="0x1" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="1x1" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="2x1" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="3x1" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="4x1" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="5x1" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="6x1" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="7x1" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="8x1" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></div><div style="width: 400px; height: 51px;"><canvas id="0x2" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="1x2" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="2x2" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="3x2" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="4x2" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="5x2" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="6x2" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="7x2" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="8x2" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas></div><div style="width: 400px; height: 51px;"><canvas id="0x3" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="1x3" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="2x3" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="3x3" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="4x3" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="5x3" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="6x3" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="7x3" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="8x3" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas></div></canvas></div><div style="width: 600px; height: 51px;"><canvas id="0x4" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="1x4" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="2x4" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="3x4" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="4x4" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="5x4" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="6x4" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="7x4" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><canvas id="8x4" style="width: 44px; height: 51px; outline: rgba(0, 0, 0, 0.2) solid 0.5px;"></canvas><img src="./PVZ2GRIDITEMS_files/Eraser.png" id="47" onclick="selectSprite(event)" style="margin-left: 15px;"></div>
</style></div>
<div style="margin-top: 15px">
<img src="./PVZ2GRIDITEMS_files/goldtile.png" id="1" onclick="selectSprite(event)" style="outline: blue solid 0.5px;">
<img src="./PVZ2GRIDITEMS_files/flame_spreader_trap.png" id="4" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/boulder_trap_falling_forward.png" id="5" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/crater.png" id="6" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/score_2x_tile.png" id="24" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/score_3x_tile.png" id="25" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/score_5x_tile.png" id="23" onclick="selectSprite(event)">
</div>
<div>
<img src="./PVZ2GRIDITEMS_files/bombegranateseeds.png" id="14" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/planttarget_squid.png" id="15" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/zombiepotion_speed.png" id="17" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/zombiepotion_toughness.png" id="18" onclick="selectSprite(event)">
</div>
<div>
<img src="./PVZ2GRIDITEMS_files/backpack.png" id="19" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/tent.png" id="20" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/surfboard.png" id="21" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/speaker.png" id="22" onclick="selectSprite(event)">
</div>
<div>
<img src="./PVZ2GRIDITEMS_files/slider_down.png" id="7" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/slider_up.png" id="8" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/slider_down_modern.png" id="9" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/slider_up_modern.png" id="10" onclick="selectSprite(event)">
</div>
<div>
<img src="./PVZ2GRIDITEMS_files/gravestone_tutorial.png" id="11" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/gravestone_egypt.png" id="2" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/gravestone_dark.png" id="3" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/gravestonePlantfoodOnDestruction.png" id="12" onclick="selectSprite(event)">
<img src="./PVZ2GRIDITEMS_files/gravestoneSunOnDestruction.png" id="13" onclick="selectSprite(event)">
</div>
<div>
<div style="margin-top: 15px">
<p id="p1" class="paragraph1"></p><p id="p2" class="paragraph1">
</p></div>
<style type="text/css">
textarea {
width: 410px; height: 250px; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif;
}
</style>
<textarea id="xml" rows="20" cols="50"></textarea>
<p> </p>
<button onclick="CompileLevelXML()">Finished</button>
<p> </p>
<textarea id="output" rows="10" cols="50"></textarea>
<script type="text/javascript">
var version = 1.0;
var eraser = 47;
document.getElementById('output').style.display = "none";
document.getElementById("xml").value = "";
document.getElementById("output").value = "###Don't forget to add### \"RTID\(Gravestones\@CurrentLevel\)\"\n\n";
var mouseOverSprite = document.createElement("img");
mouseOverSprite.style.display="block";
mouseOverSprite.style.position = "absolute";
mouseOverSprite.style.zIndex = "-1";
document.body.insertBefore(mouseOverSprite,document.body.firstChild);
document.getElementById("xml").value += "\{\n \"aliases\"\: \[\n \"Gravestones\"\n \],\n \"objclass\"\: \"GravestoneProperties\",\n \"objdata\"\: \{\n \"ForceSpawnData\"\: \[\n";
document.addEventListener("mousemove",mouseMoveFunction);
var lastGridId = null;
function mouseMoveFunction(e){
var p1 = document.getElementById("p1");
if(e.target.nodeName == "CANVAS"){
p1.innerHTML = " Grid ID: "+e.target.id
if(e.target.id == lastGridId){
return;
}
lastGridId = e.target.id;
mouseOverSprite.style.visibility ="visible";
mouseOverSprite.style.top = e.target.offsetTop+"px";
mouseOverSprite.style.left = e.target.offsetLeft+"px";
}
else{
mouseOverSprite.style.visibility ="hidden";
}
}
document.addEventListener("click",mouseClickFunction);
function mouseClickFunction(e){
if(mouseOverSprite.style.visibility == "visible" && e.target.nodeName == "CANVAS" && selectedSpriteId != eraser)
{
var targetRect = e.target.getBoundingClientRect();
var a = e.target.id;
console.log(a);
var x = a.charAt(0);
console.log(x);
var b = e.target.id;
console.log(b);
var y = b.charAt(2);
console.log(y);
document.getElementById("xml").value += (document.getElementById("xml").value.endsWith("}") ? ",\n" : "") + " {\n \"GridX\"\: " + x + ",\n \"GridY\"\: " + y + ",\n \"TypeName\"\: \""+ mouseOverSprite.src.substring(mouseOverSprite.src.lastIndexOf('/')+1).split('.')[0] + "\"\n }";
var newImg = document.createElement("img");
newImg.src = mouseOverSprite.src;
newImg.style.position = "absolute";
newImg.style.left = targetRect.x+"px";
newImg.style.top = targetRect.y+"px";
newImg.style.zIndex = -1;
newImg.className = "newImg";
newImg.addEventListener("click",function(){
if(selectedSpriteId == eraser){
victim = "\n {\n \"GridX\"\: " + x + ",\n \"GridY\"\: " + y + ",\n \"TypeName\"\: \""+ this.src.substring(this.src.lastIndexOf('/')+1).split('.')[0] + "\"\n }";
console.log(victim);
xml = document.getElementById("xml").value;
document.getElementById("xml").value = xml.substr(0,xml.indexOf(victim)) + xml.substr(xml.indexOf(victim) + victim.length + 1, xml.length);
this.remove();
xml3 = document.getElementById("xml").value;
xml4 = xml3.slice(0, -1);
if(xml3.endsWith(",")){
console.log(xml4);
document.getElementById("xml").value = xml4;
}
}
});
document.body.appendChild(newImg);
if(allAddedItems[e.target.id]==null)
allAddedItems[e.target.id] = new Array(newImg);
else
allAddedItems[e.target.id].push(newImg);
}
}
var allAddedItems = new Array();
var selectedSpriteId = 1;
document.getElementById(selectedSpriteId).style.outline=".5px solid blue";
mouseOverSprite.src = document.getElementById(selectedSpriteId).src;
function selectSprite(e){
document.getElementById(selectedSpriteId).style.outline="";
e.currentTarget.style.outline = ".5px solid blue";
selectedSpriteId = e.currentTarget.id;
mouseOverSprite.src = e.currentTarget.src;
var canvases = document.getElementsByClassName('newImg');
if(selectedSpriteId == eraser){
mouseOverSprite.style.pointerEvents="none";
//document.getElementById('gridDiv').style.pointerEvents="none";
for(i=0;i<canvases.length;i++){
canvases[i].style.zIndex=1;
}
} else {
mouseOverSprite.style.pointerEvents="";
for(i=0;i<canvases.length;i++){
canvases[i].style.zIndex=-1;
}
}
}
function toggleoutputvisibility() {
var display = document.getElementById('output').style.display;
if(display == "none")
document.getElementById('output').style.display = "block";
}
function CompileLevelXML() {
var str = document.getElementById("xml").value;
toggleoutputvisibility();
document.getElementById("output").value += str;
document.getElementById("output").value += "\n \]\n \}\n \},";
console.log(allAddedItems);
}
//Asuki says Hai!
</script>
<style>
p {
color: Blue;
}
.paragraph1 {
font-size: 12px;
font-family: Verdana, Arial, Helvetica, sans-serif;
line-height: 2px;
}
.paragraph2 {
font-size: 13px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
</style>
</body></html>