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