-
Notifications
You must be signed in to change notification settings - Fork 25
/
puzzle.py
4723 lines (3454 loc) · 158 KB
/
puzzle.py
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
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Puzzle NSMBU
# This is Puzzle 0.6, ported to Python 3 & PyQt5, and then ported to support the New Super Mario Bros. U tileset format.
# Puzzle 0.6 by Tempus; all improvements for Python 3, PyQt5 and NSMBU by RoadrunnerWMC and AboodXD
import json
import os
import os.path
import platform
import struct
import sys
import zlib
from ctypes import create_string_buffer
from PyQt5 import QtCore, QtGui, QtWidgets
Qt = QtCore.Qt
import globals
from gtx import RAWtoGTX
import SarcLib
from tileset import HandleTilesetEdited, loadGTX, writeGTX
from tileset import updateCollisionOverlay
########################################################
# To Do:
#
# - Object Editor
# - Moving objects around
#
# - Make UI simpler for Pop
# - Animated Tiles
# - fix up conflicts with different types of parameters
# - C speed saving
# - quick settings for applying to mulitple slopes
#
########################################################
Tileset = None
#############################################################################################
########################## Tileset Class and Tile/Object Subclasses #########################
class TilesetClass:
'''Contains Tileset data. Inits itself to a blank tileset.
Methods: addTile, removeTile, addObject, removeObject, clear'''
class Tile:
def __init__(self, image, nml, collision):
'''Tile Constructor'''
self.image = image
self.normalmap = nml
self.setCollision(collision)
def setCollision(self, collision):
self.coreType = (collision >> 0) & 0xFFFF
self.params = (collision >> 16) & 0xFF
self.params2 = (collision >> 24) & 0xFF
self.solidity = (collision >> 32) & 0xF
self.slide = (collision >> 36) & 0xF
self.terrain = (collision >> 40) & 0xFF
def getCollision(self):
return ((self.coreType << 0) |
(self.params << 16) |
(self.params2 << 24) |
(self.solidity << 32) |
(self.slide << 36) |
(self.terrain << 40))
class Object:
def __init__(self, height, width, randByte, uslope, lslope, tilelist):
'''Tile Constructor'''
self.randX = (randByte >> 4) & 1
self.randY = (randByte >> 5) & 1
self.randLen = randByte & 0xF
self.upperslope = uslope
self.lowerslope = lslope
assert (width, height) != 0
self.height = height
self.width = width
self.tiles = tilelist
self.determineRepetition()
if self.repeatX or self.repeatY:
assert self.height == len(self.tiles)
assert self.width == max(len(self.tiles[y]) for y in range(self.height))
if self.repeatX:
self.determineRepetitionFinalize()
else:
# Fix a bug from a previous version of Puzzle
# where the actual width and height would
# mismatch with the number of tiles for the object
self.fillMissingTiles()
self.tilingMethodIdx = self.determineTilingMethod()
def determineRepetition(self):
self.repeatX = []
self.repeatY = []
if self.upperslope[0] != 0:
return
#### Find X Repetition ####
# You can have different X repetitions between rows, so we have to account for that
for y in range(self.height):
repeatXBn = -1
repeatXEd = -1
for x in range(len(self.tiles[y])):
if self.tiles[y][x][0] & 1 and repeatXBn == -1:
repeatXBn = x
elif not self.tiles[y][x][0] & 1 and repeatXBn != -1:
repeatXEd = x
break
if repeatXBn != -1:
if repeatXEd == -1:
repeatXEd = len(self.tiles[y])
self.repeatX.append((y, repeatXBn, repeatXEd))
#### Find Y Repetition ####
repeatYBn = -1
repeatYEd = -1
for y in range(self.height):
if len(self.tiles[y]) and self.tiles[y][0][0] & 2:
if repeatYBn == -1:
repeatYBn = y
elif repeatYBn != -1:
repeatYEd = y
break
if repeatYBn != -1:
if repeatYEd == -1:
repeatYEd = self.height
self.repeatY = [repeatYBn, repeatYEd]
def determineRepetitionFinalize(self):
if self.repeatX:
# If any X repetition is present, fill in rows which didn't have X repetition set
## Should never happen, unless the tileset is broken
## Additionally, sort the list
repeatX = []
for y in range(self.height):
for row, start, end in self.repeatX:
if y == row:
repeatX.append([start, end])
break
else:
# Get the start and end X offsets for the row
start = 0
end = len(self.tiles[y])
repeatX.append([start, end])
self.repeatX = repeatX
def fillMissingTiles(self):
realH = len(self.tiles)
while realH > self.height:
del self.tiles[-1]
realH -= 1
for row in self.tiles:
realW = len(row)
while realW > self.width:
del row[-1]
realW -= 1
for row in self.tiles:
realW = len(row)
while realW < self.width:
row.append((0, 0, 0))
realW += 1
while realH < self.height:
self.tiles.append([(0, 0, 0) for _ in range(self.width)])
realH += 1
def createRepetitionX(self):
self.repeatX = []
for y in range(self.height):
for x in range(len(self.tiles[y])):
self.tiles[y][x] = (self.tiles[y][x][0] | 1, self.tiles[y][x][1], self.tiles[y][x][2])
self.repeatX.append([0, len(self.tiles[y])])
def createRepetitionY(self, y1, y2):
self.clearRepetitionY()
for y in range(y1, y2):
for x in range(len(self.tiles[y])):
self.tiles[y][x] = (self.tiles[y][x][0] | 2, self.tiles[y][x][1], self.tiles[y][x][2])
self.repeatY = [y1, y2]
def clearRepetitionX(self):
self.fillMissingTiles()
for y in range(self.height):
for x in range(self.width):
self.tiles[y][x] = (self.tiles[y][x][0] & ~1, self.tiles[y][x][1], self.tiles[y][x][2])
self.repeatX = []
def clearRepetitionY(self):
for y in range(self.height):
for x in range(len(self.tiles[y])):
self.tiles[y][x] = (self.tiles[y][x][0] & ~2, self.tiles[y][x][1], self.tiles[y][x][2])
self.repeatY = []
def clearRepetitionXY(self):
self.clearRepetitionX()
self.clearRepetitionY()
def determineTilingMethod(self):
if self.upperslope[0] == 0x93:
return 7
elif self.upperslope[0] == 0x92:
return 6
elif self.upperslope[0] == 0x91:
return 5
elif self.upperslope[0] == 0x90:
return 4
elif self.repeatX and self.repeatY:
return 3
elif self.repeatY:
return 2
elif self.repeatX:
return 1
return 0
def getRandByte(self):
"""
Builds the Randomization byte.
"""
if (self.width, self.height) != (1, 1): return 0
if self.randX + self.randY == 0: return 0
byte = 0
if self.randX: byte |= 16
if self.randY: byte |= 32
return byte | (self.randLen & 0xF)
def __init__(self):
'''Constructor'''
self.tiles = []
self.objects = []
self.overrides = [None] * 256
self.slot = 0
self.placeNullChecked = False
def addTile(self, image, nml, collision=0):
'''Adds an tile class to the tile list with the passed image or parameters'''
self.tiles.append(self.Tile(image, nml, collision))
def addObject(self, height = 1, width = 1, randByte = 0, uslope = [0, 0], lslope = [0, 0], tilelist = None, new = False):
'''Adds a new object'''
if new:
tilelist = [[(0, 0, self.slot)]]
self.objects.append(self.Object(height, width, randByte, uslope, lslope, tilelist))
def removeObject(self, index):
'''Removes an Object by Index number. Don't use this much, because we want objects to preserve their ID.'''
try:
self.objects.pop(index)
except IndexError:
pass
def clear(self):
'''Clears the tileset for a new file'''
self.tiles = []
self.objects = []
def processOverrides(self):
if self.slot != 0:
return
try:
t = self.overrides
o = globals.Overrides
# Invisible, brick and ? blocks
## Invisible
replace = 3
for i in [3, 4, 5, 6, 7, 8, 9, 10, 13, 29]:
t[i] = o[replace].main
replace += 1
## Brick
for i in range(16, 28):
t[i] = o[i].main
## ?
t[49] = o[46].main
for i in range(32, 43):
t[i] = o[i].main
# Collisions
## Full block
t[1] = o[1].main
## Vine stopper
t[2] = o[2].main
## Solid-on-top
t[11] = o[13].main
## Half block
t[12] = o[14].main
## Muncher (hit)
t[45] = o[45].main
## Muncher (hit) 2
t[209] = o[44].main
## Donut lift
t[53] = o[43].main
## Conveyor belts
### Left
#### Fast
replace = 115
for i in range(163, 166):
t[i] = o[replace].main
replace += 1
#### Slow
replace = 99
for i in range(147, 150):
t[i] = o[replace].main
replace += 1
### Right
#### Fast
replace = 112
for i in range(160, 163):
t[i] = o[replace].main
replace += 1
#### Slow
replace = 96
for i in range(144, 147):
t[i] = o[replace].main
replace += 1
## Pipes
### Green
#### Vertical
t[64] = o[48].main
t[65] = o[49].main
t[80] = o[64].main
t[81] = o[65].main
t[96] = o[80].main
t[97] = o[81].main
#### Horizontal
t[87] = o[71].main
t[103] = o[87].main
t[88] = o[72].main
t[104] = o[88].main
t[89] = o[73].main
t[105] = o[89].main
### Yellow
#### Vertical
t[66] = o[50].main
t[67] = o[51].main
t[82] = o[66].main
t[83] = o[67].main
t[98] = o[82].main
t[99] = o[83].main
#### Horizontal
t[90] = o[74].main
t[106] = o[90].main
t[91] = o[75].main
t[107] = o[91].main
t[92] = o[76].main
t[108] = o[92].main
### Red
#### Vertical
t[68] = o[52].main
t[69] = o[53].main
t[84] = o[68].main
t[85] = o[69].main
t[100] = o[84].main
t[101] = o[85].main
#### Horizontal
t[93] = o[77].main
t[109] = o[93].main
t[94] = o[78].main
t[110] = o[94].main
t[95] = o[79].main
t[111] = o[95].main
### Mini (green)
#### Vertical
t[70] = o[54].main
t[86] = o[70].main
t[102] = o[86].main
#### Horizontal
t[120] = o[104].main
t[121] = o[105].main
t[137] = o[121].main
### Joints
#### Normal
t[118] = o[102].main
t[119] = o[103].main
t[134] = o[118].main
t[135] = o[119].main
#### Mini
t[136] = o[120].main
# Coins
t[30] = o[30].main
## Outline
t[31] = o[29].main
### Multiplayer
t[28] = o[28].main
## Blue
t[46] = o[47].main
# Flowers / Grass
grassType = 5
for sprite in globals.Area.sprites:
if sprite.type == 564:
grassType = min(sprite.spritedata[5] & 0xf, 5)
if grassType < 2:
grassType = 0
elif grassType in [3, 4]:
grassType = 3
if grassType == 0: # Forest
replace_flowers = 160
replace_grass = 163
replace_both = 168
elif grassType == 2: # Underground
replace_flowers = 55
replace_grass = 171
replace_both = 188
elif grassType == 3: # Sky
replace_flowers = 176
replace_grass = 179
replace_both = 184
else: # Normal
replace_flowers = 55
replace_grass = 58
replace_both = 106
## Flowers
replace = replace_flowers
for i in range(210, 213):
t[i] = o[replace].main
replace += 1
## Grass
replace = replace_grass
for i in range(178, 183):
t[i] = o[replace].main
replace += 1
## Flowers and grass
replace = replace_both
for i in range(213, 216):
t[i] = o[replace].main
replace += 1
# Lines
## Straight lines
### Normal
t[216] = o[128].main
t[217] = o[63].main
### Corners and diagonals
replace = 122
for i in range(218, 231):
if i != 224: # random empty tile
t[i] = o[replace].main
replace += 1
## Circles and stops
for i in range(231, 256):
t[i] = o[replace].main
replace += 1
except Exception:
warningBox = QtWidgets.QMessageBox(QtWidgets.QMessageBox.NoIcon, 'OH NO',
'Whoops, something went wrong while processing the overrides...')
warningBox.exec_()
def getUsedTiles(self):
usedTiles = []
if self.slot == 0:
usedTiles.append(0)
for i, tile in enumerate(self.overrides):
if tile is not None:
usedTiles.append(i)
for object in self.objects:
for i in range(len(object.tiles)):
for tile in object.tiles[i]:
if not tile[2] & 3 and self.slot: # Pa0 tile 0 used in another slot, don't count it
continue
if object.randLen > 0:
for i in range(object.randLen):
if tile[1] + i not in usedTiles:
usedTiles.append(tile[1] + i)
else:
if tile[1] not in usedTiles:
usedTiles.append(tile[1])
return usedTiles
#############################################################################################
######################### Palette for painting behaviours to tiles ##########################
class paletteWidget(QtWidgets.QWidget):
def __init__(self, window):
super(paletteWidget, self).__init__(window)
# Core Types Radio Buttons and Tooltips
self.coreType = QtWidgets.QGroupBox()
self.coreType.setTitle('Core Type:')
self.coreWidgets = []
coreLayout = QtWidgets.QGridLayout()
path = globals.miyamoto_path + '/miyamotodata/Icons/'
self.coreTypes = [
['Default', QtGui.QIcon(path + 'Core/Default.png'), 'The standard type for tiles.\n\nAny regular terrain or backgrounds\nshould be of this generic type.'],
['Rails', QtGui.QIcon(path + 'Core/Rails.png'), 'Used for all types of rails.\n\nRails are replaced in-game with\n3D models, so modifying these\ntiles with different graphics\nwill have no effect.'],
['Dash Coin', QtGui.QIcon(path + 'Core/DashCoin.png'), 'Creates a dash coin.\n\nDash coins, also known as\n"coin outlines," turn into\na coin a second or so after they\nare touched by the player.'],
['Coin', QtGui.QIcon(path + 'Core/Coin.png'), 'Creates a coin.\n\nCoins have no solid collision,\nand when touched will disappear\nand increment the coin counter.\nUnused Blue Coins go in this\ncategory, too.'],
['Blue Coin', QtGui.QIcon(path + 'Core/BlueCoin.png'), 'This is used for the blue coin in Pa0_jyotyu\nthat has a black checkerboard outline.'],
['Explodable Block', QtGui.QIcon(path + 'Core/UsedWoodStoneRed.png'), 'Defines a used item block, a stone\nblock, a wooden block or a red block.'],
['Brick Block', QtGui.QIcon(path + 'Core/Brick.png'), 'Defines a brick block.'],
['? Block', QtGui.QIcon(path + 'Core/Qblock.png'), 'Defines a ? block.'],
['Red Block Outline(?)', QtGui.QIcon(path + 'Unknown.png'), 'Looking at NSMB2, this is supposedly the core type for Red Block Outline.'],
['Partial Block', QtGui.QIcon(path + 'Core/Partial.png'), '<b>DOESN\'T WORK!</b>\n\nUsed for blocks with partial collisions.\n\nVery useful for Mini-Mario secret\nareas, but also for providing a more\naccurate collision map for your tiles.\nUse with the "Solid" setting.'],
['Invisible Block', QtGui.QIcon(path + 'Core/Invisible.png'), 'Used for invisible item blocks.'],
['Slope', QtGui.QIcon(path + 'Core/Slope.png'), 'Defines a sloped tile.\n\nSloped tiles have sloped collisions,\nwhich Mario can slide on.'],
['Reverse Slope', QtGui.QIcon(path + 'Core/RSlope.png'), 'Defines an upside-down slope.\n\nSloped tiles have sloped collisions,\nwhich Mario can hit.'],
['Liquid', QtGui.QIcon(path + 'Core/Quicksand.png'), 'Creates a liquid area. All seen to be non-functional, except for Quicksand, which should be used with the "Quicksand" terrain type.'],
['Climbable Terrian', QtGui.QIcon(path + 'Core/Climb.png'), 'Creates terrain that can be\nclimbed on.\n\nClimable terrain cannot be walked on.\n\nWhen Mario is on top of a climable\ntile and the player presses up, Mario\nwill enter a climbing state.'],
['Damage Tile', QtGui.QIcon(path + 'Core/Skull.png'), 'Various damaging tiles.\n\nIcicle/Spike tiles will damage Mario one hit\nwhen they are touched, whereas lava and poison water will instantly kill Mario and play the corresponding death animation.'],
['Pipe/Joint', QtGui.QIcon(path + 'Core/Pipe.png'), 'Denotes a pipe tile, or a pipe joint.\n\nPipe tiles are specified according to\nthe part of the pipe. It\'s important\nto specify the right parts or\nentrances may not function correctly.'],
['Conveyor Belt', QtGui.QIcon(path + 'Core/Conveyor.png'), 'Defines moving tiles.\n\nMoving tiles will move Mario in one\ndirection or another.'],
['Donut Block', QtGui.QIcon(path + 'Core/Donut.png'), 'Creates a falling donut block.\n\nThese blocks fall after they have been\nstood on for a few seconds, and then\nrespawn later. They are replaced by\nthe game with 3D models, so you can\'t\neasily make your own.'],
['Cave Entrance', QtGui.QIcon(path + 'Core/Cave.png'), 'Creates a cave entrance.\n\nCave entrances are used to mark secret\nareas hidden behind Layer 0 tiles.'],
['Hanging Ledge', QtGui.QIcon(path + 'Core/Ledge.png'), 'Creates a hanging ledge, or terrain that can be\nclimbed on with a ledge.\n\nYou cannot climb down from the <b>hanging</b> ledge\nif climable terrian is under it,\nand you cannot climb up from the climable terrian\nif the <b>hanging</b> ledge is above it.\n\nFor such behavior, you need the climbable wall with ledge.'],
['Rope', QtGui.QIcon(path + 'Core/Rope.png'), 'Unused type that produces a rope you can hang to. If solidity is set to "None," it will have no effect. "Solid on Top" and "Solid on Bottom" produce no useful behavior.'],
['Climbable Pole', QtGui.QIcon(path + 'Core/Pole.png'), 'Creates a pole that can be climbed. Use with "No Solidity."'],
]
for i, item in enumerate(self.coreTypes):
self.coreWidgets.append(QtWidgets.QRadioButton())
if i == 0:
self.coreWidgets[i].setText(item[0])
else:
self.coreWidgets[i].setIcon(item[1])
self.coreWidgets[i].setIconSize(QtCore.QSize(24, 24))
self.coreWidgets[i].setToolTip('<b>' + item[0] + ':</b><br><br>' + item[2].replace('\n', '<br>'))
self.coreWidgets[i].clicked.connect(self.swapParams)
coreLayout.addWidget(self.coreWidgets[i], i // 4, i % 4)
self.coreWidgets[0].setChecked(True) # make "Default" selected at first
self.coreType.setLayout(coreLayout)
# Parameters
self.parametersGroup = QtWidgets.QGroupBox()
self.parametersGroup.setTitle('Parameters:')
parametersLayout = QtWidgets.QVBoxLayout()
self.parameters1 = QtWidgets.QComboBox()
self.parameters2 = QtWidgets.QComboBox()
self.parameters1.setIconSize(QtCore.QSize(24, 24))
self.parameters2.setIconSize(QtCore.QSize(24, 24))
self.parameters1.setMinimumHeight(32)
self.parameters2.setMinimumHeight(32)
self.parameters1.hide()
self.parameters2.hide()
parametersLayout.addWidget(self.parameters1)
parametersLayout.addWidget(self.parameters2)
self.parametersGroup.setLayout(parametersLayout)
GenericParams = [
['Normal', QtGui.QIcon()],
['Beanstalk Stop', QtGui.QIcon(path + '/Generic/Beanstopper.png')],
]
RailParams = [
['Upslope', QtGui.QIcon(path + 'Rails/Upslope.png')],
['Downslope', QtGui.QIcon(path + 'Rails/Downslope.png')],
['Top-Left Corner', QtGui.QIcon(path + 'Rails/Top-Left Corner.png')],
['Bottom-Right Corner', QtGui.QIcon(path + 'Rails/Bottom-Right Corner.png')],
['Horizontal', QtGui.QIcon(path + 'Rails/Horizontal.png')],
['Vertical', QtGui.QIcon(path + 'Rails/Vertical.png')],
['Blank', QtGui.QIcon()],
['Gentle Upslope 2', QtGui.QIcon(path + 'Rails/Gentle Upslope 2.png')],
['Gentle Upslope 1', QtGui.QIcon(path + 'Rails/Gentle Upslope 1.png')],
['Gentle Downslope 2', QtGui.QIcon(path + 'Rails/Gentle Downslope 2.png')],
['Gentle Downslope 1', QtGui.QIcon(path + 'Rails/Gentle Downslope 1.png')],
['Steep Upslope 2', QtGui.QIcon(path + 'Rails/Steep Upslope 2.png')],
['Steep Upslope 1', QtGui.QIcon(path + 'Rails/Steep Upslope 1.png')],
['Steep Downslope 2', QtGui.QIcon(path + 'Rails/Steep Downslope 2.png')],
['Steep Downslope 1', QtGui.QIcon(path + 'Rails/Steep Downslope 1.png')],
['1x1 Circle', QtGui.QIcon(path + 'Rails/1x1 Circle.png')],
['2x2 Circle Upper Right', QtGui.QIcon(path + 'Rails/2x2 Circle Upper Right.png')],
['2x2 Circle Upper Left', QtGui.QIcon(path + 'Rails/2x2 Circle Upper Left.png')],
['2x2 Circle Lower Right', QtGui.QIcon(path + 'Rails/2x2 Circle Lower Right.png')],
['2x2 Circle Lower Left', QtGui.QIcon(path + 'Rails/2x2 Circle Lower Left.png')],
['4x4 Circle Top Left Corner', QtGui.QIcon(path + 'Rails/4x4 Circle Top Left Corner.png')],
['4x4 Circle Top Left', QtGui.QIcon(path + 'Rails/4x4 Circle Top Left.png')],
['4x4 Circle Top Right', QtGui.QIcon(path + 'Rails/4x4 Circle Top Right.png')],
['4x4 Circle Top Right Corner', QtGui.QIcon(path + 'Rails/4x4 Circle Top Right Corner.png')],
['4x4 Circle Upper Left Side', QtGui.QIcon(path + 'Rails/4x4 Circle Upper Left Side.png')],
['4x4 Circle Upper Right Side', QtGui.QIcon(path + 'Rails/4x4 Circle Upper Right Side.png')],
['4x4 Circle Lower Left Side', QtGui.QIcon(path + 'Rails/4x4 Circle Lower Left Side.png')],
['4x4 Circle Lower Right Side', QtGui.QIcon(path + 'Rails/4x4 Circle Lower Right Side.png')],
['4x4 Circle Bottom Left Corner', QtGui.QIcon(path + 'Rails/4x4 Circle Bottom Left Corner.png')],
['4x4 Circle Bottom Left', QtGui.QIcon(path + 'Rails/4x4 Circle Bottom Left.png')],
['4x4 Circle Bottom Right', QtGui.QIcon(path + 'Rails/4x4 Circle Bottom Right.png')],
['4x4 Circle Bottom Right Corner', QtGui.QIcon(path + 'Rails/4x4 Circle Bottom Right Corner.png')],
['End Stop', QtGui.QIcon()],
]
CoinParams = [
['Generic Coin', QtGui.QIcon(path + 'Core/Coin.png')],
['Nothing', QtGui.QIcon()],
['Blue Coin', QtGui.QIcon(path + 'Core/BlueCoin.png')],
]
ExplodableBlockParams = [
['Used Item Block', QtGui.QIcon(path + 'ExplodableBlock/Used.png')],
['Stone Block', QtGui.QIcon(path + 'ExplodableBlock/Stone.png')],
['Wooden Block', QtGui.QIcon(path + 'ExplodableBlock/Wooden.png')],
['Red Block', QtGui.QIcon(path + 'ExplodableBlock/Red.png')],
]
PartialParams = [
['Upper Left', QtGui.QIcon(path + 'Partial/UpLeft.png')],
['Upper Right', QtGui.QIcon(path + 'Partial/UpRight.png')],
['Top Half', QtGui.QIcon(path + 'Partial/TopHalf.png')],
['Lower Left', QtGui.QIcon(path + 'Partial/LowLeft.png')],
['Left Half', QtGui.QIcon(path + 'Partial/LeftHalf.png')],
['Diagonal Downwards', QtGui.QIcon(path + 'Partial/DiagDn.png')],
['Upper Left 3/4', QtGui.QIcon(path + 'Partial/UpLeft3-4.png')],
['Lower Right', QtGui.QIcon(path + 'Partial/LowRight.png')],
['Diagonal Downwards', QtGui.QIcon(path + 'Partial/DiagDn.png')],
['Right Half', QtGui.QIcon(path + 'Partial/RightHalf.png')],
['Upper Right 3/4', QtGui.QIcon(path + 'Partial/UpRig3-4.png')],
['Lower Half', QtGui.QIcon(path + 'Partial/LowHalf.png')],
['Lower Left 3/4', QtGui.QIcon(path + 'Partial/LowLeft3-4.png')],
['Lower Right 3/4', QtGui.QIcon(path + 'Partial/LowRight3-4.png')],
['Full Brick', QtGui.QIcon(path + 'Partial/Full.png')],
]
SlopeParams = [
['Steep Upslope', QtGui.QIcon(path + 'Slope/steepslopeleft.png')],
['Steep Downslope', QtGui.QIcon(path + 'Slope/steepsloperight.png')],
['Upslope 1', QtGui.QIcon(path + 'Slope/slopeleft.png')],
['Upslope 2', QtGui.QIcon(path + 'Slope/slope3left.png')],
['Downslope 1', QtGui.QIcon(path + 'Slope/slope3right.png')],
['Downslope 2', QtGui.QIcon(path + 'Slope/sloperight.png')],
['Very Steep Upslope 1', QtGui.QIcon(path + 'Slope/vsteepup1.png')],
['Very Steep Upslope 2', QtGui.QIcon(path + 'Slope/vsteepup2.png')],
['Very Steep Downslope 1', QtGui.QIcon(path + 'Slope/vsteepdown2.png')],
['Very Steep Downslope 2', QtGui.QIcon(path + 'Slope/vsteepdown1.png')],
['Slope Edge (solid)', QtGui.QIcon(path + 'Slope/edge.png')],
['Gentle Upslope 1', QtGui.QIcon(path + 'Slope/gentleupslope1.png')],
['Gentle Upslope 2', QtGui.QIcon(path + 'Slope/gentleupslope2.png')],
['Gentle Upslope 3', QtGui.QIcon(path + 'Slope/gentleupslope3.png')],
['Gentle Upslope 4', QtGui.QIcon(path + 'Slope/gentleupslope4.png')],
['Gentle Downslope 1', QtGui.QIcon(path + 'Slope/gentledownslope1.png')],
['Gentle Downslope 2', QtGui.QIcon(path + 'Slope/gentledownslope2.png')],
['Gentle Downslope 3', QtGui.QIcon(path + 'Slope/gentledownslope3.png')],
['Gentle Downslope 4', QtGui.QIcon(path + 'Slope/gentledownslope4.png')],
]
ReverseSlopeParams = [
['Steep Downslope', QtGui.QIcon(path + 'Slope/Rsteepslopeleft.png')],
['Steep Upslope', QtGui.QIcon(path + 'Slope/Rsteepsloperight.png')],
['Downslope 1', QtGui.QIcon(path + 'Slope/Rslopeleft.png')],
['Downslope 2', QtGui.QIcon(path + 'Slope/Rslope3left.png')],
['Upslope 1', QtGui.QIcon(path + 'Slope/Rslope3right.png')],
['Upslope 2', QtGui.QIcon(path + 'Slope/Rsloperight.png')],
['Very Steep Downslope 1', QtGui.QIcon(path + 'Slope/Rvsteepdown1.png')],
['Very Steep Downslope 2', QtGui.QIcon(path + 'Slope/Rvsteepdown2.png')],
['Very Steep Upslope 1', QtGui.QIcon(path + 'Slope/Rvsteepup2.png')],
['Very Steep Upslope 2', QtGui.QIcon(path + 'Slope/Rvsteepup1.png')],
['Slope Edge (solid)', QtGui.QIcon(path + 'Slope/edge.png')],
['Gentle Downslope 1', QtGui.QIcon(path + 'Slope/Rgentledownslope1.png')],
['Gentle Downslope 2', QtGui.QIcon(path + 'Slope/Rgentledownslope2.png')],
['Gentle Downslope 3', QtGui.QIcon(path + 'Slope/Rgentledownslope3.png')],
['Gentle Downslope 4', QtGui.QIcon(path + 'Slope/Rgentledownslope4.png')],
['Gentle Upslope 1', QtGui.QIcon(path + 'Slope/Rgentleupslope1.png')],
['Gentle Upslope 2', QtGui.QIcon(path + 'Slope/Rgentleupslope2.png')],
['Gentle Upslope 3', QtGui.QIcon(path + 'Slope/Rgentleupslope3.png')],
['Gentle Upslope 4', QtGui.QIcon(path + 'Slope/Rgentleupslope4.png')],
]
LiquidParams = [
['Unknown 0', QtGui.QIcon(path + 'Unknown.png')],
['Unknown 1', QtGui.QIcon(path + 'Unknown.png')],
['Unknown 2', QtGui.QIcon(path + 'Unknown.png')],
['Unknown 3', QtGui.QIcon(path + 'Unknown.png')],
['Quicksand', QtGui.QIcon(path + 'Core/Quicksand.png')],
]
ClimbableParams = [
['Vine', QtGui.QIcon(path + 'Climbable/Vine.png')],
['Climbable Wall', QtGui.QIcon(path + 'Core/Climb.png')],
['Climbable Fence', QtGui.QIcon(path + 'Climbable/Fence.png')],
]
DamageTileParams = [
['Icicle', QtGui.QIcon(path + 'Damage/Icicle1x1.png')],
['Long Icicle 1', QtGui.QIcon(path + 'Damage/Icicle1x2Top.png')],
['Long Icicle 2', QtGui.QIcon(path + 'Damage/Icicle1x2Bottom.png')],
['Left-Facing Spikes', QtGui.QIcon(path + 'Damage/SpikeLeft.png')],
['Right-Facing Spikes', QtGui.QIcon(path + 'Damage/SpikeRight.png')],
['Up-Facing Spikes', QtGui.QIcon(path + 'Damage/Spike.png')],
['Down-Facing Spikes', QtGui.QIcon(path + 'Damage/SpikeDown.png')],
['Instant Death', QtGui.QIcon(path + 'Core/Skull.png')],
['Lava', QtGui.QIcon(path + 'Damage/Lava.png')],
['Poison Water', QtGui.QIcon(path + 'Damage/Poison.png')],
]
PipeParams = [
['Vert. Top Entrance Left', QtGui.QIcon(path + 'Pipes/UpLeft.png')],
['Vert. Top Entrance Right', QtGui.QIcon(path + 'Pipes/UpRight.png')],
['Vert. Bottom Entrance Left', QtGui.QIcon(path + 'Pipes/DownLeft.png')],
['Vert. Bottom Entrance Right', QtGui.QIcon(path + 'Pipes/DownRight.png')],
['Horiz. Left Entrance Top', QtGui.QIcon(path + 'Pipes/LeftTop.png')],
['Horiz. Left Entrance Bottom', QtGui.QIcon(path + 'Pipes/LeftBottom.png')],
['Horiz. Right Entrance Top', QtGui.QIcon(path + 'Pipes/RightTop.png')],
['Horiz. Right Entrance Bottom', QtGui.QIcon(path + 'Pipes/RightBottom.png')],
['Vert. Mini Pipe Top', QtGui.QIcon(path + 'Pipes/MiniUp.png')],
['Vert. Mini Pipe Bottom', QtGui.QIcon(path + 'Pipes/MiniDown.png')],
['Horiz. Mini Pipe Left', QtGui.QIcon(path + 'Pipes/MiniLeft.png')],
['Horiz. Mini Pipe Right', QtGui.QIcon(path + 'Pipes/MiniRight.png')],
['Vert. Center Left', QtGui.QIcon(path + 'Pipes/VertCenterLeft.png')],
['Vert. Center Right', QtGui.QIcon(path + 'Pipes/VertCenterRight.png')],
['Vert. Intersection Left', QtGui.QIcon(path + 'Pipes/VertIntersectLeft.png')],
['Vert. Intersection Right', QtGui.QIcon(path + 'Pipes/VertIntersectRight.png')],
['Horiz. Center Top', QtGui.QIcon(path + 'Pipes/HorizCenterTop.png')],
['Horiz. Center Bottom', QtGui.QIcon(path + 'Pipes/HorizCenterBottom.png')],
['Horiz. Intersection Top', QtGui.QIcon(path + 'Pipes/HorizIntersectTop.png')],
['Horiz. Intersection Bottom', QtGui.QIcon(path + 'Pipes/HorizIntersectBottom.png')],
['UNUSED', QtGui.QIcon(path + 'Unknown.png')],
['UNUSED', QtGui.QIcon(path + 'Unknown.png')],
['UNUSED', QtGui.QIcon(path + 'Unknown.png')],
['Vert. Mini Pipe Center', QtGui.QIcon(path + 'Pipes/MiniVertCenter.png')],
['Horiz. Mini Pipe Center', QtGui.QIcon(path + 'Pipes/MiniHorizCenter.png')],
['UNUSED', QtGui.QIcon(path + 'Unknown.png')],
['UNUSED', QtGui.QIcon(path + 'Unknown.png')],
['UNUSED', QtGui.QIcon(path + 'Unknown.png')],
['UNUSED', QtGui.QIcon(path + 'Unknown.png')],
['UNUSED', QtGui.QIcon(path + 'Unknown.png')],
['UNUSED', QtGui.QIcon(path + 'Unknown.png')],
['UNUSED', QtGui.QIcon(path + 'Unknown.png')],
['UNUSED', QtGui.QIcon(path + 'Unknown.png')],
['UNUSED', QtGui.QIcon(path + 'Unknown.png')],
['UNUSED', QtGui.QIcon(path + 'Unknown.png')],
['Pipe Joint', QtGui.QIcon(path + 'Pipes/Joint.png')],
['Vert. Mini Pipe Intersection', QtGui.QIcon(path + 'Pipes/MiniVertIntersect.png')],
['Horiz. Mini Pipe Intersection', QtGui.QIcon(path + 'Pipes/MiniHorizIntersect.png')],
]
ConveyorParams = [
['Left', QtGui.QIcon(path + 'Conveyor/Left.png')],
['Right', QtGui.QIcon(path + 'Conveyor/Right.png')],
['Left Fast', QtGui.QIcon(path + 'Conveyor/LeftFast.png')],
['Right Fast', QtGui.QIcon(path + 'Conveyor/RightFast.png')],
]
CaveParams = [
['Left', QtGui.QIcon(path + 'Cave/Left.png')],
['Right', QtGui.QIcon(path + 'Cave/Right.png')],
]
ClimbLedgeParams = [
['Hanging Ledge', QtGui.QIcon(path + 'Core/Ledge.png')],
['Climbable Wall with Ledge', QtGui.QIcon(path + 'Core/ClimbLedge.png')],
]
self.ParameterList = [
GenericParams, # 0x00
RailParams, # 0x01
None, # 0x02
CoinParams, # 0x03
None, # 0x04
ExplodableBlockParams, # 0x05
None, # 0x06
None, # 0x07
None, # 0x08
PartialParams, # 0x09
None, # 0x0A
SlopeParams, # 0x0B
ReverseSlopeParams, # 0x0C
LiquidParams, # 0x0D
ClimbableParams, # 0x0E
DamageTileParams, # 0x0F
PipeParams, # 0x10
ConveyorParams, # 0x11
None, # 0x12
CaveParams, # 0x13
ClimbLedgeParams, # 0x14
None, # 0x15
None, # 0x16
]
DamageTileParams2 = [
['Default', QtGui.QIcon()],
['Muncher (no visible difference)', QtGui.QIcon(path + 'Damage/Muncher.png')],
]
PipeParams2 = [
['Green', QtGui.QIcon(path + 'PipeColors/Green.png')],
['Red', QtGui.QIcon(path + 'PipeColors/Red.png')],
['Yellow', QtGui.QIcon(path + 'PipeColors/Yellow.png')],
['Blue', QtGui.QIcon(path + 'PipeColors/Blue.png')],
]
self.ParameterList2 = [
None, # 0x0
None, # 0x1
None, # 0x2
None, # 0x3
None, # 0x4
None, # 0x5
None, # 0x6
None, # 0x7
None, # 0x8
None, # 0x9
None, # 0xA
None, # 0xB
None, # 0xC
None, # 0xD
None, # 0xE
DamageTileParams2, # 0xF
PipeParams2, # 0x10
None, # 0x11
None, # 0x12
None, # 0x13
None, # 0x14
None, # 0x15
None, # 0x16
]
# Collision Type
self.collsType = QtWidgets.QComboBox()
self.collsGroup = QtWidgets.QGroupBox('Collision Type')
L = QtWidgets.QVBoxLayout(self.collsGroup)
L.addWidget(self.collsType)
self.collsTypes = [
['No Solidity', QtGui.QIcon(path + 'Collisions/NoSolidity.png')],
['Solid', QtGui.QIcon(path + 'Collisions/Solid.png')],
['Solid-on-Top', QtGui.QIcon(path + 'Collisions/SolidOnTop.png')],
['Solid-on-Bottom', QtGui.QIcon(path + 'Collisions/SolidOnBottom.png')],
['Solid-on-Top and Bottom', QtGui.QIcon(path + 'Collisions/SolidOnTopBottom.png')],
['Solid, Force Slide', QtGui.QIcon(path + 'Collisions/SlopedSlide.png')],
['Solid-on-Top, Force Slide', QtGui.QIcon(path + 'Collisions/SlopedSlide.png')],
['Solid, Disable Slide', QtGui.QIcon(path + 'Collisions/SlopedSolidOnTop.png')],
['Solid-on-Top, Disable Slide', QtGui.QIcon(path + 'Collisions/SlopedSolidOnTop.png')],
]
for item in self.collsTypes:
self.collsType.addItem(item[1], item[0])
self.collsType.setIconSize(QtCore.QSize(24, 24))
self.collsType.setToolTip(
'Set the collision style of the terrain.\n\n'
'<b>No Solidity:</b>\nThe tile cannot be stood on or hit.\n\n'
'<b>Solid:</b>\nThe tile can be stood on and hit from all sides.\n\n'
'<b>Solid-on-Top:</b>\nThe tile can only be stood on.\n\n'
'<b>Solid-on-Bottom:</b>\nThe tile can only be hit from below.\n\n'
'<b>Solid-on-Top and Bottom:</b>\nThe tile can be stood on and hit from below, but not any other side.\n\n'
'<b>Force Slide:</b>\nThe player immediately starts sliding without being able to jump when interacting with this solidity.\n\n'
'<b>Disable Slide:</b>\nThe player will not be able to slide when interacting with this solidity.'.replace('\n', '<br>')
)
# Terrain Type
self.terrainType = QtWidgets.QComboBox()
self.terrainGroup = QtWidgets.QGroupBox('Terrain Type')
L = QtWidgets.QVBoxLayout(self.terrainGroup)
L.addWidget(self.terrainType)
# Quicksand is unused.
self.terrainTypes = [
['Default', QtGui.QIcon()], # 0x0
['Ice', QtGui.QIcon(path + 'Terrain/Ice.png')], # 0x1
['Snow', QtGui.QIcon(path + 'Terrain/Snow.png')], # 0x2
['Quicksand', QtGui.QIcon(path + 'Terrain/Quicksand.png')], # 0x3
['Desert Sand', QtGui.QIcon(path + 'Terrain/Sand.png')], # 0x4
['Grass', QtGui.QIcon(path + 'Terrain/Grass.png')], # 0x5
['Cloud', QtGui.QIcon(path + 'Terrain/Cloud.png')], # 0x6
['Beach Sand', QtGui.QIcon(path + 'Terrain/BeachSand.png')], # 0x7
['Carpet', QtGui.QIcon(path + 'Terrain/Carpet.png')], # 0x8
['Leaves', QtGui.QIcon(path + 'Terrain/Leaves.png')], # 0x9
['Wood', QtGui.QIcon(path + 'Terrain/Wood.png')], # 0xA
['Water', QtGui.QIcon(path + 'Terrain/Water.png')], # 0xB
['Beanstalk Leaf', QtGui.QIcon(path + 'Terrain/BeanstalkLeaf.png')], # 0xC
]
for item in range(len(self.terrainTypes)):
self.terrainType.addItem(self.terrainTypes[item][1], self.terrainTypes[item][0])
self.terrainType.setIconSize(QtCore.QSize(24, 24))
self.terrainType.setToolTip(
'Set the various types of terrain.\n\n'
'<b>Default:</b>\nTerrain with no paticular properties.\n\n'
'<b>Ice:</b>\nWill be slippery.\n\n'
'<b>Snow:</b>\nWill emit puffs of snow and snow noises.\n\n'
'<b>Quicksand:</b>\nWill emit puffs of sand. Use with the "Quicksand" core type.\n\n'
'<b>Sand:</b>\nWill create dark-colored sand tufts around\nMario\'s feet.\n\n'
'<b>Grass:</b>\nWill emit grass-like footstep noises.\n\n'
'<b>Cloud:</b>\nWill emit footstep noises for cloud platforms.\n\n'
'<b>Beach Sand:</b>\nWill create light-colored sand tufts around\nMario\'s feet.\n\n'
'<b>Carpet:</b>\nWill emit footstep noises for carpets.\n\n'
'<b>Leaves:</b>\nWill emit footstep noises for Palm Tree leaves.\n\n'