@@ -96,7 +96,6 @@ function editor_load()
9696 pastemode = false -- 1 transparent, 2 opaque
9797 pastecenter = {0 , 0 }
9898 mtclipboard = {} -- fill with x, y, tile
99- renamingline = false
10099
101100 splitxscroll = {0 , 0 }
102101
@@ -318,7 +317,6 @@ function editor_load()
318317
319318 -- OBJECTS fun fact: objects were originally in the tiles tab
320319 guielements [" objectscrollbar" ] = guielement :new (" scrollbar" , 381 , 21 , 199 , 15 , 40 , 0 , " ver" , nil , nil , nil , nil , true )
321- guielements [" objectrename" ] = guielement :new (" input" , 6 , 39 , 35 , finishrenameline )
322320
323321 -- POWERLINE "SUBTAB"
324322 drawtools = 2
@@ -761,9 +759,9 @@ function editor_update(dt)
761759 end
762760 elseif editorstate == " objects" then
763761 multitilesoffset = guielements [" objectscrollbar" ].value * objectscrollbarheight * scale
764- guielements [" objectrename" ].inputting = guielements [" objectrename" ].active
765762 end
766763
764+
767765 if animationguilines then
768766 for i , v in pairs (animationguilines ) do
769767 for k , w in pairs (v ) do
@@ -823,8 +821,7 @@ function editor_draw()
823821 if pastingtiles then
824822 -- draw mtclipboard
825823 for i , v in ipairs (mtclipboard ) do
826- for j , u in ipairs (v ) do
827- w = u [1 ]
824+ for j , w in ipairs (v ) do
828825 -- w = tonumber(w)
829826 local quad = tilequads [w ]:quad () --[[ tilequads[w].quad]]
830827 if w == 1 and pastemode == false then
@@ -836,30 +833,6 @@ function editor_draw()
836833 love .graphics .setColor (1 , 1 , 1 , 0.3 )
837834 love .graphics .draw (tilequads [w ].image , quad , math.floor ((x - xscroll - 1 + pastecenter [1 ])* 16 * scale + (i - 1 )* 16 * scale ), ((y - yscroll - 1 + pastecenter [2 ])* 16 + 8 )* scale + ((j - 1 )* 16 * scale ), 0 , scale , scale )
838835 end
839-
840- if u [2 ] then -- ENTITIES!!1!
841- local ent = u [2 ]
842- local img = nil
843- quad = nil
844-
845- if entityquads [ent ] then -- entity
846- img = entityquads [ent ].image
847- quad = entityquads [ent ].quad
848- elseif enemiesdata [ent ] then -- enemy
849- img = enemiesdata [ent ].graphic
850- quad = enemiesdata [ent ].quad
851- -- else do nothing i guess
852- end
853-
854- if img and quad then
855- if enemiesdata [ent ] then
856- love .graphics .setColor (1 , 0 , 0 , 0.3 )
857- love .graphics .rectangle (" fill" , math.floor ((x - xscroll - 1 + pastecenter [1 ])* 16 * scale + (i - 1 )* 16 * scale ), ((y - yscroll - 1 + pastecenter [2 ])* 16 + 8 )* scale + ((j - 1 )* 16 * scale ), 16 * scale , 16 * scale )
858- end
859- love .graphics .setColor (1 , 1 , 1 , 0.3 )
860- love .graphics .draw (img , quad , math.floor ((x - xscroll - 1 + pastecenter [1 ])* 16 * scale + (i - 1 )* 16 * scale ), ((y - yscroll - 1 + pastecenter [2 ])* 16 + 8 )* scale + ((j - 1 )* 16 * scale ), 0 , scale , scale )
861- end
862- end
863836 end
864837 end
865838 -- end
@@ -1653,19 +1626,16 @@ function editor_draw()
16531626 if math.floor (i - 1 )* 17 * scale + 42 * scale - multitilesoffset < 200 * scale then
16541627 properprint (multitileobjectnames [i ], 8 * scale , math.floor (i - 1 )* 17 * scale + 42 * scale - multitilesoffset )
16551628 end
1656- properprint (" _dir4" , 318 * scale , math.floor (i - 1 )* 17 * scale + 42 * scale - multitilesoffset )
1657- properprint (" _dir6" , 333 * scale , math.floor (i - 1 )* 17 * scale + 42 * scale - multitilesoffset )
1658- properprint (" x" , 348 * scale , math.floor (i - 1 )* 17 * scale + 42 * scale - multitilesoffset )
1659- properprint (" r" , 363 * scale , math.floor (i - 1 )* 17 * scale + 42 * scale - multitilesoffset )
1629+ properprint (" _dir4" , 333 * scale , math.floor (i - 1 )* 17 * scale + 42 * scale - multitilesoffset )
1630+ properprint (" _dir6" , 348 * scale , math.floor (i - 1 )* 17 * scale + 42 * scale - multitilesoffset )
1631+ properprint (" x" , 363 * scale , math.floor (i - 1 )* 17 * scale + 42 * scale - multitilesoffset )
16601632 end
16611633 if mtbutton == 1 then
16621634 properprint (" move up" , 10 * scale , 210 * scale )
16631635 elseif mtbutton == 2 then
16641636 properprint (" move down" , 10 * scale , 210 * scale )
16651637 elseif mtbutton == 3 then
16661638 properprint (" delete" , 10 * scale , 210 * scale )
1667- elseif mtbutton == 4 then
1668- properprint (" rename" , 10 * scale , 210 * scale )
16691639 end
16701640 elseif editorstate == " lightdrawcustomize" then
16711641 love .graphics .setColor (0.5 , 0.5 , 0.5 )
@@ -1953,7 +1923,7 @@ function objectstab()
19531923 guielements [" tabanimations" ].active = true
19541924 guielements [" tabobjects" ].active = true
19551925
1956- guielements [" objectscrollbar" ].active = true
1926+ guielements [" objectscrollbar" ].active = true
19571927 objectscrollbarheight = math.max (0 , math.ceil ((# multitileobjects ))* 17 - 1 - (17 * 9 ) - 12 )
19581928
19591929 for i , v in pairs (mapbuttons ) do
@@ -2227,12 +2197,7 @@ function loadmtobjects()
22272197 ox = {}
22282198 local split4 = split3 [j ]:split (" ," )
22292199 for u = 1 , # split4 do
2230- local tt = {}
2231- for i , v in pairs (split4 [u ]:split (" ;" )) do
2232- table.insert (tt , tonumber (v ) or v )
2233- end
2234- -- table.insert(ox, tonumber(split4[u]))
2235- table.insert (ox , tt )
2200+ table.insert (ox , tonumber (split4 [u ]))
22362201 -- print(split4[u]..",")
22372202 end
22382203 table.insert (oo , ox )
@@ -2889,7 +2854,7 @@ function editor_mousepressed(x, y, button)
28892854 selectionstart ()
28902855 else
28912856 local cox , coy = getMouseTile (x , y + 8 * scale )
2892- if inmap (cox , coy ) then
2857+ if inmap (cox , coy ) then
28932858 local lx1 , ly1 , lx2 , ly2 , slx1 , sly1 , slx2 , sly2
28942859 lx1 = math.min (tileselectionclick1x , tileselectionclick2x )
28952860 ly1 = math.min (tileselectionclick1y , tileselectionclick2y )
@@ -2929,26 +2894,8 @@ function editor_mousepressed(x, y, button)
29292894 if w == 1 and pastemode == false then
29302895 -- nothing
29312896 else
2932- local mx = x + (i - 1 + pastecenter [1 ])* 16 * scale
2933- local my = y + (j - 1 + pastecenter [2 ])* 16 * scale
2934- local cox , coy = getMouseTile (mx , my + 8 * scale )
2935- currenttile = mtclipboard [i ][j ][1 ]
2936- if currenttile ~= 1 or pastemode then
2937- placetile (mx , my )
2938- for k = 2 , math.max (# mtclipboard [i ][j ], # map [cox ][coy ]) do
2939- local frommtc = mtclipboard [i ][j ][k ]
2940- if frommtc then
2941- if mtclipboard [i ][j ][k - 2 ] == " link" then
2942- frommtc = frommtc + cox
2943- elseif mtclipboard [i ][j ][k - 3 ] == " link" then
2944- frommtc = frommtc + coy
2945- end
2946- map [cox ][coy ][k ]= frommtc
2947- else
2948- map [cox ][coy ][k ]= nil
2949- end
2950- end
2951- end
2897+ currenttile = mtclipboard [i ][j ]
2898+ placetile (x + (i - 1 + pastecenter [1 ])* 16 * scale , y + (j - 1 + pastecenter [2 ])* 16 * scale )
29522899 end
29532900 end
29542901 end
@@ -3049,43 +2996,37 @@ function editor_mousepressed(x, y, button)
30492996 end
30502997 end
30512998 elseif editorstate == " objects" then
3052- if not renamingline then
3053- local tile = getlistpos (x , y )
3054- local mtbutton = getmtbutton (x )
3055- -- editmtobjects = false
3056- -- editentities = false
3057- print (tile )
3058- if tile then
3059- if mtbutton == 0 then
3060- allowdrag = false
3061- editorclose ()
3062- mtclipboard = multitileobjects [tile + 1 ]
3063- -- for i, v in pairs(mtclipboard) do
3064- -- for j, w in pairs(v) do
3065- -- print(w)
3066- -- end
2999+ local tile = getlistpos (x , y )
3000+ local mtbutton = getmtbutton (x )
3001+ -- editmtobjects = false
3002+ -- editentities = false
3003+ print (tile )
3004+ if tile then
3005+ if mtbutton == 0 then
3006+ allowdrag = false
3007+ editorclose ()
3008+ mtclipboard = multitileobjects [tile + 1 ]
3009+ -- for i, v in pairs(mtclipboard) do
3010+ -- for j, w in pairs(v) do
3011+ -- print(w)
30673012 -- end
3068- pastecenter = {0 , 0 }
3069- pastingtiles = true
3070- editentities = false
3071- editenemies = false
3072- else
3073- if mtbutton == 1 then
3074- moveline (" mappacks/" .. mappack .. " /objects.txt" ,tile + 1 ," up" )
3075- loadmtobjects ()
3076- elseif mtbutton == 2 then
3077- moveline (" mappacks/" .. mappack .. " /objects.txt" ,tile + 1 ," down" )
3078- loadmtobjects ()
3079- elseif mtbutton == 3 then
3080- deleteline (" mappacks/" .. mappack .. " /objects.txt" , tile + 1 )
3081- loadmtobjects ()
3082- elseif mtbutton == 4 then
3083- startrenameline (" mappacks/" .. mappack .. " /objects.txt" , tile + 1 )
3084- end
3013+ -- end
3014+ pastecenter = {0 , 0 }
3015+ pastingtiles = true
3016+ editentities = false
3017+ editenemies = false
3018+ else
3019+ if mtbutton == 1 then
3020+ moveline (" mappacks/" .. mappack .. " /objects.txt" ,tile + 1 ," up" )
3021+ loadmtobjects ()
3022+ elseif mtbutton == 2 then
3023+ moveline (" mappacks/" .. mappack .. " /objects.txt" ,tile + 1 ," down" )
3024+ loadmtobjects ()
3025+ elseif mtbutton == 3 then
3026+ deleteline (" mappacks/" .. mappack .. " /objects.txt" , tile + 1 )
3027+ loadmtobjects ()
30853028 end
30863029 end
3087- else
3088- finishrenameline (false )
30893030 end
30903031 end
30913032 end
@@ -3333,12 +3274,6 @@ function editor_keypressed(key)
33333274 rightclickm :keypressed (key )
33343275 end
33353276
3336- if key == " backspace" or key == " delete" then
3337- if tileselectionclick1 == true and tileselectionclick2 == true then
3338- emptySelection ()
3339- end
3340- end
3341-
33423277 if ctrlpressed then
33433278 if key == " s" then
33443279 if tileselectionclick1 and tileselectionclick2 then
@@ -3753,11 +3688,12 @@ end
37533688
37543689function getmtbutton (x )
37553690 local button = 0
3756- local buttonCount = 4
3757- for i = 1 , buttonCount do
3758- if x >= (377 - (buttonCount + 1 - i )* 14 )* scale and x < (377 - (buttonCount - i )* 14 - 1 )* scale then
3759- button = i
3760- end
3691+ if x >= 333 * scale and x < 347 * scale then
3692+ button = 1
3693+ elseif x >= 348 * scale and x < 362 * scale then
3694+ button = 2
3695+ elseif x >= 363 * scale and x < 377 * scale then
3696+ button = 3
37613697 end
37623698
37633699 return button
@@ -3800,30 +3736,7 @@ function getTiles(pos1, pos2)
38003736 for i = 1 , xnum do
38013737 tx = {}
38023738 for j = 1 , ynum do
3803- local tt = {}
3804- local txpos = tile1x + i - 1
3805- local typos = tile1y + j - 1
3806- local skip = 0
3807- for k = 1 , # map [txpos ][typos ] do -- excludes stuff like gels
3808- local subtile = map [txpos ][typos ][k ]
3809- if subtile == " link" then -- change the link (or remove it)
3810- local linkx = map [txpos ][typos ][k + 2 ]
3811- local linky = map [txpos ][typos ][k + 3 ]
3812- if not (linkx >= tile1x and linkx < tile2x and linky >= tile1y and linky < tile2y ) then
3813- skip = 4
3814- end
3815- elseif map [txpos ][typos ][k - 2 ] == " link" then -- change pos x
3816- subtile = subtile - txpos
3817- elseif map [txpos ][typos ][k - 3 ] == " link" then -- change pos y
3818- subtile = subtile - typos
3819- end
3820- if skip == 0 then
3821- tt [k ] = subtile
3822- else
3823- skip = skip - 1
3824- end
3825- end
3826- table.insert (tx , tt )
3739+ table.insert (tx , map [tile1x + i - 1 ][tile1y + j - 1 ][1 ])
38273740 -- print(map[tile1x + i - 1][tile1y + j - 1][1])
38283741 end
38293742 table.insert (objecttable , tx )
@@ -3874,14 +3787,7 @@ function savemtobject(objecttable, name)
38743787 for i = 1 , # objecttable do
38753788 s = objecttable [i ] -- x's
38763789 for j = 1 , # s do
3877- for k , v in pairs (s [j ]) do
3878- data = data .. v
3879- if k == # s [j ] then
3880- data = data .. " ,"
3881- else
3882- data = data .. " ;"
3883- end
3884- end
3790+ data = data .. s [j ] .. " ,"
38853791 n = j
38863792 end
38873793 data = string.sub (data , 1 , - 2 )
@@ -3980,50 +3886,7 @@ function deleteline(file, line)
39803886 love .filesystem .write (file , newdata )
39813887end
39823888
3983- function startrenameline (file , line )
3984- if not love .filesystem .getInfo (file ) then
3985- return false
3986- end
3987- line = tonumber (line )
3988- renamingline = line
3989- guielements [" objectrename" ].y = 39 + (line - 1 )* 17
3990- guielements [" objectrename" ].active = true
3991- guielements [" objectrename" ].value = multitileobjectnames [line ]
3992- end
3993-
3994- function finishrenameline (save )
3995- local newname = guielements [" objectrename" ].value
3996- guielements [" objectrename" ].value = " "
3997- guielements [" objectrename" ].active = false
3998- if save then
3999- renameline (" mappacks/" .. mappack .. " /objects.txt" , renamingline , newname )
4000- loadmtobjects ()
4001- end
4002- renamingline = false
4003- end
4004-
4005- function renameline (file , line , newname )
4006- if not love .filesystem .getInfo (file ) then
4007- return false
4008- end
4009- line = tonumber (line )
4010- local data , newdata , split1
4011- data = love .filesystem .read (file )
4012- data = string.sub (data , 1 , - 2 )
4013- newdata = " "
4014- split1 = data :split (" \n " )
4015- for i , v in ipairs (split1 ) do
4016- local linestr = split1 [i ]
4017- if i ~= line then
4018- newdata = newdata .. linestr .. " \n "
4019- else
4020- newdata = newdata .. newname .. " =" .. linestr :split (" =" )[2 ] .. " \n "
4021- end
4022- end
4023- love .filesystem .write (file , newdata )
4024- end
4025-
4026- function changeline (file , line , newstring )
3889+ function changeline (file , linenumber , newstring )
40273890 if not love .filesystem .getInfo (file ) then
40283891 return false
40293892 end
0 commit comments