2017-02-25 16:35:09 +01:00
|
|
|
|
using NLog;
|
2017-02-02 21:59:01 +01:00
|
|
|
|
using System;
|
2017-02-03 00:22:29 +01:00
|
|
|
|
using System.Collections.Immutable;
|
2017-02-02 21:59:01 +01:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2017-10-13 06:14:54 +02:00
|
|
|
|
namespace NadekoBot.Core.Services.Impl
|
2017-02-02 21:59:01 +01:00
|
|
|
|
{
|
|
|
|
|
public class ImagesService : IImagesService
|
|
|
|
|
{
|
|
|
|
|
private readonly Logger _log;
|
|
|
|
|
|
2017-02-25 16:35:09 +01:00
|
|
|
|
private const string _basePath = "data/images/";
|
2017-02-02 21:59:01 +01:00
|
|
|
|
|
2017-02-25 16:35:09 +01:00
|
|
|
|
private const string _headsPath = _basePath + "coins/heads.png";
|
|
|
|
|
private const string _tailsPath = _basePath + "coins/tails.png";
|
2017-02-03 00:22:29 +01:00
|
|
|
|
|
2017-02-25 16:35:09 +01:00
|
|
|
|
private const string _currencyImagesPath = _basePath + "currency";
|
|
|
|
|
private const string _diceImagesPath = _basePath + "dice";
|
2017-02-04 09:34:51 +01:00
|
|
|
|
|
2017-03-21 13:12:47 +01:00
|
|
|
|
private const string _slotBackgroundPath = _basePath + "slots/background2.png";
|
2017-02-25 16:35:09 +01:00
|
|
|
|
private const string _slotNumbersPath = _basePath + "slots/numbers/";
|
|
|
|
|
private const string _slotEmojisPath = _basePath + "slots/emojis/";
|
2017-02-04 09:34:51 +01:00
|
|
|
|
|
2017-02-25 16:35:09 +01:00
|
|
|
|
private const string _wifeMatrixPath = _basePath + "rategirl/wifematrix.png";
|
|
|
|
|
private const string _rategirlDot = _basePath + "rategirl/dot.png";
|
2017-02-20 23:46:34 +01:00
|
|
|
|
|
2017-09-10 03:52:34 +02:00
|
|
|
|
private const string _xpCardPath = _basePath + "xp/xp.png";
|
|
|
|
|
|
2017-02-04 09:34:51 +01:00
|
|
|
|
|
|
|
|
|
public ImmutableArray<byte> Heads { get; private set; }
|
|
|
|
|
public ImmutableArray<byte> Tails { get; private set; }
|
2017-05-29 06:13:22 +02:00
|
|
|
|
|
|
|
|
|
public ImmutableArray<(string, ImmutableArray<byte>)> Currency { get; private set; }
|
2017-02-02 21:59:01 +01:00
|
|
|
|
|
2017-05-29 06:13:22 +02:00
|
|
|
|
public ImmutableArray<ImmutableArray<byte>> Dice { get; private set; }
|
2017-02-03 11:36:58 +01:00
|
|
|
|
|
2017-02-04 09:34:51 +01:00
|
|
|
|
public ImmutableArray<byte> SlotBackground { get; private set; }
|
|
|
|
|
public ImmutableArray<ImmutableArray<byte>> SlotNumbers { get; private set; }
|
|
|
|
|
public ImmutableArray<ImmutableArray<byte>> SlotEmojis { get; private set; }
|
2017-02-02 21:59:01 +01:00
|
|
|
|
|
2017-02-20 23:46:34 +01:00
|
|
|
|
public ImmutableArray<byte> WifeMatrix { get; private set; }
|
2017-02-23 13:40:43 +01:00
|
|
|
|
public ImmutableArray<byte> RategirlDot { get; private set; }
|
2017-02-20 23:46:34 +01:00
|
|
|
|
|
2017-09-10 03:52:34 +02:00
|
|
|
|
public ImmutableArray<byte> XpCard { get; private set; }
|
|
|
|
|
|
2017-05-23 01:59:31 +02:00
|
|
|
|
public ImagesService()
|
2017-02-02 21:59:01 +01:00
|
|
|
|
{
|
|
|
|
|
_log = LogManager.GetCurrentClassLogger();
|
2017-05-23 01:59:31 +02:00
|
|
|
|
this.Reload();
|
2017-02-02 21:59:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 15:42:10 +02:00
|
|
|
|
public void Reload()
|
2017-02-02 21:59:01 +01:00
|
|
|
|
{
|
2017-02-03 00:22:29 +01:00
|
|
|
|
try
|
|
|
|
|
{
|
2017-02-25 16:35:09 +01:00
|
|
|
|
Heads = File.ReadAllBytes(_headsPath).ToImmutableArray();
|
|
|
|
|
Tails = File.ReadAllBytes(_tailsPath).ToImmutableArray();
|
2017-02-04 09:34:51 +01:00
|
|
|
|
|
2017-02-25 16:35:09 +01:00
|
|
|
|
Currency = Directory.GetFiles(_currencyImagesPath)
|
2017-05-29 06:13:22 +02:00
|
|
|
|
.Select(x => (Path.GetFileName(x), File.ReadAllBytes(x).ToImmutableArray()))
|
2017-02-04 09:34:51 +01:00
|
|
|
|
.ToImmutableArray();
|
|
|
|
|
|
2017-02-25 16:35:09 +01:00
|
|
|
|
Dice = Directory.GetFiles(_diceImagesPath)
|
2017-02-04 09:34:51 +01:00
|
|
|
|
.OrderBy(x => int.Parse(Path.GetFileNameWithoutExtension(x)))
|
2017-05-29 06:13:22 +02:00
|
|
|
|
.Select(x => File.ReadAllBytes(x).ToImmutableArray())
|
2017-02-04 09:34:51 +01:00
|
|
|
|
.ToImmutableArray();
|
|
|
|
|
|
2017-02-25 16:35:09 +01:00
|
|
|
|
SlotBackground = File.ReadAllBytes(_slotBackgroundPath).ToImmutableArray();
|
2017-02-04 09:34:51 +01:00
|
|
|
|
|
2017-02-25 16:35:09 +01:00
|
|
|
|
SlotNumbers = Directory.GetFiles(_slotNumbersPath)
|
2017-02-04 09:34:51 +01:00
|
|
|
|
.OrderBy(f => int.Parse(Path.GetFileNameWithoutExtension(f)))
|
|
|
|
|
.Select(x => File.ReadAllBytes(x).ToImmutableArray())
|
|
|
|
|
.ToImmutableArray();
|
|
|
|
|
|
2017-02-25 16:35:09 +01:00
|
|
|
|
SlotEmojis = Directory.GetFiles(_slotEmojisPath)
|
2017-02-10 13:03:15 +01:00
|
|
|
|
.OrderBy(f => int.Parse(Path.GetFileNameWithoutExtension(f)))
|
2017-02-04 09:34:51 +01:00
|
|
|
|
.Select(x => File.ReadAllBytes(x).ToImmutableArray())
|
|
|
|
|
.ToImmutableArray();
|
2017-02-03 00:22:29 +01:00
|
|
|
|
|
2017-02-20 23:46:34 +01:00
|
|
|
|
WifeMatrix = File.ReadAllBytes(_wifeMatrixPath).ToImmutableArray();
|
2017-02-23 13:40:43 +01:00
|
|
|
|
RategirlDot = File.ReadAllBytes(_rategirlDot).ToImmutableArray();
|
2017-09-10 03:52:34 +02:00
|
|
|
|
|
|
|
|
|
XpCard = File.ReadAllBytes(_xpCardPath).ToImmutableArray();
|
2017-02-03 00:22:29 +01:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_log.Error(ex);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2017-05-23 01:59:31 +02:00
|
|
|
|
}
|
2017-02-02 21:59:01 +01:00
|
|
|
|
}
|
|
|
|
|
}
|