Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Miniwindows
➜ Displaying images in a miniwindow
|
Displaying images in a miniwindow
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Asmodeusbrooding
(22 posts) Bio
|
| Date
| Mon 02 Sep 2019 11:23 AM (UTC) Amended on Mon 02 Sep 2019 11:24 AM (UTC) by Asmodeusbrooding
|
| Message
| Hey everyone,
I'm trying to make an affects window that displays images when affects are up, similar to something you might see in an MMO.
I need help with figuring out how to make the images appear and disappear in a way that if there is only 1 it shows on the top left, and if there are more, it goes to box 2, 3, 4, etc in that order from left to right, then next row left to right. (Like shown below)
https://imgur.com/a/Xpt62YV
I was thinking something similar to
but I don't really know how to get the images to align in order and all of that jazz.
I'm hoping to still use the timers on the cooldown buttons, so I can have a timer overlay of when the affect will run out.
Any guidance would be appreciated... | | Top |
|
| Posted by
| Fiendish
USA (2,541 posts) Bio
Global Moderator |
| Date
| Reply #1 on Tue 03 Sep 2019 12:38 AM (UTC) Amended on Tue 03 Sep 2019 12:40 AM (UTC) by Fiendish
|
| Message
|
Quote: I don't really know how to get the images to align in order
If you look at the code in the other plugin you linked and search for "-- where to draw the icon" you'll see that it draws icons with relative rather than fixed coordinates. It determines where to draw the next icon by multiplying the index (minus 1) of the spell in the list (0, 1, 2, 3, etc) by the width of an icon plus the space between icons.
For instance, if your icons are each 20 pixels wide, and you want 5 pixels in between them, the left side of your first icon will be at 0*(20+5), the left side of your second will be at 1*(20+5), and so on.
Moving to multiple rows is similar, but instead of using the index to figure out how far to the right to put the icon, you'll want to use the modulus of the index and how many things you want on one row and then you'd use an integer division to figure out which row to put something on.
In concrete arithmetic, say you want 5 images per row.
For the left-to-right part, you'd have:
(1-1) % 5 = 0
(2-1) % 5 = 1
(3-1) % 5 = 2
(4-1) % 5 = 3
(5-1) % 5 = 4
(6-1) % 5 = 0
(7-1) % 5 = 1
(8-1) % 5 = 2
and so on.
You can see how it loops over and over from 0 to 4.
For deciding which row, you'd have:
math.floor((1-1) / 5) = 0
math.floor((2-1) / 5) = 0
math.floor((3-1) / 5) = 0
math.floor((4-1) / 5) = 0
math.floor((5-1) / 5) = 0
math.floor((6-1) / 5) = 1
math.floor((7-1) / 5) = 1
math.floor((8-1) / 5) = 1
math.floor((9-1) / 5) = 1
math.floor((10-1) / 5) = 1
math.floor((11-1) / 5) = 2
math.floor((12-1) / 5) = 2
and so on.
You can see how it goes up one after every five items.
The trick then is to multiple those results instead of just the index by the width of each graphic plus the space.
So, to sum up, if your icons are each 20 pixels wide, and you want 5 pixels in between them, the left side of your first icon will be at (0%5)*(20+5) and the top of the first icon will be at math.floor((0/5)*(20+5), and the left side of your second icon will be at (1%5)*(20+5), and the top of your second icon will be at math.floor(1/5)*(20+5), and so on. And if you want the whole thing to be offset from the top and the left, you'd just add another 5 to every result.
The -1s in the above are because Lua starts counting indexes at 1, but we want to start counting from 0 for this. |
https://github.com/fiendish/aardwolfclientpackage | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
12,354 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top