-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodmapper.py
More file actions
691 lines (639 loc) · 26.5 KB
/
modmapper.py
File metadata and controls
691 lines (639 loc) · 26.5 KB
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
# Modmapper for Morrowind
version = "0.7b4"
#
# examines all mods in a folder and builds a HTML file with a map showing and linking to exterior cell details, specifically which mods modify that cell.
# additionally provides list of interior cells with a list of mods modifying them.
#
# usage: put modmapper.py, tes3conv.exe and the mods you want to examine all in a folder
# (or just dump modmapper.py and tes3conv.exe in your data folder, that's what I do)
#
# run python modmapper.py "path-to-modfolder"
#
# 0.1 - initial release
# 0.2 - a little code cleanup and some cosmetic fixes (forgot to close a HTML tag), made esp/esm search case insensitive because some monsters name their file something.EsM
# 0.3 - added hacky support for both rfuzzo's and G7's versions of tes3conv.exe css improvements - cell lights up on hover, entire cell (when linked) is now clickable. Might not work on all browsers.
# 0.4 - missed interior flag(s?), added, shrunk table a little, made highlighted cell white to avoid clash with gray cells,cleaned up the version check code a bit
# 0.5 - implemented random colors, increased contrast for cells with low modcount, got rid of stupid tooltip pointer since I couldn't get it to point to the cell itself, made sure mw.esm and bm.esm load first if present (to preserve color overrides)
# 0.6 - more map stuff, some new user switches for map color control, brought back color overrides now that randomness seems to work
# 0.7 - export now defaults to index.html instead of modmapper.html, split out ints and exts to separate export files (as the main file is getting chunky), some more config switches, search/text filters on interior and exterior pages, some css/presentation cleanup
#
# not tested on anything except Windows OS+(open)MW, English-language versions.
# User-configurable variables, defaults should be fine
# split into multiple web pages- good for very big modlists
splitpages = True
# produces a LOT of noise if turned on (pipe output to a file)
moreinfo = False
# normally modmapper cleans up after itself, set to False to disable (for repeated runs for instance)
deletemodjson = False
# some padding around the map
tableborder = 2
# whether the TR landmass colors should override other landmass colors (other overlapping mods will be seen as a brightening of the colors), defaults to true because the alternative is a clown car of a map (bit arguably better to see conflicts there)
overridetr = True
# skip these mods if found. You can add any mods you don't want on the map here.
excludelist = ["autoclean_cities_vanilla.esp","autoclean_cities_TR.ESP","Cyrodiil_Grass.ESP","Sky_Main_Grass.esp","TR_Data.esm","Tamriel_Data.esm","Better Heads Bloodmoon addon.esm","Better Heads Tribunal addon.esm","Better Heads.esm","OAAB_Data.esm","Better Clothes_v1.1.esp","Better Bodies.esp"]
# Map color control settings, not really fiddled with this beyond making them available
# controls coloring for cells, min value 0 max value should be less than maxbrightness, default 10
minbrightness = 15
# sensible values between ~100 and 200, min is a value above minbrightness, max 255. No checks or guard rails. Lower values produce more muted colors, default 200
maxbrightness = 180
# improve contrast for cells with few mods affecting them (only for mods, not base game)
lowmodcountcontrastincrease = True
# what is considered a "low mod count"
lowmodcount = 10
# controls the increase of values between steps (somewhat), values between 0-1 make the most sense, not really tested beyond that, default 1
stepmodifier = 1
# background and text color
bgcolor = "101010"
txcolor = "808080"
# water/untouched cell color in web/hex RGB
watercolor = "2B65EC"
watertextcolor = "1010ff"
# add empty cells to the exterior cell list. This will make that list VERY long and the program VERY slow.
addemptycells = False
# color overrides, can add your own here or change colors, just copy one of the earlier lines, color format is "modname":"web/hex RGB". CASE sEnSItIvE.
coloroverride = {}
coloroverride.update({"Morrowind.esm":"002000"})
coloroverride.update({"TR_Mainland.esm":"000040"})
coloroverride.update({"TR_Restexteriors.ESP":"400000"})
coloroverride.update({"Bloodmoon.esm":"003030"})
coloroverride.update({"Solstheim Tomb of The Snow Prince.esm":"300030"})
coloroverride.update({"Cyr_Main.esm":"909000"})
coloroverride.update({"Sky_Main.esm":"001060"})
# the default name of the exported file (THIS SWITCH DOES NOTHING CURRENTLY)
exportfilename = "index.html"
# ---
import json
import io
import sys
import os
from os import listdir
from os.path import isfile, join
from random import randrange
from datetime import datetime
html_header = """
<!DOCTYPE html>
<HTML>
<HEAD>
<title>Morrowind Modmapper v"""+str(version)+"""+</title>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<STYLE>
* {
box-sizing: border-box;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 100%;
background-color: #101010;
color: #808080;
}
a.linkstuff {
color: #a0a0a0; !important;
font-weight: bold;
text-decoration: normal;
}
a.linkstuff:visited {
color: #a0a0a0; !important;
font-weight: bold;
text-decoration: normal;
}
a.linkstuff:hover {
color: #c0c0c0; !important;
font-weight: bold;
text-decoration: normal;
}
a.linkstuff:active {
color: #b0b0b0; !important;
font-weight: bold;
text-decoration: normal;
}
a:link {
color: #909090;
text-decoration: none;
}
a:visited {
color: #909090;
text-decoration: none;
}
a:hover {
background-color: #909090;
font-weight: bold;
text-decoration: none;
color: ff0000;
}
a:active {
color: #909090;
text-decoration: none;
}
table {
width: 100%;
border: none;
border-spacing:0;
border-collapse: collapse;
}
td .content {
white-space: pre;
aspect-ratio: 1 / 1 ;
text-align: center;
font-family:"Courier New", Courier, monospace;
font-size: 70%;
}
td:hover {
background-color: #909090;
font-weight: bold;
color: #ff0000;
}
td a {
display: inline-block;
height:100%;
width:100%;
}
.tooltip {
position: relative;
display: inline-block;
font-size: 100%;
}
.tooltip .tooltiptext {
font-family: Arial, Helvetica, sans-serif;
font-size: 100%;
white-space: normal;
font-weight: normal;
visibility: hidden;
width: 1500%;
background-color: #555;
color: #fff;
text-align: left;
border-radius: 6px;
padding: 5px 5px 5px 5px;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip:hover .tooltiptext {
white-space: normal;
visibility: visible;
font-size: 100%;
opacity: 1;
}
.nav {
position: fixed;
background-color: #06111c;
background: #06111c;
top: 0;
left: 0;
right: 0;
z-index: 500;
}
.flex-container {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0px 2px;
}
.nav ul {
display: flex;
list-style-type: none;
align-items: center;
justify-content: center;
}
.nav a {
color: #fff;
text-decoration: none;
padding: 0px 5px;
}
#intextinput {
width: 40%;
padding: 12px 20px 12px 40px;
border: 1px solid #ddd;
margin-bottom: 12px;
display: block;
margin-left: auto;
margin-right: auto;
}
#intexttable {
border-collapse: collapse;
width: 100%;
border: 1px solid #ddd;
font-family: Arial, Helvetica, sans-serif;
font-size: 80%;
}
#intexttable th, #intexttable td {
text-align: left;
padding: 12px;
font-weight: normal;
text-decoration: none;
color: #d0d0d0;
}
#intexttable tr {
border-bottom: 1px solid #ddd;
}
#intexttable tr.header, #intexttable tr:hover {
background-color: #ocococ;
}
</STYLE>
</HEAD>
<BODY>
"""
html_footer = """
</div>
</BODY>
</HTML>
"""
intexttableopen = """
<table id="intexttable">
"""
intexttableclose = """
</table>
<script>
function intextsearch() {
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("intextinput");
filter = input.value.toUpperCase();
table = document.getElementById("intexttable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
"""
esplist = []
modcelltable = []
mastermoddict = {}
masterintdict = {}
basecolorhex = {}
filecounter = 1
tablexmin = 0
tablexmax = 0
tableymin = 0
tableymax = 0
excludecounter = 0
failcounter = 0
failedmodlist = ""
modcelllist = ""
intcelllist = ""
maxmodcellist = 0
tes3convversion = 0
interiorcell = False
generationdate = datetime.today().strftime('%Y-%m-%d %H:%M:%S')
global textcolors
textcolors = "000000"
def int2hex(x):
val = hex(x)[2:]
val = "0"+val if len(val)<2 else val
return val
def calcoutputcellcolor(mymodcount,mymodlist):
global textcolors
foundmod = False
returnvalue = "606060"
basevalue = 0
currentmod = ""
valuestep = stepmodifier*(250/maxmodcellist)
if mymodcount <= lowmodcount and not "Morrowind.esm" in mymodlist and not "Bloodmoon.esm" in mymodlist and lowmodcountcontrastincrease:
valuestep += 10
finalcolorincrease = min(int(basevalue+(mymodcount*valuestep)),255)
for items in mymodlist:
currentmod = items
if not foundmod and currentmod in basecolorhex:
foundmod = True
hexcolors = (basecolorhex[currentmod])
colorg= hexcolors[:-2]
colorg= int(colorg[2:],16)
colorr= int(hexcolors[:2],16)
colorb= int(hexcolors[4:],16)
reductionfactor = 2
if colorr > colorg and colorr > colorb:
finaloutr=min((colorr+finalcolorincrease), 255)
finaloutb=min((colorb+(finalcolorincrease/reductionfactor)), 255)
finaloutg=min((colorg+(finalcolorincrease/reductionfactor)), 255)
elif colorg > colorr and colorg > colorb:
finaloutg=min((colorg+finalcolorincrease), 255)
finaloutb=min((colorb+(finalcolorincrease/reductionfactor)), 255)
finaloutr=min((colorr+(finalcolorincrease/reductionfactor)), 255)
elif colorb > colorg and colorb > colorr:
finaloutb=min((colorb+finalcolorincrease), 255)
finaloutr=min((colorr+(finalcolorincrease/reductionfactor)), 255)
finaloutg=min((colorg+(finalcolorincrease/reductionfactor)), 255)
else:
finaloutr=min((colorr+finalcolorincrease), 255)
finaloutg=min((colorg+finalcolorincrease), 255)
finaloutb=min((colorb+finalcolorincrease), 255)
lumi = min((0.2126*finaloutr + 0.7152*finaloutg + 0.0722*finaloutb),255)
if lumi >= 50 and lumi <= 100:
lumi = (lumi-(lumi*0.75))
if lumi < 0:
lumi = 0
if lumi > 100 and lumi <= 150:
lumi = min((lumi+(lumi*0.75)),255)
greygradient = int2hex(min(int(255-lumi),255))
textcolors = str(greygradient)+str(greygradient)+str(greygradient)
returnvalue = str(int2hex(int(finaloutr)))+str(int2hex(int(finaloutg)))+str(int2hex(int(finaloutb)))
if foundmod:
break
return returnvalue
try:
target_folder = sys.argv[1]
target_folder = str(target_folder)
except:
print("usage: put mods + modmapper.py + tes3conv.exe in same folder")
print("run: python modmapper.py \"target directory\"")
print("output will be saved as index.html")
sys.exit()
if not os.path.isdir(target_folder):
print("FATAL: target directory \"",target_folder,"\"does not exist.")
sys.exit()
if not os.path.isfile("tes3conv.exe"):
print("FATAL: cannot find path to tes3conv.exe, is it in the same folder as this script?")
sys.exit()
esplist += [each for each in os.listdir(target_folder) if each.lower().endswith('.esm')]
esplist += [each for each in os.listdir(target_folder) if each.lower().endswith('.esp')]
# esplist += [filename for filename in listdir(target_folder) if filename.lower().rsplit('.')[2] in ["esp", "esm", "omwaddon"]]
esplist = sorted(esplist, key=str.casefold)
if overridetr:
if "TR_Update.ESP" in esplist:
esplist.insert(0, esplist.pop(esplist.index("TR_Update.ESP")))
if "TR_Restexteriors.ESP" in esplist:
esplist.insert(0, esplist.pop(esplist.index("TR_Restexteriors.ESP")))
if "TR_Mainland.esm" in esplist:
esplist.insert(0, esplist.pop(esplist.index("TR_Mainland.esm")))
if "Solstheim Tomb of The Snow Prince.esm" in esplist:
esplist.insert(0, esplist.pop(esplist.index("Solstheim Tomb of The Snow Prince.esm")))
if "Siege at Firemoth.esp" in esplist:
esplist.insert(0, esplist.pop(esplist.index("Siege at Firemoth.esp")))
if "Tribunal.esm" in esplist:
esplist.insert(0, esplist.pop(esplist.index("Tribunal.esm")))
if "Bloodmoon.esm" in esplist:
esplist.insert(0, esplist.pop(esplist.index("Bloodmoon.esm")))
if "Morrowind.esm" in esplist:
esplist.insert(0, esplist.pop(esplist.index("Morrowind.esm")))
for files in esplist:
if files not in excludelist:
colr = int2hex(randrange(minbrightness, maxbrightness))
colg = int2hex(randrange(minbrightness, maxbrightness))
colb = int2hex(randrange(minbrightness, maxbrightness))
if files in coloroverride:
hexcolors = (coloroverride[files])
colr = hexcolors[:2]
colg = hexcolors[:-2]
colg = colg[2:]
colb = hexcolors[4:]
if files not in basecolorhex:
basecolorhex.update({files:str(colr)+str(colg)+str(colb)})
tes3convversion = 0
jsonfilename = files[:-4]+".json"
if deletemodjson and os.path.isfile(str(jsonfilename)):
os.remove(jsonfilename)
if not os.path.isfile(str(jsonfilename)):
try:
target = "tes3conv.exe \""+str(files)+"\" \""+str(jsonfilename)+"\""
print("running",target)
os.system(target)
except Exception as e:
print("unable to convert mod to json: "+repr(e))
if not os.path.isfile(str(jsonfilename)):
failcounter+=1
failedmodlist = failedmodlist + str(files) + " "
if os.path.isfile(str(jsonfilename)):
f = io.open(jsonfilename, mode="r", encoding="utf-8")
espfile_contents = f.read()
modfile_parsed_json = json.loads(espfile_contents)
f.close()
del espfile_contents
if deletemodjson:
os.remove(jsonfilename)
print("examining file",filecounter,"of",len(esplist),":",files)
for keys in modfile_parsed_json:
extcellcounter = 0
if keys["type"] == "Cell" and len(keys["references"])>0:
extcellcounter += 1
tes3convversioncheck = 0
tes3convversioncheck = str(keys["data"]["flags"])
if tes3convversioncheck.isdigit():
tes3convversion = 0
intlist = [1,5,3,7,135,131,137]
if int(tes3convversioncheck) in intlist:
interiorcell = True
else:
interiorcell = False
else:
tes3convversion = 1
if "INTERIOR" in tes3convversioncheck:
interiorcell = True
else:
interiorcell = False
if not interiorcell:
if keys["data"]["grid"][0] < tablexmin:
tablexmin = keys["data"]["grid"][0]
if keys["data"]["grid"][0] > tablexmax:
tablexmax = keys["data"]["grid"][0]
if keys["data"]["grid"][1] < tableymin:
tableymin = keys["data"]["grid"][1]
if keys["data"]["grid"][1] > tableymax:
tableymax = keys["data"]["grid"][1]
# TODO: fix up this list/dict mess, I started using one and switched to the other, then ended up using both. Shitshow. A working shitshow but still.
if keys["data"]["grid"] not in modcelltable:
modcelltable.append(keys["data"]["grid"])
if str(keys["data"]["grid"]) not in mastermoddict:
mastermoddict[str(keys["data"]["grid"])] = str(files)
if moreinfo:
print("new ext cell",str(keys["data"]["grid"]))
else:
modcelllist = mastermoddict[str(keys["data"]["grid"])]
modcelllist = modcelllist + ", " + files
modcelllistcounter = int(len(str(modcelllist).split(",")))
if modcelllistcounter > maxmodcellist:
maxmodcellist = modcelllistcounter
mastermoddict[str(keys["data"]["grid"])] = modcelllist
else:
intcellname = ""
if tes3convversion == 0:
intcellname = keys["id"]
else:
intcellname = keys["name"]
if intcellname not in masterintdict:
masterintdict[intcellname] = str(files)
if moreinfo:
print("new int cell",intcellname)
else:
intcelllist = masterintdict[intcellname]
intcelllist = intcelllist + ", " + files
masterintdict[intcellname] = intcelllist
interiorcell = False
filecounter+=1
else:
print("skipping file",filecounter,"of",len(esplist),":",files,"(excludelist)")
filecounter+=1
excludecounter+=1
print("Sorting through mods and assembling tables, this will take a while...")
tablexmin = tablexmin - tableborder
tablexmax = tablexmax + tableborder
tableymin = tableymin - tableborder
tableymax = tableymax + tableborder
tablewidth = int(abs(tablexmax)+abs(tablexmin)+1)
tablelength = int(abs(tableymax)+abs(tableymin)+1)
midvaluex = int(tablexmin+abs(tablewidth/2))
midvaluey = int(tableymin+abs(tablelength/2))
if moreinfo:
print("cell x min:",tablexmin,"cells x max",tablexmax,"cell y min",tableymin,"cell y max",tableymax,"tableborder",tableborder)
print("calculated table width",tablewidth,"calculated table length",tablelength)
found = False
lookup = []
table = []
table.append("""</table>""")
tablecounter = 0
tablerows = 0
tablecolumns = 0
tooltipdata = ""
formattedextlist = ""
while tablerows < tablelength:
print("Assembling map row",tablerows,"of",(tablelength-1),"(",(tablewidth-1),"columns/cells per row)")
table.append("""\n\t</tr>\n""")
td = []
tablecolumns = 0
while tablecolumns < tablewidth:
tooltipdata = ""
done = 0
found = 0
docellcolor = "0099ff"
for values in modcelltable:
if values[0] == (tablecolumns-abs(tablexmin)) and values[1] == (tablerows-abs(tableymin)):
found = True
modcount = mastermoddict[str(values)]
modcount = len(modcount.split(","))
modifyingmodlist = []
modifyingmodlist = str(mastermoddict[str(values)]).split(",")
dedupe_modlist = []
for item in modifyingmodlist:
if item not in dedupe_modlist:
dedupe_modlist.append(item)
modifyingmodlist = []
modifyingmodlist = dedupe_modlist
tooltipdata = """cell: <b>"""+str(values)+"""</b><BR>mods: """+str(modifyingmodlist)
formattedextlist = formattedextlist + """<tr><td><a href=\"index.html#map"""+str(values)+"""\" id=\""""+str(values)+"""\" class="linkstuff">cell: <b>"""+str(values)+"""</b></a><BR>mods: """+str(modifyingmodlist)+"""</td></tr>\n"""
if found:
break
paddingleft = ""
paddingright = ""
if abs(values[0]) < 100:
paddingleft = " "
if abs(values[0]) < 10:
paddingleft = " "
if paddingleft and values[0] > -1:
paddingleft += " "
if abs(values[1]) < 100:
paddingright = " "
if abs(values[1]) < 10:
paddingright = " "
if paddingright and values[1] > -1:
paddingright += " "
cellx = str(int(tablecolumns-abs(tablexmin)))
celly = str(int(tablerows-abs(tableymin)))
if found:
docellcolor = calcoutputcellcolor(modcount,modifyingmodlist)
td.append("""<td bgcolor=#"""+str(docellcolor)+""" style=\"color:#"""+textcolors+""";\"><div class="content"><div class="tooltip"><a href=\"modmapper_exteriors.html#"""+str(values)+"""\" id=\"map"""+str(values)+"""\" style=\"color: #"""+textcolors+""";text-decoration:none;\">"""+str(paddingleft)+"["+cellx+""",<BR>"""+celly+"]"+str(paddingright)+"""</a><span class="tooltiptext">"""+tooltipdata+"""</span></div></div></td>\n""")
else:
td.append("""<td bgcolor=#"""+str(watercolor)+""" style=\"color:#"""+watertextcolor+""";\"><div class="content"><a id=\"map["""+cellx+""", """+celly+"""]\">"""+str(paddingleft)+"["+cellx+""",<BR>"""+celly+"]"+str(paddingright)+"""</a></div></td>\n""")
if addemptycells:
formattedextlist = formattedextlist + """<tr><td><a href=\"index.html#map["""+cellx+""", """+celly+"""]\" id=\"["""+cellx+""", """+celly+"""]\" class="linkstuff">cell: <b>["""+cellx+""", """+celly+"""]</b></a><BR>mods: EMPTY CELL</td></tr>"""
found = False
tablecolumns+=1
table.append("\t\t"+"".join(td))
table.append("""\t<tr>\n""")
tablerows+=1
table.append("""<table>\n""")
table.reverse()
print("generating interior list for "+str(len(masterintdict))+" interior cells.")
formattedintlist = ""
formattedintlist += intexttableopen
masterintdict = dict(sorted(masterintdict.items()))
for items in masterintdict:
formattedintlist += """<tr><span class="tooltiptext"><td>Cell: <b>"""+str(items)+"""</b><BR>Mods: """+str(masterintdict[items])+"""</td></span></tr>\n"""
formattedintlist += intexttableclose
print("exporting HTML")
html_body = ""
html_int_body = ""
html_ext_body = ""
html_allpage_navbar_start = """
<nav class="nav">
<div class="flex-container">
<h2 class="logo"><a href="index.html#map["""+str(midvaluex)+""", """+str(midvaluey)+"""]" title="jump to map center (more or less)">Morrowind Modmapper """+str(version)+"""</a></h2>"""
html_mainpage_navbar_mid = """Last ran on """+str(generationdate)+""", mapped """+str(len(esplist))+""" files."""
if excludecounter > 0:
html_mainpage_navbar_mid += """ Skipped """+str(excludecounter)+""" files on the exclude list. """
if failcounter > 0:
html_mainpage_navbar_mid += """ Failed to convert """+str(failcounter)+""" mods."""
html_intextpage_navbar_mid = """ <input type="text" id="intextinput" onkeyup="intextsearch()" placeholder="Filter cells or mods.." title="Type something">"""
html_allpage_navbar_end = """
<ul>
<li><a href="index.html#map["""+str(midvaluex)+""", """+str(midvaluey)+"""]" title="jump to map center (more or less)">Map</a></li>
<li><a href="modmapper_interiors.html" title="open page of Interior cells">Interiors</a></li>
<li><a href="modmapper_exteriors.html" title="open page of Exterior cells">Exteriors</a></li>
<li><a href="https://www.nexusmods.com/morrowind/mods/53069" title="NexusMods mod page (new tab)" target="_blank">NexusMods</a></li>
<li><a href="https://github.com/acidzebra/modmapper" title="Modmapper GitHub page (new tab)" target="_blank">Github</a></li>
</ul>
</div>
</nav>
"""
if splitpages:
# index page
html_body += html_allpage_navbar_start
html_body += html_mainpage_navbar_mid
html_body += html_allpage_navbar_end
html_body += html_body+"".join(table)
index_output = html_header+html_body+html_footer
# int page
html_int_body += html_allpage_navbar_start
html_int_body += html_intextpage_navbar_mid
html_int_body += html_allpage_navbar_end
i = 0
while i < 6:
html_int_body += """<br>"""
i+=1
html_int_body += formattedintlist
interior_output = html_header+html_int_body+html_footer
html_ext_body += html_allpage_navbar_start
html_ext_body += html_intextpage_navbar_mid
html_ext_body += html_allpage_navbar_end
i = 0
while i < 6:
html_ext_body += """<br>"""
i+=1
html_ext_body += intexttableopen
html_ext_body += formattedextlist
html_ext_body += intexttableclose
exterior_output = html_header+html_ext_body+html_footer
html_file= open("index.html","w")
html_file.write(index_output)
html_file.close()
html_file= open("modmapper_interiors.html","w")
html_file.write(interior_output)
html_file.close()
html_file= open("modmapper_exteriors.html","w")
html_file.write(exterior_output)
html_file.close()
else:
html_body += "".join(table)
html_body += formattedextlist
html_body += formattedintlist
index_output = html_header+html_body+html_footer
html_file= open("index.html","w")
html_file.write(index_output)
html_file.close()
print("all done! I hope you enjoy modmapper.")
# Copyright © 2023 acidzebra
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.