A photo manager for VRChat.
1import { Accessor, createSignal, Setter } from "solid-js";
2import { Photo } from "../Structs/Photo";
3import { ViewState } from "./ViewManager";
4
5export class PhotoViewerManager{
6 public CurrentPhoto: Accessor<Photo | null>;
7 private _setCurrentPhoto: Setter<Photo | null>;
8
9 private _currentPhotoIndex = 0;
10
11 constructor(){
12 [ this.CurrentPhoto, this._setCurrentPhoto ] = createSignal<Photo | null>(null);
13 }
14
15 public NextPhoto(){
16 if(!window.PhotoManager.FilteredPhotos[this._currentPhotoIndex + 1])return;
17 this._currentPhotoIndex++;
18
19 window.PhotoViewerManager.OpenPhoto(window.PhotoManager.FilteredPhotos[this._currentPhotoIndex]);
20 }
21
22 public PreviousPhoto(){
23 if(!window.PhotoManager.FilteredPhotos[this._currentPhotoIndex - 1])return;
24 this._currentPhotoIndex--;
25
26 window.PhotoViewerManager.OpenPhoto(window.PhotoManager.FilteredPhotos[this._currentPhotoIndex]);
27 }
28
29 public Close(){
30 window.ViewManager.ChangeState(ViewState.PHOTO_LIST);
31 this._setCurrentPhoto(null);
32 }
33
34 public OpenPhoto( photo: Photo ){
35 window.ViewManager.ChangeState(ViewState.PHOTO_VIEWER);
36
37 this._setCurrentPhoto(photo);
38 this._currentPhotoIndex = window.PhotoManager.FilteredPhotos.indexOf(photo);
39 }
40}