-
Notifications
You must be signed in to change notification settings - Fork 28
/
index.html
235 lines (226 loc) · 10 KB
/
index.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/6.3.0/jsoneditor.min.css"
integrity="sha256-YSy983pvDw/pNyv/+uiHXKNh1LlveOgHY6XAXFclM/Y=" crossorigin="anonymous" />
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<style>
#d2sJson .jsoneditor {
border: 0;
}
</style>
<title>d2s - Example</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="octicon octicon-clippy navbar-brand">
<i class="fa fa-fw fa-github"></i>
<a href="https://github.com/dschu012">dschu012</a> / <a class="font-weight-bold" href="https://github.com/dschu012/d2s">d2s</a>
</div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="/editor">Editor <span class="sr-only">(current)</span></a>
</li>
</ul>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-2 d-none d-md-block"></div>
<div class="col-8 mt-2">
<div class="card bg-light">
<div class="card-body">
<p>Load a save from 1.10-1.14d OR D2R Alpha. Parser uses <a href="https://github.com/dschu012/d2s">d2s</a>. C# version of this library found <a href="https://github.com/dschu012/D2SLib">here</a>.
<br/>Copy D2R Saves to: <code>%userprofile%\Saved Games\Diablo II Resurrected Tech Alpha</code>
<br/>Copy D2 Saves to: <code>C:\Program Files (x86)\Diablo II\Save</code>
</p>
<form id="d2sForm">
<fieldset>
<div class="form-group">
<div class="input-group">
<div class="custom-file">
<input type="file" name="d2sFile" id="d2sFile">
<label class="custom-file-label" for="d2sFile">*.d2s</label>
</div>
<div class="input-group-append">
<span> </span>
</div>
</div>
</div>
<div class="form-group mt-2">
<div id="d2sJson"></div>
</div>
</fieldset>
<div id="errors">
</div>
<button type="button" id="unlockHell" class="btn btn-primary">Unlock Hell</button>
<button type="button" id="unlockAllWPs" class="btn btn-primary">Unlock All WPs</button>
<button type="button" id="set99" class="btn btn-primary">Set Level 99</button>
<button type="button" id="maxAllSkills" class="btn btn-primary">Set All Skills 20</button>
<br /><br />
<button type="button" id="d2" class="btn btn-primary">Save D2</button>
<button type="button" id="d2r" class="btn btn-primary">Save D2R</button>
</form>
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/6.3.0/jsoneditor.min.js"
integrity="sha256-o2/L37SBn4ufKxtZAItcvBdidVsP170IKNcqfVd3ZF4="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
<script src="../dist/constants_96.bundle.js"></script>
<script src="../dist/constants_99.bundle.js"></script>
<script src="../dist/d2s.bundle.js"></script>
<script>
//if we arent local, use github latest
if (window.d2s === undefined) {
let s = document.createElement('script');
s.src = "https://github.com/dschu012/d2s/releases/latest/download/constants_96.bundle.min.js";
document.querySelector('body').appendChild(s);
s = document.createElement('script');
s.src = "https://github.com/dschu012/d2s/releases/latest/download/constants_99.bundle.min.js";
document.querySelector('body').appendChild(s);
s = document.createElement('script');
s.src = "https://github.com/dschu012/d2s/releases/latest/download/d2s.bundle.min.js";
document.querySelector('body').appendChild(s);
}
let editor = new JSONEditor(document.querySelector('#d2sJson'), {
mode: 'form',
mainMenuBar: false,
navigationBar: false
})
let errors = document.querySelector("#errors");
//read from input type=file
let input = document.querySelector('#d2sFile');
input.onchange = function (e) {
let reader = new FileReader();
reader.onload = async function (re) {
try {
if(e.target.value.endsWith('.json')) {
editor.set(re.target.result);
}
d2s.setConstantData(0x60, constants_96.constants); //1.10-1.14d
d2s.setConstantData(0x61, constants_96.constants); //alpha?
d2s.setConstantData(0x62, constants_96.constants); //2.4
d2s.setConstantData(0x63, constants_99.constants); //2.5
d2s.read(re.target.result).then(function(response) {
editor.set(response);
});
} catch (e) {
errors.innerHTML = `<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>Error: </strong>${e.message}
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>`
}
}
reader.readAsArrayBuffer(this.files[0]);
this.value = null;
}
let link = document.createElement('a');
link.style.display = 'none';
document.body.appendChild(link);
//write from json data
function save(d2r) {
let j = editor.get();
if(d2r) {
j.header.version = 0x63;
} else {
j.header.version = 0x60;
}
try {
d2s.setConstantData(0x60, constants_96.constants); //1.10-1.14d
d2s.setConstantData(0x61, constants_96.constants); //alpha?
d2s.setConstantData(0x62, constants_96.constants); //2.4
d2s.setConstantData(0x63, constants_99.constants); //2.5
d2s.write(j).then(function(response) {
let blob = new Blob([response], { type: "octet/stream" });
link.href = window.URL.createObjectURL(blob);
link.download = j.header.name + '.d2s';
link.click();
});
} catch (e) {
errors.innerHTML = `<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>Error: </strong>${e.message}
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>`
}
}
document.querySelector("#unlockHell").onclick = async function(e) {
let z = editor.get();
z.header.progression = 15;
for(var i of ["quests_normal", "quests_nm", "quests_hell"]) {
for(var j of ["act_i", "act_ii", "act_iii", "act_iv", "act_v"]) {
z.header[i][j].introduced = true;
z.header[i][j].completed = true;
}
z.header[i].act_iii.the_guardian.is_completed = true;
z.header[i].act_iv.terrors_end.is_completed = true;
}
for(var i of ["normal", "nm", "hell"]) {
z.header.waypoints[i].act_i.rogue_encampement = true;
z.header.waypoints[i].act_ii.lut_gholein = true;
z.header.waypoints[i].act_iii.kurast_docks = true;
z.header.waypoints[i].act_iv.the_pandemonium_fortress = true;
z.header.waypoints[i].act_v.harrogath = true;
}
editor.set(z);
}
document.querySelector("#unlockAllWPs").onclick = async function(e) {
let z = editor.get();
for(var i of ["normal", "nm", "hell"]) {
for(var a in z.header.waypoints[i]) {
for(var w in z.header.waypoints[i][a]) {
z.header.waypoints[i][a][w] = true;
}
}
}
editor.set(z);
}
document.querySelector("#set99").onclick = async function(e) {
let z = editor.get();
let s = z.attributes.level;
z.header.level = 99;
z.attributes.experience = 3520485254;
z.attributes.level = 99;
z.attributes.unused_stats = ((99 - s) * 5);
editor.set(z);
}
document.querySelector("#maxAllSkills").onclick = async function(e) {
let z = editor.get();
for(var s of z.skills) {
s.points = 20;
}
editor.set(z);
}
document.querySelector("#d2").onclick = async function (e) {
save(false);
}
document.querySelector("#d2r").onclick = async function (e) {
let z = editor.get();
z.header.difficulty = { Normal: 128, Nightmare: 0, Hell: 0 };
editor.set(z);
save(true);
}
</script>
</body>
</html>