-
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
e441969
dc864f1
29cdd56
0c7a57a
695a60f
604b117
b9a064d
31b1e61
570d24a
689df54
8806caf
4432358
d5b08a6
fc01c45
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 |
|---|---|---|
|
|
@@ -490,7 +490,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)); | ||
|
|
@@ -501,10 +501,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); | ||
| // 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(motion.x, motion.y, motion.state); | ||
|
|
@@ -994,24 +993,15 @@ void CMap::storeVerticesFromMouse(Uint16 MouseX, Uint16 MouseY, Uint8 /*MouseSta | |
| // 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; | ||
| Xeven = (MouseX + 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; | ||
| // Add rows are already shifted by triangleWidth / 2 | ||
| Xodd = (MouseX + displayRect.left) / triangleWidth; | ||
| // Xodd = (MouseX + 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 = MouseY + 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 = MouseY - (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++) | ||
|
|
@@ -1085,9 +1075,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)); | ||
|
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. Even though it may have been intended at some point: Why is this required?
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. To draw black background for small map&large screen.
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. But this is due to buggy zoom I guess where it doesn't draw toroidal wrapping map correctly. There should be no empty space in terrain editor. In OpenGL branch I fixed this now. But idk how review will go. morganchristiansson/s25edit@resize-window...opengl-small
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. |
||
|
|
||
| // 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 the change? Isn't handling this "issue" here better where it is caused than where mouse moves should be handled?
IIRC SDL offers a relative mouse mode. As we only support SDL here that might be the best solution if we change this
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.
This is matching current s25client VideoSDL2.cpp which doesn't use SDL_EventState.