-
Notifications
You must be signed in to change notification settings - Fork 16
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
c9cb43b
commit 5a0d7c0
Showing
14 changed files
with
428 additions
and
61 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
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,30 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Net; | ||
using EOLib.Net.Communication; | ||
|
||
namespace EOLib.Domain.Interact | ||
{ | ||
[AutoMappedType] | ||
public class BookActions : IBookActions | ||
{ | ||
private readonly IPacketSendService _packetSendService; | ||
|
||
public BookActions(IPacketSendService packetSendService) | ||
{ | ||
_packetSendService = packetSendService; | ||
} | ||
|
||
public void RequestBook(int characterId) | ||
{ | ||
var packet = new PacketBuilder(PacketFamily.Book, PacketAction.Request) | ||
.AddShort(characterId) | ||
.Build(); | ||
_packetSendService.SendPacket(packet); | ||
} | ||
} | ||
|
||
public interface IBookActions | ||
{ | ||
void RequestBook(int characterId); | ||
} | ||
} |
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,78 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Character; | ||
using EOLib.Domain.Login; | ||
using EOLib.Domain.Online; | ||
using EOLib.Net; | ||
using EOLib.Net.Handlers; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace EOLib.PacketHandlers.Paperdoll | ||
{ | ||
/// <summary> | ||
/// Sets book information for a given player | ||
/// </summary> | ||
[AutoMappedType] | ||
internal class BookReplyHandler : InGameOnlyPacketHandler | ||
{ | ||
private readonly IPaperdollRepository _paperdollRepository; | ||
|
||
public override PacketFamily Family => PacketFamily.Book; | ||
|
||
public override PacketAction Action => PacketAction.Reply; | ||
|
||
public BookReplyHandler(IPlayerInfoProvider playerInfoProvider, | ||
IPaperdollRepository paperdollRepository) | ||
: base(playerInfoProvider) | ||
{ | ||
_paperdollRepository = paperdollRepository; | ||
} | ||
|
||
public override bool HandlePacket(IPacket packet) | ||
{ | ||
var name = packet.ReadBreakString(); | ||
var home = packet.ReadBreakString(); | ||
var partner = packet.ReadBreakString(); | ||
var title = packet.ReadBreakString(); | ||
var guild = packet.ReadBreakString(); | ||
var rank = packet.ReadBreakString(); | ||
|
||
var playerID = packet.ReadShort(); | ||
var clas = packet.ReadChar(); | ||
var gender = packet.ReadChar(); | ||
|
||
var adminLevel = packet.ReadChar(); | ||
|
||
var iconType = (OnlineIcon)packet.ReadChar(); | ||
|
||
if (packet.ReadByte() != 255) | ||
return false; | ||
|
||
var questNames = new List<string>(); | ||
while (packet.ReadPosition < packet.Length) | ||
questNames.Add(packet.ReadBreakString()); | ||
|
||
var paperdollData = _paperdollRepository.VisibleCharacterPaperdolls.ContainsKey(playerID) | ||
? _paperdollRepository.VisibleCharacterPaperdolls[playerID] | ||
: new PaperdollData(); | ||
|
||
paperdollData = paperdollData | ||
.WithName(name) | ||
.WithHome(home) | ||
.WithPartner(partner) | ||
.WithTitle(title) | ||
.WithGuild(guild) | ||
.WithRank(rank) | ||
.WithPlayerID(playerID) | ||
.WithClass(clas) | ||
.WithGender(gender) | ||
.WithAdminLevel((AdminLevel)adminLevel) | ||
.WithIcon(iconType) | ||
.WithQuestNames(questNames); | ||
|
||
_paperdollRepository.VisibleCharacterPaperdolls[playerID] = paperdollData; | ||
|
||
return true; | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,132 @@ | ||
using EndlessClient.Content; | ||
using EndlessClient.Dialogs.Services; | ||
using EndlessClient.UIControls; | ||
using EOLib; | ||
using EOLib.Domain.Character; | ||
using EOLib.Graphics; | ||
using EOLib.IO.Repositories; | ||
using Microsoft.Xna.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using XNAControls; | ||
using static EndlessClient.Dialogs.QuestStatusListDialogItem; | ||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox; | ||
|
||
namespace EndlessClient.Dialogs | ||
{ | ||
public class BookDialog : PlayerInfoDialog | ||
{ | ||
private readonly IPaperdollProvider _paperdollProvider; | ||
|
||
private readonly List<XNALabel> _childItems; | ||
private ScrollBar _scrollBar; | ||
|
||
private int _lastScrollOffset; | ||
|
||
public BookDialog(INativeGraphicsManager graphicsManager, | ||
IEODialogButtonService eoDialogButtonService, | ||
IPubFileProvider pubFileProvider, | ||
IPaperdollProvider paperdollProvider, | ||
Character character, | ||
bool isMainCharacter) | ||
: base(graphicsManager, eoDialogButtonService, pubFileProvider, paperdollProvider, character, isMainCharacter) | ||
{ | ||
_paperdollProvider = paperdollProvider; | ||
|
||
_childItems = new List<XNALabel>(); | ||
|
||
var backgroundTexture = graphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 27); | ||
_scrollBar = new ScrollBar(new Vector2(188, 34), backgroundTexture, new Rectangle(303, 2, 20, 237), ScrollBarColors.DarkOnDark, graphicsManager) | ||
{ | ||
LinesToRender = 14 | ||
}; | ||
_scrollBar.SetParentControl(this); | ||
SetScrollWheelHandler(_scrollBar); | ||
|
||
BackgroundTexture = GraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 69); | ||
|
||
CenterInGameView(); | ||
|
||
if (!Game.Window.AllowUserResizing) | ||
DrawPosition = new Vector2(DrawPosition.X, 15); | ||
} | ||
|
||
public override void Initialize() | ||
{ | ||
_scrollBar.Initialize(); | ||
|
||
base.Initialize(); | ||
} | ||
|
||
protected override void OnUnconditionalUpdateControl(GameTime gameTime) | ||
{ | ||
if (_childItems.Count > _scrollBar.LinesToRender && _lastScrollOffset != _scrollBar.ScrollOffset) | ||
{ | ||
_lastScrollOffset = _scrollBar.ScrollOffset; | ||
|
||
for (int i = 0; i < _childItems.Count; i++) | ||
{ | ||
_childItems[i].DrawPosition = new Vector2(_childItems[i].DrawPosition.X, 42 + (i - _lastScrollOffset) * 16); | ||
_childItems[i].Visible = (i - _lastScrollOffset) >= 0 && (i - _lastScrollOffset) < _scrollBar.LinesToRender; | ||
} | ||
} | ||
|
||
base.OnUnconditionalUpdateControl(gameTime); | ||
} | ||
|
||
protected override void OnDrawControl(GameTime gameTime) | ||
{ | ||
base.OnDrawControl(gameTime); | ||
|
||
var iconTexture = GraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 68, true); | ||
|
||
_spriteBatch.Begin(); | ||
|
||
for (int i = 0; i < Math.Min(_childItems.Count, _scrollBar.LinesToRender); i++) | ||
{ | ||
_spriteBatch.Draw(iconTexture, DrawPositionWithParentOffset + new Vector2(26, 41 + i * 16), GetIconSourceRectangle(QuestStatusIcon.None2), Color.White); | ||
} | ||
|
||
_spriteBatch.End(); | ||
} | ||
|
||
protected override void UpdateDisplayedData(PaperdollData paperdollData) | ||
{ | ||
base.UpdateDisplayedData(paperdollData); | ||
|
||
foreach (var item in _childItems) | ||
item.Dispose(); | ||
|
||
_childItems.Clear(); | ||
|
||
for (int i = 0; i < paperdollData.QuestNames.Count; i++) | ||
{ | ||
var quest = paperdollData.QuestNames[i]; | ||
|
||
var nextLabel = new XNALabel(Constants.FontSize08pt5) | ||
{ | ||
Text = quest, | ||
ForeColor = ColorConstants.LightGrayText, | ||
AutoSize = true, | ||
DrawPosition = new Vector2(50, 42 + i * 16), | ||
Visible = i < _scrollBar.LinesToRender | ||
}; | ||
nextLabel.SetScrollWheelHandler(_scrollBar); | ||
nextLabel.ResizeBasedOnText(); | ||
nextLabel.SetParentControl(this); | ||
nextLabel.Initialize(); | ||
|
||
_childItems.Add(nextLabel); | ||
} | ||
|
||
_scrollBar.ScrollToTop(); | ||
_scrollBar.UpdateDimensions(paperdollData.QuestNames.Count); | ||
} | ||
|
||
// copied from QuestStatusListDialogItem | ||
private static Rectangle GetIconSourceRectangle(QuestStatusIcon index) | ||
{ | ||
return new Rectangle((int)index * 15, 0, 15, 15); | ||
} | ||
} | ||
} |
Oops, something went wrong.