editmod.bas

来自「吃豆子游戏的源代码。 嘿嘿」· BAS 代码 · 共 119 行

BAS
119
字号
Attribute VB_Name = "EditMod"
Global OpenIsFinished As Boolean 'used when opening files
Global FirstForm As New EditFrm  'creates a copy of EditFrm
Global IsLoaded As Boolean       'Is the First form already loaded?
Global nForm As Form             'is used when refering to child forms
Global NumFrms As Integer        'the number of forms loaded
Global nEdit(250) As Form        'is used when loading new child forms
Private LoadTimes As Integer     'used when showing the percent bar
' see if the level already exsists
' (usind in open/save dlg)
Public Function LevExists(LevelNumber As Integer, FileListName As FileListBox) As Boolean
FileListName.Refresh
FileListName.Path = App.Path & "\levels\" 'creates a list of files in the levels directory
levfilename = Trim("Level" & Trim(Str(LevelNumber)) & ".pml") 'creat the file name
For I = 0 To FileListName.ListCount
 If LCase(levfilename) = LCase(Trim(FileListName.List(I))) Then 'see if the file is in the list
  LevExists = True 'set the function to true
  Exit Function
 End If
Next I
LevExists = False 'the level doesn't exsist
End Function
'change the current directory to thid one.
Public Function ThisDir(Optional SubDir As String) As Boolean
On Error GoTo errHand:
 ChDrive App.Path 'set the drive
 ChDir App.Path & "\" & SubDir 'set the path
 ThisDir = True ' the directory exsists
 Exit Function
errHand:
ThisDir = False ' the directory dosen't exsists
End Function
'load all the images into the firstform, they can then be accesed from this form
Public Sub LoadAllImages(wForm As Form)
 SetForm wForm ' set the current form to the first one
 LoadingForm.MainTitle = "Loading Level Editor..." '\
 LoadingForm.Visible = True                        ' >-- show the loading screen
 LoadingForm.Refresh                               '/
'LoadPic Picture Box , File Name, Array Number , Sub Directory
With nForm
 'load all the images
 LoadingForm.Info = "Loading Objects..."
  LoadPic .NewBerry, "berry", , "food"
  LoadPic .NewCherry, "cherry", , "food"
  LoadPic .NewShield, "protect", , "food"
  LoadPic .NewLife, "1up", , "food"
  LoadPic .NewBeer, "beer", , "food"
  LoadPic .NewFood, "stdfood", , "schemes"
  LoadPic .NewWall, "stdwall", , "schemes"
  LoadPic .PacMan, "pacleft", , "sprites"
  LoadPic .NewGhoul, "ghoul2", , "sprites"
  
 LoadingForm.Info = "Loading Schemes..."
  LoadPic .BackPic, "stdback", 0, "schemes"
  LoadPic .BackPic, "chocolateback", 1, "schemes"
  LoadPic .BackPic, "skyback", 2, "schemes"
  LoadPic .BackPic, "metalback", 3, "schemes"
  LoadPic .BackPic, "christmasback", 4, "schemes"
  LoadPic .BackPic, "spaceback", 5, "schemes"
 
End With
 IsLoaded = True 'the first form is loaded
 LoadTimes = 0
End Sub
Public Sub LoadPic(Obj As Object, Pic As String, Optional pArray As Integer = 999, Optional SubDir As String = "")
 If Not Trim(SubDir) = "" Then SubDir = SubDir & "\" 'see if there is a sub dir
 If pArray = 999 Then 'if there is no array load the picture
  Obj.Picture = LoadPicture(App.Path & "\images\" & SubDir & Pic & ".img")
 Else 'if there is an array, load the picture into it
  Obj(pArray).Picture = LoadPicture(App.Path & "\images\" & SubDir & Pic & ".img")
 End If
LoadTimes = LoadTimes + 1 'used to calculate the percent
LoadingForm.UpdPer LoadTimes, 15 'update the percent
End Sub
'does the same as above, but this is called after the editor has loaded
Public Sub LoadPic2(Obj As Object, Pic As String, Optional pArray As Integer = 999, Optional SubDir As String = "")
 If Not Trim(SubDir) = "" Then SubDir = SubDir & "\"
 If pArray = 999 Then
  Obj.Picture = LoadPicture(App.Path & "\images\" & SubDir & Pic & ".img")
 Else
  Obj(pArray).Picture = LoadPicture(App.Path & "\images\" & SubDir & Pic & ".img")
 End If
End Sub
'set the current active form
Public Sub SetForm(wForm As Form)
 Set nForm = wForm
End Sub
'load images from the first form.
Public Sub LoadLocalImages(wForm As Form)
 SetForm wForm
 With nForm
   .NewWall.Picture = FirstForm.NewWall.Picture
   .NewBerry.Picture = FirstForm.NewBerry.Picture
   .NewCherry.Picture = FirstForm.NewCherry.Picture
   .NewShield.Picture = FirstForm.NewShield.Picture
   .NewGhoul.Picture = FirstForm.NewGhoul.Picture
   .NewLife.Picture = FirstForm.NewLife.Picture
   .NewBeer.Picture = FirstForm.NewBeer.Picture
   .NewFood.Picture = FirstForm.NewFood.Picture
   .PacMan.Picture = FirstForm.PacMan.Picture
   .BackPic(0).Picture = FirstForm.BackPic(0).Picture
   .BackPic(1).Picture = FirstForm.BackPic(1).Picture
   .BackPic(2).Picture = FirstForm.BackPic(2).Picture
   .BackPic(3).Picture = FirstForm.BackPic(3).Picture
   .BackPic(4).Picture = FirstForm.BackPic(4).Picture
   .BackPic(5).Picture = FirstForm.BackPic(5).Picture
 End With
 IsLoaded = True
End Sub
'create a copy of the current active form
Public Sub CopyForm()
 SaveDlg.SaveIT "Tmp123Lev" 'save the current form as a temp file
 NumFrms = NumFrms + 1             '\
 Set nEdit(NumFrms) = New EditFrm  ' \--- create a
 Load nEdit(NumFrms)               ' /--- new form
 SetForm nEdit(NumFrms)            '/
 nEdit(NumFrms).LoadLevel_Map "Tmp123Lev" 'load the temp file
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?