Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

DX8 Chat System [EM, EFF]


escfoe2
 Share

Recommended Posts

> Everyone can read. But most of the people here won't understand.

Then they need to learn english.

> clears the chat texture

```
'Clear the LastTexture
```

> draws some primitives

```

Direct3D_Device.DrawPrimitive

```

> Specifically to Triangle Lists

```

Direct3D_Device.DrawPrimitive D3DPT_TRIANGLELIST

```

Yeah man, this is totally hard to read! You must be an amazing coder; where'd you get your uber skills?
Link to comment
Share on other sites

> Then they need to learn english.
>
> ```
> 'Clear the LastTexture
> ```
>
> ```
>
> Direct3D_Device.DrawPrimitive
>
> ```
>
> ```
>
> Direct3D_Device.DrawPrimitive D3DPT_TRIANGLELIST
>
> ```
>
> Yeah man, this is totally hard to read! You must be an amazing coder; where'd you get your uber skills?

I never mentioned about anyone knowing english. I mean about programming and related to graphics.

```

'Clear the LastTexture

```
Didn't mention which texture.

```

Direct3D_Device.DrawPrimitive

```
Some people don't even know what DX8\. So how do you think they know what DrawingPrimitives are?

```

Direct3D_Device.DrawPrimitive D3DPT_TRIANGLELIST

```
I specified what type of primitive in case they don't know what primitives are.

Where did you get your uber common sense from?
Link to comment
Share on other sites

Alright guys quit your shit.

Let's just find the answer to the question and move on.

Thank you for trying Abhi2011.

> Yeah man, this is totally hard to read! You must be an amazing coder; where'd you get your uber skills?

Thank you Lt. Topper for making me laugh with your assholio sarcasm. XD
Link to comment
Share on other sites

Hope this is helpful. I've left out anything that wasn't chatbox related.

Sub RenderChatTextBuffer():

>! ```
>! ' Chat Box
>! Public Sub RenderChatTextBuffer()
>! Dim srcRect As RECT
>! Dim v2 As D3DVECTOR2
>! Dim v3 As D3DVECTOR2
>! Dim I As Long
>! 'Clear the LastTexture, letting the rest of the engine know that the texture needs to be changed for next rect render
>! Direct3D_Device.SetTexture 0, gTexture(Font_Default.Texture.Texture).Texture
>! 'If there is at least one line of text, render the space.
>! If ChatArrayUbound > 0 Then
>! Direct3D_Device.SetStreamSource 0, ChatVBS, FVF_SIZE
>! Direct3D_Device.DrawPrimitive D3DPT_TRIANGLELIST, 0, (ChatArrayUbound + 1) \ 3
>! Direct3D_Device.SetStreamSource 0, ChatVB, FVF_SIZE
>! Direct3D_Device.DrawPrimitive D3DPT_TRIANGLELIST, 0, (ChatArrayUbound + 1) \ 3
>! End If
>! End Sub
>! ```

This sub renders two sets of triangles for the textbox. It is done as a triangle list (3 vertices), beginning at point 0, and drawing (number of total characters + 1)/3 primitive triangles. Every 2 triangles make a rectangle for one character, including spaces. This is where the actual text is rendered. ChatVB takes care of the position, color, and character value. It seems to me that ChatVBS does nothing. I've tested it commented out and nothing seems to change. ChatArrayUbound is the number of characters in the chat. Line breaks are dealt with in addtext and updatechatarray, changing the y value of ChatVB.

To begin with, this sub is called in the constantly called DrawGUI, when inchat=false. The inchat boolean is set to true in certain dialogue boxes, for instance on pop-up boxes concerning dropping items, in quest/event chats, when depositing or withdrawing in the bank, etc. It is used as a flag to stop updating the chatbox when you normally wouldn't be paying attention to it.

SetStreamSource sets the source for the primitive vertices we will draw; here, we use the set vertices of ChatVBS and ChatVB. Both of these are set in sub UpdateChatArray, using flexible vertex format. ChatVBS is set to equal ChatVAS which always empty (dimmed and then erased). Every 3 ChatVBS includes one triangles' vertices. There are 2 sets of ChatVBS per character, as you can see in UpdateChatArray. ChatVB is set to equal ChatVA.

The rest happens in Sub UpdateChatArray. ChatVBS and ChatVB are set in a for loop in that sub. Here's a list of the variables for that sub:

>! Dim Chunk As Integer
>! chunk is set to the chatscroll, which displays the 8 lines of text within chatbuffersize (by default a public integer of 200)
>! Dim count As Integer
>! loop counter for the number of characters into the line we're on
>! Dim LoopC As Byte
>! loop counter for the number of lines
>! Dim Ascii As Byte
>! to store the ascii value of the individual character
>! Dim Row As Long
>! Row = (Ascii - Font_Default.HeaderInfo.BaseCharOffset) \ Font_Default.RowPitch
>! theFont.RowPitch = theFont.HeaderInfo.BitmapWidth \ theFont.HeaderInfo.CellWidth
>! Dim Pos As Long
>! character position for the line used in rendering
>! 'tU and tV value (basically tU = BitmapXPosition / BitmapWidth, and height for tV)
>! Dim u As Single
>! calculated ascii character value
>! u = ((Ascii - Font_Default.HeaderInfo.BaseCharOffset) - (Row * Font_Default.RowPitch)) * Font_Default.
>! Dim v As Single
>! v = Row * Font_Default.RowFactor
>! theFont.RowFactor = theFont.HeaderInfo.CellHeight / theFont.HeaderInfo.BitmapHeight
>! Dim x As Single
>! starting x position of chat text
>! x = GUIWindow(GUI_CHAT).x + ChatOffsetX
>! Dim y As Single
>! starting y position of chat text
>! y = GUIWindow(GUI_CHAT).y + ChatOffsetY
>! Dim y2 As Single
>! "set the Y position to be used" - specific line value for y
>! y2 = y - (LoopC * yOffset) + (Chunk * ChatBufferChunk * yOffset) - 32
>! Dim I As Long
>! not used
>! Dim j As Long
>! for-count variable for looping through characters on the loopc line
>! Dim Size As Integer
>! total number of characters in the chat buffer
>! Dim KeyPhrase As Byte
>! not used
>! Dim ResetColor As Byte
>! flag used to change the text color to ChatTextBuffer(LoopC).Color
>! Dim TempColor As Long
>! colour of the individual character
>! Dim yOffset As Long
>! specific y offset for chat lines

public declaration of modText:

>! ' Chat Buffer
>! Public ChatVA() As TLVERTEX
>! vertex array of characters, their colour, and position
>! Public ChatVAS() As TLVERTEX
>! empty vertex array
>! Public Const ChatTextBufferSize As Integer = 200
>! maximum lines in chatbox. Used with chatscroll.
>! Public ChatBufferChunk As Single
>! used to include/exclude chatscroll in certain algorithms
>! Public ChatTextBuffer(1 To ChatTextBufferSize) As ChatTextBuffer
>! Public Type ChatTextBuffer
>! text As String
>! Color As Long
>! End Type
>! the text and colour of an indexed line
>! 'Chat vertex buffer information
>! Public ChatArrayUbound As Long
>! number of characters in the chat array
>! Public ChatVB As Direct3DVertexBuffer8
>! set to equal ChatVA in UpdateChatArray
>! Public ChatVBS As Direct3DVertexBuffer8
>! set to equal ChatVAS in UpdateChatArray

and the globals:

>! Public inChat As Boolean
>! boolean trigger for updating chatbox. When inChat = false it updates.
>! Public chaton As Boolean
>! boolean trigger for whether the player is typing. When chatOn = true, text goes into chatbox.
>! Public Const ChatOffsetX As Long = 6
>! The starting x offset for text
>! Public Const ChatOffsetY As Long = 38
>! The starting y offset for text
>! Public Const ChatWidth As Long = 380
>! GUI width of the chat box
Link to comment
Share on other sites

> I never mentioned about anyone knowing english. I mean about programming and related to graphics.
>
> ```
>
> 'Clear the LastTexture
>
> ```
> Didn't mention which texture.
>
> ```
>
> Direct3D_Device.DrawPrimitive
>
> ```
> Some people don't even know what DX8\. So how do you think they know what DrawingPrimitives are?
>
> ```
>
> Direct3D_Device.DrawPrimitive D3DPT_TRIANGLELIST
>
> ```
> I specified what type of primitive in case they don't know what primitives are.
>
> Where did you get your uber common sense from?

Why don't you crawl back into the hole from whence you came from?

You don't know anymore than anyone else in this topic, you just like to play it off like some big shot. Get the hell out of the Q&A board if you don't know what you're talking about, there are more qualified VB6 people around here, e.g., Zeno.

All you're doing is throwing everyone off track with a ton of useless spam, which'll cause newcomers with similar questions or problems to become confused and post even more topics.

Go To Hell,

General Pony

P.S. It'd be nice if a staff member would do their job for once.
Link to comment
Share on other sites

> zeno ? was the up and down arrows of the chatbox included ? b/c i didnt see it in there O.o

No, deliberately not. It doesn't seem to me that escfoe2 is asking about that… And I kind of assume he'd be able to figure that out himself. All the same, I'll point out where it happens, but don't really see the need to explain it. It's all straightforward VB6/DX8.

The buttons are drawn using modGeneral Sub InitialiseGUI constants in modGraphics Sub DrawGUI, the same as every other button:

>! ```
' draw buttons
>! For I = 34 To 35
>! ' set co-ordinate
>! x = GUIWindow(GUI_CHAT).x + Buttons(I).x
>! y = GUIWindow(GUI_CHAT).y + Buttons(I).y
>! Width = Buttons(I).Width
>! Height = Buttons(I).Height
>! ' check for state
>! If Buttons(I).state = 2 Then
>! ' we're clicked boyo
>! 'EngineRenderRectangle Tex_Buttons_c(Buttons(i).PicNum), x, y, 0, 0, width, height, width, height, width, height
>! RenderTexture Tex_Buttons_c(Buttons(I).PicNum), x, y, 0, 0, Width, Height, Width, Height
>! ElseIf (GlobalX >= x And GlobalX <= x + Buttons(I).Width) And (GlobalY >= y And GlobalY <= y + Buttons(I).Height) Then
>! ' we're hoverin'
>! 'EngineRenderRectangle Tex_Buttons_h(Buttons(i).PicNum), x, y, 0, 0, width, height, width, height, width, height
>! RenderTexture Tex_Buttons_h(Buttons(I).PicNum), x, y, 0, 0, Width, Height, Width, Height
>! ' play sound if needed
>! If Not lastButtonSound = I Then
>! PlaySound Sound_ButtonHover, -1, -1
>! lastButtonSound = I
>! End If
>! Else
>! ' we're normal
>! 'EngineRenderRectangle Tex_Buttons(Buttons(i).PicNum), x, y, 0, 0, width, height, width, height, width, height
>! RenderTexture Tex_Buttons(Buttons(I).PicNum), x, y, 0, 0, Width, Height, Width, Height
>! ' reset sound if needed
>! If lastButtonSound = I Then lastButtonSound = 0
>! End If
>! Next
```

The input handle is linked from modInput's HandleMouseDown

>! ```
' check chat buttons
>! If Not inChat Then
>! ChatScroll_MouseDown
>! End If
```
>! to Sub chatscroll_mousedown
>! >! ```
' scroll bar
>! Public Sub ChatScroll_MouseDown()
>! Dim I As Long, x As Long, y As Long, Width As Long
>! ' find out which button we're clicking
>! For I = 34 To 35
>! x = GUIWindow(GUI_CHAT).x + Buttons(I).x
>! y = GUIWindow(GUI_CHAT).y + Buttons(I).y
>! ' check if we're on the button
>! If (GlobalX >= x And GlobalX <= x + Buttons(I).Width) And (GlobalY >= y And GlobalY <= y + Buttons(I).Height) Then
>! Buttons(I).state = 2 ' clicked
>! ' scroll the actual chat
>! Select Case I
>! Case 34 ' up
>! 'ChatScroll = ChatScroll + 1
>! ChatButtonUp = True
>! Case 35 ' down
>! 'ChatScroll = ChatScroll - 1
>! 'If ChatScroll < 8 Then ChatScroll = 8
>! ChatButtonDown = True
>! End Select
>! End If
>! Next
>! End Sub
```
>! and a tiny bit in HandleMouseUp
>! >! ```
' stop scrolling chat
>! ChatButtonUp = False
>! ChatButtonDown = False
```
>! The actual scrolling happens in sub ScrollChatBox
>! >! ```
Public Sub ScrollChatBox(ByVal direction As Byte)
>! ' do a quick exit if we don't have enough text to scroll
>! If totalChatLines < 8 Then
>! ChatScroll = 8
>! UpdateChatArray
>! Exit Sub
>! End If
>! ' actually scroll
>! If direction = 0 Then ' up
>! ChatScroll = ChatScroll + 1
>! Else ' down
>! ChatScroll = ChatScroll - 1
>! End If
>! ' scrolling down
>! If ChatScroll < 8 Then ChatScroll = 8
>! ' scrolling up
>! If ChatScroll > totalChatLines Then ChatScroll = totalChatLines
>! ' update the array
>! UpdateChatArray
>! End Sub
```
>! which is triggered in mod GameLoop
>! >! ```
If chatTmr < tick Then
>! If ChatButtonUp Then
>! ScrollChatBox 0
>! End If
>! If ChatButtonDown Then
>! ScrollChatBox 1
>! End If
>! chatTmr = tick + 50
>! End If
```
Link to comment
Share on other sites

well its minor but since the topic is the chat system thats happen tobe apart of it ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) this way you covered it all. and ik its straight forward but its nice to show it all : )well lets see if esc says thats wat he wants , from what i see i think you covered it. ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)
Link to comment
Share on other sites

> You don't know anymore than anyone else in this topic,
>
> That does include yourself. All you did was link to a topic and ask for a sub. I could do the same.
>
> > All you're doing is throwing everyone off track with a ton of useless spam, which'll cause newcomers with similar questions or problems to become confused and post even more topics.
>
> Other than explaining what the code does the way I understand it what more did I do. And if you consider that spam you should consider you to posts spam as well. Not sure why your trying to cover up what you did it.
>
> Wanna be mod.
>
> Regards,
>
> Abhi2011
Link to comment
Share on other sites

I wouldn't be surprised if someone gets a backseat moderation warning.

Anyway, that covers everything I can think of Zeno.

Thank you very much and I'd appreciate it now if everyone who said they would donate, donated to [Zeno](http://www.touchofdeathforums.com/community/index.php?/user/35202-zeno/).
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...