Add unlock conditions for gallery
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.SaveFileBuilder;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
using NathanHoad;
|
||||
using SimpleInjector.Lifestyles;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Threading.Tasks;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
@@ -12,10 +15,13 @@ using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public interface IApp : INode, IProvide<IAppRepo>;
|
||||
public interface IApp : INode, IProvide<IAppRepo>, IProvide<IApp>
|
||||
{
|
||||
public GalleryData GalleryData { get; }
|
||||
}
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class App : Node, IApp
|
||||
public partial class App : Node, IApp, IProvide<ISaveChunk<GalleryData>>
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
@@ -33,22 +39,31 @@ public partial class App : Node, IApp
|
||||
|
||||
IAppRepo IProvide<IAppRepo>.Value() => AppRepo;
|
||||
|
||||
IApp IProvide<IApp>.Value() => this;
|
||||
|
||||
public IAppRepo AppRepo { get; set; } = default!;
|
||||
public IAppLogic AppLogic { get; set; } = default!;
|
||||
public AppLogic.IBinding AppBinding { get; set; } = default!;
|
||||
|
||||
private Godot.Collections.Array _progress;
|
||||
private SimpleInjector.Container _container;
|
||||
|
||||
private IMaSaveFileManager _gallerySaveDataManager;
|
||||
private EnemyViewer _dataViewer;
|
||||
private bool _loadingGame = false;
|
||||
private bool _loadingEnemyViewer = false;
|
||||
private string _optionsSavePath = string.Empty;
|
||||
private string _controllerSavePath = string.Empty;
|
||||
private string _gallerySavePath = string.Empty;
|
||||
private ISaveFileManager _saveFileManager;
|
||||
private IGame _game;
|
||||
private IEnemyViewer _enemyViewer;
|
||||
|
||||
public ISaveChunk<GalleryData> GameChunk { get; set; } = default!;
|
||||
ISaveChunk<GalleryData> IProvide<ISaveChunk<GalleryData>>.Value() => GameChunk;
|
||||
public ISaveFile<GalleryData> GallerySaveFile { get; set; } = default!;
|
||||
|
||||
public GalleryData GalleryData { get; private set; }
|
||||
|
||||
private double _reportedProgress = 0;
|
||||
|
||||
public void Initialize()
|
||||
@@ -63,6 +78,64 @@ public partial class App : Node, IApp
|
||||
_saveFileManager = _container.GetInstance<ISaveFileManager>();
|
||||
_optionsSavePath = $"{OS.GetUserDataDir()}/options.json";
|
||||
_controllerSavePath = $"{OS.GetUserDataDir()}/controls.json";
|
||||
_gallerySavePath = $"{OS.GetUserDataDir()}/gallery.json";
|
||||
|
||||
GalleryData = new GalleryData();
|
||||
|
||||
GameChunk = new SaveChunk<GalleryData>(
|
||||
(chunk) =>
|
||||
{
|
||||
var galleryData = new GalleryData()
|
||||
{
|
||||
SproingyFifty = GalleryData.SproingyFifty,
|
||||
MichaelFifty = GalleryData.MichaelFifty,
|
||||
FilthEaterFifty = GalleryData.FilthEaterFifty,
|
||||
SaraFifty = GalleryData.SaraFifty,
|
||||
BallosFifty = GalleryData.BallosFifty,
|
||||
PlanterFifty = GalleryData.PlanterFifty,
|
||||
ChintheFifty = GalleryData.ChintheFifty,
|
||||
AmbassadorGreenFifty = GalleryData.AmbassadorGreenFifty,
|
||||
AmbassadorRedFifty = GalleryData.AmbassadorRedFifty,
|
||||
AmbassadorSteelFifty = GalleryData.AmbassadorSteelFifty,
|
||||
AgniDemonFifty = GalleryData.AgniDemonFifty,
|
||||
AqueousDemonFifty = GalleryData.AqueousDemonFifty,
|
||||
EdenPillarFifty = GalleryData.EdenPillarFifty,
|
||||
PalanFifty = GalleryData.PalanFifty,
|
||||
ShieldOfHeavenFifty = GalleryData.ShieldOfHeavenFifty,
|
||||
GoldSproingFifty = GalleryData.GoldSproingFifty,
|
||||
TotalEnemiesFifty = GalleryData.TotalEnemiesFifty,
|
||||
TotalEnemiesHundred = GalleryData.TotalEnemiesHundred,
|
||||
NormalEnd = GalleryData.NormalEnd,
|
||||
TrueEnd = GalleryData.TrueEnd,
|
||||
BadEnd = GalleryData.BadEnd,
|
||||
StelesTen = GalleryData.StelesTen
|
||||
};
|
||||
return galleryData;
|
||||
},
|
||||
onLoad:
|
||||
(chunk, data) =>
|
||||
{
|
||||
GalleryData = data ?? new GalleryData();
|
||||
});
|
||||
|
||||
_gallerySaveDataManager = new MaSaveFileManager(_gallerySavePath);
|
||||
GallerySaveFile = new SaveFile<GalleryData>(
|
||||
root: GameChunk,
|
||||
onSave: _gallerySaveDataManager.Save,
|
||||
onLoad: async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var galleryData = await _gallerySaveDataManager.Load<GalleryData>();
|
||||
return galleryData;
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
GD.Print("No save file found.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
MainMenu.StartGame += OnStartGame;
|
||||
MainMenu.EnemyViewer += OnEnemyViewer;
|
||||
@@ -119,7 +192,7 @@ public partial class App : Node, IApp
|
||||
MainMenu.OptionsButton.GrabFocus();
|
||||
}
|
||||
|
||||
private void GalleryExited()
|
||||
private async void GalleryExited()
|
||||
{
|
||||
GalleryMenu.Hide();
|
||||
MainMenu.GalleryButton.GrabFocus();
|
||||
@@ -204,6 +277,7 @@ public partial class App : Node, IApp
|
||||
_game.GameLoaded += OnGameLoaded;
|
||||
_game.GameExitRequested += GameExitRequested;
|
||||
CallDeferred(MethodName.AddChild, scene);
|
||||
_game.UnlockGalleryItem += UnlockGalleryItem;
|
||||
}
|
||||
|
||||
private void OnGameLoaded() => LoadingScreen.HideLoadingScreen();
|
||||
@@ -216,6 +290,56 @@ public partial class App : Node, IApp
|
||||
LoadingScreen.HideLoadingScreen();
|
||||
}
|
||||
|
||||
private void UnlockGalleryItem(string obj)
|
||||
{
|
||||
if (obj == nameof(GalleryData.SproingyFifty))
|
||||
GalleryData.SproingyFifty = true;
|
||||
if (obj == nameof(GalleryData.MichaelFifty))
|
||||
GalleryData.MichaelFifty = true;
|
||||
if (obj == nameof(GalleryData.FilthEaterFifty))
|
||||
GalleryData.FilthEaterFifty = true;
|
||||
if (obj == nameof(GalleryData.SaraFifty))
|
||||
GalleryData.SaraFifty = true;
|
||||
if (obj == nameof(GalleryData.BallosFifty))
|
||||
GalleryData.BallosFifty = true;
|
||||
if (obj == nameof(GalleryData.PlanterFifty))
|
||||
GalleryData.PlanterFifty = true;
|
||||
if (obj == nameof(GalleryData.ChintheFifty))
|
||||
GalleryData.ChintheFifty = true;
|
||||
if (obj == nameof(GalleryData.AmbassadorGreenFifty))
|
||||
GalleryData.AmbassadorGreenFifty = true;
|
||||
if (obj == nameof(GalleryData.AmbassadorRedFifty))
|
||||
GalleryData.AmbassadorRedFifty = true;
|
||||
if (obj == nameof(GalleryData.AmbassadorSteelFifty))
|
||||
GalleryData.AmbassadorSteelFifty = true;
|
||||
if (obj == nameof(GalleryData.AgniDemonFifty))
|
||||
GalleryData.AgniDemonFifty = true;
|
||||
if (obj == nameof(GalleryData.AqueousDemonFifty))
|
||||
GalleryData.AqueousDemonFifty = true;
|
||||
if (obj == nameof(GalleryData.EdenPillarFifty))
|
||||
GalleryData.EdenPillarFifty = true;
|
||||
if (obj == nameof(GalleryData.PalanFifty))
|
||||
GalleryData.PalanFifty = true;
|
||||
if (obj == nameof(GalleryData.ShieldOfHeavenFifty))
|
||||
GalleryData.ShieldOfHeavenFifty = true;
|
||||
if (obj == nameof(GalleryData.GoldSproingFifty))
|
||||
GalleryData.GoldSproingFifty = true;
|
||||
if (obj == nameof(GalleryData.TotalEnemiesFifty))
|
||||
GalleryData.TotalEnemiesFifty = true;
|
||||
if (obj == nameof(GalleryData.TotalEnemiesHundred))
|
||||
GalleryData.TotalEnemiesHundred = true;
|
||||
if (obj == nameof(GalleryData.NormalEnd))
|
||||
GalleryData.NormalEnd = true;
|
||||
if (obj == nameof(GalleryData.TrueEnd))
|
||||
GalleryData.TrueEnd = true;
|
||||
if (obj == nameof(GalleryData.BadEnd))
|
||||
GalleryData.BadEnd = true;
|
||||
if (obj == nameof(GalleryData.StelesTen))
|
||||
GalleryData.StelesTen = true;
|
||||
|
||||
GallerySaveFile.Save();
|
||||
}
|
||||
|
||||
private async Task<Node> LoadSceneInternal(string sceneName)
|
||||
{
|
||||
LoadingScreen.ShowLoadingScreen();
|
||||
@@ -239,7 +363,11 @@ public partial class App : Node, IApp
|
||||
OptionsMenu.GameTab.GrabFocus();
|
||||
}
|
||||
|
||||
private async void OnGallery() => GalleryMenu.Show();
|
||||
private async void OnGallery()
|
||||
{
|
||||
GalleryData = await _gallerySaveDataManager.Load<GalleryData>();
|
||||
GalleryMenu.Show();
|
||||
}
|
||||
|
||||
public void OnQuit() => AppLogic.Input(new AppLogic.Input.QuitGame());
|
||||
|
||||
|
||||
@@ -190,8 +190,7 @@ public abstract partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLo
|
||||
_hitSFX.Play();
|
||||
_dieSFX.Play();
|
||||
_gameRepo.OnEnemyDied(this);
|
||||
IncrementDefeatCount();
|
||||
await _game.Save();
|
||||
await _game.IncrementEnemyDefeatedCount(EnemyModelView.EnemyLoreInfo.Name);
|
||||
var tweener = CreateTween();
|
||||
tweener.TweenInterval(1.0f);
|
||||
tweener.TweenCallback(Callable.From(QueueFree));
|
||||
@@ -323,14 +322,6 @@ public abstract partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLo
|
||||
StatusEffectComponent.Rust.OnNext(false);
|
||||
}
|
||||
|
||||
public void IncrementDefeatCount()
|
||||
{
|
||||
if (_game.StatData.EnemiesDefeated.ContainsKey(EnemyModelView.EnemyLoreInfo.Name))
|
||||
_game.StatData.EnemiesDefeated[EnemyModelView.EnemyLoreInfo.Name]++;
|
||||
else
|
||||
_game.StatData.EnemiesDefeated.TryAdd(EnemyModelView.EnemyLoreInfo.Name, 1);
|
||||
}
|
||||
|
||||
public int GetDefeatCount(IEnemy enemyType)
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -93,6 +93,9 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
public event Action<string> InventoryEventNotification;
|
||||
|
||||
|
||||
public event Action<string> UnlockGalleryItem;
|
||||
|
||||
public Game()
|
||||
{
|
||||
_container = new SimpleInjector.Container();
|
||||
@@ -105,6 +108,7 @@ public partial class Game : Node3D, IGame
|
||||
RescuedItems = new RescuedItemDatabase(20);
|
||||
SarcoData = new SarcoData();
|
||||
NpcData = new NpcData() { SteleDiscovered = [] };
|
||||
StatData = new StatData();
|
||||
ItemDatabase = ItemDatabase.Instance;
|
||||
|
||||
GameChunk = new SaveChunk<GameData>(
|
||||
@@ -150,7 +154,7 @@ public partial class Game : Node3D, IGame
|
||||
}
|
||||
);
|
||||
|
||||
var saveFileManager = new MaSaveFileManager();
|
||||
var saveFileManager = new MaSaveFileManager($"{OS.GetUserDataDir()}/game.json");
|
||||
SaveFile = new SaveFile<GameData>(
|
||||
root: GameChunk,
|
||||
onSave: saveFileManager.Save,
|
||||
@@ -956,6 +960,49 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
public void NotifyInventory(string message) => InventoryEventNotification?.Invoke(message);
|
||||
|
||||
public async Task IncrementEnemyDefeatedCount(string enemyName)
|
||||
{
|
||||
if (StatData.EnemiesDefeated.ContainsKey(enemyName))
|
||||
StatData.EnemiesDefeated[enemyName]++;
|
||||
else
|
||||
StatData.EnemiesDefeated.TryAdd(enemyName, 1);
|
||||
|
||||
if (StatData.EnemiesDefeated[enemyName] == 50)
|
||||
UnlockGalleryItem.Invoke(enemyName + "Fifty");
|
||||
if (StatData.EnemiesDefeated[enemyName] == 100)
|
||||
UnlockGalleryItem.Invoke(enemyName + "Hundred");
|
||||
|
||||
await Save();
|
||||
}
|
||||
|
||||
public async Task IncrementSteleCount(int steleId)
|
||||
{
|
||||
if (!NpcData.SteleDiscovered.Contains(steleId))
|
||||
{
|
||||
NpcData.SteleDiscovered.Add(steleId);
|
||||
|
||||
if (NpcData.SteleDiscovered.Count == 10)
|
||||
UnlockGalleryItem.Invoke("StelesTen");
|
||||
|
||||
await Save();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OnReachNormalEnd()
|
||||
{
|
||||
UnlockGalleryItem.Invoke("NormalEnd");
|
||||
}
|
||||
|
||||
public async Task OnReachBadEnd()
|
||||
{
|
||||
UnlockGalleryItem.Invoke("BadEnd");
|
||||
}
|
||||
|
||||
public async Task OnReachTrueEnd()
|
||||
{
|
||||
UnlockGalleryItem.Invoke("TrueEnd");
|
||||
}
|
||||
|
||||
private void OnQuit() => GameExitRequested?.Invoke();
|
||||
|
||||
private void GameOverMenuAppeared() => _map.ClearFloor();
|
||||
|
||||
@@ -42,6 +42,16 @@ public interface IGame : IProvide<IGame>, IProvide<IGameRepo>, IProvide<IPlayer>
|
||||
|
||||
public void NotifyInventory(string message);
|
||||
|
||||
public Task IncrementEnemyDefeatedCount(string enemyName);
|
||||
|
||||
public Task IncrementSteleCount(int steleId);
|
||||
|
||||
public Task OnReachNormalEnd();
|
||||
|
||||
public Task OnReachBadEnd();
|
||||
|
||||
public Task OnReachTrueEnd();
|
||||
|
||||
public ItemRescueMenu ItemRescueMenu { get; }
|
||||
|
||||
public QuestData QuestData { get; }
|
||||
@@ -57,4 +67,6 @@ public interface IGame : IProvide<IGame>, IProvide<IGameRepo>, IProvide<IPlayer>
|
||||
public event Action GameLoaded;
|
||||
|
||||
public event Action<string> InventoryEventNotification;
|
||||
|
||||
public event Action<string> UnlockGalleryItem;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -13,21 +12,24 @@ public partial class FinalFloor : SpecialFloor
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency] protected IPlayer _player => this.DependOn(() => GetParent().GetChildren().OfType<IPlayer>().Single());
|
||||
[Dependency] protected IGame _game => this.DependOn<IGame>();
|
||||
|
||||
[Node] public Area3D Exit { get; set; }
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
Exit.AreaEntered += Exit_AreaEntered;
|
||||
Exit.AreaEntered += Exit_AreaEntered;
|
||||
}
|
||||
|
||||
private void Exit_AreaEntered(Area3D area)
|
||||
private async void Exit_AreaEntered(Area3D area)
|
||||
{
|
||||
_player.Die();
|
||||
await _game.OnReachNormalEnd();
|
||||
// Start Ending Cutscene
|
||||
_player.Die();
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
Exit.AreaEntered -= Exit_AreaEntered;
|
||||
Exit.AreaEntered -= Exit_AreaEntered;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,12 @@ public partial class BadEnd : SpecialFloor
|
||||
tweener.TweenMethod(Callable.From((float x) => SetShakeValue(x)), ShakeAmount, 1f, 700f).SetDelay(30);
|
||||
}
|
||||
|
||||
public void StartEndGameCutscene()
|
||||
public async void StartEndGameCutscene()
|
||||
{
|
||||
_player.Deactivate();
|
||||
_player.ShowCamera(false);
|
||||
Camera3D.Current = true;
|
||||
await _game.OnReachBadEnd();
|
||||
}
|
||||
|
||||
public void EndGame()
|
||||
|
||||
@@ -10,9 +10,9 @@ namespace Zennysoft.Game.Ma;
|
||||
public partial class Stele : Node3D
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
|
||||
[Dependency] public IGame _game => this.DependOn<IGame>();
|
||||
|
||||
|
||||
[Node] public AnimationPlayer AnimationPlayer { get; set; }
|
||||
|
||||
[Node] public Area3D DialogueZone { get; set; } = default!;
|
||||
@@ -77,12 +77,8 @@ public partial class Stele : Node3D
|
||||
|
||||
public async Task EndDialogue()
|
||||
{
|
||||
if (!_game.NpcData.SteleDiscovered.Contains(ID))
|
||||
{
|
||||
_game.NpcData.SteleDiscovered.Add(ID);
|
||||
await _game.Save();
|
||||
AnimationPlayer.Play("fade_in");
|
||||
}
|
||||
await _game.IncrementSteleCount(ID);
|
||||
AnimationPlayer.Play("fade_in");
|
||||
}
|
||||
|
||||
public override int GetHashCode() => GetPath().GetHashCode();
|
||||
|
||||
@@ -12,7 +12,7 @@ public partial class GalleryData : Node
|
||||
[Save("MichaelFifty")]
|
||||
public bool MichaelFifty { get; set; } = false;
|
||||
[Save("FilthEaterFifty")]
|
||||
public bool FilthEaterFifty { get; set; } = true;
|
||||
public bool FilthEaterFifty { get; set; } = false;
|
||||
[Save("SaraFifty")]
|
||||
public bool SaraFifty { get; set; } = false;
|
||||
[Save("BallosFifty")]
|
||||
@@ -20,7 +20,7 @@ public partial class GalleryData : Node
|
||||
[Save("PlanterFifty")]
|
||||
public bool PlanterFifty { get; set; } = false;
|
||||
[Save("ChintheFifty")]
|
||||
public bool ChintheFifty { get; set; } = true;
|
||||
public bool ChintheFifty { get; set; } = false;
|
||||
[Save("AmbassadorGreenFifty")]
|
||||
public bool AmbassadorGreenFifty { get; set; } = false;
|
||||
[Save("AmbassadorRedFifty")]
|
||||
@@ -40,7 +40,7 @@ public partial class GalleryData : Node
|
||||
[Save("GoldSproingyFifty")]
|
||||
public bool GoldSproingFifty { get; set; } = false;
|
||||
[Save("TotalEnemiesFifty")]
|
||||
public bool TotalEnemiesFifty { get; set; } = true;
|
||||
public bool TotalEnemiesFifty { get; set; } = false;
|
||||
[Save("TotalEnemiesHundred")]
|
||||
public bool TotalEnemiesHundred { get; set; } = false;
|
||||
[Save("NormalEnd")]
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public interface IMaSaveFileManager
|
||||
{
|
||||
Task Save<T>(T gameData);
|
||||
Task Save<T>(T data);
|
||||
|
||||
Task<T?> Load<T>();
|
||||
}
|
||||
@@ -18,17 +18,20 @@ public sealed class MaSaveFileManager : IMaSaveFileManager
|
||||
{
|
||||
private readonly ISaveFileManager _saveFileManager;
|
||||
private readonly ImmutableList<IJsonTypeInfoResolver> _converters;
|
||||
private string _filePath = string.Empty;
|
||||
|
||||
public MaSaveFileManager()
|
||||
public MaSaveFileManager(string filePath)
|
||||
{
|
||||
_saveFileManager = new SaveFileManager(new FileSystem());
|
||||
_converters = [WeaponTagEnumContext.Default, ItemTagEnumContext.Default, ElementTypeEnumContext.Default, AccessoryTagEnumContext.Default, UsableItemTagEnumContext.Default, BoxItemTagEnumContext.Default, JewelTagsEnumContext.Default, BaseInventoryItemContext.Default, RescuedItemDatabaseContext.Default];
|
||||
_filePath = filePath;
|
||||
|
||||
}
|
||||
|
||||
public async Task Save<T>(T gameData)
|
||||
{
|
||||
await _saveFileManager.WriteToFile(gameData, [.. _converters]);
|
||||
await _saveFileManager.WriteToFile(gameData, _filePath, [.. _converters]);
|
||||
}
|
||||
|
||||
public async Task<T?> Load<T>() => await _saveFileManager.ReadFromFile<T>([.. _converters]);
|
||||
public async Task<T?> Load<T>() => await _saveFileManager.ReadFromFile<T>(_filePath, [.. _converters]);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
using NathanHoad;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
using Zennysoft.Game.Ma;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
@@ -40,6 +37,8 @@ public partial class GalleryMenu : Control
|
||||
[Node] public TextureRect ItemThumb10 { get; set; }
|
||||
#endregion
|
||||
|
||||
[Dependency] public IApp _app => this.DependOn<IApp>();
|
||||
|
||||
[Node] public TextureButton PreviousButton { get; set; }
|
||||
[Node] public TextureButton NextButton { get; set; }
|
||||
[Node] public TextureButton BackButton { get; set; }
|
||||
@@ -48,8 +47,6 @@ public partial class GalleryMenu : Control
|
||||
[Node] public Control ThumbnailView { get; set; }
|
||||
[Node] public TextureRect FullSizeImage { get; set; }
|
||||
|
||||
public GalleryData GalleryData { get; set; }
|
||||
|
||||
[Signal] public delegate void GalleryExitedEventHandler();
|
||||
|
||||
private List<Button> ItemLabels;
|
||||
@@ -69,17 +66,41 @@ public partial class GalleryMenu : Control
|
||||
ItemLabels = [ItemLabel1, ItemLabel2, ItemLabel3, ItemLabel4, ItemLabel5, ItemLabel6, ItemLabel7, ItemLabel8, ItemLabel9, ItemLabel10];
|
||||
ItemLabels.ForEach(x => x.Pressed += ViewFullImage);
|
||||
ItemThumbnails = [ItemThumb1, ItemThumb2, ItemThumb3, ItemThumb4, ItemThumb5, ItemThumb6, ItemThumb7, ItemThumb8, ItemThumb9, ItemThumb10];
|
||||
GalleryData = new GalleryData();
|
||||
BackButton.Pressed += BackButton_Pressed;
|
||||
NextButton.Pressed += NextButton_Pressed;
|
||||
PreviousButton.Pressed += PreviousButton_Pressed;
|
||||
PreviousButton.Disabled = true;
|
||||
|
||||
var allFiles = DirAccess.GetFilesAt(_textures).Where(x => x.EndsWith(".jpg")).Concat(DirAccess.GetFilesAt(_textures).Where(x => x.EndsWith(".png"))).ToArray();
|
||||
Filepaths = [.. allFiles.Chunk(10)];
|
||||
GalleryImages.Add(allFiles[0], false);
|
||||
GalleryImages.Add(allFiles[1], false);
|
||||
GalleryImages.Add(allFiles[2], false);
|
||||
GalleryImages.Add(allFiles[3], false);
|
||||
GalleryImages.Add(allFiles[4], false);
|
||||
GalleryImages.Add(allFiles[5], false);
|
||||
GalleryImages.Add(allFiles[6], false);
|
||||
GalleryImages.Add(allFiles[7], false);
|
||||
GalleryImages.Add(allFiles[8], false);
|
||||
GalleryImages.Add(allFiles[9], false);
|
||||
GalleryImages.Add(allFiles[10], false);
|
||||
GalleryImages.Add(allFiles[11], false);
|
||||
GalleryImages.Add(allFiles[12], false);
|
||||
GalleryImages.Add(allFiles[13], false);
|
||||
GalleryImages.Add(allFiles[14], false);
|
||||
GalleryImages.Add(allFiles[15], false);
|
||||
GalleryImages.Add(allFiles[16], false);
|
||||
GalleryImages.Add(allFiles[17], false);
|
||||
GalleryImages.Add(allFiles[18], false);
|
||||
GalleryImages.Add(allFiles[19], false);
|
||||
GalleryImages.Add(allFiles[20], false);
|
||||
GalleryImages.Add(allFiles[21], false);
|
||||
|
||||
VisibilityChanged += GalleryMenu_VisibilityChanged;
|
||||
_selectedItem = 0;
|
||||
}
|
||||
|
||||
private void GalleryMenu_VisibilityChanged()
|
||||
private async void GalleryMenu_VisibilityChanged()
|
||||
{
|
||||
if (Visible)
|
||||
{
|
||||
@@ -104,29 +125,28 @@ public partial class GalleryMenu : Control
|
||||
public void LoadImages()
|
||||
{
|
||||
var allFiles = DirAccess.GetFilesAt(_textures).Where(x => x.EndsWith(".jpg")).Concat(DirAccess.GetFilesAt(_textures).Where(x => x.EndsWith(".png"))).ToArray();
|
||||
Filepaths = [.. allFiles.Chunk(10)];
|
||||
GalleryImages.Add(allFiles[0], GalleryData.SproingyFifty);
|
||||
GalleryImages.Add(allFiles[1], GalleryData.MichaelFifty);
|
||||
GalleryImages.Add(allFiles[2], GalleryData.FilthEaterFifty);
|
||||
GalleryImages.Add(allFiles[3], GalleryData.SaraFifty);
|
||||
GalleryImages.Add(allFiles[4], GalleryData.BallosFifty);
|
||||
GalleryImages.Add(allFiles[5], GalleryData.PlanterFifty);
|
||||
GalleryImages.Add(allFiles[6], GalleryData.ChintheFifty);
|
||||
GalleryImages.Add(allFiles[7], GalleryData.AmbassadorGreenFifty);
|
||||
GalleryImages.Add(allFiles[8], GalleryData.AmbassadorRedFifty);
|
||||
GalleryImages.Add(allFiles[9], GalleryData.AmbassadorSteelFifty);
|
||||
GalleryImages.Add(allFiles[10], GalleryData.AgniDemonFifty);
|
||||
GalleryImages.Add(allFiles[11], GalleryData.AqueousDemonFifty);
|
||||
GalleryImages.Add(allFiles[12], GalleryData.EdenPillarFifty);
|
||||
GalleryImages.Add(allFiles[13], GalleryData.PalanFifty);
|
||||
GalleryImages.Add(allFiles[14], GalleryData.ShieldOfHeavenFifty);
|
||||
GalleryImages.Add(allFiles[15], GalleryData.GoldSproingFifty);
|
||||
GalleryImages.Add(allFiles[16], GalleryData.TotalEnemiesFifty);
|
||||
GalleryImages.Add(allFiles[17], GalleryData.TotalEnemiesHundred);
|
||||
GalleryImages.Add(allFiles[18], GalleryData.NormalEnd);
|
||||
GalleryImages.Add(allFiles[19], GalleryData.TrueEnd);
|
||||
GalleryImages.Add(allFiles[20], GalleryData.BadEnd);
|
||||
GalleryImages.Add(allFiles[21], GalleryData.StelesTen);
|
||||
GalleryImages[allFiles[0]] = _app.GalleryData.SproingyFifty;
|
||||
GalleryImages[allFiles[1]] = _app.GalleryData.MichaelFifty;
|
||||
GalleryImages[allFiles[2]] = _app.GalleryData.FilthEaterFifty;
|
||||
GalleryImages[allFiles[3]] = _app.GalleryData.SaraFifty;
|
||||
GalleryImages[allFiles[4]] = _app.GalleryData.BallosFifty;
|
||||
GalleryImages[allFiles[5]] = _app.GalleryData.PlanterFifty;
|
||||
GalleryImages[allFiles[6]] = _app.GalleryData.ChintheFifty;
|
||||
GalleryImages[allFiles[7]] = _app.GalleryData.AmbassadorGreenFifty;
|
||||
GalleryImages[allFiles[8]] = _app.GalleryData.AmbassadorRedFifty;
|
||||
GalleryImages[allFiles[9]] = _app.GalleryData.AmbassadorSteelFifty;
|
||||
GalleryImages[allFiles[10]] = _app.GalleryData.AgniDemonFifty;
|
||||
GalleryImages[allFiles[11]] = _app.GalleryData.AqueousDemonFifty;
|
||||
GalleryImages[allFiles[12]] = _app.GalleryData.EdenPillarFifty;
|
||||
GalleryImages[allFiles[13]] = _app.GalleryData.PalanFifty;
|
||||
GalleryImages[allFiles[14]] = _app.GalleryData.ShieldOfHeavenFifty;
|
||||
GalleryImages[allFiles[15]] = _app.GalleryData.GoldSproingFifty;
|
||||
GalleryImages[allFiles[16]] = _app.GalleryData.TotalEnemiesFifty;
|
||||
GalleryImages[allFiles[17]] = _app.GalleryData.TotalEnemiesHundred;
|
||||
GalleryImages[allFiles[18]] = _app.GalleryData.NormalEnd;
|
||||
GalleryImages[allFiles[19]] = _app.GalleryData.TrueEnd;
|
||||
GalleryImages[allFiles[20]] = _app.GalleryData.BadEnd;
|
||||
GalleryImages[allFiles[21]] = _app.GalleryData.StelesTen;
|
||||
SetImages(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user