Kaymak Posted May 27, 2015 Author Share Posted May 27, 2015 **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 = NothingEnd SubPublic 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 = NothingEnd 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 = TrueEnd SubPrivate 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 = TrueEnd 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 LongDim 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 NextEnd 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 StringPublic 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 NextEnd SubPublic 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 resetClickedButtonsEnd 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 ByteEnd 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 More sharing options...
GalacticGlum Posted May 27, 2015 Share Posted May 27, 2015 Goodjob! I really like this! Will be using it. Link to comment Share on other sites More sharing options...
Colonello Posted May 27, 2015 Share Posted May 27, 2015 This is an awesome tutorial and something I think every game should use. I could definitely see this being used to inform players of the weekly patch notes, new quests, an upcoming update, etc. Link to comment Share on other sites More sharing options...
Kaymak Posted May 27, 2015 Author Share Posted May 27, 2015 thank you alot Link to comment Share on other sites More sharing options...
Agoraphobic Posted May 27, 2015 Share Posted May 27, 2015 Looks great, this is something people could use. Link to comment Share on other sites More sharing options...
Kaymak Posted May 27, 2015 Author Share Posted May 27, 2015 I try to improve it in a couple of days. Link to comment Share on other sites More sharing options...
Kitam Posted May 28, 2015 Share Posted May 28, 2015 What name is news graphics? ( in Gui folders) :P Link to comment Share on other sites More sharing options...
Growlith1223 Posted May 28, 2015 Share Posted May 28, 2015 @'Kitam':> What name is news graphics? ( in Gui folders) :PRenderTexture Tex_GUI(21), look for 21.png in the gui foder Link to comment Share on other sites More sharing options...
Miharukun Posted December 23, 2015 Share Posted December 23, 2015 If you guys encounter the same problem as me (The news invisible or didn't show up.) Try thisAt 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 LongDim 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 NextEnd 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 DrawNewClassIf 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 More sharing options...
skyzero Posted December 27, 2015 Share Posted December 27, 2015 How would provide Example file ?I tried to do with any here , but nothing happened gave error in DX8I think it was because of the dimensions . Link to comment Share on other sites More sharing options...
BladeHart Posted December 27, 2015 Share Posted December 27, 2015 Can someone help me with the error i get? i dont know what to do anymore with this error :(![](http://i.imgur.com/shCbX9g.png) Link to comment Share on other sites More sharing options...
Solstice Posted December 27, 2015 Share Posted December 27, 2015 @'BladeHart':> Can someone help me with the error i get? i dont know what to do anymore with this error :(> ![](http://i.imgur.com/shCbX9g.png)Do you have anything called "GUI_NEWS" in your project? Link to comment Share on other sites More sharing options...
BladeHart Posted December 27, 2015 Share Posted December 27, 2015 Yes i have it since its from this tutorial, do you know what to do when i get that error? where should i add to make it works? :huh: Link to comment Share on other sites More sharing options...
abhi2011 Posted December 27, 2015 Share Posted December 27, 2015 What exactly is the error? You just showed us a highlighted line. For all I know, that's not an error, just a pic of the next line of execution. Link to comment Share on other sites More sharing options...
Miharukun Posted December 28, 2015 Share Posted December 28, 2015 @'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 More sharing options...
skyzero Posted December 28, 2015 Share Posted December 28, 2015 @Edit Fixed ! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now