Skip to content

Commit

Permalink
feat(phone/photo): emit an event when exiting/entering photo mode
Browse files Browse the repository at this point in the history
  • Loading branch information
TasoOneAsia committed Dec 3, 2021
1 parent 6c34bec commit 36362be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions resources/client/cl_photo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ RegisterNuiCB<void>(PhotoEvents.TAKE_PHOTO, async (_, cb) => {
CellCamActivate(true, true);
// Hide phone from rendering temporary
closePhoneTemp();

SetNuiFocus(false, false);

inCameraMode = true;

// We want to emit this event for UI handling in other resources
emit(PhotoEvents.NPWD_PHOTO_MODE_STARTED);

// Player shouldnt have radar on screen
DisplayRadar(false);

while (inCameraMode) {
await Delay(0);
if (IsControlJustPressed(1, 27)) {
Expand All @@ -68,10 +73,14 @@ RegisterNuiCB<void>(PhotoEvents.TAKE_PHOTO, async (_, cb) => {
}
displayHelperText();
}

ClearHelp(true);
// We can now signal to other resources for ending photo mode
emit(PhotoEvents.NPWD_PHOTO_MODE_ENDED);
DisplayRadar(true);

emit('npwd:disableControlActions', true);
await animationService.closeCamera();
console.log('anim - closing camera');
});

const handleTakePicture = async () => {
Expand Down
2 changes: 2 additions & 0 deletions typings/photo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export interface GalleryPhoto {

export enum PhotoEvents {
TAKE_PHOTO = 'npwd:TakePhoto',
NPWD_PHOTO_MODE_STARTED = 'npwd:PhotoModeStarted',
NPWD_PHOTO_MODE_ENDED = 'npwd:PhotoModeEnded',
TAKE_PHOTO_SUCCESS = 'npwd:TakePhotoSuccess',
UPLOAD_PHOTO = 'npwd:UploadPhoto',
FETCH_PHOTOS = 'npwd:FetchPhotos',
Expand Down

0 comments on commit 36362be

Please sign in to comment.