Allegro.cc - Online Community

Allegro.cc Forums » The Depot » MapSlapper

This thread is locked; no one can reply to it. rss feed Print
MapSlapper
23yrold3yrold
Member #1,134
March 2001
avatar

1) Yes, I've thought of that. I just haven't gotten around to it (wasn't a priority for this release).

2) Good idea; which ones? PgUp/PgDown (on second thought, that seems unintuitive)? I was actually thinking of one idea; clicking and dragging on the current tile would select other tiles, so dragging right would bring up the next tile, then the tile after that. Up and down would skip tiles by 20 or something.

3) I wrote about those in the Future Plans docs. Didn't read that, didja? ;)

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

Make the tile window automatically "wrap" the tiles when you resize it, and only use scrollbars if necessary.

I made a widget like that for Icons...

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

X-G
Member #856
December 2000
avatar

Don't do it the dragging way ... that can get REALLY frustrating. You could have Pgup/Pgdn, or maybe use the scroll wheel for that? You could also add up/down buttons next to the tile.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

23yrold3yrold
Member #1,134
March 2001
avatar

Keyboard shortcuts for next/prev are a good idea, I just need intuitive keys for it. I can add it in five minutes after that :)

I think A for previous and S for next would work. Left hand there, right hand on the mouse. Maybe make a previous and next for the secondary tile too (Q and W?). I'm not a fan of using PgUp/Down for this for some reason :-/ I don't have a mouse wheel, so I won't attempt that yet :) Up/Down buttons would be slow; almost as slow as just clicking back and forth in the tile window ...

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

X-G
Member #856
December 2000
avatar

I'm not coming up with alternatives; you should use ALL of them. ;)
The more ways of doing the same thing you can cram in there, the better. At least when they're as trivial as this.
A/S and Q/W sound good, by the way. :)

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Thomas Fjellstrom
Member #476
June 2000
avatar

23: Want the phunky widget? ITs sorta useless to me right now ;)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

23yrold3yrold
Member #1,134
March 2001
avatar

TF: What widget? What's it do? The auto-wrapping one? Sure; I'd like to see how to set the window to a certian area. Never got the hang of that ...

Anyway, new version up.

A - Previous left tile.
S - Next left tile.
Q - Previous right tile.
W - Next right tile.

I'm glad I added that; it works great :D

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Mike Vox
Member #2,701
September 2002
avatar

It did not work with alleg41.dll so I needed to switch to alleg40.dll. After that, it worked fine and I'm using XP. Good stuff, I was slapp'n and map'n, baby! At first I was like "how do you select another tile" so I was forced to read the instructions and found out the tile selector was under "View".

Quick question, seeing how it runs under a window, is the code portable to other platforms? I'm working on a map editor specifically for my project, and I'm using a hacked up version of the Allegro gui. I'm eventually going to have to swap out the gui with something faster and better. If I want a version to run under Windows, that means I need to re-code a version just for Windows, correct?

Mike_Vox

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

is the code portable to other platforms?

Not this; it's heavy Win32 code here.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Thomas Fjellstrom
Member #476
June 2000
avatar

I coded this little widget for a windows program to associate files with programs, select the icon, and optionally add to the send to menu... but In XP that was really useless as XP includes that... And noone was interested in it :)

#SelectExpand
1HICON *big_list = NULL; 2int icon_count = 0, icon_selected = 0; 3 4LRESULT CALLBACK icon_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 5{ 6 static int xPos = 0, yPos = 0, xChar = 32, yChar = 32, icon_x = 0, icon_y = 0, mx = 0, my = 0, md = 0, ox = 0, oy = 0, i = 0; 7 int j = 0, k = 0, icon_xy = 0; 8 RECT rect; 9 static SCROLLINFO si; 10 PAINTSTRUCT ps; 11 12 switch (message) 13 { 14 case WM_CREATE: 15 GetClientRect(hwnd, &rect); 16 17 icon_x = (rect.right / xChar); 18 icon_y = (rect.bottom / yChar); 19 20 icon_xy = icon_x * icon_y; 21 22 if(icon_xy <= icon_count) { 23 SetScrollPos(hwnd, SB_VERT, 0, FALSE); 24 SetScrollRange(hwnd, SB_VERT, 0, 0, TRUE); 25 } else { 26 SetScrollRange(hwnd, SB_VERT, 0, icon_y, TRUE); 27 ShowScrollBar(hwnd, SB_VERT, TRUE); 28 } 29 return 0; 30 31 case WM_SIZING: { 32 LPRECT lprc = (LPRECT)lParam; 33 int oyPos = 0; 34 35 GetClientRect(hwnd, &rect); 36 37 icon_x = (rect.right / xChar); 38 icon_y = (rect.bottom / yChar); 39 40 //lprc->right = ((lprc->right % xChar < xChar)? lprc->right -= lprc->right % xChar : lprc->right); 41 //lprc->bottom = ((lprc->bottom % yChar < yChar)? lprc->bottom -= lprc->bottom % yChar : lprc->bottom); 42 icon_selected = 0; 43 ox = oy = md = 0; 44 45 oyPos = yPos; 46 yPos = (((lprc->bottom-lprc->top) / yChar) < i) && yPos ? i - ((lprc->bottom-lprc->top-1) / yChar) : 0; 47 if(yPos && yPos != oyPos) { 48 SetScrollRange(hwnd, SB_VERT, 0, (lprc->bottom-lprc->top) / yChar, FALSE); 49 } else if(yPos != oyPos) { 50 SetScrollPos(hwnd, SB_VERT, 0, FALSE); 51 SetScrollRange(hwnd, SB_VERT, 0, 0, FALSE); 52 } 53 } return 0; 54 55 case WM_PAINT: 56 GetClientRect(hwnd, &rect); 57 58 icon_x = (rect.right / xChar); 59 icon_y = (rect.bottom / yChar) - ((rect.right % xChar)?1:0); 60 icon_xy = icon_x * icon_y; 61 62 //printf("xy:%i, %i,%i, %%:%i\n", icon_xy, icon_x, icon_y, rect.bottom % yChar); 63 64 BeginPaint(hwnd, &ps); 65 //warn("Paint:"); 66 i = 0; 67 while(k <= icon_count) { 68 if(j >= icon_x) { i++; j = 0; } 69 DrawIconEx(ps.hdc, (j*xChar)-(xPos*xChar), (i*yChar)-(yPos*yChar), big_list[k], 32, 32, 0, NULL, DI_NORMAL); 70 71 if(icon_selected == k) { 72 rect.left = (j*xChar)-(xPos*xChar); 73 rect.right = (j*xChar)-(xPos*xChar)+32; 74 rect.top = (i*yChar)-(yPos*yChar); 75 rect.bottom = (i*yChar)-(yPos*yChar)+32; 76 DrawFocusRect(ps.hdc, &rect); 77 } 78 79 j++; 80 k++; 81 } 82 83 if(i <= icon_y) { 84 SetScrollPos(hwnd, SB_VERT, 0, FALSE); 85 SetScrollRange(hwnd, SB_VERT, 0, 0, FALSE); 86 xPos = 0; 87 yPos = 0; 88 } else { 89 SetScrollRange(hwnd, SB_VERT, 0, i-icon_y, FALSE); 90 } 91 92 //printf("Draw: x:%i, y:%i\n", xPos, yPos); 93 EndPaint(hwnd, &ps); 94 return 0; 95 96 case WM_LBUTTONDOWN: { 97 mx = LOWORD(lParam); 98 my = HIWORD(lParam); 99 md = 1; 100 } return 0; 101 102 case WM_LBUTTONUP: { 103 int fwKeys = wParam; // key flags 104 int x = LOWORD(lParam); // horizontal position of cursor 105 int y = HIWORD(lParam); // vertical position of cursor 106 md = 0; 107 ReleaseCapture(); 108 109 GetClientRect(hwnd, &rect); 110 111 icon_x = (rect.right / xChar); 112 icon_y = (rect.bottom / yChar) - ((rect.right % xChar)?1:0); 113 icon_xy = icon_x * icon_y; 114 115 x /= xChar; 116 y /= yChar; 117 x += xPos; 118 y += yPos; 119 120 if(x + y * icon_x <= icon_count && x + y * icon_x != icon_selected) { 121 rect.left = (ox*xChar)-(xPos*xChar); 122 rect.right = (ox*xChar)-(xPos*xChar)+32; 123 rect.top = (oy*yChar)-(yPos*yChar); 124 rect.bottom = (oy*yChar)-(yPos*yChar)+32; 125 InvalidateRect(hwnd, &rect, TRUE); 126 127 rect.left = (x*xChar)-(xPos*xChar); 128 rect.right = (x*xChar)-(xPos*xChar)+32; 129 rect.top = (y*yChar)-(yPos*yChar); 130 rect.bottom = (y*yChar)-(yPos*yChar)+32; 131 InvalidateRect(hwnd, &rect, TRUE); 132 133 icon_selected = x + y * icon_x; 134 //printf("MB: %ix%i %ix%i\n", ox, oy, x, y); 135 UpdateWindow (hwnd); 136 ox = x; 137 oy = y; 138 } 139 } return 0; 140 141 case WM_MOUSEMOVE: { 142 int fwKeys = wParam; // key flags 143 int x = LOWORD(lParam); // horizontal position of cursor 144 int y = HIWORD(lParam); // vertical position of cursor 145 146 if(md) { 147 SetCapture(hwnd); 148 149 GetClientRect(hwnd, &rect); 150 151 icon_x = (rect.right / xChar); 152 icon_y = (rect.bottom / yChar) - ((rect.right % xChar)?1:0); 153 icon_xy = icon_x * icon_y; 154 155 x /= xChar; 156 y /= yChar; 157 x += xPos; 158 y += yPos; 159 160 if(x + y * icon_x <= icon_count && x + y * icon_x != icon_selected) { 161 rect.left = (ox*xChar)-(xPos*xChar); 162 rect.right = (ox*xChar)-(xPos*xChar)+32; 163 rect.top = (oy*yChar)-(yPos*yChar); 164 rect.bottom = (oy*yChar)-(yPos*yChar)+32; 165 InvalidateRect(hwnd, &rect, TRUE); 166 167 rect.left = (x*xChar)-(xPos*xChar); 168 rect.right = (x*xChar)-(xPos*xChar)+32; 169 rect.top = (y*yChar)-(yPos*yChar); 170 rect.bottom = (y*yChar)-(yPos*yChar)+32; 171 InvalidateRect(hwnd, &rect, FALSE); 172 173 icon_selected = x + y * icon_x; 174 UpdateWindow (hwnd); 175 //printf("Move: %ix%i %ix%i\n", ox, oy, x, y); 176 ox = x; 177 oy = y; 178 } 179 180 } else { 181 //x /= xChar; 182 //y /= yChar; 183 //ox = x; 184 //oy = y; 185 } 186 187 } return 0; 188 189 case WM_HSCROLL: 190 // Get all the vertial scroll bar information 191 si.cbSize = sizeof (si); 192 si.fMask = SIF_ALL; 193 // Save the position for comparison later on 194 GetScrollInfo (hwnd, SB_HORZ, &si); 195 xPos = si.nPos; 196 switch (LOWORD (wParam)) 197 { 198 // user clicked left arrow 199 case SB_LINELEFT: 200 si.nPos -= 1; 201 break; 202 203 // user clicked right arrow 204 case SB_LINERIGHT: 205 si.nPos += 1; 206 break; 207 208 // user clicked shaft left of the scroll box 209 case SB_PAGELEFT: 210 si.nPos -= si.nPage; 211 break; 212 213 // user clicked shaft right of the scroll box 214 case SB_PAGERIGHT: 215 si.nPos += si.nPage; 216 break; 217 218 // user dragged the scroll box 219 case SB_THUMBTRACK: 220 si.nPos = si.nTrackPos; 221 break; 222 223 default: 224 break; 225 } 226 // Set the position and then retrieve it. Due to adjustments 227 // by Windows it may not be the same as the value set. 228 si.fMask = SIF_POS; 229 SetScrollInfo (hwnd, SB_HORZ, &si, TRUE); 230 GetScrollInfo (hwnd, SB_HORZ, &si); 231 232 // If the position has changed, scroll the window 233 if (si.nPos != xPos) { 234 ScrollWindow(hwnd, xChar * (xPos - si.nPos), 0, NULL, NULL); 235 xPos = si.nPos; 236 InvalidateRect(hwnd, NULL, TRUE); 237 UpdateWindow(hwnd); 238 239 } 240 return 0; 241 242 case WM_VSCROLL: 243 // Get all the vertial scroll bar information 244 si.cbSize = sizeof (si); 245 si.fMask = SIF_ALL; 246 GetScrollInfo (hwnd, SB_VERT, &si); 247 // Save the position for comparison later on 248 yPos = si.nPos; 249 switch (LOWORD (wParam)) 250 { 251 // user clicked the HOME keyboard key 252 case SB_TOP: 253 si.nPos = si.nMin; 254 break; 255 256 // user clicked the END keyboard key 257 case SB_BOTTOM: 258 si.nPos = si.nMax; 259 break; 260 261 // user clicked the top arrow 262 case SB_LINEUP: 263 si.nPos -= 1; 264 break; 265 266 // user clicked the bottom arrow 267 case SB_LINEDOWN: 268 si.nPos += 1; 269 break; 270 271 // user clicked the shaft above the scroll box 272 case SB_PAGEUP: 273 si.nPos -= si.nPage; 274 break; 275 276 // user clicked the shaft below the scroll box 277 case SB_PAGEDOWN: 278 si.nPos += si.nPage; 279 break; 280 281 // user dragged the scroll box 282 case SB_THUMBTRACK: 283 si.nPos = si.nTrackPos; 284 break; 285 286 default: 287 break; 288 } 289 290 // Set the position and then retrieve it. Due to adjustments 291 // by Windows it may not be the same as the value set. 292 si.fMask = SIF_POS; 293 SetScrollInfo (hwnd, SB_VERT, &si, TRUE); 294 GetScrollInfo (hwnd, SB_VERT, &si); 295 // If the position has changed, scroll window and update it 296 if (si.nPos != yPos) { 297 ScrollWindow(hwnd, 0, yChar * (yPos - si.nPos), NULL, NULL); 298 yPos = si.nPos; 299 InvalidateRect(hwnd, NULL, TRUE); 300 UpdateWindow (hwnd); 301 } 302 return 0; 303 304 case WM_COMMAND: 305 break; 306 307 case WM_CLOSE: 308 309 DestroyWindow( hwnd ); 310 return 0; 311 } 312 313 return DefWindowProc (hwnd, message, wParam, lParam); 314}

I doubt its bug free ;) I tried to make it as functional as possible... Make it a top level resizeable window, and have fun ;)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

DanielH
Member #934
January 2001
avatar

I'm using win98. What is MSVCR70? I just got that error again running another allegro program.

23yrold3yrold
Member #1,134
March 2001
avatar

I thought it was a standard DLL ???

Anyway, the code in CTilemap.h has been updated now that I have been schooled :) So hopefully that'll help anyone trying to compile this bugger. I don't know if it'll fix the crashing; I should think it would only affect compilation. Plus I added the tilemap from my old game demo just for fun :) ...

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Matthew Leverton
Supreme Loser
January 1999
avatar

Quote:

I'm using win98. What is MSVCR70? I just got that error again running another allegro program.

If you downloaded the original 4.0.3 end-user DLL, I accidently put the MSVC7 version in there. I have since replaced it with the MSVC6 version. You can either download the new DLL from the files section, or you can download the msvcr70.dll file and place it in your system32 folder.

Now, for some general comments on the program itself. The native Win32 feel is nice; that is reason alone to use an editor. I'm not a fan of these universal non-native GUI toolkit libs, nor am I fan of a full screen Allegro GUI. Having a dual monitor setup and being able to have multiple windows open is very nice.

That said, the interface definately feels "primitive", but I know working with Win32 is tedious. (But at least under Windows a primitive Win32 is better than a non-Win32 app.) As long as all the features (layers, etc) make there way in, it shouldn't be an issue.

You should use the scroller on the mouse to select between tiles. It would actually be nice if it were configurable...

How simplistic is the file format? It would be nice to have a really simple "CVS export" format available in case someone wanted to use MapSlapper to create the map, but didn't want to use its native format.

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

How simplistic is the file format?

Very. You can see it pretty plainly just by reading CTilemap::Save() (which is well commented).

Quote:

That said, the interface definately feels "primitive", but I know working with Win32 is tedious.

What would be needed to make it feel less "primitive"? It's just a tilemap editor ;) If you mean it needs more bells and whistles like animation and stuff, then, yeah ... but if that's not what you meant, could you elaborate?

Quote:

It would be nice to have a really simple "CVS export" format available in case someone wanted to use MapSlapper to create the map, but didn't want to use its native format.

Unless someone can spell this out for me or just downright code it for me, I'm not sure its worth the bother. :P It would be much easier for someone to write code to load a MapSlapper file into their tilemap structures than to make MapSlapper handle all instances IMHO. It'll be even nicer for the do-all tilemap editor, but I don't think anyone's commented on the plans for that yet :-/ ...

Thanks for the feedback though :)

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Derezo
Member #1,666
April 2001
avatar

Disabled themes and it ran fine :)

I agree with Matthew: Scrolling should change tiles :) Allegro can handle that pretty nicely - I use that in my own tile map editor.

Looks alright thus far. I love the copy/paste functions. Customizability of the tile blitting operations is pretty kewl too.

Good job :)

"He who controls the stuffing controls the Universe"

X-G
Member #856
December 2000
avatar

I dunno if you have this already, but ...

Go download RPG Maker 2000. That tile editor has a sweet feature where you can select large portions of a tileset or map and just paste it in a "pattern" kind of way wherever you want it. Try Drawing a wall, selecting it, and then drawing a large area with that brush.
You should have that. :)

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

I agree with Matthew: Scrolling should change tiles

The mouse wheel? DIdn't X-G propose that first? ;)

I'm going to have to pick up a mouse with 3 buttons and a wheel this paycheck ... oh, and Win32 can handle the wheel as well :)

Quote:

That tile editor has a sweet feature where you can select large portions of a tileset or map and just paste it in a "pattern" kind of way wherever you want it.

*cough*Clone Tool*cough* :) Did anyone fully read the docs? ::)

Quote:

Go download RPG Maker 2000.

Ooooh, feature plagarism! I love it! :D

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

X-G
Member #856
December 2000
avatar

It's more of a combination between the Stamp and Clone tools. Clicking once places ALL OF IT, like a Stamp, but if you keep placing, it won't place the whole Stamp again at the same position.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

23yrold3yrold
Member #1,134
March 2001
avatar

Can you give me a reliable link for RM2K? A lot of the sites I found on Google either don't have it or give me the runaround :P

I see what you're saying; that's an interesting idea. A Pattern Brush; could come in handy ...

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

aybabtu
Member #2,891
November 2002

I can't give you a link, but after trying your "MapSlapper", a lot of good could come from you seeing RM2K's editor. I'm not saying yours is bad...because it's not...it's just that I have very high standards after using RM2K (for way too many hours!)...my map editor pales in comparison to yours, yet. Good job!

EDIT: Here's the support site for it by the guy that translated it: http://rpgmaker2000.narod.ru/

MiquelFire
Member #3,110
January 2003
avatar

When compiling with MingW, it complains about there not being a newline at the end of the file.
(Was just trying to have an icon for the exe file :P)
Just so you know

And nothing happens when you choose Help->About either. (And I mean NOTHING!)

[edit] Just found this. On the 'Edit Tile Blit Style' If you hold down on a mouse button and move the mouse left and right a few times, it crashes.

---
Febreze (and other air fresheners actually) is just below perfumes/colognes, and that's just below dead skunks in terms of smells that offend my nose.
MiquelFire.red
If anyone is of the opinion that there is no systemic racism in America, they're either blind, stupid, or racist too. ~Edgar Reynaldo

23yrold3yrold
Member #1,134
March 2001
avatar

End of what file? I wasn't aware this was something the compiler cared about ...

Quote:

And nothing happens when you choose Help->About either. (And I mean NOTHING!)

This is noted in the docs :)

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

kazzmir
Member #1,786
December 2001
avatar

i havent attempted to compile it for linux, it probbaly has windows specific things in it, but if you want to write portable happy code, gcc will also complain about newlines at the end of every file. its quite annoying to see such things.

MiquelFire
Member #3,110
January 2003
avatar

main.cpp, Sorry, thought I said that...

And I should read the docs shouldn't I?

---
Febreze (and other air fresheners actually) is just below perfumes/colognes, and that's just below dead skunks in terms of smells that offend my nose.
MiquelFire.red
If anyone is of the opinion that there is no systemic racism in America, they're either blind, stupid, or racist too. ~Edgar Reynaldo

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

i havent attempted to compile it for linux, it probbaly has windows specific things in it

Oh yes, oh yes ...

Quote:

it complains about there not being a newline at the end of the file.

....

gcc will also complain about newlines at the end of every file.

So there should be one or there shouldn't be one? ??? This is totally news to me ...

Quote:

Just found this. On the 'Edit Tile Blit Style' If you hold down on a mouse button and move the mouse left and right a few times, it crashes.

I'll be buggered; you're right. I thought I took care of all that >:( ...

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.



Go to: