Jump to content

Recoil

Contributors
  • Posts

    184
  • Joined

  • Last visited

Everything posted by Recoil

  1. Imports OrionRevampedGeneral.Core Imports OrionRevampedGeneral.Core.Enumerations Imports OrionRevampedGeneral.Core.Types Public Class PlayerCls ' General Public Property Name As String Public Property Classes As Byte Public Property Sprite As Integer Public Property Level As Byte Public Property Exp As Long Public Property Access As Byte Public Property Pk As Byte ' Vitals Public Property Vital() As New List(Of Integer) ' Stats Public Property Stat() As New List(Of Integer) Public Property Points As Byte ' Worn equipment Public Property Equipment() As New List(Of Integer) ' Position Public Property Map As Integer Public Property X As Byte Public Property Y As Byte Public Property Dir As Byte Public Property Guild As String ' Server use only Public Property Login As String Public Property Password As String Public Property Sex As Byte Public Property Inv As New List(Of PlayerInv) Public Property Spell As New List(Of Byte) ' Client use only Public Property MaxHp As Long Public Property MaxMp As Long Public Property MaxSp As Long Public Property XOffset As Integer Public Property YOffset As Integer Public Property Moving As Byte Public Property Attacking As Byte Public Property Running As Byte Public Property AttackTimer As Long Public Property MapGetTimer As Long Public Property Steps As Byte Public Sub New() For i = 0 To Enumerations.Vitals.VitalCount - 1 Vital.Add(0) Next For i = 0 To Enumerations.Stats.StatCount - 1 Stat.Add(0) Next For i = 0 To Enumerations.Equipment.EquipmentCount - 1 Equipment.Add(0) Next End Sub End Class Public Class PlayerInv Public Property Num As Byte Public Property Value As Long End Class
  2. For some reason it was causing an error with the equipment, so I changed it to this: Public Sub New() For X = 0 To Vitals.VitalCount - 1 Vital.Add(0) Next For X = 0 To Stats.StatCount - 1 Stat.Add(0) Next For X = 0 To Enumerations.Equipment.EquipmentCount - 1 Equipment.Add(0) Next End Sub And am now getting the error on each of the "X": "Loop control variable cannot be a property or a late-bound indexed array." Also, my properties look like this: Public Property Vital() As List(Of Integer) = New List(Of Integer) Public Property Stat() As List(Of Integer) = New List(Of Integer) Public Property Equipment() As List(Of Integer) = New List(Of Integer)
  3. Here is what I have listed in my Player class: Public Property Name As String Public Property Classes As Byte Public Property Sprite As Integer Public Property Level As Byte Public Property Exp As Long Public Property Access As Byte Public Property Pk As Byte ' Vitals Public Property Vital() As List(Of Vitals) ' Stats Public Property Stat() As List(Of Stats) Public Property Points As Byte ' Worn equipment Public Property Equipment() As List(Of Equipment) ' Position Public Property Map As Integer Public Property X As Byte Public Property Y As Byte Public Property Dir As Byte Public Property Guild As String ' Server use only Public Property Login As String Public Property Password As String Public Property Sex As Byte Public Property Inv() As List(Of PlayerInv) Public Property Spell() As List(Of Byte) ' Client use only Public Property MaxHp As Long Public Property MaxMp As Long Public Property MaxSp As Long Public Property XOffset As Integer Public Property YOffset As Integer Public Property Moving As Byte Public Property Attacking As Byte Public Property Running As Byte Public Property AttackTimer As Long Public Property MapGetTimer As Long Public Property Steps As Byte Public Sub New() End Sub Now in Client, modGeneral, this is the only 3 errors I am pulling, everywhere it says Redim it says it requires an array. I have tried to change the first one below, but it is not working either, and says Error 6 'Vital' is not a member of 'System.Collections.Generic.List(Of OrionRevampedGeneral.Player)'. Sub startup() Dim players() As List(Of Player) = New List(Of Player)() {} 'Set the Initial picScreen Sizes 'ReDim Player(0 To MaxPlayers) For i = 0 To MaxPlayers For x = 0 To Vitals.VitalCount - 1 ReDim players(i).Vital(x) Next For x = 0 To Stats.StatCount - 1 ReDim Player(i).Stat(x) Next For x = 0 To Equipment.EquipmentCount - 1 ReDim Player(i).Equipment(x) Next Right now I am only trying to do the players, then I will move on to the rest.
  4. For me it has been difficult trying to navigate and make changes. A lot of people are used to the VB6 framework that this project was originally built on, but a lot of .NET hobby devs like me seems to get lost trying to track everything down. Making any changes, or adding additional features has become difficult. Since I have already gotten all of the panels drawing to the screen I found a good stopping point to tackle the next part on my list. I have decided to move the Orion Revamped project to using classes instead of holding everything in structures. Just by putting a new class for drawing panels and button in I was able to clear out over 2000 lines just out of my ClientGraphics (modGraphics) file. Not only is this more efficient, it makes things so much easier when I need to make a change to ALL of instances of my new class. I have taken a look at an old project called Aphelia to see how it was done, and I have also looked at the Prospekt engine to see how it is done there. Honestly this is not going to be a quick-fix to make the move to classes. Right now I would like to get some ideas on the most logical approach to getting everything setup first before I even start deleting and making the necessary changes to weed out the structures. In my general library I have created new folders to help sort all of this out. Here are a few new classes I have on there: Public Class Account Public Property ID As Integer Public Property Login As String Public Property Password As String Public Property Banned As Boolean Public Property Players() As List(Of Player) Public Sub New() 'ID = Login = "[email protected]" Password = "password" Banned = False Players = New List(Of Player)() End Sub End Class Public Class Player ' General 'Public Property ID As Integer Public Property Name As String Public Property Classes As Byte Public Property Sprite As Integer Public Property Level As Byte Public Property Exp As Long Public Property Access As Byte Public Property Pk As Byte ' Vitals Public Property Vital() As List(Of Vitals) ' Stats Public Property Stat() As List(Of Stats) Public Property Points As Byte ' Worn equipment Public Property Equipment() As List(Of Equipment) ' Position Public Property Map As Integer Public Property X As Byte Public Property Y As Byte Public Property Dir As Byte ' Server use only 'Public Property Login As String 'Public Property Password As String Public Property Sex As Byte Public Property Inv() As PlayerInv Public Property Spell() As Byte ' Client use only Public Property MaxHp As Long Public Property MaxMp As Long Public Property MaxSp As Long Public Property XOffset As Integer Public Property YOffset As Integer Public Property Moving As Byte Public Property Attacking As Byte Public Property Running As Byte Public Property AttackTimer As Long Public Property MapGetTimer As Long Public Property Steps As Byte Public Sub New() 'ID = 0 Name = "New Player" Classes = 1 Sprite = 1 Level = 1 Exp = 0 Access = 0 Pk = 0 'Vitals 'Stats Points = 0 'Equipment = (0 to MaxEquipmentItems) Map = 1 X = 10 Y = 15 Dir = 1 Sex = 0 'Inv = (0 to MaxInvItems) 'Spell = (0 to MaxSpells) MaxHp = 10 MaxMp = 10 MaxSp = 10 XOffset = 0 YOffset = 0 Moving = 0 Attacking = 0 Running = 0 AttackTimer = 0 MapGetTimer = 0 Steps = 0 End Sub End Class On prospekt there are no get/set values under the properties...I'm not sure why either, maybe this a a new thing and doesn't require these statements? Regardless, I need some guidance on the best approach on creating a model on how to make everything into new classes.
  5. I don't normally take part in general discussion craps, let alone make them...Yesterday I did windows update and kept being prompted that GWX needs access through my firewall. I had never heard of this before so I did a quick search and found this: http://www.myce.com/news/windows-update-silently-installs-windows-10-downloader-75647/ M$FT can suck an egg! VB.NET is the ONLY reason I am still even using Windows period. And if I had the will I'd learn something else just to get out from underneath them all together.
  6. Alright, this thread has become longer than I had planned and I still can't figure the mouse event issue out... But I did figure out that if I include another boolean property (IsButton), and a windowOffset, I can bypass the button offsets and use this for both the button and panels... The OrionGfxControl: #Region "Imports" Imports System.Drawing Imports System.Drawing.Imaging Imports System.IO Imports System.Windows.Forms Imports SFML.Graphics Imports SFML.Window #End Region Public Class OrionGfxControl Inherits Control Private _tempButtonBitmap As Bitmap Private _mButtonGfx As Texture Private _memStream As MemoryStream Private _mIsButton As Boolean Private _mControlLocation As Rectangle Private _mMyRenderWindow As RenderWindow Private _mGfxImage As Bitmap Private _mMouseIsOver As Boolean Private _mMouseIsDown As Boolean Public Property Is_Button As Boolean Get Return _mIsButton End Get Set(value As Boolean) _mIsButton = value End Set End Property Public Property ControlLocation As Rectangle Get Return _mControlLocation End Get Set(value As Rectangle) _mControlLocation = value End Set End Property Public Property MyRenderWindow As RenderWindow Get Return _mMyRenderWindow End Get Set(value As RenderWindow) _mMyRenderWindow = value End Set End Property Public Property GfxImage As Bitmap Get Return _mGfxImage End Get Set(value As Bitmap) _mGfxImage = value End Set End Property Public Property MouseIsOver As Boolean Get Return _mMouseIsOver End Get Set(value As Boolean) _mMouseIsOver = value End Set End Property Public Property MouseIsDown As Boolean Get Return _mMouseIsDown End Get Set(value As Boolean) _mMouseIsDown = value End Set End Property Public Sub New(ByVal isButton As Boolean) Is_Button = isButton End Sub Public Sub Init(ByVal agfximage As Bitmap) _mGfxImage = agfximage _mMouseIsOver = False _mMouseIsDown = False _tempButtonBitmap = New Bitmap(_mGfxImage) _memStream = New MemoryStream() _tempButtonBitmap.Save(_memStream, ImageFormat.Png) _mButtonGfx = New Texture(_memStream) _memStream.Dispose() End Sub Public Sub DrawControl(ByVal arenderwindow As RenderWindow, ByVal locX As Integer, ByVal locY As Integer) _mMyRenderWindow = arenderwindow Dim buttonOffset As Integer = 0 Dim windowOffset As Integer = _tempButtonBitmap.Height If Is_Button Then If _mMouseIsOver = True Then buttonOffset = (_tempButtonBitmap.Height / 3) ElseIf _mMouseIsDown = True Then buttonOffset = ((_tempButtonBitmap.Height / 3) * 2) End If windowOffset = _tempButtonBitmap.Height / 3 End If Dim buttonSprite As Sprite = New Sprite(_mButtonGfx) buttonSprite.TextureRect = New IntRect(0, buttonOffset, _tempButtonBitmap.Width, windowOffset) buttonSprite.Position = New Vector2f(locX, locY) _mControlLocation = New Rectangle(buttonSprite.Position.X, buttonSprite.Position.Y, buttonSprite.GetLocalBounds().Width, buttonSprite.GetLocalBounds().Height) _mMyRenderWindow.Draw(buttonSprite) End Sub Sub Disposer() If Not _tempButtonBitmap Is Nothing Then _tempButtonBitmap.Dispose() End Sub EndClass Declaration compared to 12 lines of code: Public BankWindow As OrionGfxControl Public BankItemWindow As OrionGfxControl Public BankLeaveButton As OrionGfxControl Initialization compared to 36 lines of code: BankWindow = New OrionGfxControl(False) If FileExist(Application.StartupPath & GFX_PATH & BANKWINDOW_PATH & "BankWindow" & GFX_EXT) Then Dim bmp As New Bitmap(Application.StartupPath & GFX_PATH & BANKWINDOW_PATH & "BankWindow" & GFX_EXT) BankWindow.Init(bmp) End If BankItemWindow = New OrionGfxControl(False) If FileExist(Application.StartupPath & GFX_PATH & BANKWINDOW_PATH & "BankItemWindow" & GFX_EXT) Then Dim bmp As New Bitmap(Application.StartupPath & GFX_PATH & BANKWINDOW_PATH & "BankItemWindow" & GFX_EXT) BankItemWindow.Init(bmp) End If BankLeaveButton = New OrionGfxControl(True) If FileExist(Application.StartupPath & GFX_PATH & BANKWINDOW_PATH & "BankLeaveButton" & GFX_EXT) Then Dim bmp As New Bitmap(Application.StartupPath & GFX_PATH & BANKWINDOW_PATH & "BankLeaveButton" & GFX_EXT) BankLeaveButton.Init(bmp) End If Drawing compared to 21 lines of code: BankWindow.DrawControl(GameWindow, (frmMainGame.GameScreen.Width / 2) - (BankWindow.ControlLocation.Width / 2), 10) BankItemWindow.DrawControl(GameWindow, ((BankWindow.ControlLocation.X + BankWindow.ControlLocation.Width / 2)) - (BankItemWindow.ControlLocation.Width / 2), ((BankWindow.ControlLocation.Y + BankWindow.ControlLocation.Height / 2)) - (BankItemWindow.ControlLocation.Height / 2)) BankLeaveButton.DrawControl(GameWindow, ((BankWindow.ControlLocation.X + BankWindow.ControlLocation.Width / 2)) - (BankLeaveButton.ControlLocation.Width / 2), ((BankWindow.ControlLocation.Y + BankWindow.ControlLocation.Height)) - (BankLeaveButton.ControlLocation.Height) - 3) Then I draw all the inventory stuff onto the BankItemPanel. There is still only 3 lines to for disposing, but they are much shorter: BankWindow.Disposer() BankItemWindow.Disposer() BankLeaveButton.Disposer() Even though I think it would be better to have 2 separate classes for the panels and buttons, there isn't much that is changed. I want to see if I can use the same class for the item graphics too, but those consist of arrays of items and may not be as easy to do...but I am going to look into it.
  7. I'm not sure how I wold do that with the way my current subs are doing. I have the majority of the stuff in mouse down, but I am going to have to move most of that when an actual button is created so it will display the MouseIsDown image. I'm not sure if the copy you have include the mouse subs like I ahve now, but my shortest looks like: Private Sub GameScreen_MouseUp(sender As Object, e As MouseEventArgs) Handles GameScreen.MouseUp ' If user clicks down, moves mouse off button location, then mouse up, need to reset MouseDownOffset ShopBuyItemMouseDownButton = False ShopSellItemMouseDownButton = False ShopLeaveMouseDownButton = False BankLeaveMouseDownButton = False If UiVisible Then If StatusWindowLocation.Contains(e.Location) Then ' Do nothing... End If If ActionWindowLocation.Contains(e.Location) Then ' Do nothing... End If If InventoryWindowLocation.Contains(e.Location) Then If InventoryWindowVisible Then Dim i As Long Dim recPos As Rectangle If InTrade > 0 Then Exit Sub If InBank Or InShop Then Exit Sub If DragInvSlotNum > 0 Then For i = 1 To MaxInv With recPos .Y = InventoryWindowLocation.Y + InvTop + ((InvOffsetY + 32) * ((i - 1) \ InvColumns)) .Height = PIC_Y .X = InventoryWindowLocation.X + InvLeft + ((InvOffsetX + 32) * (((i - 1) Mod InvColumns))) .Width = PIC_X End With If e.Location.X >= recPos.Left And e.Location.X <= recPos.Right Then If e.Location.Y >= recPos.Top And e.Location.Y <= recPos.Bottom Then ' If DragInvSlotNum <> i Then SendChangeInvSlots(DragInvSlotNum, i) Exit For End If End If End If Next End If DragInvSlotNum = 0 pnlTmpInv.Visible = False End If ' InventoryWindowVisible If SkillWindowVisible Then ' Do nothing... End If If OptionsWindowVisible Then ' Do nothing... End If If CharWindowVisible Then ' Do nothing... End If End If ' PanelWindowLocation End If ' UIVisible If InBank Then '#TESTBUTTON If testButton.ButtonLocation.Contains(e.Location) Then testButton.MouseIsOver = False 'CloseBank() End If If BankLeaveButtonLocation.Contains(e.Location) Then BankLeaveMouseOverButton = False CloseBank() End If Dim i As Long Dim x As Long, y As Long Dim recPos As Rectangle x = e.Location.X y = e.Location.Y ' TODO : Add sub to change bankslots client side first so there's no delay in switching If DragBankSlotNum > 0 Then For i = 1 To MaxBank With recPos .Y = BankItemWindowLocation.Y + BankTop + ((BankOffsetY + 32) * ((i - 1) \ BankColumns)) .Height = PIC_Y .X = BankItemWindowLocation.X + BankLeft + ((BankOffsetX + 32) * (((i - 1) Mod BankColumns))) .Width = PIC_X End With If x >= recPos.Left And x <= recPos.Right Then If y >= recPos.Top And y <= recPos.Bottom Then If DragBankSlotNum <> i Then ChangeBankSlots(DragBankSlotNum, i) Exit For End If End If End If Next End If DragBankSlotNum = 0 pnlTempBank.Visible = False End If If InShop > 0 Then If ShopBuyItemButtonLocation.Contains(e.Location) Then ShopBuyItemMouseOverButton = False If ShopAction = 1 Then Exit Sub ShopAction = 1 ' buying an item AddText("Click on the item in the shop you wish to buy.") End If If ShopSellItemButtonLocation.Contains(e.Location) Then ShopSellItemMouseOverButton = False If ShopAction = 2 Then Exit Sub ShopAction = 2 ' selling an item AddText("Double-click on the item in your inventory you wish to sell.") End If If ShopLeaveButtonLocation.Contains(e.Location) Then ShopLeaveMouseOverButton = False Dim buffer As ByteBuffer buffer = New ByteBuffer buffer.WriteLong(ClientPackets.CCloseShop) SendData(buffer.ToArray()) buffer = Nothing InShop = 0 ShopAction = 0 End If Dim shopItem As Long Dim x As Long, y As Long x = e.Location.X y = e.Location.Y shopItem = IsShopItem(x, y) If shopItem > 0 Then Select Case ShopAction Case 0 ' no action, give cost With Shop(InShop).TradeItem(shopItem) AddText("You can buy this item for " & .CostValue & " " & Trim$(Item(.CostItem).Name) & ".") End With Case 1 ' buy item ' buy item code BuyItem(shopItem) End Select End If End If If InTrade Then ' Do nothing... End If GameScreen.Focus() End Sub It is going through and checking if UiVisible, InBank, or InShop, etc, then going through all of the necessary commands. I really dislike having the long, drawn out If/Else statements, but it seems with the current setup that is the only thing I could figure out that would work. Regardless if they are in an array or not I would still have to check the locations to perform certain tasks. Even if I was able to get the control class to automatically swap the image from the mouse location, I'm not going to be cutting out very many lines of code, and my mouse events for the GameScreen are still going to be huge. It may be time to look into a redesign.
  8. Nothing...I am finding nothing. Currently I can set the control's MouseIsOver and MouseIsDown boolean values in the same place I am setting the boolean values for the other drawn images, on the GameScreen mouse events. I am trying to bypass that requirement, and have them set in the actual control itself. Here is my current class without the non-working mouse subs: #Region "Imports" Imports System.Drawing Imports System.Drawing.Imaging Imports System.IO Imports System.Windows.Forms Imports SFML.Graphics Imports SFML.Window #End Region Public Class OrionButton Inherits PictureBox Private _tempButtonBitmap As Bitmap Private _mButtonGfx As Texture Private Const MouseOverOffsetY As Integer = 22 Private Const MouseDownOffsetY As Integer = 44 Private _memStream As MemoryStream Private _mButtonLocation As Rectangle Private _mMyRenderWindow As RenderWindow Private _mGfxImage As Bitmap Private _mMouseIsOver As Boolean Private _mMouseIsDown As Boolean Public Property ButtonLocation As Rectangle Get Return _mButtonLocation End Get Set(value As Rectangle) _mButtonLocation = value End Set End Property Public Property MyRenderWindow As RenderWindow Get Return _mMyRenderWindow End Get Set(value As RenderWindow) _mMyRenderWindow = value End Set End Property Public Property GfxImage As Bitmap Get Return _mGfxImage End Get Set(value As Bitmap) _mGfxImage = value End Set End Property Public Property MouseIsOver As Boolean Get Return _mMouseIsOver End Get Set(value As Boolean) _mMouseIsDown = value End Set End Property Public Property MouseIsDown As Boolean '= False Get Return _mMouseIsDown End Get Set(value As Boolean) _mMouseIsDown = value End Set End Property Public Sub New() End Sub Public Sub Init(ByVal agfximage As Bitmap) _mGfxImage = agfximage _mMouseIsOver = False _mMouseIsDown = False ' Button _tempButtonBitmap = New Bitmap(_mGfxImage) _memStream = New MemoryStream() _tempButtonBitmap.Save(_memStream, ImageFormat.Png) _mButtonGfx = New Texture(_memStream) _memStream.Dispose() 'End If End Sub Public Sub DrawButton(ByVal arenderwindow As RenderWindow, ByVal locX As Integer, ByVal locY As Integer) _mMyRenderWindow = arenderwindow Dim buttonOffset As Integer = 0 If MouseIsOver = True Then buttonOffset = MouseOverOffsetY ElseIf _mMouseIsDown = True Then buttonOffset = MouseDownOffsetY End If ' Button Image Dim buttonSprite As Sprite = New Sprite(_mButtonGfx) buttonSprite.TextureRect = New IntRect(0, buttonOffset, _tempButtonBitmap.Width, _tempButtonBitmap.Height / 3) buttonSprite.Position = New Vector2f(locX, locY) '((locX + bmp.Width / 2) - (TempButtonBitmap.Width / 2), ((locY + bmp.Height) - TempButtonBitmap.Height / 3) - 3) _mButtonLocation = New Rectangle(buttonSprite.Position.X, buttonSprite.Position.Y, buttonSprite.GetLocalBounds().Width, buttonSprite.GetLocalBounds().Height) _mMyRenderWindow.Draw(buttonSprite) End Sub Sub Disposer() If Not _tempButtonBitmap Is Nothing Then _tempButtonBitmap.Dispose() End Sub Private Sub OrionButton_MouseDown(sender As Object, e As MouseEventArgs) Handles MyBase.MouseDown If ButtonLocation.Contains(e.Location) Then _mMouseIsDown = True _mMouseIsOver = False Else _mMouseIsDown = False End If End Sub End Class (Following in ClientGraphics) Declaration: Public testButton As OrionButton Initialization: testButton = New OrionButton If FileExist(Application.StartupPath & GFX_PATH & BANKWINDOW_PATH & "BankLeaveButton" & GFX_EXT) Then Dim bmp As New Bitmap(Application.StartupPath & GFX_PATH & BANKWINDOW_PATH & "BankLeaveButton" & GFX_EXT) testButton.Init(bmp) End If Drawing: testButton.DrawButton(GameWindow, 0, 0) Disposing: testButton.Disposer() And in the frmMainGame, GameScreen_MouseUp: '#TESTBUTTON If InBank Then If testButton.ButtonLocation.Contains(e.Location) Then testButton.MouseIsOver = False CloseBank() End If I have to do something similar in all 3 mouse events for the GameScreen(up/down/move). If I had the ability to use the custom controls mouse subs that would essentially make this a finished product.
  9. Almost there... I am trying to catch the mouse events on the custom control, so I have inherited picturebox in order to get all the properties of a picturebox just like the GameScreen where I am currently handling all the events. The private subs for the mouse events do not work for a new control. So I am trying this: Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs) MessageBox.Show("mouse move...") MyBase.OnMouseMove(e) End Sub I just need to catch the mouse moving on it, or some mouse sub, in order to shift the Y position of the image. This will work when I set them from the GameScreen's MouseMove event, but not the one for the control. Any suggestions?
  10. Okay, here is what I got so far... #Region "Imports" Imports System.Drawing Imports System.Drawing.Imaging Imports System.IO Imports SFML.Graphics Imports SFML.Window #End Region Public Class OrionButton Private TempButtonBitmap As Bitmap Public ButtonLocation As Rectangle Private _mButtonGfx As Texture Private _mButtonGfxInfo As GraphicInfo 'Public MouseOverOffsetY As Integer = 22 'Public MouseDownOffsetY As Integer = 44 Dim _transcolor As Drawing.Color Dim _memStream As MemoryStream ' Button Parent 'Dim windowSprite As Sprite Structure GraphicInfo Dim Width As Long Dim Height As Long End Structure Private _mMyRenderWindow As RenderWindow Public Property MyRenderWindow As RenderWindow Get Return _mMyRenderWindow End Get Set(value As RenderWindow) _mMyRenderWindow = value End Set End Property Private _mGfxImage As Bitmap Public Property GfxImage As Bitmap Get Return _mGfxImage End Get Set(value As Bitmap) _mGfxImage = value End Set End Property Private _mMouseOverButton As Boolean '= False Public Property MouseOverButton As Boolean '= False Get Return _mMouseOverButton End Get Set(value As Boolean) _mMouseOverButton = value End Set End Property Private _mMouseDownButton As Boolean '= False Public Property MouseDownButton As Boolean '= False Get Return _mMouseDownButton End Get Set(value As Boolean) _mMouseDownButton = value End Set End Property Public Sub Init(ByVal agfximage As Bitmap) _mGfxImage = agfximage _mMouseOverButton = False _mMouseDownButton = False ' Button _mButtonGfxInfo = New GraphicInfo 'If FileExist(_mGfxImage) Then TempButtonBitmap = New Bitmap(_mGfxImage) _mButtonGfxInfo.Width = TempButtonBitmap.Width _mButtonGfxInfo.Height = TempButtonBitmap.Height _transcolor = TempButtonBitmap.GetPixel(0, 0) _memStream = New MemoryStream() TempButtonBitmap.Save(_memStream, ImageFormat.Png) _mButtonGfx = New Texture(_memStream) _memStream.Dispose() 'End If End Sub Public Sub New() End Sub Public Sub DrawButton(ByVal arenderwindow As RenderWindow) _mMyRenderWindow = arenderwindow Dim ButtonOffset As Integer = 0 If _mMouseOverButton = True Then ButtonOffset = 22 'MouseOverOffsetY ElseIf _mMouseDownButton = True Then ButtonOffset = 44 'MouseDownOffsetY End If ' Button Image Dim ButtonSprite As Sprite = New Sprite(_mButtonGfx) ButtonSprite.TextureRect = New IntRect(0, ButtonOffset, TempButtonBitmap.Width, TempButtonBitmap.Height / 3) ButtonSprite.Position = New Vector2f(0, 0) '(windowSprite.Position.X + TempBankWindowBitmap.Width / 2) - (TempButtonBitmap.Width / 2), ((windowSprite.Position.Y + TempBankWindowBitmap.Height) - TempButtonBitmap.Height / 3) - 3) ButtonLocation = New Rectangle(ButtonSprite.Position.X, ButtonSprite.Position.Y, ButtonSprite.GetLocalBounds().Width, ButtonSprite.GetLocalBounds().Height) _mMyRenderWindow.Draw(ButtonSprite) End Sub Sub Dispose() If Not TempButtonBitmap Is Nothing Then TempButtonBitmap.Dispose() End Sub End Class In ClientGraphics... Declaration: Dim testButton As OrionButton Initilization: testButton = New OrionButton If FileExist(Application.StartupPath & GFX_PATH & BANKWINDOW_PATH & "BankLeaveButton" & GFX_EXT) Then Dim bmp As New Bitmap(Application.StartupPath & GFX_PATH & BANKWINDOW_PATH & "BankLeaveButton" & GFX_EXT) testButton.Init(bmp) End If Then when I need to draw: testButton.DrawButton(GameWindow) It's working, but my brain is not very well. Can you suggest changes that should be made to the class? I know I have to pass the location in which is not an issue, but once I get this working I can do this for ALL the bloody panels too and save a whole bunch of lines!
  11. I was looking into both of those previously when I was wanting custom transparent panel controls that I could reuse. However, it seems anything outside of what is in the current code, and anything written in C# that is unable to transfer over to VB, is going to be a very foreign process for me, especially since there seem to be no straight forward examples. Last time I think I spent well over 4 wasted days of just trying to figure something out until you suggested just drawing the panels to the window. I'm probably just fried, having spent 6 straight days code, minus that sleep thing every now and then...I'm even having a difficult time trying to figure out how to make a reusable class. Hopefully I will be able to figure out soon to keep from rewriting code over and over.
  12. Doesn't someone who posts the first 3 topics in a forum get brownie points or something I have been drawing text with rectangles for buttons as a temporary solution just to get something up and running. The rectangles would be used to check the location of the mouse on mouse up, mouse down, and mouse over subs. This worked but looked horrid... Today I side tracked from my massive list-o-stuffs to do and tried to make buttons. So far I have 1 for the bank and 3 for the shop working. All 3 normal/down/hover images are on the same image that I adjust to Y position of in order to change the image. On the mouse events it checks if the location contains the mouse, then turns on a global variable. (Mouse Move Sub) If InBank Then If BankLeaveButtonLocation.Contains(e.Location) Then If BankLeaveMouseDownButton = False Then BankLeaveMouseOverButton = True End If Else BankLeaveMouseOverButton = False End If On the ClientGraphics I have to declare the image for the button. ' Bank Leave Button Public BankLeaveButtonGfx As Texture Public BankLeaveButtonGfxInfo As GraphicInfo Public TempBankLeaveButtonBitmap As Bitmap Public BankLeaveButtonLocation As Rectangle Then I have to initialize the button graphics with the rest of the graphics. ' Bank Leave Button BankLeaveButtonGfxInfo = New GraphicInfo If FileExist(Application.StartupPath & GFX_PATH & BANKWINDOW_PATH & "BankLeaveButton" & GFX_EXT) Then TempBankLeaveButtonBitmap = New Bitmap(Application.StartupPath & GFX_PATH & BANKWINDOW_PATH & "BankLeaveButton" & GFX_EXT) BankLeaveButtonGfxInfo.Width = TempBankLeaveButtonBitmap.Width BankLeaveButtonGfxInfo.Height = TempBankLeaveButtonBitmap.Height _transcolor = TempBankLeaveButtonBitmap.GetPixel(0, 0) _memStream = New MemoryStream() TempBankLeaveButtonBitmap.Save(_memStream, ImageFormat.Png) BankLeaveButtonGfx = New Texture(_memStream) _memStream.Dispose() End If When the panel is drawing, then drawing the button, I have to check what the global variable is first and set the Y position. Dim BankLeaveButtonOffset As Integer = 0 If BankLeaveMouseOverButton = True Then BankLeaveButtonOffset = MouseOverOffsetY ElseIf BankLeaveMouseDownButton = True Then BankLeaveButtonOffset = MouseDownOffsetY End If Then draw the button. ' Bank Leave Button Background Dim windowLeaveButtonSprite As Sprite = New Sprite(BankLeaveButtonGfx) windowLeaveButtonSprite.TextureRect = New IntRect(0, BankLeaveButtonOffset, TempBankLeaveButtonBitmap.Width, TempBankLeaveButtonBitmap.Height / 3) windowLeaveButtonSprite.Position = New Vector2f((windowSprite.Position.X + TempBankWindowBitmap.Width / 2) - (TempBankLeaveButtonBitmap.Width / 2), ((windowSprite.Position.Y + TempBankWindowBitmap.Height) - TempBankLeaveButtonBitmap.Height / 3) - 3) BankLeaveButtonLocation = New Rectangle(windowLeaveButtonSprite.Position.X, windowLeaveButtonSprite.Position.Y, windowLeaveButtonSprite.GetLocalBounds().Width, windowLeaveButtonSprite.GetLocalBounds().Height) GameWindow.Draw(windowLeaveButtonSprite) Then I dispose of the TempBitmap along with the rest of the TempBitmaps... OMG, that seems like too much to do, and that is only 4 of the buttons that have to be drawn. My main game form is already nearly 3k lines, and my ClientGraphics file is well over 5k lines...currently I am wrapping lines up into regions, but when they get over several hundred lines it defeats the purpose of using them in the first place. It seems like there has got to be a much better, more efficient, and cleaner way of doing this...my thoughts are creating a custom button class that can just be reused. But because of how intricate and tedious the current code base is this may not be an option. I need some thoughts on what I am doing, and an idea or two on a better way. Thanks guys!
  13. I get aggravated when it is small crap like this that takes me several hours to figure out, LOL.
  14. No, it isn't with the packets. I figured it out though. I had two if statements...one to check for Enter or backspace, then another to check the rest of the keys. All I had to do was move that to the first if statement and it worked <.<
  15. No, I have it scrolling to adjust the view of the text working, what I meant was catching the limit of the MyTextLength. When I type over the amount and hit enter to send it, it errors for some reason but isn't showing anything. When I bypass the char limit, everything works fine, but just has unlimited characters that can be input.
  16. It seems like I am running into issues with every simple task... Declared a global: Public Const MyTextLength As Integer = 70 Now I need to check what the user is typing: ' Check for IsTalking = True, continue with the rest of this... ' Check for Keys.Enter and do stuff ' Check for Keys.Back and delete a letter from MyText If MyText.Length = MyTextLength Then Exit Sub End If ' Check for other keys... I'm setting a small limit for testing. When I bypass the length check everything works fine. When I include the above check before checking the rest of the keys, when I hit [Enter] to send the text (if it was typed over the limit) it starts the whole disconnecting deal over again. I have tried several variations of the above but running into walls. I could use an idea on how to check the length of MyText to limit the number of characters the user can input.
  17. So yeah, I'm an idiot... I was still using the renderblock to compile a list of the ChatLines, then write them to the screen. That is why I needed to add vbCrLf to every line segment. It did not dawn on me until nearly 2 hours this morning of trying to tweak it to instead loop through the ChatLines, draw them, then add to the position that the next line was being drawn. Now this works with any font, but I still like the one I found for right now. The ONLY issues that someone may run into is: If their font is too wide, then the word wrap length will have to be changed. If their font height is too tall, then the number of rendered lines will have to be reduced.
  18. I so tried doing this, I swear...it just did not work out too well whenever I tried to create a new line and using vbCrLf anywhere. The good news is until I come back to fix this problem I found http://www.1001fonts.com/share-tech-mono-font.html which is a fixed-width, true-type font. I had to increase the size to 12, and cut down the number of lines being drawn to 9, but it looks good for now. I may try to fix this tomorrow. Right now I am adding the text to be rendered for each string through my word wrap sub (used to be a function).
  19. I needed to have a fixed-width font for the text wrapping on the chat area. It has to be a true-type font, which calibri is, but it's not fixed-width. I am looking around for an alternative though
  20. It took me about 3 hours to figure out to remove vbCrLf and replace it with "|" pipe key instead...otherwise it would just split at the vbCrLf but it would not delete it and would still throw in an extra new line...
  21. When use that method I have text that will run below the chat window. To keep my text from running off the screen I found a way to make it wrap, this is in modText: Dim splitChars As Char() = New Char() {" "c, "-"c, ControlChars.Tab} Private Function WordWrap(str As String, width As Integer) As String Dim words As String() = Explode(str, splitChars) Dim curLineLength As Integer = 0 Dim strBuilder As New StringBuilder() Dim i As Integer = 0 While i < words.Length Dim word As String = words(i) ' If adding the new word to the current line would be too long, ' then put it on a new line (and split it up if it's too long). If curLineLength + word.Length > width Then ' Only move down to a new line if we have text on the current line. ' Avoids situation where wrapped whitespace causes emptylines in text. If curLineLength > 0 Then strBuilder.Append(Environment.NewLine) curLineLength = 0 End If ' If the current word is too long to fit on a line even on it's own then ' split the word up. While word.Length > width strBuilder.Append(word.Substring(0, width - 1) + "-") word = word.Substring(width - 1) strBuilder.Append(Environment.NewLine) End While ' Remove leading whitespace from the word so the new line starts flush to the left. word = word.TrimStart() End If strBuilder.Append(word) curLineLength += word.Length i += 1 End While Return strBuilder.ToString() End Function Private Function Explode(str As String, splitChars As Char()) As String() Dim parts As New List(Of String)() Dim startIndex As Integer = 0 Explode = Nothing While True Dim index As Integer = str.IndexOfAny(splitChars, startIndex) If index = -1 Then parts.Add(str.Substring(startIndex)) Return parts.ToArray() End If Dim word As String = str.Substring(startIndex, index - startIndex) Dim nextChar As Char = str.Substring(index, 1)(0) ' Dashes and the likes should stick to the word occuring before it. Whitespace doesn't have to. If Char.IsWhiteSpace(nextChar) Then parts.Add(word) parts.Add(nextChar.ToString()) Else parts.Add(word + nextChar) End If startIndex = index + 1 End While End Function And here is my modified AddText sub: Public Sub AddText(ByVal Msg As String) txtChatAdd += WordWrap(Msg, 70) End Sub And in modGameLogic when all the text is being added: If Not txtChatAdd = Nothing Then txtChatAdd += vbCrLf ChatLines.Add(txtChatAdd) frmMainGame.rtbChat.AppendText(txtChatAdd) txtChatAdd = Nothing End If Is there a more efficient way that you know of in order to achieve this? It is drawing to the screen, but on a test if the test is very long then it adds more than the chat height.
  22. Almost nearly there...somewhat. I have no idea about txtMeChat yet, but for the rtb I am writing the lines to a file and clearing it out on dispose. Here I am reading the first 9 lines great, but when it goes over the 9 lines I only want to show the last 9. So close... Dim tmpChat As String = "" Dim lines() As String = File.ReadAllLines(Application.StartupPath & "tmpChat.txt") '.Length Dim line As String If lines.Count <= 9 Then Using sr As New StreamReader(Application.StartupPath & "tmpChat.txt") line = sr.ReadToEnd() tmpChat += line End Using Else Using sr As New StreamReader(Application.StartupPath & "tmpChat.txt") For i As Integer = (lines.Count - 9) To lines.Count line = sr.ReadLine(lines(i)) '.ReadToEnd() tmpChat += line Next End Using End If[code]
  23. Right now I am drawing the text from the rtbChat and txtMeChat on my generic image during each render method. When the picScreen has focus you press "t" to start talking which enables the txtMeChat...of course this disables the movement so that text can be entered without messing it up with other key presses. The square at the end of each line is from the font's CRLF character, which can be fixed by changing the font. Here is what I currently have: Dim tmpChat As String = "" For Each line In frmMainGame.rtbChat.Lines tmpChat += line & vbCrLf Next First I need to figure out how to limit the text to a certain number of lines. Since I am going to delete the txtMeChat and rtbChat once this is done I really don't want to use either of those...but still I have been unable to get the last 9 lines of the rtbChat so only they display. Second I need to limit the line length to about 50 characters so it will not draw off screen. Third I need to poll the keys being pressed during the keydown event (I know how to do this), but something like backspace I am lost on how I would delete that from a string. Fourth when text is being entered into the chat portion at the bottom I need to shift the view area to the right and clip off the left so the rest of the string can be viewed...either that or limit the text to only 50 characters. Last I need to figure how to make this act like an actual rtb that can scroll up and down so many lines. I can create a generic scrollbar graphics to handle this on mouse up later... ALL that being said, I have looked through the vb6 sources to get an idea of how this is done on there, but I don't have vb6 installed and am using notepad++. With what is there it is in no way compatible with the current setup. I'm hoping to get a straight forward idea of what does need to be done in order to do this in the most efficient manner. Any help is much appreciated!
×
×
  • Create New...