-
Notifications
You must be signed in to change notification settings - Fork 8
s25edit backports from s25client #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
67c147c
7b71843
511324b
05fcd18
74d768d
20cd336
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -493,7 +493,7 @@ void CMap::moveMap(Position offset) | |
| void CMap::setMouseData(const SDL_MouseMotionEvent& motion) | ||
| { | ||
| // following code important for blitting the right field of the map | ||
| // Are we scrolling? | ||
| // Are we scrolling? (right mouse button held) | ||
| if(startScrollPos) | ||
| { | ||
| assert(motion.state & SDL_BUTTON(3)); | ||
|
|
@@ -504,10 +504,9 @@ void CMap::setMouseData(const SDL_MouseMotionEvent& motion) | |
| offset.y = 0; | ||
| moveMap(offset); | ||
|
|
||
| // this whole "warping-thing" is to prevent cursor-moving WITHIN the window while user moves over the map | ||
| SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the change? Isn't handling this "issue" here better where it is caused than where mouse moves should be handled?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is matching current s25client VideoSDL2.cpp which doesn't use SDL_EventState.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is not a good reason to me. |
||
| // Warp mouse back to start position so we can keep scrolling | ||
| // Duplicate motion events generated by this warp are filtered in CGame::EventHandling | ||
| SDL_WarpMouseInWindow(nullptr, startScrollPos->x, startScrollPos->y); | ||
| SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE); | ||
| } | ||
|
|
||
| storeVerticesFromMouse(Position(motion.x, motion.y), motion.state); | ||
|
|
@@ -995,26 +994,17 @@ void CMap::storeVerticesFromMouse(Position mousePos, Uint8 /*MouseState*/) | |
|
|
||
| // get X | ||
| // following out commented lines are the correct ones, but for tolerance (to prevent to early jumps of the cursor) | ||
| // we subtract "triangleWidth/2" Xeven = (MouseX + displayRect.left) / triangleWidth; | ||
| // we subtract "triangleWidth/2" Xeven = (mousePos.x + displayRect.left) / triangleWidth; | ||
| Xeven = (mousePos.x + displayRect.left - triangleWidth / 2) / triangleWidth; | ||
| if(Xeven < 0) | ||
| Xeven += (map->width); | ||
| else if(Xeven > map->width - 1) | ||
| Xeven -= (map->width - 1); | ||
| Xeven = ((Xeven % map->width) + map->width) % map->width; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a function for that please? Something like |
||
| // Add rows are already shifted by triangleWidth / 2 | ||
| Xodd = (mousePos.x + displayRect.left) / triangleWidth; | ||
| // Xodd = (mousePos.x + displayRect.left) / triangleWidth; | ||
| if(Xodd < 0) | ||
| Xodd += (map->width - 1); | ||
| else if(Xodd > map->width - 1) | ||
| Xodd -= (map->width); | ||
| Xodd = ((Xodd % (map->width - 1)) + (map->width - 1)) % (map->width - 1); | ||
|
|
||
| MousePosY = mousePos.y + displayRect.top; | ||
| // correct mouse position Y if displayRect is outside map edges | ||
| if(MousePosY < 0) | ||
| MousePosY += map->height_pixel; | ||
| else if(MousePosY > map->height_pixel) | ||
| MousePosY = mousePos.y - (map->height_pixel - displayRect.top); | ||
| MousePosY = ((MousePosY % map->height_pixel) + map->height_pixel) % map->height_pixel; | ||
|
|
||
| // get Y | ||
| for(int j = 0; j < map->height; j++) | ||
|
|
@@ -1088,9 +1078,8 @@ void CMap::render() | |
| else | ||
| Surf_Map = makeRGBSurface(displayRect.getSize().x, displayRect.getSize().y); | ||
| } | ||
| // else | ||
| // clear the surface before drawing new (in normal case not needed) | ||
| // SDL_FillRect( Surf_Map, nullptr, SDL_MapRGB(Surf_Map->format,0,0,0) ); | ||
| // Clear the surface before drawing so areas not covered by triangles stay black | ||
| SDL_FillRect(Surf_Map.get(), nullptr, SDL_MapRGBA(Surf_Map->format, 0, 0, 0, 0)); | ||
|
Flamefire marked this conversation as resolved.
|
||
|
|
||
| // touch vertex data if user modifies it | ||
| if(modify) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why am I using anonymous namespaces like this?
Please advice, my review overlords.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok it's just file local helper function that is not available from other object files.
So it's fine. Not needed but whatever.
I'd assumed that not being added to .h would've made it inaccessible but I guess this is explicit and goes further.
AI adds these on it's own initiative and then makes a mess and chokes on it when there's multiple namespace scopes in same file.