Dialog.frm.VisualBasicSourceCode.c

00001 VERSION 5.00
00002 Begin VB.Form Dialog 
00003    BorderStyle     =   3  'Fixed Dialog
00004    Caption         =   "TittyMemory Settings"
00005    ClientHeight    =   1635
00006    ClientLeft      =   2760
00007    ClientTop       =   3750
00008    ClientWidth     =   6030
00009    Icon            =   "Dialog.frx":0000
00010    LinkTopic       =   "Form1"
00011    MaxButton       =   0   'False
00012    MinButton       =   0   'False
00013    ScaleHeight     =   1635
00014    ScaleWidth      =   6030
00015    ShowInTaskbar   =   0   'False
00016    Begin VB.ComboBox Combo3 
00017       Height          =   315
00018       Left            =   2280
00019       TabIndex        =   4
00020       Top             =   1080
00021       Width           =   2175
00022    End
00023    Begin VB.ComboBox Combo2 
00024       Height          =   315
00025       Left            =   2280
00026       TabIndex        =   3
00027       Top             =   600
00028       Width           =   2175
00029    End
00030    Begin VB.ComboBox Combo1 
00031       Height          =   315
00032       Left            =   2280
00033       TabIndex        =   2
00034       Top             =   120
00035       Width           =   2175
00036    End
00037    Begin VB.CommandButton CancelButton 
00038       Caption         =   "Cancel"
00039       Height          =   375
00040       Left            =   4680
00041       TabIndex        =   1
00042       Top             =   600
00043       Width           =   1215
00044    End
00045    Begin VB.CommandButton OKButton 
00046       Caption         =   "OK"
00047       Height          =   375
00048       Left            =   4680
00049       TabIndex        =   0
00050       Top             =   120
00051       Width           =   1215
00052    End
00053    Begin VB.Label Label3 
00054       AutoSize        =   -1  'True
00055       Caption         =   "select Gamefield"
00056       Height          =   195
00057       Left            =   360
00058       TabIndex        =   7
00059       Top             =   1080
00060       Width           =   1170
00061       WordWrap        =   -1  'True
00062    End
00063    Begin VB.Label Label2 
00064       AutoSize        =   -1  'True
00065       Caption         =   "select Deck"
00066       Height          =   195
00067       Left            =   360
00068       TabIndex        =   6
00069       Top             =   600
00070       Width           =   855
00071       WordWrap        =   -1  'True
00072    End
00073    Begin VB.Label Label1 
00074       AutoSize        =   -1  'True
00075       Caption         =   "select Card-Set"
00076       Height          =   195
00077       Left            =   360
00078       TabIndex        =   5
00079       Top             =   120
00080       Width           =   1080
00081       WordWrap        =   -1  'True
00082    End
00083 End
00084 Attribute VB_Name = "Dialog"
00085 Attribute VB_GlobalNameSpace = False
00086 Attribute VB_Creatable = False
00087 Attribute VB_PredeclaredId = True
00088 Attribute VB_Exposed = False
00089 
00090 Option Explicit
00091 
00092 Private Sub Form_Load()
00093     Dim cards() As String
00094     Dim decks() As String
00095     Dim i As Long
00096     Combo1.text = Form1.cardName
00097     Combo2.text = Form1.deckName
00098     cards = getCardNames()
00099     If (cards(0) <> "::~~##") Then
00100         For i = 0 To UBound(cards) - 1
00101             Combo1.AddItem cards(i)
00102         Next i
00103     End If
00104     decks = getDeckNames()
00105     If (decks(0) <> "::~~##") Then
00106         For i = 0 To UBound(decks) - 1
00107             Combo2.AddItem decks(i)
00108         Next i
00109     End If
00110     Combo3.AddItem "4 x 4"
00111     Combo3.AddItem "5 x 4"
00112     Combo3.AddItem "6 x 4"
00113     Combo3.AddItem "6 x 5"
00114     Combo3.AddItem "6 x 6"
00115     Combo3.text = Form1.squareMaxX & " x " & Form1.squareMaxY
00116 End Sub
00117 
00118 Function getDeckNames() As String()
00119     On Error GoTo Hell
00120     Dim res() As String
00121     Dim path As String
00122     Dim fileFound As String
00123     Dim i As Long
00124     ReDim res(1)
00125     res(0) = "::~~##"
00126     path = App.path & "\pics\" & "deck*.*"
00127     fileFound = Dir(path)
00128     Do
00129         If (fileFound <> "") Then
00130             i = i + 1
00131             ReDim Preserve res(i)
00132             res(i - 1) = getFileName(fileFound)
00133         Else
00134             Exit Do
00135         End If
00136         DoEvents
00137         fileFound = Dir
00138     Loop
00139     getDeckNames = res
00140     Exit Function
00141 Hell:
00142     MsgBox "Error finding Deck-Types" & vbNewLine & _
00143             "Please read the 'ReadMe.txt' file.", _
00144             vbCritical, "TittyMemory"
00145 End Function
00146 
00147 Function getCardNames() As String()
00148     On Error GoTo Hell
00149     Dim res() As String
00150     Dim path As String
00151     Dim fileFound As String
00152     Dim lastFound As String
00153     Dim i As Long
00154     Dim k As Long
00155     Dim saveFlag As Boolean
00156     ReDim res(1)
00157     lastFound = "::~~##"
00158     res(0) = lastFound
00159     path = App.path & "\pics\" & "card*.*"
00160     fileFound = Dir(path)
00161     Do
00162         If (fileFound <> "") Then
00163             If (InStr(fileFound, lastFound) = 0) Then
00164                 saveFlag = False
00165                 For k = 0 To UBound(res) - 1
00166                     If (InStr(fileFound, res(k)) > 0) Then
00167                         saveFlag = True
00168                     End If
00169                 Next k
00170                 If Not (saveFlag) Then
00171                     i = i + 1
00172                     ReDim Preserve res(i)
00173                     lastFound = getFileName(fileFound)
00174                     lastFound = Left$(lastFound, Len(lastFound) - 2)
00175                     res(i - 1) = lastFound
00176                 End If
00177             End If
00178         Else
00179             Exit Do
00180         End If
00181         DoEvents
00182         fileFound = Dir
00183     Loop
00184     getCardNames = res
00185     Exit Function
00186 Hell:
00187     MsgBox "Error finding Card-Types." & vbNewLine & _
00188             "Please read the 'ReadMe.txt' file.", _
00189             vbCritical, "TittyMemory"
00190 End Function
00191 
00192 
00193 Function getFileName(path As String) As String
00194     Dim res As String
00195     Dim slashPos As Long
00196     slashPos = InStrRev(path, "\")
00197     res = Right$(path, Len(path) - slashPos)
00198     getFileName = Left$(res, Len(res) - 4)
00199 End Function
00200 
00201 Private Sub OKButton_Click()
00202     Form1.cardName = Combo1.text
00203     Form1.deckName = Combo2.text
00204     Form1.squareMaxX = Left$(Combo3.text, 1)
00205     Form1.squareMaxY = Right$(Combo3.text, 1)
00206     Unload Me
00207 End Sub
00208 
00209 Private Sub CancelButton_Click()
00210     Unload Me
00211 End Sub
00212 

Generated on Sun Jan 6 16:43:10 2008 for TittyMemory by  doxygen 1.5.4