- tweak: some lobby screens
This commit is contained in:
@@ -18,12 +18,7 @@ public sealed class AnimatedBackgroundControl : TextureRect
|
|||||||
private string _rsiPath = "/Textures/Ohio/Lobby/backgrounds/native.rsi";
|
private string _rsiPath = "/Textures/Ohio/Lobby/backgrounds/native.rsi";
|
||||||
private const int States = 1;
|
private const int States = 1;
|
||||||
|
|
||||||
private IRenderTexture? _buffer;
|
private readonly BackgroundData[] _data = new BackgroundData[States];
|
||||||
|
|
||||||
private readonly float[] _timer = new float[States];
|
|
||||||
private readonly float[][] _frameDelays = new float[States][];
|
|
||||||
private readonly int[] _frameCounter = new int[States];
|
|
||||||
private readonly Texture[][] _frames = new Texture[States][];
|
|
||||||
|
|
||||||
public AnimatedBackgroundControl()
|
public AnimatedBackgroundControl()
|
||||||
{
|
{
|
||||||
@@ -41,9 +36,12 @@ public sealed class AnimatedBackgroundControl : TextureRect
|
|||||||
if (!rsi.TryGetState((i + 1).ToString(), out var state))
|
if (!rsi.TryGetState((i + 1).ToString(), out var state))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
_frames[i] = state.GetFrames(RsiDirection.South);
|
var frames = state.GetFrames(RsiDirection.South);
|
||||||
_frameDelays[i] = state.GetDelays();
|
var delays = state.GetDelays();
|
||||||
_frameCounter[i] = 0;
|
|
||||||
|
// Похуй, Linq во время инициализации можно юзать... полагаю
|
||||||
|
var frameData = frames.Select((texture, index) => new Frame(texture, delays[index])).ToArray();
|
||||||
|
_data[i] = new BackgroundData(frameData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,48 +49,21 @@ public sealed class AnimatedBackgroundControl : TextureRect
|
|||||||
{
|
{
|
||||||
base.FrameUpdate(args);
|
base.FrameUpdate(args);
|
||||||
|
|
||||||
for (var i = 0; i < _frames.Length; i++)
|
foreach (var backData in _data)
|
||||||
{
|
{
|
||||||
var delays = _frameDelays[i];
|
var frame = backData.Current();
|
||||||
if (delays.Length == 0)
|
backData.Timer += args.DeltaSeconds;
|
||||||
|
|
||||||
|
if(backData.Timer < frame.Delay)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
_timer[i] += args.DeltaSeconds * 0.20f;
|
backData.Timer = 0;
|
||||||
|
|
||||||
var currentFrameIndex = _frameCounter[i];
|
Texture = frame.Texture;
|
||||||
|
backData.Next();
|
||||||
if (!(_timer[i] >= delays[currentFrameIndex]))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
_timer[i] -= delays[currentFrameIndex];
|
|
||||||
_frameCounter[i] = (currentFrameIndex + 1) % _frames[i].Length;
|
|
||||||
Texture = _frames[i][_frameCounter[i]];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Draw(DrawingHandleScreen handle)
|
|
||||||
{
|
|
||||||
base.Draw(handle);
|
|
||||||
|
|
||||||
if (_buffer is null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
handle.DrawTextureRect(_buffer.Texture, PixelSizeBox);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Resized()
|
|
||||||
{
|
|
||||||
base.Resized();
|
|
||||||
_buffer?.Dispose();
|
|
||||||
_buffer = _clyde.CreateRenderTarget(PixelSize, RenderTargetColorFormat.Rgba8Srgb);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
base.Dispose(disposing);
|
|
||||||
_buffer?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RandomizeBackground()
|
public void RandomizeBackground()
|
||||||
{
|
{
|
||||||
var backgroundsProto = _prototypeManager.EnumeratePrototypes<AnimatedLobbyScreenPrototype>().ToList();
|
var backgroundsProto = _prototypeManager.EnumeratePrototypes<AnimatedLobbyScreenPrototype>().ToList();
|
||||||
@@ -102,3 +73,27 @@ public sealed class AnimatedBackgroundControl : TextureRect
|
|||||||
InitializeStates();
|
InitializeStates();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public record struct Frame(Texture Texture,float Delay);
|
||||||
|
|
||||||
|
public sealed class BackgroundData
|
||||||
|
{
|
||||||
|
public readonly Frame[] Frames;
|
||||||
|
public int Counter;
|
||||||
|
public float Timer;
|
||||||
|
|
||||||
|
public BackgroundData(Frame[] frames)
|
||||||
|
{
|
||||||
|
Frames = frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Frame Current()
|
||||||
|
{
|
||||||
|
return Frames[Counter];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Next()
|
||||||
|
{
|
||||||
|
Counter = (Counter + 1) % Frames.Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
- type: animatedLobbyScreen
|
- type: animatedLobbyScreen
|
||||||
id: FourthLobbyScreen
|
id: CyberLobbyScreen
|
||||||
path: Ohio/Lobby/backgrounds/4.rsi
|
path: Ohio/Lobby/backgrounds/cyber.rsi
|
||||||
|
|
||||||
|
- type: animatedLobbyScreen
|
||||||
|
id: DoorLobbyScreen
|
||||||
|
path: Ohio/Lobby/backgrounds/door.rsi
|
||||||
|
|
||||||
|
#- type: animatedLobbyScreen
|
||||||
|
# id: FourthLobbyScreen
|
||||||
|
# path: Ohio/Lobby/backgrounds/4.rsi
|
||||||
|
|
||||||
#- type: animatedLobbyScreen
|
#- type: animatedLobbyScreen
|
||||||
# id: NativeLobbyScreen
|
# id: NativeLobbyScreen
|
||||||
|
|||||||
BIN
Resources/Textures/Ohio/Lobby/backgrounds/cyber.rsi/1.png
Normal file
BIN
Resources/Textures/Ohio/Lobby/backgrounds/cyber.rsi/1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 MiB |
@@ -0,0 +1,89 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"license": "CC-BY-SA-4.0",
|
||||||
|
"copyright": "212",
|
||||||
|
"size": {
|
||||||
|
"x": 498,
|
||||||
|
"y": 220
|
||||||
|
},
|
||||||
|
"states": [
|
||||||
|
{
|
||||||
|
"name": "1",
|
||||||
|
"delays": [
|
||||||
|
[
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.08,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.08,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.08,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04,
|
||||||
|
0.04
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
Resources/Textures/Ohio/Lobby/backgrounds/door.rsi/1.png
Normal file
BIN
Resources/Textures/Ohio/Lobby/backgrounds/door.rsi/1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 MiB |
64
Resources/Textures/Ohio/Lobby/backgrounds/door.rsi/meta.json
Normal file
64
Resources/Textures/Ohio/Lobby/backgrounds/door.rsi/meta.json
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"license": "CC-BY-SA-4.0",
|
||||||
|
"copyright": "1",
|
||||||
|
"size": {
|
||||||
|
"x": 811,
|
||||||
|
"y": 455
|
||||||
|
},
|
||||||
|
"states": [
|
||||||
|
{
|
||||||
|
"name": "1",
|
||||||
|
"delays": [
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
0.1,
|
||||||
|
0.2,
|
||||||
|
2,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.05,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.05,
|
||||||
|
0.05,
|
||||||
|
0.05,
|
||||||
|
0.05,
|
||||||
|
2,
|
||||||
|
0.05,
|
||||||
|
0.05,
|
||||||
|
0.2,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.5,
|
||||||
|
0.05,
|
||||||
|
0.05,
|
||||||
|
2,
|
||||||
|
0.05,
|
||||||
|
0.05,
|
||||||
|
0.05,
|
||||||
|
0.05,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user