erkro1 Posted May 2, 2012 Share Posted May 2, 2012 [![](http://filehost.worldlifewarfare.com/pics/4b5113b3bfd24516a402e36820882ec3.bmp)](http://filehost.worldlifewarfare.com/#4b5113b3bfd24516a402e36820882ec3.bmp) Link to comment Share on other sites More sharing options...
Justn Posted May 2, 2012 Share Posted May 2, 2012 Yes mine looks the same the txt is not centered or something Link to comment Share on other sites More sharing options...
erkro1 Posted May 2, 2012 Share Posted May 2, 2012 It looks like something that can be fixed by using Trim$ a few times, but I'm not sure that will work. Link to comment Share on other sites More sharing options...
Mondo Posted May 2, 2012 Author Share Posted May 2, 2012 @Erwin:> It looks like something that can be fixed by using Trim$ a few times, but I'm not sure that will work.Yeah the problem really is that the text width is "calculated" by guess estimating the pixel sizes of each letter, so you calculate the bubble size to be say 150 pixels, but the reality is that your text is only 100 pixels long (o's being wider that i's). And since the text is placed on the left border of the bubble you get 50 pixels of air.I've been thinking to fix it, just never came around it.The magic will happen at:``` ' render each line centralised y = y - (yheight - 5) For i = 1 To UBound(theArray) DrawTextNoShadow TexthDC, x - (xwidth - 10), y, theArray(i), QBColor(Black) ' .colour y = y + 12 Next```I just need to figure out how to better calculate x - (xwidth - 10). Link to comment Share on other sites More sharing options...
Domino_ Posted May 2, 2012 Share Posted May 2, 2012 Smtn works``` ' render each line centralised Y = Y - (yheight - 5) For i = 1 To UBound(theArray) DrawTextNoShadow TexthDC, x - (xwidth - (x / xwidth)), Y, theArray(i), QBColor(Black) ' .colour Y = Y + 12 Next```P.S. _**THIS WORKS ONLY WITH ~ 5+ LETTERS!**_ :( Link to comment Share on other sites More sharing options...
Mondo Posted May 2, 2012 Author Share Posted May 2, 2012 @Domino_:> Smtn works> > ```> ' render each line centralised> Y = Y - (yheight - 5)> For i = 1 To UBound(theArray)> DrawTextNoShadow TexthDC, x - (xwidth - (x / xwidth)), Y, theArray(i), QBColor(Black) ' .colour> Y = Y + 12> Next> > ```> P.S. _**THIS WORKS ONLY WITH ~ 5+ LETTERS!**_ :(Its a bit more complicated than that, you need to calculate the TextDC width, and then half that and substract that amount from the bubble's xwidth divided by half… or something fo the sort... ;)I'll review it tonight after work. Link to comment Share on other sites More sharing options...
Guest Posted May 2, 2012 Share Posted May 2, 2012 Uhm when i write something and press enter the game closes,there is no error ,weird. Link to comment Share on other sites More sharing options...
Mondo Posted May 2, 2012 Author Share Posted May 2, 2012 @Lumiere:> Uhm when i write something and press enter the game closes,there is no error ,weird.It did that to me once, the game closes when its broken in a routine that has no error handler…When it happened to me it was that my game didn't know how to handle the server message to open a bubble... So it could be somewhere in handlechatbubble routine or the declarations of the SChatBubble in the serverpackets. Link to comment Share on other sites More sharing options...
Guest Posted May 2, 2012 Share Posted May 2, 2012 @Mondo:> It did that to me once, the game closes when its broken in a routine that has no error handler…> > When it happened to me it was that my game didn't know how to handle the server message to open a bubble... So it could be somewhere in handlechatbubble routine or the declarations of the SChatBubble in the serverpackets.Oh dummy me,fixed ^^ thanksie Link to comment Share on other sites More sharing options...
Mondo Posted May 2, 2012 Author Share Posted May 2, 2012 Ok this is the corrected DrawChatBubble routine, it does center now.```' CHAT BUBBLE HACKPublic Sub DrawChatBubble(ByVal Index As Long)Dim theArray() As String, x As Long, Y As Long, i As Long, MaxWidth As Long, xwidth As Long, yheight As Long, colour As Long, x3 As Long, y3 As LongDim MMx As LongDim MMy As LongDim TOPLEFTrect As RECTDim TOPCENTERrect As RECTDim TOPRIGHTrect As RECTDim MIDDLELEFTrect As RECTDim MIDDLECENTERrect As RECTDim MIDDLERIGHTrect As RECTDim BOTTOMLEFTrect As RECTDim BOTTOMCENTERrect As RECTDim BOTTOMRIGHTrect As RECTDim TIPrect As RECT' DESIGNATE CHATBUBBLE SECTIONS FROM CHATBUBBLE IMAGEWith TOPRIGHTrect .top = 0 .Bottom = .top + 4 .Left = 0 .Right = .Left + 4End WithWith TOPCENTERrect .top = 0 .Bottom = .top + 4 .Left = 4 .Right = .Left + 4End WithWith TOPLEFTrect .top = 0 .Bottom = .top + 4 .Left = 8 .Right = .Left + 4End WithWith MIDDLERIGHTrect .top = 4 .Bottom = .top + 4 .Left = 0 .Right = .Left + 4End WithWith MIDDLECENTERrect .top = 4 .Bottom = .top + 4 .Left = 4 .Right = .Left + 4End WithWith MIDDLELEFTrect .top = 4 .Bottom = .top + 4 .Left = 8 .Right = .Left + 4End WithWith BOTTOMRIGHTrect .top = 8 .Bottom = .top + 4 .Left = 0 .Right = .Left + 4End WithWith BOTTOMCENTERrect .top = 8 .Bottom = .top + 4 .Left = 4 .Right = .Left + 4End WithWith BOTTOMLEFTrect .top = 8 .Bottom = .top + 4 .Left = 8 .Right = .Left + 4End WithWith TIPrect .top = 12 .Bottom = .top + 4 .Left = 0 .Right = .Left + 4End With Call DDS_BackBuffer.SetForeColor(RGB(255, 255, 255)) With chatBubble(Index) If .targetType = TARGET_TYPE_PLAYER Then ' it's a player If GetPlayerMap(.target) = GetPlayerMap(MyIndex) Then ' change the colour depending on access colour = QBColor(Yellow) ' it's on our map - get co-ords x = ConvertMapX((Player(.target).x * 32) + Player(.target).XOffset) + 16 Y = ConvertMapY((Player(.target).Y * 32) + Player(.target).YOffset) - 16 ' word wrap the text WordWrap_Array .Msg, ChatBubbleWidth, theArray ' find max width For i = 1 To UBound(theArray) If getWidth(TexthDC, theArray(i)) > MaxWidth Then MaxWidth = getWidth(TexthDC, theArray(i)) Next ' calculate the new position xwidth relative to DDS_ChatBubble and yheight relative to DDS_ChatBubble xwidth = 10 + MaxWidth ' the first five is just air. yheight = 3 + (UBound(theArray) * 7) ' the first three are just air. ' Compensate the yheight drift Y = Y - yheight ' render bubble ' top left ' RenderTexture Tex_GUI(37), xwidth - 9, yheight - 5, 0, 0, 9, 5, 9, 5 Call Engine_BltFast(x + (xwidth + 4), Y - (yheight - 4), DDS_ChatBubble, TOPLEFTrect, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) ' top center ' RenderTexture Tex_GUI(37), xwidth + MaxWidth, yheight - 5, 119, 0, 9, 5, 9, 5 For x3 = x - (xwidth - 8) To x + (xwidth) Call Engine_BltFast(x3, Y - (yheight - 4), DDS_ChatBubble, TOPCENTERrect, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) Next x3 ' top right ' RenderTexture Tex_GUI(37), xwidth, yheight - 5, 9, 0, MaxWidth, 5, 5, 5 Call Engine_BltFast(x - (xwidth - 4), Y - (yheight - 4), DDS_ChatBubble, TOPRIGHTrect, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) ' middle left ' RenderTexture Tex_GUI(37), xwidth - 9, y, 0, 19, 9, 6, 9, 6 For y3 = Y - (yheight - 8) To Y + (yheight) Call Engine_BltFast(x + (xwidth + 4), y3, DDS_ChatBubble, MIDDLELEFTrect, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) Next y3 ' middle center ' RenderTexture Tex_GUI(37), xwidth + MaxWidth, y, 119, 19, 9, 6, 9, 6 For y3 = Y - (yheight - 8) To Y + (yheight) For x3 = x - (xwidth - 8) To x + (xwidth) Call Engine_BltFast(x3, y3, DDS_ChatBubble, MIDDLECENTERrect, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) Next x3 Next y3 ' middle right ' RenderTexture Tex_GUI(37), xwidth, y, 9, 19, (MaxWidth \ 2) - 5, 6, 9, 6 For y3 = Y - (yheight - 8) To Y + (yheight) Call Engine_BltFast(x - (xwidth - 4), y3, DDS_ChatBubble, MIDDLERIGHTrect, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) Next y3 ' bottom left ' RenderTexture Tex_GUI(37), xwidth + (MaxWidth \ 2) + 6, y, 9, 19, (MaxWidth \ 2) - 5, 6, 9, 6 Call Engine_BltFast(x + (xwidth + 4), Y + (yheight + 4), DDS_ChatBubble, BOTTOMLEFTrect, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) ' bottom center ' RenderTexture Tex_GUI(37), xwidth - 9, yheight, 0, 6, 9, (UBound(theArray) * 12), 9, 1 For x3 = x - (xwidth - 8) To x + (xwidth) Call Engine_BltFast(x3, Y + (yheight + 4), DDS_ChatBubble, BOTTOMCENTERrect, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) Next x3 ' bottom right ' RenderTexture Tex_GUI(37), xwidth + MaxWidth, yheight, 119, 6, 9, (UBound(theArray) * 12), 9, 1 Call Engine_BltFast(x - (xwidth - 4), Y + (yheight + 4), DDS_ChatBubble, BOTTOMRIGHTrect, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) ' little pointy bit ' RenderTexture Tex_GUI(37), x - 5, y, 58, 19, 11, 11, 11, 11 Call Engine_BltFast(x, Y + (yheight + 8), DDS_ChatBubble, TIPrect, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) ' Lock the backbuffer so we can draw text and names TexthDC = DDS_BackBuffer.GetDC ' render each line centralised Y = Y - (yheight - 5) For i = 1 To UBound(theArray) DrawTextNoShadow TexthDC, x - (getWidth(TexthDC, theArray(i)) - 10), Y, theArray(i), QBColor(Black) ' .colour Y = Y + 12 Next ' Release DC DDS_BackBuffer.ReleaseDC TexthDC End If End If ' check if it's timed out - close it if so If .Timer + 5000 < GetTickCount Then .active = False End If End WithEnd Sub' CHAT BUBBLE HACK```The real change was only to call the old getwidth function, passing the texthdc and the message as parameters and it gets you back the real size, no guesstimating anymore.Try it out… Link to comment Share on other sites More sharing options...
Guest Posted May 3, 2012 Share Posted May 3, 2012 Very good,thank you ^.^But is not really centered,tell me where to change some numbers and such to fit?Because the text is more to the right side![](http://s15.postimage.org/f0fjueqfv/hppl.png) Link to comment Share on other sites More sharing options...
DarkDino Posted May 4, 2012 Share Posted May 4, 2012 @Yui:> link=topic=79790.msg855811#msg855811 date=1335940442]> Did you even edit both client and server?> > Nice tutorial by the way :>Yes and no display chat bubble :S!? how too fix D; Link to comment Share on other sites More sharing options...
erkro1 Posted May 4, 2012 Share Posted May 4, 2012 @DarkDino:> Yes and no display chat bubble :S!? how too fix D;Did you compile both client and server? Link to comment Share on other sites More sharing options...
DarkDino Posted May 5, 2012 Share Posted May 5, 2012 @Erwin:> Did you compile both client and server?Yes i compile client and server, no display chat bubble and no vb errors S: Link to comment Share on other sites More sharing options...
erkro1 Posted May 5, 2012 Share Posted May 5, 2012 @DarkDino:> Yes i compile client and server, no display chat bubble and no vb errors S:Have you put the speech picture in your graphics folder? Link to comment Share on other sites More sharing options...
DarkDino Posted May 5, 2012 Share Posted May 5, 2012 @Erwin:> Have you put the speech picture in your graphics folder?Yes D:, and no display bubble Link to comment Share on other sites More sharing options...
Killa_ Posted May 5, 2012 Share Posted May 5, 2012 Select the map channel,if you have added chat channels. Link to comment Share on other sites More sharing options...
DarkDino Posted May 5, 2012 Share Posted May 5, 2012 I dont added chat channels :/ Link to comment Share on other sites More sharing options...
Guest Posted May 6, 2012 Share Posted May 6, 2012 @DarkDino:> I dont added chat channels :/Then do again the tutorial ,instead waiting for answers,is not so long,try again! ;) Link to comment Share on other sites More sharing options...
erkro1 Posted May 6, 2012 Share Posted May 6, 2012 @Lumiere:> Very good,thank you ^.^> But is not really centered,tell me where to change some numbers and such to fit?> Because the text is more to the right side> ![](http://s15.postimage.org/f0fjueqfv/hppl.png)Bump on this problem. Link to comment Share on other sites More sharing options...
DarkDino Posted May 7, 2012 Share Posted May 7, 2012 @Lumiere:> Then do again the tutorial ,instead waiting for answers,is not so long,try again! ;)i reinstall and none, the bubble don't display :/ Link to comment Share on other sites More sharing options...
Justn Posted May 7, 2012 Share Posted May 7, 2012 @DarkDino:> i reinstall and none, the bubble don't display :/Ur doing something wrong bro.. if u want send me ur source and ill add it for u.. even though there are still issues with the txt Link to comment Share on other sites More sharing options...
DarkDino Posted May 7, 2012 Share Posted May 7, 2012 @Justn:> Ur doing something wrong bro.. if u want send me ur source and ill add it for u.. even though there are still issues with the txtbut i install all codes in respective modules S: no have runtime erros D:. Link to comment Share on other sites More sharing options...
Justn Posted May 7, 2012 Share Posted May 7, 2012 Well I can't help u out if there is no errors I'm sure its something simple… Are u sure u compiled everything? Link to comment Share on other sites More sharing options...
DarkDino Posted May 7, 2012 Share Posted May 7, 2012 Yes i compiled everything! and me reinstall 4 times, use Modification(S) 2.6 Nova Source x.x. 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