Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
[KoZ]MatthewPe2

DB Bug Fix for CodeImp

Recommended Posts

Could you please add this to frmThings?

Private Sub txtThing_Change()
     Dim Cat As String
     Dim a As Long
     
     'Erase thing preview
     Set imgThing.Picture = Nothing
     
     'Select current thing type
     If (txtThing.Text <> "") Then
          
          'Do not give an error when the item cant be found
          On Local Error Resume Next
          trvThings.SelectedItem.selected = False
          trvThings.nodes("T" & txtThing.Text).selected = True
          trvThings.nodes("T" & txtThing.Text).EnsureVisible
          lstThings.SelectedItem.selected = False
          lstThings.ListItems("T" & txtThing.Text).selected = True
          lstThings.ListItems("T" & txtThing.Text).EnsureVisible
          On Local Error GoTo 0
          
          'Check if a thing type is given
          If (Trim$(txtThing.Text) <> "") Then
               
               'Show thing preview if possible
               GetScaledSpritePicture Val(txtThing.Text), imgThing, picThing.ScaleWidth, picThing.ScaleHeight, False
               
               'Find its category
               Cat = GetThingTypeCategory(Val(txtThing.Text))
               
               'Check if in any category
               If (Trim$(Cat) <> "") Then
                    
               'The Bug Fix I Made
                    If (mapconfig("thingtypes")(Cat).Exists(txtThing.Text) = False) Then
                    Exit Sub
                    End If
                    
                    'Check if the thing has any arguments
                    If mapconfig("thingtypes")(Cat)(txtThing.Text).Exists("arg1") Or _
                       mapconfig("thingtypes")(Cat)(txtThing.Text).Exists("arg2") Or _
                       mapconfig("thingtypes")(Cat)(txtThing.Text).Exists("arg3") Or _
                       mapconfig("thingtypes")(Cat)(txtThing.Text).Exists("arg4") Or _
                       mapconfig("thingtypes")(Cat)(txtThing.Text).Exists("arg5") Then
                         
                         'Disable thing effect
                         txtType.Enabled = False
                         lblEffect.ForeColor = vbGrayText
                         cmdSelectType.Enabled = False
                         
                         'Set all arguments
                         For a = 0 To 4
                              
                              'Check if argument is defined
                              If (mapconfig("thingtypes")(Cat)(txtThing.Text).Exists("arg" & a + 1)) Then
                                   
                                   'Set argument
                                   lblArgument(a).Caption = mapconfig("thingtypes")(Cat)(txtThing.Text)("arg" & a + 1) & ":"
                                   lblArgument(a).ForeColor = vbButtonText
                                   'txtArgument(a).Enabled = True
                              Else
                                   
                                   'Disable argument
                                   lblArgument(a).Caption = "Argument " & a + 1 & ":"
                                   lblArgument(a).ForeColor = vbGrayText
                                   'txtArgument(a).Enabled = False
                              End If
                         Next a
                    Else
                         
                         'Enable thing effect
                         txtType.Enabled = True
                         lblEffect.ForeColor = vbButtonText
                         cmdSelectType.Enabled = True
                         
                         'Let the arguments be set by effect
                         txtType_Change
                    End If
                    
                    'Show thing properties
                    lblThingWidth.Caption = GetThingWidth(Val(txtThing.Text))
                    lblThingHeight.Caption = GetThingHeight(Val(txtThing.Text))
                    lblThingHangs.Caption = YesNo(GetThingHangs(Val(txtThing.Text)))
                    lblThingBlocks.Caption = GetThingBlockingDesc(GetThingBlocking(Val(txtThing.Text)))
               Else
                    
                    'Enable thing effect
                    txtType.Enabled = True
                    lblEffect.ForeColor = vbButtonText
                    cmdSelectType.Enabled = True
                    
                    'No clue about its properties
                    lblThingWidth.Caption = "?"
                    lblThingHeight.Caption = "?"
                    lblThingHangs.Caption = "?"
                    lblThingBlocks.Caption = "?"
                    
                    'Let the arguments be set by effect
                    txtType_Change
               End If
          End If
     End If
End Sub
it fixes the error when you type an invalid number like: 1-

Share this post


Link to post

I dont know what you changed in there, but I believe I already fixed that error for next version (see changelog). Thanks anyway ;)

Share this post


Link to post

this is the bit

               'The Bug Fix I Made
                    If (mapconfig("thingtypes")(Cat).Exists(txtThing.Text) = False) Then
                    Exit Sub
                    End If

the changelog hadn't had it because it was a rare but annoying

Share this post


Link to post

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
×