Skip to content
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

Load position improvements #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion OpenSpaceToolbox/ViewModels/Bookmarks/BookmarksViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void LoadBookmark()
if (SelectedBookmark == null)
return;

GameManager.PlayerCoordinates = (SelectedBookmark.X, SelectedBookmark.Y, SelectedBookmark.Z);
GameManager.PlayerCoordinates = GameManager.SavedPosition = (SelectedBookmark.X, SelectedBookmark.Y, SelectedBookmark.Z);
}

/// <summary>
Expand Down Expand Up @@ -318,6 +318,8 @@ public void AddBookmark()

AllBookmarkItems.Add(bookmark);
BookmarkItems.Add(bookmark);

GameManager.SavedPosition = coords;
}

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions OpenSpaceToolbox/ViewModels/GameManagerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public void LoadOffsetLevel(int offset)
/// </summary>
public void LoadSavedPosition()
{
if (GameManager.SavedPosition == default)
return;

GameManager.PlayerCoordinates = GameManager.SavedPosition;
}

Expand Down
6 changes: 4 additions & 2 deletions OpenSpaceToolbox/Views/GameManagerFullView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ public GameManagerFullView()
private void BookmarkListItemDoubleClick(object sender, MouseButtonEventArgs e)
{
if (DataContext is MainViewModel viewModel)
viewModel.GameManager.PlayerCoordinates = (viewModel.BookmarksVm.SelectedBookmark.X,
viewModel.BookmarksVm.SelectedBookmark.Y, viewModel.BookmarksVm.SelectedBookmark.Z);
viewModel.GameManager.PlayerCoordinates = viewModel.GameManager.SavedPosition =
(viewModel.BookmarksVm.SelectedBookmark.X,
viewModel.BookmarksVm.SelectedBookmark.Y,
viewModel.BookmarksVm.SelectedBookmark.Z);
}

private void LevelTreeItemDoubleClick(object sender, MouseButtonEventArgs e)
Expand Down
6 changes: 4 additions & 2 deletions OpenSpaceToolbox/Views/GameManagerMinimizedView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ public GameManagerMinimizedView()
private void BookmarkListItemDoubleClick(object sender, MouseButtonEventArgs e)
{
if (DataContext is MainViewModel viewModel)
viewModel.GameManager.PlayerCoordinates = (viewModel.BookmarksVm.SelectedBookmark.X,
viewModel.BookmarksVm.SelectedBookmark.Y, viewModel.BookmarksVm.SelectedBookmark.Z);
viewModel.GameManager.PlayerCoordinates = viewModel.GameManager.SavedPosition =
(viewModel.BookmarksVm.SelectedBookmark.X,
viewModel.BookmarksVm.SelectedBookmark.Y,
viewModel.BookmarksVm.SelectedBookmark.Z);
}

private void LevelTreeItemDoubleClick(object sender, MouseButtonEventArgs e)
Expand Down