Ah okay, sorry I missed that - Thanks, that will solve it
Edit: Okay cool, I got it working as per your suggestion, and I think the implementation is quite good (to my novice eyes at least
)
private void mapXScrollbar_Scroll
(object sender, ScrollEventArgs e
){ gridWindow
.DefaultView.Center = new Vector2f
(Constants
.ViewXCenter + Constants
.TileSize * e
.NewValue, gridWindow
.DefaultView.Center.Y);}private void mapYScrollbar_Scroll
(object sender, ScrollEventArgs e
){ gridWindow
.DefaultView.Center = new Vector2f
(gridWindow
.DefaultView.Center.X, Constants
.ViewYCenter + Constants
.TileSize * e
.NewValue);} If you don't mind, I have one more question. Essentially, I've got a panel for my container, another panel for my sfml window, and two scrollbars for the scrolling, I did this so I can scale the window at runtime. It all works good and scales well.
One struggle I'm having however is that mouse clicks are registered even when I'm outside of the sfml window, but still in the WinForms window (Note that this happened in my c++ version when I used one window and multiple views, as opposed to one winforms window).
Basically, I think I need a way to stop events from being registered when the mouse is out of context, i.e. If i'm scrolling on the scrollbar, and the mouse is raised on to the map, since I'm holding down left click, It will go ahead and place tiles, even though I'm scrolling. This is not what I want, I want it to essentially "ignore" the map, while I'm scrolling.
A solution could be while scrolling implement a boolean... if not scrolling then allow tile placement, however I don't want to add a conditional check unless it's vital.
What i'm kind of looking for is something like:
*Scroll function called
*Disable view input
*Scroll function returns
*Enable view input
Or something similar. I also need the input to not register if the click is not within the view, at the moment it does.
public void ChangeCurrentTileTemp(ref RenderWindow window, ref int tile, ref int mouseX, ref int mouseY)
{
Vector2f mouse = window.MapPixelToCoords(Mouse.GetPosition(window));
That's the start of the function, so I could add a conditional if not scrolling && if mouse within viewport x and y, but I just want to see if there's a more elegant solution first.
Do you know anything that I could do instead of implementing a conditional (which might reduce speed by a tiny bit)?
Edit, as per
http://www.sfml-dev.org/tutorials/2.0/window-events.php I may be able to use LostFocus, and GainedFocus for the scrollbar scenario.