public static void SetupInstance(PacketAPI api) { if(Instance != null) Instance.Close(null, XNADialogResult.NO_BUTTON_PRESSED); Instance = new QuestDialog(api); }
private ShopDialog(PacketAPI api, int id) : base(api) { Buttons = ScrollingListDialogButtons.Cancel; ListItemType = ListDialogItem.ListItemStyle.Large; ID = id; DialogClosing += (o, e) => { if (e.Result == XNADialogResult.Cancel) { Instance = null; ID = 0; } else if (e.Result == XNADialogResult.Back) { e.CancelClose = true; _setState(ShopState.Initial); } }; m_state = ShopState.None; //note - may need to lock around these. //other note - no good way to dispose static textures like this if (BuyIcon == null || SellIcon == null || CraftIcon == null) { BuyIcon = _getDlgIcon(ListIcon.Buy); SellIcon = _getDlgIcon(ListIcon.Sell); CraftIcon = _getDlgIcon(ListIcon.Craft); } }
private QuestDialog(PacketAPI api) : base(api) { DialogClosing += (o, e) => { if (e.Result == XNADialogResult.OK) { if (!m_api.RespondToQuestDialog(_stateInfo, DialogReply.Ok)) ((EOGame) Game).DoShowLostConnectionDialogAndReturnToMainMenu(); } Instance = null; }; _dialogNames = new Dictionary<short, string>(); _links = new Dictionary<short, string>(); _pages = new List<string>(); _setBackgroundTexture(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 67)); caption = new XNALabel(new Rectangle(16, 16, 255, 18), Constants.FontSize08pt5) { AutoSize = false, TextAlign = LabelAlignment.MiddleLeft, ForeColor = Constants.LightGrayText }; caption.SetParent(this); m_scrollBar.SetParent(null); m_scrollBar.Close(); m_scrollBar = new ScrollBar(this, new Vector2(252, 44), new Vector2(16, 99), ScrollBarColors.LightOnMed); m_scrollBar.SetParent(this); SmallItemStyleMaxItemDisplay = 6; }
private SkillmasterDialog(PacketAPI api) : base(api) { Buttons = ScrollingListDialogButtons.Cancel; ListItemType = ListDialogItem.ListItemStyle.Large; DialogClosing += (o, e) => { if (e.Result == XNADialogResult.Cancel) { Instance = null; } else if (e.Result == XNADialogResult.Back) { e.CancelClose = true; if (m_state == SkillState.Learn && m_showingRequirements) { m_state = SkillState.Initial; //force it to re-generate the list items _setState(SkillState.Learn); m_showingRequirements = false; } else _setState(SkillState.Initial); } }; m_state = SkillState.None; if (LearnIcon == null || ForgetIcon == null) { //getDlgIcon LearnIcon = _getDlgIcon(ListIcon.Learn); ForgetIcon = _getDlgIcon(ListIcon.Forget); } }
private BankAccountDialog(PacketAPI api) : base(api) { //this uses EODialogListItems but does not inherit from ListDialog since it is a different size //offsety 50 bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 53); _setSize(bgTexture.Width, bgTexture.Height); m_accountBalance = new XNALabel(new Rectangle(129, 20, 121, 16), Constants.FontSize08pt5) { ForeColor = Constants.LightGrayText, Text = "", TextAlign = LabelAlignment.MiddleRight, AutoSize = false }; m_accountBalance.SetParent(this); XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(92, 191), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel)); cancel.SetParent(this); cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel); ListDialogItem deposit = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0) { Text = World.GetString(DATCONST2.DIALOG_BANK_DEPOSIT), SubText = string.Format("{0} gold {1}", World.GetString(DATCONST2.DIALOG_BANK_TRANSFER), World.GetString(DATCONST2.DIALOG_BANK_TO_ACCOUNT)), IconGraphic = _getDlgIcon(ListIcon.BankDeposit), OffsetY = 55, ShowItemBackGround = false }; deposit.OnLeftClick += (o, e) => _deposit(); deposit.OnRightClick += (o, e) => _deposit(); ListDialogItem withdraw = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1) { Text = World.GetString(DATCONST2.DIALOG_BANK_WITHDRAW), SubText = string.Format("{0} gold {1}", World.GetString(DATCONST2.DIALOG_BANK_TAKE), World.GetString(DATCONST2.DIALOG_BANK_FROM_ACCOUNT)), IconGraphic = _getDlgIcon(ListIcon.BankWithdraw), OffsetY = 55, ShowItemBackGround = false }; withdraw.OnLeftClick += (o, e) => _withdraw(); withdraw.OnRightClick += (o, e) => _withdraw(); ListDialogItem upgrade = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2) { Text = World.GetString(DATCONST2.DIALOG_BANK_LOCKER_UPGRADE), SubText = World.GetString(DATCONST2.DIALOG_BANK_MORE_SPACE), IconGraphic = _getDlgIcon(ListIcon.BankLockerUpgrade), OffsetY = 55, ShowItemBackGround = false }; upgrade.OnLeftClick += (o, e) => _upgrade(); upgrade.OnRightClick += (o, e) => _upgrade(); DialogClosing += (o, e) => { Instance = null; }; Center(Game.GraphicsDevice); DrawLocation = new Vector2(DrawLocation.X, 50); endConstructor(false); }
public static void Show(PacketAPI api, Character character, PaperdollDisplayData data) { if (Instance != null) return; Instance = new EOPaperdollDialog(api, character, data); Instance.DialogClosing += (o, e) => Instance = null; }
public PaperdollDialogItem(PacketAPI api, Rectangle location, EOPaperdollDialog parent, ItemRecord info, EquipLocation locationEnum) : base(null, null, parent) { m_api = api; SetInfo(location, info); EquipLoc = locationEnum; }
public EOMapContextMenu(PacketAPI api) { m_api = api; //first, load up the images. split in half: the right half is the 'over' text Texture2D bgImage = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 41, true); //this GFX is stupid. a bunch of white space throws off coordinates so I have to use hard-coded values const int W = 96, H = 137; Color[] dat = new Color[W*H]; m_bg = new Texture2D(EOGame.Instance.GraphicsDevice, W, H); m_bgOver = new Texture2D(EOGame.Instance.GraphicsDevice, W, H); bgImage.GetData(0, new Rectangle(0, 0, W, H), dat, 0, dat.Length); m_bg.SetData(dat); bgImage.GetData(0, new Rectangle(W, 0, W, H), dat, 0, dat.Length); m_bgOver.SetData(dat); //define regions for clicking and their associated actions //6,11,86,14 for (int i = 0; i < (int) MenuAction.NUM_MENU_ACTIONS; ++i) { Rectangle region = new Rectangle(6, (i < 5 ? 11 : 13)+ 14*i, 86, 14); m_menuActions.Add(region, _getActionFromMenuAction((MenuAction) i)); } //set the fill color m_fill = new Texture2D(EOGame.Instance.GraphicsDevice, 1, 1); m_fill.SetData(new [] { Color.White }); //set default control stuff; _setSize(W, H); Visible = false; SetParent(null); }
public static void Show(PacketAPI api, short npcIndex, short questID, string name) { NPCName = name; //note: dialog is created in packet callback! sometimes talking to the quest NPC does nothing (if you already completed)! if (!api.TalkToQuestNPC(npcIndex, questID)) EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu(); }
public static void Show(PacketAPI api, byte x, byte y) { if (Instance != null) return; Instance = new LockerDialog(api, x, y); if (!api.OpenLocker(x, y)) EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu(); }
public Character(PacketAPI api, int id, CharRenderData data) { m_packetAPI = api; ID = id; RenderData = data ?? new CharRenderData(); Inventory = new List<InventoryItem>(); Spells = new List<CharacterSpell>(); PaperDoll = new short[(int)EquipLocation.PAPERDOLL_MAX]; }
protected EODialogBase(PacketAPI apiHandle = null) { if (apiHandle != null) { if (!apiHandle.Initialized) throw new ArgumentException("The API is not initialzied. Data transfer will not work."); m_api = apiHandle; } smallButtonSheet = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 15, true); }
public bool SetActiveCharacter(PacketAPI api, int id) { if (World.Initialized && ActiveCharacter != null) Logger.Log("Setting Active Character to new ID {0}", id); CharRenderData activeData = CharData.FirstOrDefault(d => d.id == id); if (activeData == null) return false; ActiveCharacter = new Character(api, id, activeData); return true; }
private LockerDialog(PacketAPI api, byte x, byte y) : base(api) { Title = string.Format(TITLE_FMT, 0); Buttons = ScrollingListDialogButtons.Cancel; ListItemType = ListDialogItem.ListItemStyle.Large; X = x; Y = y; DialogClosing += (o, e) => { Instance = null; X = 0; Y = 0; }; }
public static void Show(PacketAPI api) { if (Instance != null) Instance.Close(null, XNADialogResult.NO_BUTTON_PRESSED); Instance = new QuestProgressDialog(api); if (!api.RequestQuestHistory(QuestPage.Progress)) { Instance.Close(null, XNADialogResult.NO_BUTTON_PRESSED); EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu(); } }
public static void Show(PacketAPI apiHandle, byte chestX, byte chestY) { if (Instance != null) return; Instance = new ChestDialog(apiHandle, chestX, chestY); Instance.DialogClosing += (o, e) => Instance = null; if (!apiHandle.ChestOpen(chestX, chestY)) { Instance.Close(null, XNADialogResult.NO_BUTTON_PRESSED); EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu(); } }
public static void Show(PacketAPI api, short npcID) { if (Instance != null) return; Instance = new BankAccountDialog(api); if (!api.BankOpen(npcID)) { Instance.Close(); Instance = null; EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu(); } }
public static void Show(PacketAPI api, short npcIndex) { if (Instance != null) return; Instance = new SkillmasterDialog(api); if (!api.RequestSkillmaster(npcIndex)) { Instance.Close(); Instance = null; EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu(); } }
public static void Show(PacketAPI api, NPCRenderer shopKeeper) { if (Instance != null) return; Instance = new ShopDialog(api, shopKeeper.NPC.Data.ID); //request from server is based on the map index if (!api.RequestShop(shopKeeper.NPC.Index)) { Instance.Close(); Instance = null; EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu(); } }
//constructs a character from a packet sent from the server public Character(PacketAPI api, CharacterData data) { //initialize lists m_packetAPI = api; Inventory = new List<InventoryItem>(); Spells = new List<CharacterSpell>(); PaperDoll = new short[(int)EquipLocation.PAPERDOLL_MAX]; Name = data.Name; ID = data.ID; CurrentMap = data.Map; X = data.X; Y = data.Y; PaddedGuildTag = data.GuildTag; RenderData = new CharRenderData { facing = data.Direction, level = data.Level, gender = data.Gender, hairstyle = data.HairStyle, haircolor = data.HairColor, race = data.Race }; Stats = new CharStatData { maxhp = data.MaxHP, hp = data.HP, maxtp = data.MaxTP, tp = data.TP }; EquipItem(ItemType.Boots, 0, data.Boots, true); EquipItem(ItemType.Armor, 0, data.Armor, true); EquipItem(ItemType.Hat, 0, data.Hat, true); EquipItem(ItemType.Shield, 0, data.Shield, true); EquipItem(ItemType.Weapon, 0, data.Weapon, true); RenderData.SetSitting(data.Sitting); RenderData.SetHidden(data.Hidden); }
//all bots are going to want to do the init handshake with the server public virtual void Initialize() { _client = new EOClient(); if (!_client.ConnectToServer(_host, _port)) throw new ArgumentException(string.Format("Bot {0}: Unable to connect to server! Host={1} Port={2}", _index, _host, _port)); _api = new PacketAPI(_client); InitData data; if (!_api.Initialize(0, 0, 28, EOLib.HDDSerial.GetHDDSerial(), out data)) throw new TimeoutException(string.Format("Bot {0}: Failed initialization handshake with server!", _index)); _client.SetInitData(data); if (!_api.ConfirmInit(data.emulti_e, data.emulti_d, data.clientID)) throw new TimeoutException(string.Format("Bot {0}: Failed initialization handshake with server!", _index)); if (!_api.Initialized || !_client.ConnectedAndInitialized || data.ServerResponse != InitReply.INIT_OK) throw new InvalidOperationException(string.Format("Bot {0}: Invalid response from server or connection failed! Must receive an OK reply.", _index)); _initialized = true; }
private ChestDialog(PacketAPI api, byte chestX, byte chestY) : base(api) { CurrentChestX = chestX; CurrentChestY = chestY; XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(92, 227), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel)); cancel.OnClick += (sender, e) => Close(cancel, XNADialogResult.Cancel); dlgButtons.Add(cancel); whichButtons = XNADialogButtons.Cancel; bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 51); _setSize(bgTexture.Width, bgTexture.Height); endConstructor(false); DrawLocation = new Vector2((Game.GraphicsDevice.PresentationParameters.BackBufferWidth - DrawArea.Width) / 2f, 15); cancel.SetParent(this); EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_CHEST_YOU_OPENED, World.GetString(DATCONST2.STATUS_LABEL_DRAG_AND_DROP_ITEMS)); }
private QuestProgressDialog(PacketAPI api) : base(api) { DialogClosing += (o, e) => { Instance = null; }; _setupBGTexture(); m_history = new XNAButton(smallButtonSheet, new Vector2(288, 252), _getSmallButtonOut(SmallButton.History), _getSmallButtonOver(SmallButton.History)); m_history.SetParent(this); m_history.OnClick += _historyClick; m_progress = new XNAButton(smallButtonSheet, new Vector2(288, 252), _getSmallButtonOut(SmallButton.Progress), _getSmallButtonOver(SmallButton.Progress)) { Visible = false }; m_progress.SetParent(this); m_progress.OnClick += _progressClick; var ok = new XNAButton(smallButtonSheet, new Vector2(380, 252), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok)); ok.SetParent(this); ok.OnClick += (o, e) => Close(ok, XNADialogResult.OK); dlgButtons.AddRange(new[] { m_history, ok }); m_titleText = new XNALabel(new Rectangle(18, 14, 452, 19), Constants.FontSize08pt5) { AutoSize = false, TextAlign = LabelAlignment.MiddleLeft, ForeColor = Constants.LightGrayText, Text = " " }; m_titleText.SetParent(this); m_scrollBar.DrawLocation = new Vector2(449, 44); SmallItemStyleMaxItemDisplay = 10; ListItemType = ListDialogItem.ListItemStyle.Small; }
public EOBot(int index, string host, int port) { m_index = index + 1; m_client = new EOClient(); if (!m_client.ConnectToServer(host, port)) throw new ArgumentException(); m_api = new PacketAPI(m_client); InitData data; if (!m_api.Initialize(0, 0, 28, EOLib.Win32.GetHDDSerial(), out data)) throw new TimeoutException(); m_client.SetInitData(data); if (!m_api.ConfirmInit(data.emulti_e, data.emulti_d, data.clientID)) throw new TimeoutException(); if (!m_api.Initialized || !m_client.ConnectedAndInitialized || data.ServerResponse != InitReply.INIT_OK) throw new InvalidOperationException(); m_terminationEvent = new AutoResetEvent(false); }
public EOInventoryItem(PacketAPI api, int slot, ItemRecord itemData, InventoryItem itemInventoryInfo, EOInventory inventory) : base(null, null, inventory) { m_api = api; m_itemData = itemData; m_inventory = itemInventoryInfo; Slot = slot; UpdateItemLocation(Slot); m_itemgfx = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, 2 * itemData.Graphic, true); m_highlightBG = new Texture2D(Game.GraphicsDevice, DrawArea.Width - 3, DrawArea.Height - 3); Color[] highlight = new Color[(drawArea.Width - 3) * (drawArea.Height - 3)]; for (int i = 0; i < highlight.Length; ++i) { highlight[i] = Color.FromNonPremultiplied(200, 200, 200, 60); } m_highlightBG.SetData(highlight); _initItemLabel(); m_recentClickTimer = new Timer( _state => { if (m_recentClickCount > 0) Interlocked.Decrement(ref m_recentClickCount); }, null, 0, 1000); }
public GameLoadingDialog(PacketAPI apiHandle) : base(apiHandle) { bgTexture = null; //don't use the built in bgtexture, we're going to use a sprite sheet for the BG bgSprites = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 33); DrawLocation = new Vector2(Game.GraphicsDevice.PresentationParameters.BackBufferWidth - (bgSprites.Width / 4) - 10, Game.GraphicsDevice.PresentationParameters.BackBufferHeight - bgSprites.Height - 10); _setSize(bgSprites.Width / 4, bgSprites.Height); bgSrcIndex = 0; EDFFile file = World.Instance.DataFiles[World.Instance.Localized2]; map = file.Data[(int)DATCONST2.LOADING_GAME_UPDATING_MAP]; item = file.Data[(int)DATCONST2.LOADING_GAME_UPDATING_ITEMS]; npc = file.Data[(int)DATCONST2.LOADING_GAME_UPDATING_NPCS]; skill = file.Data[(int)DATCONST2.LOADING_GAME_UPDATING_SKILLS]; classes = file.Data[(int)DATCONST2.LOADING_GAME_UPDATING_CLASSES]; loading = file.Data[(int)DATCONST2.LOADING_GAME_LOADING_GAME]; caption = new XNALabel(new Rectangle(12, 9, 1, 1), Constants.FontSize10) { Text = file.Data[(int)DATCONST2.LOADING_GAME_PLEASE_WAIT], ForeColor = Constants.LightYellowText }; caption.SetParent(this); Random gen = new Random(); int msgTxt = gen.Next((int)DATCONST2.LOADING_GAME_HINT_FIRST, (int)DATCONST2.LOADING_GAME_HINT_LAST); message = new XNALabel(new Rectangle(18, 61, 1, 1), Constants.FontSize08) { TextWidth = 175, ForeColor = Constants.MediumGrayText, Text = file.Data[msgTxt] }; message.SetParent(this); endConstructor(false); }
public PacketAPICallbackManager(PacketAPI apiObj, EOGame game) { m_packetAPI = apiObj; m_game = game; }
public void ApplyWelcomeRequest(PacketAPI api, WelcomeRequestData data) { MainPlayer.SetPlayerID(data.PlayerID); MainPlayer.SetActiveCharacter(api, data.ActiveCharacterID); MainPlayer.ActiveCharacter.CurrentMap = data.MapID; CheckMap(data.MapID, data.MapRID, data.MapLen); _checkPub(InitFileType.Item, data.EifRid, data.EifLen); _checkPub(InitFileType.Npc, data.EnfRid, data.EnfLen); _checkPub(InitFileType.Spell, data.EsfRid, data.EsfLen); _checkPub(InitFileType.Class, data.EcfRid, data.EcfLen); MainPlayer.ActiveCharacter.Name = data.Name; MainPlayer.ActiveCharacter.Title = data.Title; MainPlayer.ActiveCharacter.GuildName = data.GuildName; MainPlayer.ActiveCharacter.GuildRankStr = data.GuildRankStr; MainPlayer.ActiveCharacter.GuildRankNum = data.GuildRankNum; MainPlayer.ActiveCharacter.Class = data.ClassID; MainPlayer.ActiveCharacter.PaddedGuildTag = data.PaddedGuildTag; MainPlayer.ActiveCharacter.AdminLevel = data.AdminLevel; MainPlayer.ActiveCharacter.Stats = new CharStatData { Level = data.Level, Experience = data.Exp, Usage = data.Usage, HP = data.HP, MaxHP = data.MaxHP, TP = data.TP, MaxTP = data.MaxTP, SP = data.MaxSP, MaxSP = data.MaxSP, StatPoints = data.StatPoints, SkillPoints = data.SkillPoints, MinDam = data.MinDam, MaxDam = data.MaxDam, Karma = data.Karma, Accuracy = data.Accuracy, Evade = data.Evade, Armor = data.Armor, Str = data.DispStr, Int = data.DispInt, Wis = data.DispWis, Agi = data.DispAgi, Con = data.DispCon, Cha = data.DispCha }; Array.Copy(data.PaperDoll, MainPlayer.ActiveCharacter.PaperDoll, (int) EquipLocation.PAPERDOLL_MAX); JailMap = data.JailMap; }
public void SetAPIHandle(PacketAPI api) { m_api = api; }
private static void PartyRequest(PacketAPI api, short id) { s_partyEvent.WaitOne(); Action<List<PartyMember>> action = _list => s_partyEvent.Set(); api.OnPartyDataRefresh += action; api.OnPartyDataRefresh += t => api.OnPartyDataRefresh -= action; api.PartyRequest(PartyRequestType.Join, id); }