help making a level editor

hi, I am primarily a Minecraft mod/modpack developer and when I found out how easy it is to make custom levels for the game tasty planet I wanted to make a level editor for it so turned to java as it's what I have the most experience with but I'm getting to the edge of my knowledge and AI isn't being very helpful. basically what I need is help adding a few features I can't (even just placeholder stuff I can use to actually do what I want as I know it's hard to write code to interact with files you don't actually have) so the main thing is I want to add some images to the program but can't seem to figure that out. https://github.com/RemagOfficial/Tasty-Planet-1-Level-Editor here's the GitHub and please don't roast my bad code too hard lol
GitHub
GitHub - RemagOfficial/Tasty-Planet-1-Level-Editor: a very basic le...
a very basic level editor for the original tasty planet - RemagOfficial/Tasty-Planet-1-Level-Editor
51 Replies
JavaBot
JavaBot2mo ago
This post has been reserved for your question.
Hey @Remag! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Remag
RemagOP2mo ago
this is the current program and the grid represents the level tiles, I want to add an image to the center of the grid kinda as a scale and maybe with a different layout to make the grid bigger I want the grid squares to use the appropriate textures from the game files for the level that has been chosen in the drop-down
No description
Remag
RemagOP2mo ago
it's like 4am for me btw so if I don't respond immediately that's why lol
JavaBot
JavaBot2mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Remag
RemagOP2mo ago
huh it already was tho
dan1st
dan1st2mo ago
maybe someone sent a message or clicked on open and then it was marked as dormant again so you want to insert images in the grid?
Remag
RemagOP2mo ago
not quite, i want the image to be on top of the grid because the center isnt always one square and i also dont want to mess up the shape of the grid
dan1st
dan1st2mo ago
you mean behind the grid? or above it?
Remag
RemagOP2mo ago
above wait let me make a mockup lol
Remag
RemagOP2mo ago
essentially this is what i want, the image cant be in one of the grid cells because that isnt always possible and i cant like add a new cell for the image because that would change the shape of the grid
No description
Remag
RemagOP2mo ago
its basically just a marker to show the center so you can at least guess the size of the level
dan1st
dan1st2mo ago
Where are you plotting the grid? I don't see that in your code
Remag
RemagOP2mo ago
its in getButton, should probably rename that
dan1st
dan1st2mo ago
GitHub
Tasty-Planet-1-Level-Editor/mapEdit.java at main · RemagOfficial/Ta...
a very basic level editor for the original tasty planet - RemagOfficial/Tasty-Planet-1-Level-Editor
Remag
RemagOP2mo ago
thats the wrong branch, master is the branch im using because i only recently started working on it again and my IDE hates me
Remag
RemagOP2mo ago
dan1st
dan1st2mo ago
I think you can get the location of the grid in the previewPanel as well as its width and height then you add the image to the previewPanel as well but in the middle of the grid
Remag
RemagOP2mo ago
im pretty sure i tried that, honestly tho i think my issue was actually like getting the image lol
dan1st
dan1st2mo ago
though you might need a LayoutManager for that What you can try is: - Create a new JPanel for both the grid and the image - These are added to that JPanel, not previewPanel - use a LayoutManager on that JPanel ensuring both are centered and on top of each other - That JPanel is added to previewPanel
Remag
RemagOP2mo ago
i mean previewPanel is already just a blank panel
dan1st
dan1st2mo ago
yeah but you probably want to continue putting stuff one after each other there so you probably don't want to change that, right?
dan1st
dan1st2mo ago
Stack Overflow
How can I put 2 java swing elements on top of each other?
so I have this project that I'm doing, which draws a circle and a square, and resizes them through buttons. Everything works great, however what I must do is put the circle inside the square, so th...
Remag
RemagOP2mo ago
and just as a sanity test, what path should i use for images cause i couldnt even get an image to load like at all and idk why
dan1st
dan1st2mo ago
You probably want to use it as a resource so in the resource folder and load it with getClass().getResource() or the src folder since you don't have a resource folder
Remag
RemagOP2mo ago
progress, i just cant get it to center now
No description
dan1st
dan1st2mo ago
Can you show the relevant code?
Remag
RemagOP2mo ago
No description
dan1st
dan1st2mo ago
can you try centerGooIcon.setAlignmentX(Component.CENTER_ALIGNMENT); and centerGooIcon.setAlignmentY(Component.CENTER_ALIGNMENT);?
Remag
RemagOP2mo ago
that worked, thanks
JavaBot
JavaBot2mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Remag
RemagOP2mo ago
No description
Remag
RemagOP2mo ago
ima keep this open just because im probably going to have more issues
dan1st
dan1st2mo ago
If it's marked dormant, you can just send a new message to reopen it if necessary
Remag
RemagOP2mo ago
yep
Remag
RemagOP2mo ago
got the other images working
No description
Remag
RemagOP2mo ago
im trying to add some labels to the preview and ive got the labels working but they are being centred in the overlayPanel like the image i tried to add before but i dont want that this time i want them to be on the side
No description
Remag
RemagOP2mo ago
how its rendering
No description
Remag
RemagOP2mo ago
i also moved the preview to its own window but that didnt cause issues
JavaBot
JavaBot2mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Remag
RemagOP2mo ago
just waking up this post since I have another issue :AWAKEN:
dan1st
dan1st2mo ago
Can you do yourLabel.setAlignmentX(Component.LEFT_ALIGNMENT); or similar?
Remag
RemagOP2mo ago
doesnt change it, i tried aligning the panel the labels are on too and that also didnt help
dan1st
dan1st2mo ago
Where are you adding the label? ah I see Why are you using a BoxLayout for it?
Remag
RemagOP2mo ago
i dont know tbh lol i was probably just testing things and didnt remove that
Remag
RemagOP2mo ago
using no layout makes only the labels show, thats probably why lol
No description
dan1st
dan1st2mo ago
?
Remag
RemagOP2mo ago
idk wait maybe im just being dumb, i cant have things wider than the grid in the overlayPanel because the overlayPanel restrains the size of the grid okay yeah adding them to previewPanel directly fixed it, ill probably have the same issue when i need to add more images to the overlay but for now its working
Remag
RemagOP2mo ago
No description
Remag
RemagOP2mo ago
the text is just for debug so itll look better but they are in the right place now
JavaBot
JavaBot2mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server