-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c341ae
commit 0ecdd31
Showing
6 changed files
with
146 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using NFive.SDK.Client.Interface; | ||
using System; | ||
|
||
namespace NFive.Start.Client.Overlays | ||
{ | ||
public class StartOverlay : Overlay | ||
{ | ||
public event EventHandler<OverlayEventArgs> Play; | ||
|
||
public StartOverlay(OverlayManager manager) : base("StartOverlay.html", manager) | ||
{ | ||
this.Attach("play", (_, callback) => this.Play?.Invoke(this, new OverlayEventArgs(this))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=PT+Sans:700"> | ||
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> | ||
|
||
<style type="text/css"> | ||
html, body { | ||
width: 100vw; | ||
height: 100vh; | ||
margin: 0; | ||
overflow: hidden; | ||
font-size: 10vh; | ||
font-family: 'PT Sans', sans-serif; | ||
user-select: none; | ||
outline: none; | ||
background-color: transparent; | ||
} | ||
</style> | ||
|
||
<script> | ||
$(() => { | ||
nfive.show(); | ||
|
||
$('button').on('click', () => { | ||
nfive.send('play'); | ||
}); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body class="d-flex"> | ||
<main class="justify-content-center align-self-center mx-auto"> | ||
<button type="button" class="btn btn-xl btn-light shadow-none" autofocus>Play</button> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,92 @@ | ||
using System.Threading.Tasks; | ||
using CitizenFX.Core; | ||
using CitizenFX.Core.Native; | ||
using CitizenFX.Core.UI; | ||
using JetBrains.Annotations; | ||
using NFive.SDK.Client.Events; | ||
using NFive.SDK.Client.Extensions; | ||
using NFive.SDK.Client.Interface; | ||
using NFive.SDK.Client.Rpc; | ||
using NFive.SDK.Client.Services; | ||
using NFive.SDK.Core.Diagnostics; | ||
using NFive.SDK.Core.Models.Player; | ||
using NFive.Start.Client.Overlays; | ||
using System.Threading.Tasks; | ||
|
||
namespace NFive.Start.Client | ||
{ | ||
[PublicAPI] | ||
public class StartService : Service | ||
{ | ||
public StartService(ILogger logger, ITickManager ticks, IEventManager events, IRpcHandler rpc, INuiManager nui, User user) : base(logger, ticks, events, rpc, nui, user) | ||
public StartService(ILogger logger, ITickManager ticks, IEventManager events, IRpcHandler rpc, OverlayManager overlayManager, User user) : base(logger, ticks, events, rpc, overlayManager, user) { } | ||
|
||
public override async Task Started() | ||
{ | ||
// Hide HUD | ||
Screen.Hud.IsVisible = false; | ||
|
||
// Disable the loading screen from automatically being dismissed | ||
API.SetManualShutdownLoadingScreenNui(true); | ||
|
||
// Position character, required for switching | ||
Game.Player.Character.Position = Vector3.Zero; | ||
|
||
// Freeze | ||
Game.Player.Freeze(); | ||
|
||
// Switch out the player if it isn't already in a switch state | ||
if (!API.IsPlayerSwitchInProgress()) API.SwitchOutPlayer(API.PlayerPedId(), 0, 1); | ||
|
||
// Remove most clouds | ||
API.SetCloudHatOpacity(0.01f); | ||
|
||
// Wait for switch | ||
while (API.GetPlayerSwitchState() != 5) await this.Delay(10); | ||
|
||
// Hide loading screen | ||
API.ShutdownLoadingScreen(); | ||
|
||
// Fade out | ||
Screen.Fading.FadeOut(0); | ||
while (Screen.Fading.IsFadingOut) await this.Delay(10); | ||
|
||
// Show overlay | ||
var overlay = new StartOverlay(this.OverlayManager); | ||
overlay.Play += OnPlay; | ||
|
||
// Focus overlay | ||
API.SetNuiFocus(true, true); | ||
|
||
// Shut down the NUI loading screen | ||
API.ShutdownLoadingScreenNui(); | ||
|
||
// Fade in | ||
Screen.Fading.FadeIn(500); | ||
while (Screen.Fading.IsFadingIn) await this.Delay(10); | ||
} | ||
|
||
private async void OnPlay(object sender, OverlayEventArgs e) | ||
{ | ||
Task.Factory.StartNew(async () => | ||
{ | ||
// Position character | ||
Game.Player.Character.Position = new Vector3(0f, 0f, 71f); | ||
// Load character model | ||
while (!await Game.Player.ChangeModel(new Model(PedHash.FreemodeMale01))) await BaseScript.Delay(100); | ||
Game.Player.Character.Style.SetDefaultClothes(); | ||
// Fade out | ||
Screen.Fading.FadeOut(1000); | ||
while (Screen.Fading.IsFadingOut) await BaseScript.Delay(100); | ||
// Hide loading screen | ||
API.ShutdownLoadingScreen(); | ||
// Set menus | ||
API.SetPauseMenuActive(true); | ||
API.SetNoLoadingScreen(true); | ||
// Fade in | ||
Screen.Fading.FadeIn(1000); | ||
while (Screen.Fading.IsFadingIn) await BaseScript.Delay(100); | ||
}); | ||
// Destroy overlay | ||
e.Overlay.Dispose(); | ||
|
||
// Un-focus overlay | ||
API.SetNuiFocus(false, false); | ||
|
||
// Position character | ||
Game.Player.Character.Position = new Vector3(0f, 0f, 71f); | ||
|
||
// Load character model | ||
while (!await Game.Player.ChangeModel(new Model(PedHash.FreemodeMale01))) await this.Delay(10); | ||
Game.Player.Character.Style.SetDefaultClothes(); | ||
|
||
// Unfreeze | ||
Game.Player.Unfreeze(); | ||
|
||
// Show HUD | ||
Screen.Hud.IsVisible = true; | ||
|
||
// Switch in | ||
API.SwitchInPlayer(API.PlayerPedId()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="CitizenFX.Client" version="1.3.0.1124361" targetFramework="net452" /> | ||
<package id="CitizenFX.Client" version="1.3.0.1125840" targetFramework="net452" /> | ||
<package id="JetBrains.Annotations" version="2018.2.1" allowedVersions="[2018.2.1]" targetFramework="net452" /> | ||
<package id="Newtonsoft.Json" version="11.0.2" allowedVersions="[11.0.2]" targetFramework="net452" /> | ||
<package id="NFive.SDK.Client" version="0.1.0.7" targetFramework="net452" /> | ||
<package id="NFive.SDK.Core" version="0.1.0.11" allowedVersions="[0.1.0.11,0.2)" targetFramework="net452" /> | ||
<package id="NFive.SDK.Client" version="0.1.0.11" targetFramework="net452" /> | ||
<package id="NFive.SDK.Core" version="0.1.0.14" allowedVersions="[0.1.0.11,0.2)" targetFramework="net452" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
name: NFive/plugin-start | ||
version: 1.0.0 | ||
version: 1.1.0 | ||
description: Simple plugin to start the game | ||
author: NFive | ||
license: LGPL | ||
website: https://nfive.io/ | ||
client: | ||
main: | ||
- NFive.Start.Client | ||
files: | ||
- Overlays/StartOverlay.html |