Jump to content

Click on drawn text.


Recoil

Recommended Posts

Yay, the first 10 consecutive posts in a forum I should get a brownie, or a shirt :P

When I draw this text to the screen, how on earth do I select the index of it so that I can bring up the info panel?  I need to get it by the index or name because this list will be scrollable >100 quests.

Public Sub DrawQuestLogWindow()
        If Not InGame Then Exit Sub

        QuestLogWindow.DrawControl(GameWindow, (frmMainGame.GameScreen.Width - QuestLogWindow.ControlLocation.Width) - ScreenPadding, (frmMainGame.GameScreen.Height - QuestLogWindow.ControlLocation.Height) - ScreenPadding)
        QuestItemWindow.DrawControl(GameWindow, QuestLogWindow.ControlLocation.X + 20, QuestLogWindow.ControlLocation.Y + 20)
        
        Dim newLinePos As Integer = QuestItemWindow.ControlLocation.Y + QuestItemWindow.Location.Y + 2
        For i = 1 To QuestCount

            DrawText(QuestItemWindow.ControlLocation.X + 2, newLinePos, QuestList(i), SFML.Graphics.Color.Black, SfmlChatFont, FONT_CHAT_SIZE, GameWindow)
            newLinePos += ChatLineSpacing
            
        Next

        QuestInfoButton.DrawControl(GameWindow, (QuestLogWindow.ControlLocation.X + (QuestLogWindow.ControlLocation.Width / 2)) - QuestInfoButton.ControlLocation.Width / 2, (QuestLogWindow.ControlLocation.Y + QuestLogWindow.ControlLocation.Height) - (QuestInfoButton.ControlLocation.Height) - WindowPadding)
        QuestLogDownButton.DrawControl(GameWindow, QuestItemWindow.ControlLocation.X + QuestItemWindow.ControlLocation.Width + 10, (QuestItemWindow.ControlLocation.Y + QuestItemWindow.ControlLocation.Height) - QuestLogDownButton.ControlLocation.Height)
        QuestLogUpButton.DrawControl(GameWindow, QuestItemWindow.ControlLocation.X + QuestItemWindow.ControlLocation.Width + 10, QuestLogWindow.ControlLocation.Y + 20)

    End Sub

width=500http://i61.tinypic.com/2j2c215.jpg[/img]

Link to comment
Share on other sites

Divide your quests into pages.

Say that you can have 10 quests per page (per scroll) and 100 quests total. You will have to start using a PageIndex variable.

For example, PageIndex = 0 would mean the first page.

The math to show 10 quests per page would look like this

Dim newLinePos As Integer = QuestItemWindow.ControlLocation.Y + QuestItemWindow.Location.Y + 2
dim y = 0 'This is the position in the list you are drawing
For i = PageIndex * 10 + 1 to PageIndex * 10 + 1 + 10
   DrawText(QuestItemWindow.ControlLocation.X + 2, newLinePos + y * ChatLineSpacing, QuestList(i), SFML.Graphics.Color.Black, SfmlChatFont, FONT_CHAT_SIZE, GameWindow)
   y = y + 1
next

Later on you check in your QuestItemWindow mouse events.

You do something like this.

Dim newLinePos As Integer = QuestItemWindow.ControlLocation.Y + QuestItemWindow.Location.Y + 2
dim y = 0 'This is the position in the list you are drawing
For i = PageIndex * 10 + 1 to PageIndex * 10 + 1 + 10
   if (MouseX >= QuestItemWindow.ControlLocation.X + 1 and MouseX <= QuestItemWindow.ControlLocation.X + 1 + QUESTITEMWINDOWWIDTH) then
       if (MouseY >= newLinePos + y * ChatLineSpacing and MouseY <= newLinePos + y * ChatLineSpacing + ChatLineSpacing) then
               'Clicked on quest number i do stuff and then exit sub
        end if
   end if
   y = y + 1
next

Link to comment
Share on other sites

I have had to modify things slightly to only show 10 quests instead of 11 with a (9).  At the bottom I am doing this in the mouse up event:

For i = PageIndex * 10 + 1 To PageIndex * 10 + 1 + 9

            If QuestListButton1.ControlLocation.Contains(e.Location) Then
                QuestListButton1.MouseIsOver = False
                ' Display info window
                ' #HERE
                AskQuest(Quest(i).Name, Quest(i).QuestDesc, "", "", True)
                ' AskQuest(ByVal qName As String, ByVal qText As String, ByVal qAcceptText As String, ByVal qDeclineText As String, Optional ByVal qNew As Boolean = True)
            End If

...more button codes...

Which is supposed to replace:

Dim newLinePos As Integer = QuestItemWindow.ControlLocation.Y + QuestItemWindow.Location.Y + 2
dim y = 0 'This is the position in the list you are drawing
For i = PageIndex * 10 + 1 to PageIndex * 10 + 1 + 10
   if (MouseX >= QuestItemWindow.ControlLocation.X + 1 and MouseX <= QuestItemWindow.ControlLocation.X + 1 + QUESTITEMWINDOWWIDTH) then
       if (MouseY >= newLinePos + y * ChatLineSpacing and MouseY <= newLinePos + y * ChatLineSpacing + ChatLineSpacing) then
               'Clicked on quest number i do stuff and then exit sub
        end if
   end if
   y = y + 1
next

At the top I have declared PageIndex As Integer = 0.  So right now when I click on one of the buttons I have added as a backing to the text it will display the info panel but it is not displaying the name or the text.  I have copied the code that I am using for when the quest is given and only changed the name, pretty much identical code.

Link to comment
Share on other sites

In my abandon mouse up event I am doing this:

For i = PageIndex * 10 + 1 To PageIndex * 10 + 1 + 9

                InInfoQuest = False
                PlayerHandleQuest((i), 2)
                'Exit For

            Next

I am trying to send the selected quest index to the server to remove the quest log item from the list, but I am pulling null exceptions.  Other ways we have tried it always says that quest 1 has been cancelled each time, but that remains in the list as well as the one we are trying to delete.

We needz help.

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
×
×
  • Create New...