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

[EO DX8]Ingame News/Patchnotes Tutorial


Kaymak
 Share

Recommended Posts

**Ingame News/Patchnotes Tutorial**

(This Tutorial was made for every DX8 Engine)
Check my other Tutorials
[Target Details](http://www.eclipseorigins.com/showthread.php?tid=27)

![](http://fs1.directupload.net/images/150527/epavqmt6.png)

**Hello Eclipse Community**

Basically all this Tutorial does is, when you come ingame you will get the news and click through that window to check the patchnotes.
which will get loaded from the server. So your players will be up2date everytime.

****Lets get started! (Server-Side)****

In **"modEnumerations"** look for
```
   ' Make sure SMSG_COUNT is below everything else

[align]   SMSG_COUNT[/align]

[align]above add:[/align]

[align][code] SSendNews

   SSendPatchNotes[/code][/align]

[align]In [b][u]"modServerTCP"[/u][/b] at the bottom you add:[/align]
[align](make sure you create at your servers/data folder news.txt and patchnotes.txt)[/align]

[align][code]Public Sub SendNews(ByVal index As Long)

Dim News As String, f As Long
   Dim Buffer As clsBuffer
   Set Buffer = New clsBuffer

   Buffer.WriteLong SSendNews
   f = FreeFile
   Open App.path & "\data\news.txt" For Input As #f
       Line Input #f, News
   Close #f
   Buffer.WriteString News

   SendDataTo index, Buffer.ToArray

   Set Buffer = Nothing
End Sub

Public Sub SendPatchNotes(ByVal index As Long)
Dim Patchnotes As String, f As Long
   Dim Buffer As clsBuffer
   Set Buffer = New clsBuffer

   Buffer.WriteLong SSendPatchNotes
   f = FreeFile
   Open App.path & "\data\patchnotes.txt" For Input As #f
       Line Input #f, Patchnotes
   Close #f
   Buffer.WriteString Patchnotes

   SendDataTo index, Buffer.ToArray

   Set Buffer = Nothing
End Sub[/code][/align]

In [b][u]"modPlayer"[/u][/b] at the bottom in "JoineGame" after "SendInGame index" you add:
[code]    Call SendNews(index)
   Call SendPatchNotes(index)[/code]
[align][color][size][font][u][b][color][size][font][u][b][u][color][size][font][b][color][font][u][b]Lets get started! (Client-Side)[/b][/u][/font][/color][/b][/font][/size][/color][/u]
[/b][/u][/font][/size][/color][/b][/u][/font][/size][/color][/align]

In [b][u]"modEnumerations"[/u][/b] look for

[align][code]    ' Make sure SMSG_COUNT is below everything else
[align]   SMSG_COUNT[/align]

[align]above add:[/align]

[align][code] SSendNews
   SSendPatchNotes[/code][/align]

[align]In [b][u]"modHandleData"[/u][/b] look for[/align]

[align][code]HandleDataSub(STradeRequest) = GetAddress(AddressOf HandleTradeRequest)[/code][/align]

[align]above add:[/align]

[align][code]HandleDataSub(SSendNews) = GetAddress(AddressOf HandleSendNews)
   HandleDataSub(SSendPatchNotes) = GetAddress(AddressOf HandleSendPatchnotes)[/code][/align]

[align]In [b][u]"modHandleData"[/u][/b] at the Bottom add[/align]

[align][code]Private Sub HandleSendNews(ByVal Index As Long, ByRef data() As Byte, ByVal StartAddR As Long, ByVal ExtraVar As Long)

   Dim Buffer As clsBuffer
   Set Buffer = New clsBuffer

   Buffer.WriteBytes data()

   NewsText = Buffer.ReadString
   Set Buffer = Nothing
   GUIWindow(GUI_NEWS).Visible = True
End Sub

Private Sub HandleSendPatchnotes(ByVal Index As Long, ByRef data() As Byte, ByVal StartAddR As Long, ByVal ExtraVar As Long)
   Dim Buffer As clsBuffer
   Set Buffer = New clsBuffer

   Buffer.WriteBytes data()

   PatchNotes = Buffer.ReadString
   Set Buffer = Nothing
   GUIWindow(GUI_NEWS).Visible = True
End Sub
[align][/align]
[align][align][b][i][u]!Now everything you need to do is, render everything ingame! if you dont know how read below![/u][/i][/b][/align]

In [b][u]"modGraphics"[/u][/b] at the Bottom add

[code]Public Sub DrawNews()

Dim I As Long, X As Long, Y As Long, Sprite As Long, Width As Long
Dim Height As Long
   ' draw background
   X = GUIWindow(GUI_NEWS).X
   Y = GUIWindow(GUI_NEWS).Y

   ' render chatbox
   Width = GUIWindow(GUI_NEWS).Width
   Height = GUIWindow(GUI_NEWS).Height
   'EngineRenderRectangle Tex_GUI(21), x, y, 0, 0, width, height, width, height, width, height
   RenderTexture Tex_GUI(48), X, Y, 0, 0, Width, Height, Width, Height

   Select Case PlayerInfo.CurrentWindow
       Case 0
              ' Draw the text
       RenderText Font_Default, "Recent News", X + 120, Y + 20, White
       RenderText Font_Default, WordWrap(NewsText, Width - 70), X + 35, Y + 45, White
       Case 1
       RenderText Font_Default, "Patch Notes", X + 120, Y + 20, White
       RenderText Font_Default, WordWrap(PatchNotes, Width - 70), X + 35, Y + 45, White
   End Select

   For I = 54 To 56
       X = GUIWindow(GUI_NEWS).X + Buttons(I).X
       Y = GUIWindow(GUI_NEWS).Y + Buttons(I).Y
       Width = Buttons(I).Width
       Height = Buttons(I).Height
       ' render accept button
       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
               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

End Sub[/code]
[b]Look for [u]"Public Const MAX_BUTTONS As Long ="[/u] and change the value behind "=" to [u]"200"[/u][/b]

In [b][u]"modGlobals"[/u][/b] you add
[code]Public NewsText As String
Public PatchNotes As String[/code]
In [b][u]"Public Enum GUIType"[/u][/b] you add
[code]GUI_NEWS[/code]
In [b][u]"HandleMouseDown"[/u][/b] you add
[code]Case GUI_NEWS

                           News_MouseDown
                           mouseState = I
                           If Button = vbRightButton Then mouseClicked = True
                           Exit Sub[/code]
In [b][u]"HandleMouseUp"[/u][/b] you add
[code]Case GUI_NEWS
                           News_MouseUp[/code]
In [b][u]"modInput"[/u][/b] at the bottom you add

[code]Public Sub News_MouseDown()

Dim I As Long, X As Long, Y As Long
   For I = 54 To 56
       X = GUIWindow(GUI_NEWS).X + Buttons(I).X
       Y = GUIWindow(GUI_NEWS).Y + Buttons(I).Y
       If (GlobalX >= X And GlobalX <= X + Buttons(I).Width) And (GlobalY >= Y And GlobalY <= Y + Buttons(I).Height) Then
           Buttons(I).state = 2 ' clicked
       End If
   Next
End Sub
Public Sub News_MouseUp()
Dim I As Long, X As Long, Y As Long, Buffer As clsBuffer

   ' find out which button we're clicking
   For I = 54 To 56
       X = GUIWindow(GUI_NEWS).X + Buttons(I).X
       Y = GUIWindow(GUI_NEWS).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
           If Buttons(I).state = 2 Then
               ' do stuffs
               Select Case I
                   Case 54
                       If PlayerInfo.CurrentWindow <= 0 Then
                           PlayerInfo.CurrentWindow = 1
                       Else
                           PlayerInfo.CurrentWindow = PlayerInfo.CurrentWindow - 1
                       End If
                   Case 55
                       If PlayerInfo.CurrentWindow >= 1 Then
                           PlayerInfo.CurrentWindow = 0
                        Else
                           PlayerInfo.CurrentWindow = PlayerInfo.CurrentWindow + 1
                       End If
                   Case 56
                       If GUIWindow(GUI_NEWS).Visible = True Then
                           GUIWindow(GUI_NEWS).Visible = False
                       End If
               End Select
               ' play sound
               'PlaySound Sound_ButtonClick
           End If
       End If
   Next

   ' reset buttons
   resetClickedButtons
End Sub[/code]
In [b][u]"modGeneral"[/u][/b] at [b][u]"InitialiseGUI"[/u][/b] the  you add
[code]
    ' 26 - News

    With GUIWindow(GUI_NEWS)
        .X = 220
        .Y = 180
        .Width = 320
        .Height = 320
        .Visible = False
    End With

' main - News Left

   With Buttons(54)
       .state = 0 ' normal
       .X = 50
       .Y = 15
       .Width = 19
       .Height = 19
       .Visible = True
       .PicNum = 23
   End With

   ' main - News Right
   With Buttons(55)
       .state = 0 ' normal
       .X = 250
       .Y = 15
       .Width = 19
       .Height = 19
       .Visible = True
       .PicNum = 24
   End With

    ' main - News Exit
   With Buttons(56)
       .state = 0 ' normal
       .X = 210
       .Y = 280
       .Width = 128
       .Height = 32
       .Visible = True
       .PicNum = 29
   End With[/code]
In [b][u]"modTypes"[/u][/b] the  you add
[code]Public PlayerInfo As InfoRec[/code][/align]

[align]at the bottom:[/align]
[align][code]Public Type InfoRec

   CurrentWindow As Byte
End Type[/code][/align]

[align][b][i]Now you just add the Graphics and voila you got it![/i][/b][/align]
[align][b][i]If i miss something please reply so i can edit the tutorial, if you have question write me a pm or ask in thread[/i][/b][/align][/code][/align][/code][/align]
```
Link to comment
Share on other sites

  • 6 months later...
If you guys encounter the same problem as me (The news invisible or didn't show up.) Try this

At the bottom of ModGraphics, Public Sub DrawNews. Replace with this

```
Public Sub DrawNews()

Dim I As Long, X As Long, Y As Long, Sprite As Long, Width As Long
Dim Height As Long
  ' draw background
  X = GUIWindow(GUI_NEWS).X
  Y = GUIWindow(GUI_NEWS).Y

  ' render chatbox
  Width = GUIWindow(GUI_NEWS).Width
  Height = GUIWindow(GUI_NEWS).Height
  'EngineRenderRectangle Tex_GUI(45), x, y, 0, 0, width, height, width, height, width, height
  RenderTexture Tex_GUI(45), X, Y, 0, 0, Width, Height, Width, Height

  Select Case PlayerInfo.CurrentWindow
      Case 0
             ' Draw the text
      RenderText Font_Default, "Recent News", X + 120, Y + 20, White
      RenderText Font_Default, WordWrap(NewsText, Width - 70), X + 35, Y + 45, Brown
      Case 1
      RenderText Font_Default, "Patch Notes", X + 120, Y + 20, White
      RenderText Font_Default, WordWrap(PatchNotes, Width - 70), X + 35, Y + 45, Brown
  End Select

  For I = 59 To 61
      X = GUIWindow(GUI_NEWS).X + Buttons(I).X
      Y = GUIWindow(GUI_NEWS).Y + Buttons(I).Y
      Width = Buttons(I).Width
      Height = Buttons(I).Height
      ' render accept button
      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
              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

End Sub
```
And find ' render menus and 
```
If GUIWindow(GUI_NEWCLASS).Visible Then DrawNewClass
```Below add (or in the bottom of that)
```
If GUIWindow(GUI_NEWS).Visible = True Then DrawNews
```
It will looks like this
```
If GUIWindow(GUI_NEWCLASS).Visible Then DrawNewClass
If GUIWindow(GUI_NEWS).Visible = True Then DrawNews
```
Make sure you set the right Buttons in the InitialiseGUI. and your good to go!

Credits to Benjo for Helping me solve this :D 
and Kaymak for the Awesome feature<3

![](http://s30.postimg.org/a8ukx3or5/vb6_2015_12_24_10_39_34_065.jpg)
Link to comment
Share on other sites

@'skyzero':

> How would provide Example file ?
>
> I tried to do with any here , but nothing happened gave error in DX8
> I think it was because of the dimensions .

```
' render chatbox

 Width = GUIWindow(GUI_NEWS).Width
 Height = GUIWindow(GUI_NEWS).Height
 'EngineRenderRectangle Tex_GUI(45), x, y, 0, 0, width, height, width, height, width, height
 RenderTexture Tex_GUI(45), X, Y, 0, 0, Width, Height, Width, Height
```
In that line see the Tex_GUI (45). I put both graphic for it, but it works. This is the graphic.
![](http://s17.postimg.org/60w95zxzz/image.png)
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...