@@ -89,8 +89,7 @@ function editor_load()
8989
9090 mtsavehighlighttime = 5
9191 mtsavetimer = 0
92- mtjustsaved = false
93- mtsavecolors = {1 , 0.44 , 0.44 , 0.7 }
92+ mtjustsaved = 0
9493
9594 pastingtiles = false
9695 pastemode = false -- 1 transparent, 2 opaque
@@ -527,14 +526,14 @@ function editor_update(dt)
527526 next = " down"
528527 end
529528
530- if mushroomplatform then
529+ if advanceddrawtool == " mushroom " then
531530 powerlinedrawtable = { -- mushroom platform
532531 {" down" , " up" , 65 , false },
533532 {" left" , " right" , 22 , false , hprev , 0 , 20 , false , (hprev / math.abs (hprev )), 0 , 21 , false , hprev - (hprev / math.abs (hprev )), 0 , 21 },
534533 {" right" , " left" , 20 , false , hprev , 0 , 22 , false , (hprev / math.abs (hprev )), 0 , 21 , false , hprev - (hprev / math.abs (hprev )), 0 , 21 },
535534 {" down" , " right" , 21 , false , 0 , 1 , 43 },
536535 {" down" , " left" , 21 , false , 0 , 1 , 43 }}
537- else
536+ elseif advanceddrawtool == " powerlines " then
538537 powerlinedrawtable = { -- powerlines
539538 {" up" , " down" , 43 , true },
540539 {" down" , " up" , 43 , true },
@@ -590,6 +589,7 @@ function editor_update(dt)
590589 elseif love .mouse .isDown (" m" ) and not middlemode [1 ] then
591590 if math.abs (love .mouse .getX () - middlemode [2 ]) >= 8 * scale or math.abs (love .mouse .getY () - middlemode [3 ]) >= 8 * scale then
592591 middlemode [1 ] = true
592+ love .mouse .setVisible (false )
593593 end
594594 end
595595
@@ -894,46 +894,38 @@ function editor_draw()
894894 lx2 = math.max (tileselectionclick1x , tileselectionclick2x )
895895 ly2 = math.max (tileselectionclick1y , tileselectionclick2y )
896896
897- love .graphics .setColor (0.67 ,1 ,0.67 ,0.3 )
898- if mtjustsaved then
899- local r , g , b , a = unpack (mtsavecolors )
900- if r > 172 then
901- r = r - math.floor (mtsavetimer * 3 )
902- end
903- if r < 172 then
904- r = 172
905- end
906- if g < 255 then
907- g = g + math.floor (mtsavetimer * 3 )
908- end
909- if g > 255 then
910- g = 255
911- end
912- if b > 172 then
913- b = b - math.floor (mtsavetimer * 3 )
914- end
915- if b < 172 then
916- b = 172
917- end
918- if a > 72 then
919- a = a - math.floor (mtsavetimer * 3 )
920- end
921- if a < 72 then
922- a = 72
923- end
924- love .graphics .setColor (r / 255 , g / 255 , b / 255 , a / 255 )
925- if r == 172 and g == 255 and b == 172 and a == 72 then
926- mtsavehighlighttime = 5
927- mtsavetimer = 0
928- mtjustsaved = false
929- r = 255
930- g = 112
931- b = 112
932- a = 128
897+ -- Laziness or cleverness?
898+ local px , py = math.floor ((lx1 - xscroll - 1 )* 16 * scale ), ((ly1 - yscroll - 1 )* 16 + 8 )* scale
899+ local pw , ph = (lx2 - lx1 )* 16 * scale + 16 * scale , (ly2 - ly1 )* 16 * scale + 16 * scale
900+
901+ love .graphics .setColor (0.67 ,1 ,0.67 ,0.7 )
902+ local timeOscilator = love .timer .getTime () % 2
903+ timeOscilator = 1 - math.abs ( math.cos (timeOscilator * math.pi ) )
904+
905+ -- Highlight thing
906+ love .graphics .rectangle (" fill" , px - (2 + timeOscilator * 3 )* scale , py - (2 + timeOscilator * 3 )* scale , 5 * scale , scale )
907+ love .graphics .rectangle (" fill" , px - (2 + timeOscilator * 3 )* scale , py - (1 + timeOscilator * 3 )* scale , scale , 4 * scale )
908+ love .graphics .rectangle (" fill" , px + pw + (2 + timeOscilator * 3 - 5 )* scale , py - (2 + timeOscilator * 3 )* scale , 5 * scale , scale )
909+ love .graphics .rectangle (" fill" , px + pw + (1 + timeOscilator * 3 )* scale , py - (1 + timeOscilator * 3 )* scale , scale , 4 * scale )
910+ love .graphics .rectangle (" fill" , px - (2 + timeOscilator * 3 )* scale , py + ph + (1 + timeOscilator * 3 )* scale , 5 * scale , scale )
911+ love .graphics .rectangle (" fill" , px - (2 + timeOscilator * 3 )* scale , py + ph + (1 + timeOscilator * 3 - 4 )* scale , scale , 4 * scale )
912+ love .graphics .rectangle (" fill" , px + pw + (2 + timeOscilator * 3 - 5 )* scale , py + ph + (1 + timeOscilator * 3 )* scale , 5 * scale , scale )
913+ love .graphics .rectangle (" fill" , px + pw + (1 + timeOscilator * 3 )* scale , py + ph + (1 + timeOscilator * 3 - 4 )* scale , scale , 4 * scale )
914+
915+ local saveColors = {1 , 0.44 , 0.44 , 0.7 }
916+ local selectColors = {0.67 , 1 , 0.67 , 0.3 }
917+ love .graphics .setColor (selectColors )
918+
919+ if mtjustsaved > 0 then
920+ local r , g , b , a = gradient (selectColors , saveColors , mtjustsaved )
921+ love .graphics .setColor (r , g , b , a )
922+
923+ mtjustsaved = math.max (mtjustsaved - love .timer .getDelta (), 0 )
924+ if mtjustsaved == 0 then -- Negative 0 thing
925+ mtjustsaved = 0
933926 end
934- mtsavecolors = {r , g , b , a }
935927 end
936- love .graphics .rectangle (" fill" ,math.floor (( lx1 - xscroll - 1 ) * 16 * scale ), (( ly1 - yscroll - 1 ) * 16 + 8 ) * scale , ( lx2 - lx1 ) * 16 * scale + 16 * scale , ( ly2 - ly1 ) * 16 * scale + 16 * scale )
928+ love .graphics .rectangle (" fill" , px , py , pw , ph )
937929 end
938930 elseif middlemode [1 ] then
939931 love .graphics .push ()
@@ -1225,6 +1217,38 @@ function editor_draw()
12251217 rightclickm :draw ()
12261218 end
12271219
1220+ -- EDITOR UI
1221+ local mode = " tiles"
1222+ local submode = false
1223+ if editorstate == " selection" then
1224+ mode = " selection"
1225+ elseif editorstate == " lightdraw" then
1226+ mode = " advanced draw tool"
1227+ submode = " power line draw"
1228+ if advanceddrawtool == " mushroom" then
1229+ submode = " mushroom platforms"
1230+ end
1231+ else
1232+ submode = " tiles"
1233+ if editenemies then
1234+ submode = " enemies"
1235+ elseif editentities then
1236+ submode = " entities"
1237+ end
1238+ end
1239+ love .graphics .setColor (1 , 1 , .8 , .75 )
1240+ properprint (" editor mode" , 10 * scale , 10 * scale )
1241+ if submode then
1242+ properprint (" tool submode" , 10 * scale , 18 * scale )
1243+ end
1244+ properprint (" f1 for help" , (400 - 10 - 8 * 11 )* scale , 10 * scale )
1245+
1246+ love .graphics .setColor (1 , 1 , 1 , .75 )
1247+ properprint (" :" .. mode , (10 + 12 * 8 )* scale , 10 * scale )
1248+ if submode then
1249+ properprint (" :" .. submode , (10 + 12 * 8 )* scale , 18 * scale )
1250+ end
1251+
12281252 if love .keyboard .isDown (" f1" ) and not rightclickm then
12291253 love .graphics .setColor (0 , 0 , 0 , .85 )
12301254 love .graphics .rectangle (" fill" , helpui [1 ]* scale , helpui [2 ]* scale , (helpui [3 ]- helpui [1 ])* scale , (helpui [4 ]- helpui [2 ])* scale )
@@ -1244,7 +1268,7 @@ function editor_draw()
12441268 {" ctrl+g" ," transforms the selected tiles into a|" ..
12451269 " group bound to the top-left-most tile." , 1 },
12461270 {" u" ," on the tile screen, removes the tile group|" ..
1247- " bound to the tile." , 1 },-- |
1271+ " bound to the highlighted tile." , 1 },-- |
12481272 {" ctrl+z/ctrl+y" ," undo/redo the last changes." , 0 },
12491273 {" ctrl+c/ctrl+x/ctrl+v" ," copy/cut/paste region." , 0 },
12501274 {" ctrl+a" ," select the entire level." , 0 },-- |
@@ -1768,11 +1792,14 @@ function editor_draw()
17681792 properprint (" delete" , 10 * scale , 210 * scale )
17691793 end
17701794 elseif editorstate == " lightdrawcustomize" then
1771- love .graphics .setColor (0.5 , 0.5 , 0.5 )
1772- properprint (" more coming soon" , 5 * scale , 55 * scale )
1773- guielements [" tabtools" ].textcolor = {math.random (),math.random (),math.random ()}
1774- guielements [" tabtools" ].fillcolor = {math.random (),math.random (),math.random ()}
1775- guielements [" tabtools" ].bordercolor = {math.random (),math.random (),math.random ()}
1795+ -- love.graphics.setColor(0.5, 0.5, 0.5)
1796+ -- properprint("more coming soon", 5*scale, 55*scale)
1797+
1798+ -- I'm cancelling this stroke-inducing nightmare
1799+
1800+ -- guielements["tabtools"].textcolor = {math.random(),math.random(),math.random()}
1801+ -- guielements["tabtools"].fillcolor = {math.random(),math.random(),math.random()}
1802+ -- guielements["tabtools"].bordercolor = {math.random(),math.random(),math.random()}
17761803 end
17771804 end
17781805 end
@@ -2080,7 +2107,7 @@ function powerlinestab()
20802107 v .active = false
20812108 end
20822109
2083- guielements [" tabtools" ].text = " party"
2110+ -- guielements["tabtools"].text = "party"
20842111 guielements [" tabmain" ].active = true
20852112 guielements [" tabtiles" ].active = true
20862113 guielements [" tabtools" ].active = true
@@ -2927,10 +2954,13 @@ function savestate()
29272954 table.remove (savestates , 1 )
29282955 end
29292956 local t = {}
2957+ t .coinmap = {}
29302958 for x = 1 , # map do
29312959 t [x ] = {}
2960+ t .coinmap [x ] = {}
29322961 for y = 1 , # map [x ] do
29332962 t [x ][y ] = {}
2963+ t .coinmap [x ][y ] = coinmap [x ][y ]
29342964 for i , v in pairs (map [x ][y ]) do
29352965 t [x ][y ][i ] = v
29362966 end
@@ -2945,10 +2975,13 @@ function loadstate(s)
29452975
29462976 local v = savestates [s ]
29472977 map = {}
2978+ coinmap = {}
29482979 for x = 1 , # v do
29492980 map [x ] = {}
2981+ coinmap [x ] = {}
29502982 for y = 1 , # v [x ] do
29512983 map [x ][y ] = {}
2984+ coinmap [x ][y ] = v .coinmap [x ][y ]
29522985 for i , w in pairs (v [x ][y ]) do
29532986 map [x ][y ][i ] = w
29542987 end
@@ -3234,6 +3267,9 @@ function editor_mousepressed(x, y, button)
32343267 loadmtobjects ()
32353268 elseif mtbutton == 4 then
32363269 deleteline (" mappacks/" .. mappack .. " /objects.txt" , tile + 1 )
3270+ if guielements [" renamebar" ] and guielements [" renamebar" ].active then
3271+ guielements [" renamebar" ].active = false
3272+ end
32373273 loadmtobjects ()
32383274 end
32393275 end
@@ -3242,6 +3278,7 @@ function editor_mousepressed(x, y, button)
32423278 end
32433279 elseif button == " m" then
32443280 middlemode = {false , x , y }
3281+ love .mouse .setVisible (true )
32453282 elseif button == " wu" then
32463283 if not editormenuopen then
32473284 if love .keyboard .isDown (" lshift" ) or love .keyboard .isDown (" rshift" ) then
@@ -3424,14 +3461,16 @@ function editor_mousereleased(x, y, button)
34243461 elseif button == " m" then
34253462 if middlemode [1 ] == false then
34263463 local cox , coy = getMouseTile (love .mouse .getX (), love .mouse .getY ()+ 8 * scale )
3427- print (" cox, coy = " .. cox .. " , " .. coy )
34283464 if inmap (cox , coy ) == false then
34293465 return
34303466 end
3431- print (" Tile selected" )
34323467 if not editentities then
34333468 tilesall ()
34343469 currenttile = map [cox ][coy ][1 ]
3470+
3471+ if currenttile == 1 and coinmap [cox ][coy ] then
3472+ currenttile = 116 -- Let's be nice to the map maker, alright?
3473+ end
34353474 elseif not editenemies then
34363475 tilesentities ()
34373476 generateentitylist ()
@@ -3450,6 +3489,7 @@ function editor_mousereleased(x, y, button)
34503489 end
34513490 end
34523491 middlemode [1 ] = false
3492+ love .mouse .setVisible (true )
34533493 end
34543494 allowdrag = true
34553495 hprev = 0
@@ -3515,6 +3555,7 @@ function editor_keypressed(key)
35153555
35163556 savemtobject (group , tostring (name ), " groups" )
35173557 loadmtgroups ()
3558+ notice .new (" Saved as group!" , notice .white , 2 )
35183559 end
35193560 elseif key == " c" or key == " x" then
35203561 if tileselectionclick1 == true and tileselectionclick2 == true then
@@ -3831,8 +3872,8 @@ function toggleskiplevelscreen(var)
38313872end
38323873
38333874function changepastemode (var )
3834- -- pastemode = var
3835- -- guielements["pastemodedropdown"].var = var
3875+ -- pastemode = var
3876+ -- guielements["pastemodedropdown"].var = var
38363877 if var ~= nil then
38373878 pastemode = var
38383879 else
@@ -3941,17 +3982,21 @@ function test_level()
39413982end
39423983
39433984function drawpowerlines ()
3944- mushroomplatform = false
3945-
3985+ advanceddrawtool = " powerlines"
3986+
3987+ editenemies = false
3988+ editentities = true
39463989 editorstate = " lightdraw"
39473990 lightdrawX = nil
39483991 lightdrawY = nil
39493992 editorclose ()
39503993end
39513994
39523995function drawmushrooms ()
3953- mushroomplatform = true
3996+ advanceddrawtool = " mushroom "
39543997
3998+ editenemies = false
3999+ editentities = false
39554000 editorstate = " lightdraw"
39564001 lightdrawX = nil
39574002 lightdrawY = nil
@@ -4166,7 +4211,7 @@ function savemtobject(objecttable, name, file)
41664211 data = string.gsub (data , " mtobjsize" , m .. " * " .. n )
41674212 data = data .. " \n "
41684213 love .filesystem .write (" mappacks/" .. mappack .. " /" .. file .. " .txt" , data )
4169- mtjustsaved = true
4214+ mtjustsaved = 1
41704215end
41714216
41724217function objectclipboardcopy (objecttable )
0 commit comments