forked from alesan99/mari0_ae
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditor.lua
8291 lines (7650 loc) · 295 KB
/
editor.lua
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
--i figured i should start using local functions despite 1.6 using like none
local undo_clear, undo_store, undo_stopstore--[[, undo_undo]]
local meta_data, promptedmetadatasave
local updatetilesscrollbar, updatelevelscrollbar
local worldscrollbarheight, levelscrollbarheight
local tilehotkeys = {
["1"] = {t=false, entity=false},
["2"] = {t=false, entity=false},
["3"] = {t=false, entity=false},
["4"] = {t=false, entity=false},
["5"] = {t=false, entity=false},
["6"] = {t=false, entity=false},
["7"] = {t=false, entity=false},
["8"] = {t=false, entity=false},
["9"] = {t=false, entity=false},
["0"] = {t=false, entity=false},
}
local tilehotkeysindex = {}
local tilehotkeysentityindex = {}
local editorsavedata = false
local trackgenerationid
function editor_load(player_position) --{x, y, xscroll, yscroll}
--BLOCKTOGGLE STUFF
solidblockperma = {false, false, false, false}
collectables = {} --[marioworld-mariolevel-mariosublevel][x-y]
collectableslist = {{},{},{},{},{},{},{},{},{},{}}
collectablescount = {0,0,0,0,0,0,0,0,0,0}
animationnumbers = {}
autosave = false
subleveltest = false
--assist mode
if assistmode == nil then
if AutoAssistMode then
assistmode = true
else
assistmode = false
end
latesttiles = {{1, 1}, {2, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}} --{type of tile, id}
end
backgroundtilemode = false
--sublevels in level
sublevelstable = {}
if not (mappacklevels[marioworld]) then
print("PANIC, levels not found!")
for k = 0, defaultsublevels do
table.insert(sublevelstable, k)
end
else
if (not mappacklevels[marioworld][mariolevel]) then
print("PANIC, sublevels not found!")
mappacklevels[marioworld][mariolevel] = defaultsublevels
end
for k = 0, mappacklevels[marioworld][mariolevel] do
table.insert(sublevelstable, k)
end
end
brushsizetoggle = false
brushsizex = 1
brushsizey = 1
quickmenuopen = false
quickmenuopeny = (height*16)-24
quickmenuclosedy = (height*16)
quickmenuy = quickmenuclosedy
quickmenusel = false
quickmenuspeed = 200
tilehotkeysindex = {}
tilehotkeysentityindex = {}
for i, t in pairs(tilehotkeys) do
if t.entity then
tilehotkeysentityindex[t.t] = i
else
tilehotkeysindex[t.t] = i
end
end
levelmodified = false
if not currentanimation then
currentanimation = 1
end
animationguilines = {}
tileselection = false
tileselectionants = 0
tileselectionmoving = false --dragging tile selection
if tilesoffset == nil then
--there was a weird crash with this, idk if this fixes it
tilesoffset = 0
end
editmtobjects = false
mtsavehighlighttime = 5
mtsavetimer = 0
mtjustsaved = false
mtsavecolors = {255, 112, 112, 128}
pastingtiles = false
pastemode = 1
pastecenter = {0, 0}
mtclipboard = {} -- fill with x, y, tile
tooltipa = -1000
minimapscroll = 0
minimapx = 3
minimapy = 30
minimapheight = 15
currenttile = 1
minimapscrollspeed = 30
minimapdragging = false
minimapmoving = false
tilemenuy = 0
tilemenumoving = false
allowdrag = true
if love.mouse.isDown("l") then
allowdrag = false
end
animationguiarea = {12, 33, 399, 212}
animationlineinset = 14
rightclickmenuopen = false
customrcopen = false
powerlinestate = 1
selectiontoolclick = {{false, false}, {false, false}}
selectiontoolselection = {}
guielements["tabmain"] = guielement:new("button", 1, 1, TEXT["main"], maintab, 3)
guielements["tabmain"].fillcolor = {63, 63, 63}
guielements["tabtiles"] = guielement:new("button", guielements["tabmain"].x+guielements["tabmain"].width+10, 1, TEXT["tiles"], tilestab, 3)
guielements["tabtiles"].fillcolor = {63, 63, 63}
guielements["tabtools"] = guielement:new("button", guielements["tabtiles"].x+guielements["tabtiles"].width+10, 1, TEXT["tools"], toolstab, 3)
guielements["tabtools"].fillcolor = {63, 63, 63}
guielements["tabmaps"] = guielement:new("button", guielements["tabtools"].x+guielements["tabtools"].width+10, 1, TEXT["maps"], mapstab, 3)
guielements["tabmaps"].fillcolor = {63, 63, 63}
guielements["tabcustom"] = guielement:new("button", guielements["tabmaps"].x+guielements["tabmaps"].width+10, 1, TEXT["custom"], customtab, 3)
guielements["tabcustom"].fillcolor = {63, 63, 63}
guielements["tabanimations"] = guielement:new("button", guielements["tabcustom"].x+guielements["tabcustom"].width+10, 1, TEXT["animations"], animationstab, 3)
guielements["tabanimations"].fillcolor = {63, 63, 63}
--MAIN
if android then
autoscroll = false
end
guielements["autoscrollcheckbox"] = guielement:new("checkbox", width*16-14-utf8.len(TEXT["follow player"])*8, 20, toggleautoscroll, autoscroll, TEXT["follow player"])
for i = 1, #backgroundcolor do
guielements["defaultcolor" .. i] = guielement:new("button", 17+(i-1)*12, 78, " ", defaultbackground, 0, {i})
if i == 4 then
guielements["defaultcolor" .. i].fillcolor = backgroundrgb
else
guielements["defaultcolor" .. i].fillcolor = backgroundcolor[i]
end
end
--guielements["backgrounddropdown"] = guielement:new("dropdown", 17, 85, 6, changebackground, background, "blue", "black", "water", "rgb")
guielements["backgroundinput1"] = guielement:new("input", 65, 78, 3, changebackgroundrgb, backgroundrgb[1], 3, nil, nil, 0)
guielements["backgroundinput2"] = guielement:new("input", 93, 78, 3, changebackgroundrgb, backgroundrgb[2], 3, nil, nil, 0)
guielements["backgroundinput3"] = guielement:new("input", 121, 78, 3, changebackgroundrgb, backgroundrgb[3], 3, nil, nil, 0)
guielements["backgroundinput1"].numdrag = {0,255}
guielements["backgroundinput2"].numdrag = {0,255}
guielements["backgroundinput3"].numdrag = {0,255}
guielements["musicdropdown"] = guielement:new("dropdown", 17, 102, 15, changemusic, musici, unpack(editormusictable))
guielements["custommusiciinput"] = guielement:new("input", 150, 102, 2, changemusic, custommusici, 2, 1, "music", 0)
guielements["spritesetdropdown"] = guielement:new("dropdown", 17, 126, 11, changespriteset, spriteset, "overworld", "underground", "castle", "underwater")
guielements["timelimitdecrease"] = guielement:new("button", 17, 152, "{", decreasetimelimit, 0)
guielements["timelimitdecrease"].autorepeat = true
guielements["timelimitdecrease"].repeatwait = 0.3
guielements["timelimitdecrease"].repeatdelay = 0.08
guielements["timelimitinput"] = guielement:new("input", 29, 152, string.len(mariotimelimit), changetimelimit, tostring(mariotimelimit), 6, nil, nil, 0)
guielements["timelimitinput"].justdisplay = true
guielements["timelimitinput"].textoffset = 0
guielements["timelimitinput"].inputtingfunc = changetimelimitinputting
guielements["timelimitinput"].uninputtingfunc = changetimelimituninputting
guielements["timelimitincrease"] = guielement:new("button", 33 + string.len(mariotimelimit)*8, 152, "}", increasetimelimit, 0)
guielements["timelimitincrease"].autorepeat = true
guielements["timelimitincrease"].repeatwait = 0.3
guielements["timelimitincrease"].repeatdelay = 0.08
guielements["portalgundropdown"] = guielement:new("dropdown", 17, 175, 11, changeportalgun, portalguni, "normal", "none", "1 only", "2 only", "gel")
--guielements["portalgundropdown"].dropup = true
guielements["widthbutton"] = guielement:new("button", 384-(utf8.len(TEXT["change size"])*8), 200, TEXT["change size"], openchangewidth, 2)
guielements["savebutton"] = guielement:new("button", 10, 200, TEXT["save"], function() savelevel(); levelmodified = false end, 2)
guielements["menubutton"] = guielement:new("button", guielements["savebutton"].x+guielements["savebutton"].width+12, 200, TEXT["exit"], function() openconfirmmenu("exit") end, 2)
guielements["testbutton"] = guielement:new("button", guielements["menubutton"].x+guielements["menubutton"].width+12, 200, TEXT["test level"], test_level, 2)
guielements["testbuttonplayer"] = guielement:new("button", guielements["testbutton"].x+guielements["testbutton"].width+12, 200, TEXT["quick test"], function() test_level(objects["player"][1].x, objects["player"][1].y) end, 2)
guielements["savebutton"].bordercolor = {255, 0, 0}
guielements["savebutton"].bordercolorhigh = {255, 127, 127}
--guielements["levelpropertiesdropdown"] = guielement:new("dropdown", 200, 69, 20, function() end, 1, "level properties")
guielements["levelpropertiesdropdown"] = guielement:new("button", 200, 69, TEXT["level properties ↓"], levelpropertiestoggle, 1)
levelpropertiesdropdown = false
local lpx = 202
local lpy = guielements["levelpropertiesdropdown"].y+14
guielements["intermissioncheckbox"] = guielement:new("checkbox", lpx, lpy+10*(1-1), toggleintermission, intermission, TEXT["intermission"])
guielements["warpzonecheckbox"] = guielement:new("checkbox", lpx, lpy+10*(2-1), togglewarpzone, haswarpzone, TEXT["warpzone text"])
guielements["underwatercheckbox"] = guielement:new("checkbox", lpx, lpy+10*(3-1), toggleunderwater, underwater, TEXT["underwater"])
guielements["bonusstagecheckbox"] = guielement:new("checkbox", lpx, lpy+10*(4-1), togglebonusstage, bonusstage, TEXT["bonus stage"])
guielements["edgewrappingcheckbox"] = guielement:new("checkbox", lpx, lpy+10*(5-1), toggleedgewrapping, edgewrapping, TEXT["wrap around"])
guielements["lightsoutcheckbox"] = guielement:new("checkbox", lpx, lpy+10*(6-1), togglelightsout, lightsout, TEXT["lights out"])
guielements["lowgravitycheckbox"] = guielement:new("checkbox", lpx, lpy+10*(7-1), togglelowgravity, lowgravity, TEXT["low gravity"])
guielements["autoscrollingcheckbox"] = guielement:new("checkbox", 200, 86, toggleautoscrolling, autoscrolling, TEXT["autoscroll"])
guielements["autoscrollingscrollbar"] = guielement:new("scrollbar", 298, 86, 93, 35, 9, reverseautoscrollingscrollbar(), "hor")
guielements["autoscrollingscrollbar"].scrollstep = 0
guielements["custombackgroundcheckbox"] = guielement:new("checkbox", 200, 133, togglecustombackground, custombackground, TEXT["background"])
guielements["customforegroundcheckbox"] = guielement:new("checkbox", 200, 166, togglecustomforeground, customforeground, TEXT["foreground"])
guielements["scrollfactorxscrollbar"] = guielement:new("scrollbar", 298, 145, 93, 35, 9, reversescrollfactor(), "hor")
guielements["scrollfactoryscrollbar"] = guielement:new("scrollbar", 298, 155, 93, 35, 9, reversescrollfactor(scrollfactory), "hor")
guielements["scrollfactor2xscrollbar"] = guielement:new("scrollbar", 298, 177, 93, 35, 9, reversescrollfactor2(), "hor")
guielements["scrollfactor2yscrollbar"] = guielement:new("scrollbar", 298, 187, 93, 35, 9, reversescrollfactor2(scrollfactor2y), "hor")
guielements["scrollfactorxscrollbar"].scrollstep = 0
guielements["scrollfactoryscrollbar"].scrollstep = 0
guielements["scrollfactor2xscrollbar"].scrollstep = 0
guielements["scrollfactor2yscrollbar"].scrollstep = 0
guielements["backgrounddropdown"] = guielement:new("dropdown", 298, 133, 10, changecustombackground, 1, unpack(custombackgrounds))
guielements["foregrounddropdown"] = guielement:new("dropdown", 298, 165, 10, changecustomforeground, 1, unpack(custombackgrounds))
for i = 1, #custombackgrounds do
if custombackground and type(custombackground) == "string" and custombackground == custombackgrounds[i] then
guielements["backgrounddropdown"].var = i
guielements["custombackgroundcheckbox"].var = true
end
if customforeground and type(customforeground) == "string" and customforeground == custombackgrounds[i] then
guielements["foregrounddropdown"].var = i
guielements["customforegroundcheckbox"].var = true
end
end
--mapsize stuff
guielements["maptopup"] = guielement:new("button", 0, 0, "↑", changenewmapsize, nil, {"top", "up"}, nil, 8, 0.02)
guielements["maptopdown"] = guielement:new("button", 0, 0, "↓", changenewmapsize, nil, {"top", "down"}, nil, 8, 0.02)
guielements["mapleftleft"] = guielement:new("button", 0, 0, "{", changenewmapsize, nil, {"left", "left"}, nil, 8, 0.02)
guielements["mapleftright"] = guielement:new("button", 0, 0, "}", changenewmapsize, nil, {"left", "right"}, nil, 8, 0.02)
guielements["maprightleft"] = guielement:new("button", 0, 0, "{", changenewmapsize, nil, {"right", "left"}, nil, 8, 0.02)
guielements["maprightright"] = guielement:new("button", 0, 0, "}", changenewmapsize, nil, {"right", "right"}, nil, 8, 0.02)
guielements["mapbottomup"] = guielement:new("button", 0, 0, "↑", changenewmapsize, nil, {"bottom", "up"}, nil, 8, 0.02)
guielements["mapbottomdown"] = guielement:new("button", 0, 0, "↓", changenewmapsize, nil, {"bottom", "down"}, nil, 8, 0.02)
guielements["mapwidthapply"] = guielement:new("button", 0, 0, TEXT["apply"], mapwidthapply, 3)
guielements["mapwidthcancel"] = guielement:new("button", 0, 0, TEXT["cancel"], mapwidthcancel, 3)
--TILES
guielements["tilesall"] = guielement:new("button", 5, 20, TEXT["all"], tilesall, 2)
guielements["tilessmb"] = guielement:new("button", guielements["tilesall"].x+guielements["tilesall"].width+8, 20, TEXT["smb"], tilessmb, 2)
guielements["tilesportal"] = guielement:new("button", guielements["tilessmb"].x+guielements["tilessmb"].width+8, 20, TEXT["portal"], tilesportal, 2)
guielements["tilescustom"] = guielement:new("button", guielements["tilesportal"].x+guielements["tilesportal"].width+8, 20, TEXT["custom"], tilescustom, 2)
guielements["tilesanimated"] = guielement:new("button", guielements["tilescustom"].x+guielements["tilescustom"].width+8, 20, TEXT["animated"], tilesanimated, 2)
guielements["tilesobjects"] = guielement:new("button", guielements["tilesanimated"].x+guielements["tilesanimated"].width+8, 20, TEXT["objects"], tilesobjects, 2)
guielements["tilesentities"] = guielement:new("button", width*16-12-utf8.len(TEXT["entities"])*8, 20, TEXT["entities"], tilesentities, 2)
guielements["tilesscrollbar"] = guielement:new("scrollbar", 381, 37, 167, 15, 40, 0, "ver")
--TOOLS
guielements["linkbutton"] = guielement:new("button", 5, 22, TEXT["link tool"], linkbutton, 2, false, 1, 120)
guielements["linkbutton"].bordercolor = {0, 255, 0}
guielements["linkbutton"].bordercolorhigh = {220, 255, 220}
guielements["portalbutton"] = guielement:new("button", 5, 40, TEXT["portal gun"], portalbutton, 2, false, 1, 120)
guielements["portalbutton"].bordercolor = {0, 0, 255}
guielements["portalbutton"].bordercolorhigh = {127, 127, 255}
guielements["selectionbutton"] = guielement:new("button", 5, 58, TEXT["selection tool"], selectionbutton, 2, false, 1, 120)
guielements["selectionbutton"].bordercolor = {255, 106, 0}
guielements["selectionbutton"].bordercolorhigh = {255, 206, 127}
guielements["powerlinebutton"] = guielement:new("button", 5, 76, TEXT["power line draw"], powerlinebutton, 2, false, 1, 120)
guielements["powerlinebutton"].bordercolor = {255, 216, 0}
guielements["powerlinebutton"].bordercolorhigh = {255, 255, 220}
currenttooldesc = 1 --what description should be displayed for the buttons
guielements["livesdecrease"] = guielement:new("button", 294, 104, "{", livesdecrease, 0)
guielements["livesincrease"] = guielement:new("button", 314, 104, "}", livesincrease, 0)
guielements["physicsdropdown"] = guielement:new("dropdown", 294, 117, 11, changephysics, currentphysics, "mari0", "smb", "mari0-smb2j", "smb2j", "mari0-maker", "mario maker", "portal")
guielements["cameradropdown"] = guielement:new("dropdown", 294, 130, 11, changecamerasetting, camerasetting, "default", "centered"--[[, "forward only"]])
guielements["dropshadowcheckbox"] = guielement:new("checkbox", 294, 143, toggledropshadow, dropshadow, TEXT["drop shadow"])
guielements["realtimecheckbox"] = guielement:new("checkbox", 294, 154, togglerealtime, realtime, TEXT["real time"])
local _, count = TEXT["real time"]:gsub("\n", '')
guielements["continuemusiccheckbox"] = guielement:new("checkbox", 294, guielements["realtimecheckbox"].y+11+10*count, togglecontinuemusic, continuesublevelmusic, TEXT["cont. music"])
_, count = TEXT["cont. music"]:gsub("\n", '')
guielements["nolowtimecheckbox"] = guielement:new("checkbox", 294, guielements["continuemusiccheckbox"].y+11+10*count, togglenolowtime, nolowtime, TEXT["no low time"])
--MAPS
guielements["savebutton2"] = guielement:new("button", 300, 196, TEXT["save level"], guielements["savebutton"].func, 0, nil, 2.4, 94, true)
--guielements["autosavecheckbox"] = guielement:new("checkbox", 300, guielements["savebutton2"].y+16, function() autosave = not autosave; guielements["autosavecheckbox"].var = autosave end, autosave, TEXT["autosave"])
guielements["savebutton2"].bordercolor = {255, 0, 0}
guielements["savebutton2"].bordercolorhigh = {255, 127, 127}
guielements["worldscrollbar"] = guielement:new("scrollbar", 90, 20, 201, 11, 75, 0, "ver")
guielements["levelscrollbar"] = guielement:new("scrollbar", 383, 20, 173, 14, 60, oldlevelscrollbar or 0, "ver")
oldworldscrollbarv = 0
oldlevelscrollbarv = 0
oldlevelscrollbar = 0
levelrightclickmenu = guielement:new("rightclick", 0, 0, 6, levelrightclickmenuclick, false, "action", "copy", "paste", "delete")
levelrightclickmenu.active = false
--CUSTOM TAB
guielements["graphicscustomtab"] = guielement:new("button", 5, 20, TEXT["graphics"], customtabtab, 2, {"graphics"})
guielements["tilescustomtab"] = guielement:new("button", guielements["graphicscustomtab"].x+guielements["graphicscustomtab"].width+8, 20, TEXT["tiles"], customtabtab, 2, {"tiles"})
guielements["backgroundscustomtab"] = guielement:new("button", guielements["tilescustomtab"].x+guielements["tilescustomtab"].width+8, 20, TEXT["backgrounds"], customtabtab, 2, {"backgrounds"})
guielements["soundscustomtab"] = guielement:new("button", guielements["backgroundscustomtab"].x+guielements["backgroundscustomtab"].width+8, 20, TEXT["sounds"], customtabtab, 2, {"sounds"})
guielements["textcustomtab"] = guielement:new("button", guielements["soundscustomtab"].x+guielements["soundscustomtab"].width+8, 20, TEXT["text"], customtabtab, 2, {"text"})
guielements["enemiescustomtab"] = guielement:new("button", guielements["textcustomtab"].x+guielements["textcustomtab"].width+8, 20, TEXT["enemies"], customtabtab, 2, {"enemies"})
customtabstate = "graphics"
--custom graphics
changecurrentimage(1, true)
guielements["currentimagedropdown"] = guielement:new("dropdown", 184, 63, 22, changecurrentimage, currentcustomimage[1], unpack(imagestable))
guielements["currentimagedropdown"].displayentries = imagestabledisplay
--guielements["currentimagedropdown"].scrollbar.scrollstep = 0.11 --how much mousewheel scrolls
guielements["exportimagetemplate"] = guielement:new("button", 184, 88, TEXT["export template"], exportcustomimage, 2)
guielements["openfoldercustom"] = guielement:new("button", 184, 105, TEXT["open folder"], opencustomimagefolder, 2)
guielements["saveimage"] = guielement:new("button", 176, 199, TEXT["update image"], savecustomimage, 2)
guielements["saveimage"].bordercolor = {255, 0, 0}
guielements["saveimage"].bordercolorhigh = {255, 127, 127}
guielements["resetimage"] = guielement:new("button", guielements["saveimage"].x+guielements["saveimage"].width+8, 199, TEXT["reset"], resetcustomimage, 2)
--custom tiles
guielements["exporttilestemplate"] = guielement:new("button", 184, 63, TEXT["export template"], exportcustomimage, 2)
guielements["exportanimatedtilestemplate"] = guielement:new("button", 184, 163, TEXT["export template"], exportcustomimage, 2, {"animated"})
guielements["openfoldertilescustom"] = guielement:new("button", 184, 80, TEXT["open folder"], opencustomimagefolder, 2, {"tiles"})
guielements["openfolderanimatedtilescustom"] = guielement:new("button", 184, 180, TEXT["open folder"], opencustomimagefolder, 2, {"animated"})
--custom background
changecurrentbackground(1, true)
guielements["currentbackgrounddropdown"] = guielement:new("dropdown", 184, 63, 10, changecurrentbackground, 1, "background", "foreground")
guielements["openfolderbackgroundscustom"] = guielement:new("button", 184, 131, TEXT["open folder"], opencustomimagefolder, 2, {"backgrounds"})
--custom sounds
changecurrentsound(1, true)
guielements["currentsounddropdown"] = guielement:new("dropdown", 184, 63, 16, changecurrentsound, 1, unpack(soundliststring))
--guielements["currentsounddropdown"].scrollbar.scrollstep = 0.11 --how much mousewheel scrolls
guielements["openfoldersoundscustom"] = guielement:new("button", 184, 105, TEXT["open folder"], opencustomimagefolder, 2, {"sounds"})
guielements["openfoldermusiccustom"] = guielement:new("button", 184, 164, TEXT["open folder"], opencustomimagefolder, 2, {"music"})
guielements["savesounds"] = guielement:new("button", 176, 199, TEXT["update sounds"], savecustomimage, 2)
guielements["savesounds"].bordercolor = {255, 0, 0}
guielements["savesounds"].bordercolorhigh = {255, 127, 127}
--custom enemies
changecurrentenemy(1, true)
guielements["currentenemydropdown"] = guielement:new("dropdown", 184, 63, 22, changecurrentenemy, 1, unpack(customenemies))
if guielements["currentenemydropdown"].scrollbar then
--guielements["currentenemydropdown"].scrollbar.scrollstep = 0.11 --how much mousewheel scrolls
end
guielements["openfolderenemiescustom"] = guielement:new("button", 184, 105, TEXT["open folder"], opencustomimagefolder, 2)
textcolorl = endingtextcolorname
textcolorp = hudtextcolorname
textstate = "hud"
--custom text
guielements["savecustomtext"] = guielement:new("button", 10, 201, "save text", savecustomtext, 2)
guielements["savecustomtext"].bordercolor = {255, 0, 0}
guielements["savecustomtext"].bordercolorhigh = {255, 127, 127}
guielements["hudtexttab"] = guielement:new("button", 10, 40, TEXT["hud"], texttabtab, 2, {"hud"})
guielements["endingtexttab"] = guielement:new("button", guielements["hudtexttab"].x+guielements["hudtexttab"].width+8, 40, TEXT["ending"], texttabtab, 2, {"ending"})
guielements["castletexttab"] = guielement:new("button", guielements["endingtexttab"].x+guielements["endingtexttab"].width+8, 40, TEXT["castle"], texttabtab, 2, {"castle"})
guielements["levelscreentexttab"] = guielement:new("button", guielements["castletexttab"].x+guielements["castletexttab"].width+8, 40, TEXT["levelscreen"], texttabtab, 2, {"levelscreen"})
guielements["editendingtext1"] = guielement:new("input", 10, 67, 32, nil, endingtext[1], 32)
guielements["editendingtext2"] = guielement:new("input", 10, 81, 32, nil, endingtext[2], 32)
guielements["editplayername"] = guielement:new("input", 10, 67, 12, nil, playername, 12)
guielements["endingcolor"] = guielement:new("dropdown", 10, 97, 7, changeendingtextcolor, tablecontainsi(textcolorsnames, textcolorl), unpack(textcolorsnames))
guielements["endingcolor"].coloredtext = true
--guielements["endingcolor<"] = guielement:new("button", 10, 97, "{", endingtextcolorleft, 1)
--guielements["endingcolor>"] = guielement:new("button", guielements["endingcolor<"].x+guielements["endingcolor<"].width+utf8.len(TEXT["color"])*8+7, 97, "}", endingtextcolorright, 1)
guielements["edittoadtext1"] = guielement:new("input", 10, 67, 32, nil, toadtext[1], 32)
guielements["edittoadtext2"] = guielement:new("input", 10, 81, 32, nil, toadtext[2], 32)
guielements["edittoadtext3"] = guielement:new("input", 10, 95, 32, nil, toadtext[3], 32)
guielements["editpeachtext1"] = guielement:new("input", 10, 121, 32, nil, peachtext[1], 32)
guielements["editpeachtext2"] = guielement:new("input", 10, 135, 32, nil, peachtext[2], 32)
guielements["editpeachtext3"] = guielement:new("input", 10, 149, 32, nil, peachtext[3], 32)
guielements["editpeachtext4"] = guielement:new("input", 10, 163, 32, nil, peachtext[4], 32)
guielements["editpeachtext5"] = guielement:new("input", 10, 177, 32, nil, peachtext[5], 32)
guielements["stevecheckbox"] = guielement:new("checkbox", 10, 191, togglesteve, pressbtosteve, "steve")
guielements["hudcolor"] = guielement:new("dropdown", 10, 83, 7, changehudtextcolor, tablecontainsi(textcolorsnames, textcolorp), unpack(textcolorsnames))
guielements["hudcolor"].coloredtext = true
--guielements["hudcolor<"] = guielement:new("button", 10, 83, "{", hudtextcolorleft, 1)
--guielements["hudcolor>"] = guielement:new("button", guielements["hudcolor<"].x+guielements["hudcolor<"].width+utf8.len(TEXT["color"])*8+7, 83, "}", hudtextcolorright, 1)
guielements["hudworldlettercheckbox"] = guielement:new("checkbox", 10, 98, togglehudworldletter, hudworldletter, TEXT["use letters for worlds over 9"])
guielements["hudvisiblecheckbox"] = guielement:new("checkbox", 10, 109, togglehudvisible, hudvisible, TEXT["hud visible"])
guielements["hudoutlinecheckbox"] = guielement:new("checkbox", 10, 120, togglehudoutline, hudoutline, TEXT["hud outline"])
guielements["hudsimplecheckbox"] = guielement:new("checkbox", 10, 131, togglehudsimple, hudsimple, TEXT["simple hud"])
guielements["editlevelscreentext"] = guielement:new("input", 10, 81, 40, nil, levelscreentext[marioworld .. "-" .. mariolevel] or "", 45)
--animationS
guielements["animationsscrollbarver"] = guielement:new("scrollbar", animationguiarea[1]-10, animationguiarea[2], animationguiarea[4]-animationguiarea[2], 10, 40, 0, "ver", nil, nil, nil, nil, true)
guielements["animationsscrollbarhor"] = guielement:new("scrollbar", animationguiarea[1], animationguiarea[4], animationguiarea[3]-animationguiarea[1], 40, 10, 0, "hor", nil, nil, nil, nil, false)
guielements["animationsscrollbarhor"].scrollstep = 0
local args = {}
for i, v in ipairs(animations) do
table.insert(args, string.sub(v.name, 1, -6))
end
guielements["animationselectdrop"] = guielement:new("dropdown", 15, 20, 15, selectanimation, 1, unpack(args))
guielements["animationnewbutton"] = guielement:new("button", 3, 20, "+", createnewanimation, nil)
guielements["animationsavebutton"] = guielement:new("button", 150, 19, TEXT["save"], saveanimation, 1)
guielements["animationdelbutton"] = guielement:new("button", guielements["animationsavebutton"].x+guielements["animationsavebutton"].width+8, 19, "x", removeanimation, 1)
guielements["animationnameinput"] = guielement:new("input", 282, 20, 14, function() animationsaveas = guielements["animationnameinput"].value; guielements["animationnameinput"].inputting = false end, "", 20, nil, nil, 0)
if animations[currentanimation] then
guielements["animationnameinput"].value = string.sub(animations[currentanimation].name, 1, -6)
guielements["animationnameinput"]:updatePos()
end
addanimationtriggerbutton = guielement:new("button", 0, 0, "+", addanimationtrigger, nil, nil, nil, 8)
addanimationtriggerbutton.textcolor = {0, 200, 0}
addanimationconditionbutton = guielement:new("button", 0, 0, "+", addanimationcondition, nil, nil, nil, 8)
addanimationconditionbutton.textcolor = {0, 200, 0}
addanimationactionbutton = guielement:new("button", 0, 0, "+", addanimationaction, nil, nil, nil, 8)
addanimationactionbutton.textcolor = {0, 200, 0}
--get current description and shit
local mappackname = ""
local mappackauthor = ""
local mappackdescription = ""
if love.filesystem.getInfo(mappackfolder .. "/" .. mappack .. "/settings.txt") then
local data = love.filesystem.read(mappackfolder .. "/" .. mappack .. "/settings.txt")
local split1 = data:split("\n")
for i = 1, #split1 do
local split2 = split1[i]:split("=")
if split2[1] == "name" then
mappackname = split2[2]
elseif split2[1] == "author" then
mappackauthor = split2[2]
elseif split2[1] == "description" then
mappackdescription = split2[2]
end
end
end
if love.filesystem.getInfo( mappackfolder .. "/" .. mappack .. "/icon.png" ) then
editmappackicon = love.graphics.newImage(mappackfolder .. "/" .. mappack .. "/icon.png")
else
editmappackicon = nil
end
multitileobjects = {}
multitileobjectnames = {}
loadmtobjects()
guielements["mtobjectrename"] = guielement:new("input", 6, 39, 30,
function()
multitileobjectnames[guielements["mtobjectrename"].i] = guielements["mtobjectrename"].value
guielements["mtobjectrename"].active = false
changemtname(guielements["mtobjectrename"].i)
end, "", 30)
guielements["edittitle"] = guielement:new("input", 5, 115, 17, nil, mappackname, 17)
guielements["editauthor"] = guielement:new("input", 5, 140, 13, nil, mappackauthor, 13)
guielements["editdescription"] = guielement:new("input", 5, 165, 17, nil, mappackdescription, 51, 3)
guielements["savesettings"] = guielement:new("button", 5, 203, TEXT["save settings"], savesettings, 2)
guielements["savesettings"].bordercolor = {255, 0, 0}
guielements["savesettings"].bordercolorhigh = {255, 127, 127}
confirmmenuopen = false
confirmmenuguisave = false
--MISC
editortilemousescroll = false
editortilemousescrolltimer = 0
undo_clear()
tilesall()
if editorloadopen then
editoropen()
editorloadopen = false
else
editorclose()
editorstate = "main"
editentities = false
end
if PersistentEditorTools then
if PersistentEditorToolsLocal and (not editorsavedata) and love.filesystem.getInfo(mappackfolder .. "/" .. mappack .. "/editorsave.json") then
local data = love.filesystem.read(mappackfolder .. "/" .. mappack .. "/editorsave.json")
editorsavedata = JSON:decode(data)
end
if editorsavedata then
local e = editorsavedata
currenttile = e.currenttile
editentities = e.editentities
brushsizex = e.brushsizex
brushsizey = e.brushsizey
if e.editorstate then
editorstate = e.editorstate
end
customtabstate = e.customtabstate
assistmode = e.assistmode
backgroundtilemode = e.backgroundtilemode
editorsavedata = false
end
end
if currentanimation and currentanimation ~= 1 then
selectanimation(currentanimation, "initial")
end
if player_position then
--test from position
objects["player"][1].x = player_position[1]
objects["player"][1].y = player_position[2]
camerasnap(player_position[3], player_position[4])
end
trackgenerationid = 0
trackpreviews = false
end
function editor_update(dt)
----------
--EDITOR--
----------
--[[level modified debug
if oldlevelmodified ~= nil then
if oldlevelmodified ~= levelmodified and levelmodified then
notice.new("level modified",notice.white)
end
end
oldlevelmodified = levelmodified]]
if editormenuopen == false or minimapmoving then
--key scroll
local speed = 30
if love.keyboard.isDown("rshift") then
speed = 70
end
if (love.keyboard.isDown("left") or (android and leftkey(1) and not autoscroll)) and ((rightclickmenuopen or (not brushsizetoggle)) and not typingintextinput) then
autoscroll = false
guielements["autoscrollcheckbox"].var = autoscroll
splitxscroll[1] = splitxscroll[1] - speed*gdt
if splitxscroll[1] < 0 then
splitxscroll[1] = 0
end
generatespritebatch()
elseif (love.keyboard.isDown("right") or (android and rightkey(1) and not autoscroll)) and ((rightclickmenuopen or (not brushsizetoggle)) and not typingintextinput) then
autoscroll = false
guielements["autoscrollcheckbox"].var = autoscroll
splitxscroll[1] = splitxscroll[1] + speed*gdt
if splitxscroll[1] > mapwidth-width then
splitxscroll[1] = mapwidth-width
end
generatespritebatch()
end
if mapheight ~= 15 and ((rightclickmenuopen or (not brushsizetoggle)) and not typingintextinput) then
if (love.keyboard.isDown("up") or (android and upkey(1) and not autoscroll)) then
autoscroll = false
guielements["autoscrollcheckbox"].var = autoscroll
splityscroll[1] = splityscroll[1] - speed*gdt
if splityscroll[1] < 0 then
splityscroll[1] = 0
end
generatespritebatch()
elseif (love.keyboard.isDown("down") or (android and downkey(1) and not autoscroll)) then
autoscroll = false
guielements["autoscrollcheckbox"].var = autoscroll
splityscroll[1] = splityscroll[1] + speed*gdt
if splityscroll[1] >= mapheight-height-1 then
splityscroll[1] = mapheight-height-1
end
generatespritebatch()
end
end
end
if editormenuopen == false and (not minimapmoving) then
if editorstate == "powerline" then
local x, y = love.mouse.getPosition()
if love.mouse.isDown("l") then
powerlinedraw(x, y)
elseif love.mouse.isDown("r") then
editentities = true
currenttile = 1
placetile(x, y)
end
elseif customrcopen == "path" and allowdrag then
--draw path (this used to be so simple, but then i added clear pipes ;( )
local x, y = love.mouse.getPosition()
local rcp = rightclickpath
local ox, oy = rcp.last[1], rcp.last[2]
local dir = rcp.dir
local mtx, mty = getMouseTile(x, y+8*screenzoom*scale)
local tx = mtx-rcp.x
local ty = mty-rcp.y
local changedorigin = false
if (not rcp.pipe) and rcp.path and #rcp.path == 1 and love.mouse.isDown("l") then --change origin of snakeblock
local length = rcp.snakelength or 3
if (ty == 0 and (tx == 1 or tx == -length)) or ((ty == -1 or ty == 1) and (tx == 0 or tx == 1-length)) then
rcp.path[1][1], rcp.path[1][2] = tx, ty
if ty == 0 then
if mtx > rcp.x then
rcp.dir = "right"
else
rcp.dir = "left"
end
elseif ty > 0 then
rcp.dir = "down"
else
rcp.dir = "up"
end
rcp.last[1], rcp.last[2] = tx, ty
changedorigin = true
end
end
if love.mouse.isDown("l") and not changedorigin then
local coveredtiles = {}
--fit into pipe path
if rcp.pipe then
if (dir == "right" or dir == "left") and ty < oy then
ty = ty + 1
elseif (dir == "down" or dir == "up") and tx < ox then
tx = tx + 1
end
--allow going left too
if #rcp.path == 1 and tx == ox-1 then
dir = "left"
end
end
local overlap = ((tx == ox) and (ty == oy))
--allow dragging again
if (not rcp.drag) and overlap then
rcp.drag = true
end
if not overlap then
local lx, ly = rcp.last[1], rcp.last[2]--last pos
for i = #rcp.path, 1, -1 do
--check normal overlap
local pass = true
if (tx == rcp.path[i][1] and ty == rcp.path[i][2]) and not (i == #rcp.path-1) then
pass = false
end
--check pipe overlap
if rcp.pipe and not (i == #rcp.path-1) then
local cx, cy = rcp.path[i][1], rcp.path[i][2]--check x, check y
table.insert(coveredtiles, {cx, cy})
local dir
if ly < cy then dir = "up"; table.insert(coveredtiles, {cx-1, cy})
elseif lx > cx then dir = "right"; table.insert(coveredtiles, {cx, cy-1})
elseif lx < cx then dir = "left"; table.insert(coveredtiles, {cx, cy-1})
elseif ly > cy then dir = "down"; table.insert(coveredtiles, {cx-1, cy})
end
lx, ly = cx, cy
if dir then
if dir == "up" and ty == cy and tx == cx-1 then pass = false
elseif dir == "right" and tx == cx and ty == cy-1 then pass = false
elseif dir == "left" and tx == cx and ty == cy-1 then pass = false
elseif dir == "down" and ty == cy and tx == cx-1 then pass = false
end
end
end
if not pass then
overlap = true
break
end
end
end
if (not overlap) and rcp.drag then
local erase = false
local place = false
if tx == ox+1 and ty == oy then
if dir == "left" then
erase = true
else
--no overlapping turns
local pass = true
if rcp.pipe and dir == "down" and rcp.path[#rcp.path-2] and rcp.path[#rcp.path][1] ~= rcp.path[#rcp.path-2][1] then
pass = false
end
if pass then
rcp.dir = "right"
place = true
end
end
elseif tx == ox-1 and ty == oy then
if dir == "right" then
erase = true
else
--no overlapping turns
local pass = true
if rcp.pipe and dir == "down" and rcp.path[#rcp.path-2] and rcp.path[#rcp.path][1] ~= rcp.path[#rcp.path-2][1] then
pass = false
end
if pass then
rcp.dir = "left"
place = true
end
end
elseif tx == ox and ty == oy+1 then
if dir == "up" then
erase = true
else
--no overlapping turns
local pass = true
if rcp.pipe and dir == "right" and rcp.path[#rcp.path-2] and rcp.path[#rcp.path][2] ~= rcp.path[#rcp.path-2][2] then
pass = false
end
if pass then
rcp.dir = "down"
place = true
end
end
elseif tx == ox and ty == oy-1 then
if dir == "down" then
erase = true
else
--no overlapping turns
local pass = true
if rcp.pipe and dir == "right" and rcp.path[#rcp.path-2] and rcp.path[#rcp.path][2] ~= rcp.path[#rcp.path-2][2] then
pass = false
end
if pass then
rcp.dir = "up"
place = true
end
end
end
if place then
if rcp.pipe then
local turn = (dir ~= rcp.dir)
--add additional segment for turning pipe
local pass = true
for i, t in pairs(coveredtiles) do
if tx == t[1] and ty == t[2] then pass = false
elseif turn and rcp.dir == "up" and tx == t[1] and ty-1 == t[2] then pass = false
elseif turn and rcp.dir == "left" and tx-1 == t[1] and ty == t[2] then pass = false
elseif (rcp.dir == "up" or rcp.dir == "down") and tx-1 == t[1] and ty == t[2] then pass = false
elseif (rcp.dir == "left" or rcp.dir == "right") and tx == t[1] and ty-1 == t[2] then pass = false
end
end
if pass then
table.insert(rcp.path, {tx, ty})
if turn then
if rcp.dir == "up" then
table.insert(rcp.path, {tx, ty-1})
rcp.drag = false
elseif rcp.dir == "left" then
table.insert(rcp.path, {tx-1, ty})
rcp.drag = false
end
end
rcp.last = {rcp.path[#rcp.path][1], rcp.path[#rcp.path][2]}
else
rcp.dir = dir
end
else
table.insert(rcp.path, {tx, ty})
rcp.last = {rcp.path[#rcp.path][1], rcp.path[#rcp.path][2]}
end
elseif erase and #rcp.path > 1 then
table.remove(rcp.path, #rcp.path)
--remove additional segment for turning pipe
if rcp.pipe and (dir == "left" or dir == "up") and rcp.path[#rcp.path-1] and rcp.path[#rcp.path-2] then
if not ((tx == rcp.path[#rcp.path-2][1]) or (ty == rcp.path[#rcp.path-2][2])) then
tx, ty = rcp.path[#rcp.path-1][1], rcp.path[#rcp.path-1][2]
table.remove(rcp.path, #rcp.path)
rcp.drag = false
end
end
rcp.last = {rcp.path[#rcp.path][1], rcp.path[#rcp.path][2]}
rcp.dir = "right"
if #rcp.path > 1 then
local lx, ly = rcp.path[#rcp.path-1][1], rcp.path[#rcp.path-1][2]
if lx > tx then
rcp.dir = "left"
elseif ly < ty then
rcp.dir = "down"
elseif ly > ty then
rcp.dir = "up"
end
end
end
end
end
elseif customrcopen == "trackpath" and allowdrag then
--draw track
local x, y = love.mouse.getPosition()
if love.mouse.isDown("l") then
local rcp = rightclicktrack
local ox, oy = rcp.last[1], rcp.last[2]
local dir = rcp.dir
local tx, ty = getMouseTile(x, y+8*screenzoom*scale)
tx = tx-rcp.x
ty = ty-rcp.y
local overlap = ((tx == ox) and (ty == oy))
--allow dragging again
if (not rcp.drag) and overlap then
rcp.drag = true
end
local looped, looping = false, false
if #rcp.path > 3 and rcp.path[1][3] ~= "c" and rcp.path[1][3] ~= "o" then
looped = true
overlap = false
end
if #rcp.path > 3 and rcp.path[1][1] == tx and rcp.path[1][2] == ty then
looping = true
end
if not overlap then
for i = #rcp.path, 1, -1 do
--check overlap
if (tx == rcp.path[i][1] and ty == rcp.path[i][2]) and i ~= #rcp.path-1 and (#rcp.path <= 3 or i ~= 1) and not (looped and i == #rcp.path) then
overlap = true
break
end
end
end
if (not overlap) and rcp.drag and (not (looping and looped)) then
local erase = false
local place = false
if rcp.path[#rcp.path-1] and (tx == rcp.path[#rcp.path-1][1] and ty == rcp.path[#rcp.path-1][2]) then
erase = true
elseif looped and tx == rcp.path[#rcp.path][1] and ty == rcp.path[#rcp.path][2] then
erase = true
end
if (not erase) and (not looped) then
if tx == ox+1 and ty == oy then
rcp.dir = "r"
place = true
elseif tx == ox-1 and ty == oy then
rcp.dir = "l"
place = true
elseif tx == ox and ty == oy+1 then
rcp.dir = "d"
place = true
elseif tx == ox-1 and ty == oy-1 then
rcp.dir = "lu"
place = true
elseif tx == ox+1 and ty == oy-1 then
rcp.dir = "ru"
place = true
elseif tx == ox-1 and ty == oy+1 then
rcp.dir = "ld"
place = true
elseif tx == ox+1 and ty == oy+1 then
rcp.dir = "rd"
place = true
elseif tx == ox and ty == oy-1 then
rcp.dir = "u"
place = true
end
end
if place then
if looping then
--make loop
rcp.path[1][3] = oppositetrackdirection(rcp.dir)
rcp.path[#rcp.path][4] = rcp.dir
else
local openorclosed = rcp.path[#rcp.path][4]
rcp.path[#rcp.path][4] = rcp.dir
table.insert(rcp.path, {tx, ty, oppositetrackdirection(rcp.dir), openorclosed, "d"})
end
elseif erase and #rcp.path > 1 then
if looped then
--remove loop
rcp.path[#rcp.path][4] = "c"
rcp.path[1][3] = "c"
else
local openorclosed = rcp.path[#rcp.path][4]
table.remove(rcp.path, #rcp.path)
rcp.path[#rcp.path][4] = openorclosed
end
end
if place or erase then
rcp.last = {rcp.path[#rcp.path][1], rcp.path[#rcp.path][2], rcp.path[#rcp.path][3], rcp.path[#rcp.path][4], rcp.path[#rcp.path][5]}
end
end
end
end
if not android then
if love.keyboard.isDown("lshift") then
brushsizetoggle = true
else
brushsizetoggle = false
end
end
if love.keyboard.isDown("rctrl") or love.keyboard.isDown("lctrl") or love.keyboard.isDown("rgui") or love.keyboard.isDown("lgui") then
ctrlpressed = true
else
ctrlpressed = false
end
if rightclickmenuopen and customrcopen then
if rightclickobjects then
for i = 1, #rightclickobjects do
local obj = rightclickobjects[i]
obj:update(dt)
end
end
end
if editorstate == "linktool" or editorstate == "portalgun" or editorstate == "selectiontool" or editorstate == "powerline" then
return
end
tileselectionants = (tileselectionants + 8*dt)%16
if love.mouse.isDown("l") and allowdrag and customrcopen == false and not (assistmode and quickmenuopen) then
local x, y = love.mouse.getPosition()
if tileselection then
if not tileselection.finished then
--increase tileselection
local tx, ty = getMouseTile(x, y+8*screenzoom*scale)
tileselection[3] = tx
tileselection[4] = ty
end
elseif pastingtiles then
--PASTE TILES
for i, v in pairs(mtclipboard) do
for j, w in pairs(v) do
if w[1] == 1 and (not w[2]) and (not w["back"]) and pastemode == 1 then
-- nothing
else
local tx, ty = getMouseTile(x+(i-1 + pastecenter[1])*16*scale, y+(j-1 + pastecenter[2])*16*scale+8*scale)
if ismaptile(tx, ty) then
local d = mtclipboard[i][j]
currenttile = d[1]
--[[placetile(x+(i-1 + pastecenter[1])*16*scale, y+(j-1 + pastecenter[2])*16*scale)
local tile1 = d[1]
if tile1 == 1 then
tile1 = false --don't paste empty space
end
if not backgroundtilemode then
if not d[3] then
map[tx][ty][1] = tile1 or map[tx][ty][1]
map[tx][ty][2] = d[2] or map[tx][ty][2]
map[tx][ty]["back"] = d["back"]
else
map[tx][ty] = {tile1 or map[tx][ty][1], d[2] or map[tx][ty][2], d[3] or map[tx][ty][3], back=d["back"]}
end
end
map[tx][ty]["gels"] = {}]]
end
end
end
end
allowdrag = false
elseif (brushsizex > 1 or brushsizey > 1) and not pastingtiles then
for lx = 1, brushsizex do
for ly = 1, brushsizey do
placetile(x+((lx-1)*16*scale), y+((ly-1)*16*scale))
end
end
elseif not pastingtiles then
placetile(x, y)
end
end
elseif editorstate == "main" then
if love.mouse.isDown("l") and not changemapwidthmenu and not minimapmoving then
local mousex, mousey = love.mouse.getPosition()
if mousey >= minimapy*scale and mousey < (minimapy+34)*scale then
if mousex >= minimapx*scale and mousex < (minimapx+394)*scale then
--HORIZONTAL
if mousex < (minimapx+width)*scale then
if minimapscroll > 0 then
minimapscroll = minimapscroll - minimapscrollspeed*dt
if minimapscroll < 0 then
minimapscroll = 0
end
end
elseif mousex >= (minimapx+394-width)*scale then
if minimapscroll < mapwidth-width-170 then
minimapscroll = minimapscroll + minimapscrollspeed*dt
if minimapscroll > mapwidth-width-170 then
minimapscroll = mapwidth-width-170
end
end
end
--VERTICAL
if mousey < (minimapy+5)*scale then
if yscroll > 0 then
yscroll = yscroll - minimapscrollspeed*dt
if yscroll < 0 then
yscroll = 0
end
splityscroll[1] = yscroll
end
elseif mousey >= (minimapy+minimapheight*2+4-5)*scale then
if yscroll < mapheight-height then
yscroll = yscroll + minimapscrollspeed*dt
if yscroll > mapheight-height-1 then
yscroll = mapheight-height-1
end