Advertisement
eldiegotee

Untitled

Dec 29th, 2022
770
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2.  
  3. Private Const p_SEGUNDOS As Byte = 7
  4.  
  5. Private p_CANTIDADDIALOGOS As Byte
  6.  
  7. Private Type t_GuildDlg
  8.     Texto As String
  9.     Segundos As Byte
  10. End Type
  11.  
  12. Private p_Dialogos() As t_GuildDlg
  13. Private p_Activo As Boolean
  14.  
  15. Public Property Let CantidadDialogos(ByVal v As Byte)
  16.     If v > 0 Then
  17.         ReDim Preserve p_Dialogos(1 To v) As t_GuildDlg
  18.         p_CANTIDADDIALOGOS = v
  19.     End If
  20. End Property
  21.  
  22. ''
  23. ' Removes all dialogs from screen.
  24.  
  25. Public Sub RemoveDialogs()
  26.     '***************************************************
  27.    'Author: Juan Martín Sotuyo Dodero (Maraxus)
  28.    'Last Modification: 04/02/07
  29.    'Removes all dialogs
  30.    '***************************************************
  31.    Dim i As Long
  32.  
  33.     For i = 1 To p_CANTIDADDIALOGOS
  34.         p_Dialogos(i).Texto = vbNullString
  35.     Next i
  36. End Sub
  37.  
  38. ''
  39. ' Retrieves the number of dialogs to be displayed on screen.
  40. '
  41. ' @return   The number of dialogs to be displayed on screen.
  42.  
  43. Public Property Get CantidadDialogos() As Byte
  44.     '***************************************************
  45.    'Author: Juan Martín Sotuyo Dodero (Maraxus)
  46.    'Last Modification: 04/01/07
  47.    'Retrieves the number of dialogs to be displayed on screen
  48.    '***************************************************
  49.    CantidadDialogos = p_CANTIDADDIALOGOS
  50. End Property
  51.  
  52. Public Property Let Activo(ByVal v As Boolean)
  53.     p_Activo = v
  54. End Property
  55.  
  56. Public Property Get Activo() As Boolean
  57.     Activo = p_Activo
  58. End Property
  59.  
  60. Private Sub Class_Initialize()
  61.     p_CANTIDADDIALOGOS = 5
  62.     ReDim p_Dialogos(1 To p_CANTIDADDIALOGOS) As t_GuildDlg
  63.     p_Activo = True
  64. End Sub
  65.  
  66. Public Sub Draw()
  67.    
  68.     If Not p_Activo Then Exit Sub
  69.    
  70.     Dim i As Long
  71.     Dim Count As Byte
  72.  
  73.     For i = 1 To p_CANTIDADDIALOGOS
  74.         If LenB(p_Dialogos(i).Texto) > 0 Then
  75.             Count = Count + 1
  76.             If left$(p_Dialogos(i).Texto, 1) = Chr$(3) Then
  77.                 Call DrawText(10, (Count * 10), mid$(p_Dialogos(i).Texto, 2), -16711936)
  78.             Else
  79.                 Call DrawText(10, (Count * 10), p_Dialogos(i).Texto, -256)
  80.             End If
  81.         End If
  82.     Next i
  83.    
  84. End Sub
  85.  
  86. Public Sub PassTimer()
  87.  
  88.     Dim i As Byte
  89.  
  90.     For i = 1 To p_CANTIDADDIALOGOS
  91.         If p_Dialogos(i).Segundos > 0 Then
  92.             p_Dialogos(i).Segundos = p_Dialogos(i).Segundos - 1
  93.            
  94.             If p_Dialogos(i).Segundos < 1 Then
  95.                 p_Dialogos(i).Texto = vbNullString
  96.             End If
  97.         End If
  98.     Next i
  99.  
  100. End Sub
  101.  
  102. ''
  103. ' Splits dialogs into lines fitting properly the render area and inserts them
  104.  
  105. Public Sub PushBackText(ByVal s As String)
  106.     '***************************************************
  107.    'Author: Juan Martín Sotuyo Dodero (Maraxus)
  108.    'Last Modification: 07/04/2009
  109.    'Splits dialogs into lines fitting properly the render area and inserts them
  110.    '07/04/2009: Now cuts the string properly in spite of not fitting in the screen. This avoids an infite loop.
  111.    '***************************************************
  112.    Dim Str As String
  113.     Dim Tmp As Integer
  114.  
  115.     Str = s
  116.  
  117.     ' If it's too long to fit, split it
  118.    Do While frmMain.TextWidth(Str) > 500
  119.         Tmp = InStrRev(Str, " ")
  120.  
  121.         If Tmp = 0 Then Exit Do
  122.  
  123.         Str = left$(Str, Tmp - 1)
  124.     Loop
  125.  
  126.     'Show message and continue with the rest
  127.    Call RealPushBackText(Str)
  128.  
  129.     If LenB(Str) <> LenB(s) Then
  130.         Call PushBackText(Right$(s, Len(s) - Len(Str) - 1))
  131.     End If
  132. End Sub
  133.  
  134. Private Sub RealPushBackText(ByVal s As String)
  135.  
  136.     s = Trim$(s)
  137.  
  138.     Dim i As Byte
  139.     Dim Vacio As Boolean
  140.  
  141.     If p_CANTIDADDIALOGOS > 0 Then
  142.         i = p_CANTIDADDIALOGOS
  143.         Vacio = True
  144.         While i > 0 And Vacio
  145.             Vacio = p_Dialogos(i).Texto = vbNullString
  146.             If Vacio Then i = i - 1
  147.         Wend
  148.         If i = p_CANTIDADDIALOGOS Then
  149.             'hay q scrollear, estamos llenos
  150.            i = 1
  151.             While i < p_CANTIDADDIALOGOS
  152.                 p_Dialogos(i) = p_Dialogos(i + 1)
  153.                 i = i + 1
  154.             Wend
  155.             p_Dialogos(i).Texto = s
  156.             p_Dialogos(i).Segundos = p_SEGUNDOS
  157.         Else
  158.             p_Dialogos(i + 1).Texto = s
  159.             p_Dialogos(i + 1).Segundos = p_SEGUNDOS
  160.         End If
  161.     End If
  162.  
  163. End Sub
  164.  
  165.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement