unfortunately it is blitz3D although i'm thinking of doing a conversion once a decent GUI lib is released. i can send you the source but i must warn you that its 2000 lines without one comment so it might be very hard to understand (there are parts that, looking back at it, i dont understand.) So i can send it to you and you decide.
Include "Inc_BCF.bb"
Const VS_UNITFILE# = 0.31
Const VS_TILESET# = 0.1
Const VS_TEAMFILE# = 0.2
Const VS_BUILDINGFILE# = 0.12
Type Prefs
Field GW
Field GH
Field GBD
Field GWindowed
Field GUIS
End Type
Type TileSet
Field FileName$
Field SetName$
Field Number
Field hImage
End Type
Type Tile
Field Name$
Field Mountains
Field Temp#
Field Road
Field Forest
Field Water
End Type
Type WeaponList
Field WeaponName$
Field WeaponType$
Field Damage
Field Speed
Field AirDamage
Field Range
Field NextWeapon.WeaponList
End Type
Type UnitData
Field Speed
Field Armor$
Field UnitType$
Field Health
Field Transport
Field TransportSpace
Field Detector
Field Builder
Field Fuel
Field Stealth
Field Cost
End Type
Type ImageList
Field ImageType
Field Image
Field NextImage.ImageList
End Type
Type BuildingList
Field BuildingName$
Field BuildingType.Building
Field NextBuilding.BuildingList
End Type
Type Unit
Field Name$
Field NumWeapons
Field NumBuildings
Field ImgSm$;,ImgLg
Field TeamID
Field Weapons.WeaponList
Field Buildings.BuildingList
Field UnitData.UnitData
End Type
Type UnitList
Field u.Unit
Field NextUnit.UnitList
End Type
Type Team
Field Name$
Field NameSmall$
Field ID
Field HasUnitImage
Field HasBuildingImage
End Type
Type Building
Field Name$
Field InfantryDefence#
Field ArmorDefence#
Field Health
Field Armor$
Field Units.UnitList
Field UnitsIn.Building
Field Weapons.WeaponList
Field NumWeapons
Field NumUnits
Field TeamID
Field ImgLg$
Field ImgSmString$
Field ImgSm
Field bDetector
Field bAir
Field bArmor
Field bInfantry
Field bShips
Field bRefuel
Field Cost
End Type
AppTitle "WarGames Editor v0.22"
Global p.Prefs = LoadPrefs()
Graphics p\GW,p\GH,p\GBD,p\GWindowed
SetBuffer BackBuffer()
Global MouseImage
Global GroundTile
Global MapWidth
Global MapHeight
Global MapName$
Global MapTileSet$
Global MapFilename$
Global LoadedLevel = False
Global OffsetX = 0
Global OffsetY = 0
Global SelectedTile = 0
Global PositionScrollHorizontal
Global PositionScrollVerticle
Global PositionWindowOpen = False
Global PositionWindow
Global TileToolWindow
Global TileSetLoaded = False
Global CurrentTileInput
Global CurrentTile
Global NothingChanged
Global PrefrencesWindow
Global GuiStyleList
Global WindowDrivers
Global OldDriver$
Global WindowedCheckbox
Global UnitWindow
Global UnitListBox
Global UnitSelectedTileLabel
Global UnitSelectedLabel
Global TileUnitListBox
Global UnitAddButton
Global UnitSubtractButton
Global UnitPropertiesButton
Global UnitPropertiesWindow
Global NewUnitPropertiesComboBoxValue$ = ""
Global OldUnitPropertiesComboBoxValue$ = ""
Global TileUnitTeamComboBox
Global LastTileUnitTeamComboBoxValue$
Global BuildingWindow
Global BuildingSelectedTileLabel
Global BuildingInTileLabel
Global TileBuildingTeamComboBox
Global BuildingListBox
Global LastTileBuildingTeamComboBoxValue$
Global BuildingSelectedLabel
Global BuildingPropertiesButton
Global BuildingChangeBuildingButton
Global BuildingPropertiesWindow
Global NewBuildingPropertiesComboBoxValue$ =""
Global OldBuildingPropertiesComboBoxValue$ =""
Global NumUnit
Global NumBuildings
Global SelectedX
Global SelectedY
Dim CurrentLevel(0,0)
Dim CurrentUnitLevel.UnitList(0,0)
Dim CurrentBuildingLevel.Building(0,0)
Dim UnitProperties(9)
Dim BuildingProperties(9)
Dim CurrentTileSet.Tile(0)
BCF_InitBCF(p\GUIS)
;BCF_Init3DMouse(4)
Init()
MainWindow = BCF_CreateWindow(0,-20,p\GW,60,1,1,"",True,False,False)
QuitButton = BCF_CreateButton(MainWindow,p\GW-70,10,60,20,"Quit")
NewButton = BCF_CreateButton(MainWindow,10,10,80,20,"New Map")
LoadButton = BCF_CreateButton(MainWindow,100,10,80,20,"Load Map")
SaveButton = BCF_CreateButton(MainWindow,190,10,80,20,"Save Map")
ToolBarSelect = BCF_CreateComboxBox(MainWindow,280,10,150,80)
BCF_AddComboBoxItem(ToolBarSelect, "--None--")
BCF_AddComboBoxItem(ToolBarSelect, "Tile Edit Mode")
BCF_AddComboBoxItem(ToolBarSelect, "Level Position")
BCF_AddComboBoxItem(ToolBarSelect, "Unit Edit Mode")
BCF_AddComboBoxItem(ToolBarSelect, "Building Edit Mode")
BCF_AddComboBoxItem(ToolBarSelect, "Preferences")
BCF_SelectedComboBoxValue(ToolBarSelect,"--None--")
AboutButton = BCF_CreateButton(MainWindow,p\GW-(70+90),10,80,20,"About")
While Not KeyDown(1) Or BCF_TestButton(QuitButton)
Cls
If BCF_TestButton(AboutButton) Then AboutWindow
If BCF_TestButton(NewButton)
If CreateNewWindow()
AppTitle "War Games Editor v 0.22 : " + MapName$
MapFilename$=""
LoadedLevel = True
EndIf
EndIf
If BCF_TestComboBox$(ToolBarSelect) = "Level Position" And LoadedLevel = True And BCF_Window(PositionWindow) = False
PositionWindow = CreateMapPositionWindow()
BCF_SelectedComboBoxValue(ToolBarSelect,"--None--")
Else If BCF_TestComboBox$(ToolBarSelect) = "Tile Edit Mode" And LoadedLevel = True
CreateTileToolWindow
BCF_SelectedComboBoxValue(ToolBarSelect,"--None--")
Else If BCF_TestComboBox$(ToolBarSelect) ="Unit Edit Mode" And LoadedLevel = True
CreateUnitWindow
BCF_SelectedComboBoxValue(ToolBarSelect,"--None--")
Else If BCF_TestComboBox$(ToolBarSelect)="Preferences"
CreatePrefrencesWindow
BCF_SelectedComboBoxValue(ToolBarSelect,"--None--")
Else If BCF_TestComboBox$(ToolBarSelect)="Building Edit Mode" And LoadedLevel = True
CreateBuildingWindow
BCF_SelectedComboBoxValue(ToolBarSelect,"--None--")
Else If LoadedLevel = False And BCF_TestComboBox$(ToolBarSelect) <> "--None--"
BCF_MsgBox("Warning","You Can Not Open This Tool With No Level Open",0)
BCF_SelectedComboBoxValue(ToolBarSelect,"--None--")
EndIf
If LoadedLevel = True
DrawMap()
If BCF_Window(TileToolWindow)
CurrentTile = GetTileIndex(BCF_TestComboBox$(CurrentTileInput))
EndIf
If PositionWindowOpen = True Then OffsetX = (BCF_TestScrollBar#(PositionScrollHorizontal)*32)*-1
If PositionWindowOpen = True Then OffsetY = (BCF_TestScrollBar#(PositionScrollVerticle)*32)*-1
EndIf
If PositionWindowOpen = True
If BCF_Window(PositionWindow) = False Then PositionWindowOpen = False
EndIf
If BCF_TestButton(SaveButton)
SaveName$ = BCF_FileRequester$(2)
If Not SaveName$ = "" And LoadedLevel = True
SaveLevel(SaveName$)
ElseIf LoadedLevel = False
BCF_MsgBox("Warning","you can not save with no level opened",0)
EndIf
EndIf
If BCF_Window(PrefrencesWindow)
GuiStyleString = BCF_TestComboBox$(GuiStyleList)
CurrentDriver$ = BCF_TestComboBox$(WindowDrivers)
If Not GuiStyleString = p\GUIS
BCF_InitScheme(GuiStyleString)
p\GUIS = GuiStyleString
EndIf
If Not CurrentDriver$ = OldDriver$
CurrentDriver$ = CurrentDriver$ + ","
Buffer$ = ""
StrPos = 1
While StrPos<=Len(CurrentDriver$)
If Mid(CurrentDriver$,StrPos,1) = ","
If DvrMod = 0 Then p\GW = Buffer$
If DvrMod = 1 Then p\GH = Buffer$
If DvrMod = 2 Then p\GBD = Buffer$
Buffer = ""
StrPos = StrPos + 1
DvrMod = DvrMod + 1
If DvrMod = 3 Then Exit
EndIf
Buffer$ = Buffer$ + Mid(CurrentDriver$,StrPos,1)
StrPos = StrPos+1
Wend
p\GWindowed = BCF_TestCheckbox(WindowedCheckbox)+1
If p\GWindowed = 0 Then p\GWindowed = 1
EndIf
EndIf
If BCF_TestButton(SaveButton)
SaveName$ = BCF_FileRequester$(2)
If Not SaveName$ = "" And LoadedLevel = True
SaveLevel(SaveName$)
ElseIf LoadedLevel = False
BCF_MsgBox("Warning","you can not save with no level opened",0)
EndIf
EndIf
If BCF_TestButton(LoadButton)
LoadName$ = BCF_FileRequester$(1)
If Not LoadName$ = ""
LoadLevel(SaveName$)
EndIf
EndIf
If BCF_Window(UnitWindow)
BCF_ChangeLabelTextLabel(UnitSelectedTileLabel,"Selected Tile = " + SelectedX + " x " + SelectedY)
thisStr$ = BCF_TestListBox$(UnitListBox)
If thisStr$<>""
BCF_ChangeLabelTextLabel(UnitSelectedLabel,"Selected Unit = " + GetNameFromUnit$(GetHandleFromString(thisStr$)))
Else
BCF_ChangeLabelTextLabel(UnitSelectedLabel,"Selected Unit = NONE")
EndIf
CurrentTileUnitTeamComboBoxValue$ = BCF_TestComboBox$(TileUnitTeamComboBox)
If CurrentTileUnitTeamComboBoxValue$ <> LastTileUnitTeamComboBoxValue$
If Not CurrentUnitLevel(SelectedX,SelectedY)\NextUnit = Null
BCF_MsgBox("Warning","You cannot change team while there are units on the tile on which you wish to place more units",0)
team.Team = First Team
LastTileUnitTeamComboBoxValue$ = team\Name$
BCF_SelectedComboBoxValue(TileUnitTeamComboBox,team\Name$)
Else
team.Team = FindTeam(CurrentTileUnitTeamComboBoxValue$)
LastTileUnitTeamComboBoxValue$ = CurrentTileUnitTeamComboBoxValue$
BCF_ClearListBox(UnitListBox)
For u.Unit = Each Unit
If u\teamID = team\ID Then BCF_AddListBoxItem(UnitListBox,u\Name$ + " : H" + Handle(u))
Next
EndIf
EndIf
EndIf
If BCF_TestButton(UnitAddButton)
thisStr$ = BCF_TestListBox$(UnitListBox)
If thisStr$<>""
UnitHandle = GetHandleFromString(thisStr$)
thisStr$ = GetNameFromUnit$(UnitHandle)
AppendUnit thisStr$,UnitHandle
EndIf
EndIf
If BCF_TestButton(UnitSubtractButton)
thisStr$ = BCF_TestListBox$(TileUnitListBox)
If thisStr$<>""
UnitListHandle = GetHandleFromString(thisStr$)
RemoveUnit UnitListHandle
EndIf
EndIf
If BCF_TestButton(UnitPropertiesButton)
thisStr$ = BCF_TestListBox$(UnitListBox)
If thisStr$<>""
If Not BCF_Window(UnitPropertiesWindow)
CreateUnitPropertiesWindow(thisStr$)
Else
BCF_MsgBox("Warning","You cannot open more than one Unit Properties Window at a time",0)
EndIf
Else
BCF_MsgBox("Warning","You need to select a unit",0)
EndIf
EndIf
If BCF_Window(UnitPropertiesWindow)
NewUnitPropertiesComboBoxValue$ = BCF_TestComboBox$(UnitProperties(1))
If Not OldUnitPropertiesComboBoxValue$ = NewUnitPropertiesComboBoxValue$
OldUnitPropertiesComboBoxValue$ = NewUnitPropertiesComboBoxValue$
UpdateUnitPropertiesWindow(OldUnitPropertiesComboBoxValue$)
EndIf
If BCF_TestButton(UnitProperties(8)) And UnitProperties(9)=True
CreateBuildingPropertiesWindow(BCF_TestComboBox$(UnitProperties(7)))
EndIf
EndIf
If BCF_Window(BuildingPropertiesWindow)
NewBuildingPropertiesComboBoxValue$ = BCF_TestComboBox$(BuildingProperties(1))
If Not OldBuildingPropertiesComboBoxValue$ = NewBuildingPropertiesComboBoxValue$
OldBuildingPropertiesComboBoxValue$ = NewBuildingPropertiesComboBoxValue$
UpdateBuildingPropertiesWindow(OldBuildingPropertiesComboBoxValue$)
EndIf
If BCF_TestButton(BuildingProperties(8)) And BuildingProperties(9)=True
CreateUnitPropertiesWindow(BCF_TestComboBox$(BuildingProperties(7)))
EndIf
EndIf
If BCF_Window(BuildingWindow)
thisStr$ = BCF_TestListBox$(BuildingListBox)
If thisStr$<>""
BCF_ChangeLabelTextLabel(BuildingSelectedLabel,"Selected Building = " + GetNameFromBuilding$(GetHandleFromString(thisStr$)))
Else
BCF_ChangeLabelTextLabel(BuildingSelectedLabel,"Selected Building = NONE")
EndIf
CurrentTileBuildingTeamComboBoxValue$ = BCF_TestComboBox$(TileBuildingTeamComboBox)
If CurrentTileBuildingTeamComboBoxValue$<>LastTileBuildingTeamComboBoxValue$
team.Team = FindTeam(CurrentTileBuildingTeamComboBoxValue$)
LastTileBuildingTeamComboBoxValue$ = CurrentTileBuildingTeamComboBoxValue$
BCF_ClearListBox(BuildingListBox)
For b.Building = Each Building
If b\teamID = team\ID Then BCF_AddListBoxItem(BuildingListBox,b\Name$ + " : H" + Handle(b))
Next
EndIf
If BCF_TestButton(BuildingPropertiesButton)
thisStr$ = BCF_TestListBox$(BuildingListBox)
If thisStr$<>""
CreateBuildingPropertiesWindow(thisStr$)
Else
BCF_MsgBox("Warning","You need to select a building",0)
EndIf
EndIf
EndIf
If BCF_TestButton(BuildingChangeBuildingButton)
thisStr$ = BCF_TestListBox$(BuildingListBox)
If thisStr$ <> ""
If thisStr$ = "NONE"
FreeBuilding CurrentBuildingLevel(SelectedX,SelectedY)
BCF_ChangeLabelTextLabel(BuildingInTileLabel,"Building on Tile = NONE")
Else
BuildingHandle = GetHandleFromString(thisStr$)
b.Building = Object.Building(BuildingHandle)
BCF_ChangeLabelTextLabel(BuildingInTileLabel,"Building on Tile = " + b\Name$)
CurrentBuildingLevel(SelectedX,SelectedY) = b
EndIf
EndIf
EndIf
BCF_RenderBCF()
DrawTileToolWindow
Flip
Wend
SavePrefs()
FreeCurrentSet
FreeUnits
FreeBuildings
Function LoadPrefs.Prefs()
p.Prefs = New Prefs
in = ReadFile("prefs.txt")
If in = 0 Then RuntimeError "Could Not find prefs.txt"
While Not Eof(in)
ln$ = ReadLine$(in)
ln$ = EatWhite$(ln$)
If Instr(ln$,"GraphicsWidth")
p\GW = Right$(ln$,Len(ln$)-(Instr(ln$,"=")))
EndIf
If Instr(ln$,"GraphicsHeight")
p\GH = Right$(ln$,Len(ln$)-(Instr(ln$,"=")))
EndIf
If Instr(ln$,"GraphicsDepth")
p\GBD = Right$(ln$,Len(ln$)-(Instr(ln$,"=")))
EndIf
If Instr(ln$,"Windowed")
p\GWindowed = Right$(ln$,Len(ln$)-(Instr(ln$,"=")))
EndIf
If Instr(ln$,"GuiStyle")
p\GUIS = Right$(ln$,Len(ln$)-(Instr(ln$,"=")))
EndIf
Wend
CloseFile(in)
Return p
End Function
Function SavePrefs()
out = WriteFile("prefs.txt")
WriteLine out,"GraphicsWidth = " + p\GW
WriteLine out,"GraphicsHeight = " + p\GH
WriteLine out,"GraphicsDepth = " + p\GBD
WriteLine out,"Windowed = " + p\GWindowed
WriteLine out, "GuiStyle = " + p\GUIS
CloseFile out
End Function
Function AboutWindow()
AboutWindow = BCF_CreateWindow(GraphicsWidth()/2-340/2,GraphicsHeight()/2-220/2,340,220,1,1,"About War Games",True,False)
AboutOkButton = BCF_CreateButton(AboutWindow,340/2-40,220-60,80,20,"OK")
AboutBCFButton = BCF_CreateButton(AboutWindow,340/2-80,220-90,80*2,20,"About BCF")
BCF_CreateLabelText(AboutWindow,0,10,"Welcome to the War Games editor version 0.1.|the War Games Editor was made for use with the game WarGames(c)|It is made with the gui system known to|mortals as BCF check it out its awsome",1,1)
While Not BCF_TestButton(AboutOkButton)
Cls
If BCF_TestButton(AboutBCFButton) Then BCF_AboutBCF()
BCF_RenderBCF()
Flip
Wend
BCF_KillWindow(AboutWindow)
End Function
Function CreateNewWindow()
If LoadedLevel = True
If BCF_MsgBox("Warning","There is currently a level opened, If you create a New level you will lose all changes",1) = 1
FreeCurrentSet
LoadedLevel = False
Delete Each UnitList
For x = 0 To MapWidth
For y = 0 To MapHeight
If Not CurrentBuildingLevel(x,y) = Null Then CurrentBuildingLevel(x,y) = Null
Next
Next
Else
Return False
EndIf
EndIf
Local myDir = 0
NewWindow = BCF_CreateWindow(GraphicsWidth()/2-100,GraphicsHeight()/2-100,200,200,1,1,"New Map",True,True)
TileViewWindow = BCF_CreateWindow(20,20,110,80,1,1,"Tile Viewer",True,False,True)
BCF_CreateLabelText(NewWindow,10,10,"Map Width:",1,1)
InputWidth = BCF_CreateInputBox(NewWindow,10,25,"0",6,False)
BCF_CreateLabelText(NewWindow,10,50,"Map Height:",1,1)
InputHeight = BCF_CreateInputBox(NewWindow,10,65,"0",6,False)
BCF_CreateLabelText(NewWindow,10,90,"Map Name:",1,1)
InputName = BCF_CreateInputBox(NewWindow,10,105,"",16,False)
BCF_CreateLabelText(NewWindow,100,10,"Select Tile Set:",1,1)
InputTileSet = BCF_CreateComboxBox(NewWindow,85,25,105,60)
myDir = ReadDir("TileSets")
While True
file$ = NextFile$(myDir)
If file$ = "" Then Exit
If FileType("TileSets"+file$) = 1
TileSetName$ = LoadTileSetName$("TileSets"+file$)
If Not TileSetName$ = ""
If num = 0
num = num + 1
DefaultSetName$ = TileSetName$
DefaultFileName$ = file$
EndIf
BCF_AddComboBoxItem(InputTileSet, TileSetName$)
EndIf
EndIf
Wend
CloseDir myDir
myDir = 0
BCF_SelectedComboBoxValue(InputTileSet,DefaultSetName$)
set.TileSet = LoadTileSet("TileSets"+DefaultFileName$)
OkButton = BCF_CreateButton(NewWindow,100-40,150,80,20,"Confirm")
BCF_CreateLabelText(NewWindow,85,50,"Select Default Tile:",1,1)
InputDefaultTile = BCF_CreateComboxBox(NewWindow,85,65,105,60)
For i = 0 To set\Number-1
BCF_AddComboBoxItem(InputDefaultTile,CurrentTileSet(i)\Name$)
If i = 0 Then BCF_SelectedComboBoxValue(InputDefaultTile,CurrentTileSet(i)\Name$)
Next
While Not BCF_TestButton(OkButton)
Cls
If Not BCF_Window(NewWindow)
BCF_KillWindow(TileViewWindow)
FreeCurrentSet
Return False
EndIf
If Not BCF_TestComboBox$(InputTileSet) = DefaultSetName$
BCF_ClearComboBox(InputDefaultTile)
myDir = ReadDir("TileSets")
While True
file$ = NextFile$(myDir)
If file$ = "" Then Exit
If FileType("TileSets"+file$) = 1
DefaultSetName$ = LoadTileSetName$("TileSets"+file$)
If DefaultSetName$ = BCF_TestComboBox$(InputTileSet)
FreeCurrentSet
set.TileSet = LoadTileSet("TileSets"+file$)
For i = 0 To set\Number-1
BCF_AddComboBoxItem(InputDefaultTile,CurrentTileSet(i)\Name$)
If i = 0 Then BCF_SelectedComboBoxValue(InputDefaultTile,CurrentTileSet(i)\Name$)
Next
Exit
EndIf
EndIf
Wend
CloseDir myDir
EndIf
CloseDir myDir
BCF_RenderBCF()
If BCF_Window(NewWindow)
If GetTileIndex(BCF_TestComboBox$(InputDefaultTile)) = -1 Then RuntimeError("Error: Tile Does Not Exist")
DrawImage set\hImage,BCF_GetWindowX(TileViewWindow)+31,BCF_GetWindowY(TileViewWindow)+33,GetTileIndex(BCF_TestComboBox$(InputDefaultTile))
EndIf
Flip
Wend
MapWidth = BCF_TestInputBox$(InputWidth)
MapHeight = BCF_TestInputBox$(InputHeight)
MapName$ = BCF_TestInputBox$(InputName)
MapTileSet$ = BCF_TestComboBox$(InputTileSet)
MapDefaultTile = GetTileIndex(BCF_TestComboBox$(InputDefaultTile))
BCF_KillWindow(NewWindow)
BCF_KillWindow(TileViewWindow)
Dim CurrentLevel(MapWidth,MapHeight)
Dim CurrentUnitLevel(MapWidth,MapHeight)
Dim CurrentBuildingLevel(MapWidth,MapHeight)
For x = 0 To MapWidth
For y = 0 To MapHeight
CurrentLevel(x,y) = MapDefaultTile
CurrentUnitLevel(x,y) = New UnitList
Next
Next
Return True
End Function
Function EatWhite$(String$)
state = 0
For i = 1 To Len(String$)
If Asc(Mid$(String$,i,1)) = 34 And state = 0
state = 1
Else If Asc(Mid$(String$,i,1)) = 34 And state = 1
state = 0
Else
If Mid$(String$,i,1) <> " " And state = 0 Then NewString$ = NewString$ + Mid$(String$,i,1)
If Asc(Mid$(String$,i,1)) <> 34 And state = 1 Then NewString$ = NewString$ + Mid$(String$,i,1)
EndIf
Next
Return NewString$
End Function
Function DrawMap()
t.TileSet = First TileSet
Origin OffsetX,40+OffsetY
For y = 0 To MapHeight
For x =0 To MapWidth
DrawImage t\hImage,x*32+(( y Mod 2)*16),y*27,CurrentLevel(x,y)
If MouseX()>0 And MouseX()<(MapWidth+1)*32+OffsetX And MouseY()>0 And MouseY()<(MapHeight+1)*36+OffsetY And ImagesOverlap (t\hImage,x*32+(( y Mod 2)*16),y*27+40,MouseImage,MouseX()-OffsetX,MouseY()-OffsetY)
If ImagesCollide(t\hImage,x*32+(( y Mod 2)*16),y*27+40,1,MouseImage,MouseX()-OffsetX,MouseY()-OffsetY,0)
If BCF_Window(TileToolWindow) Then DrawImage t\hImage,x*32+(( y Mod 2)*16),y*27,CurrentTile
DrawImage t\hImage,x*32+(( y Mod 2)*16),y*27,0
If MouseDown(1) And BCF_MouseOverWindow() = False And BCF_Window(TileToolWindow) Then CurrentLevel(x,y) = CurrentTile
If MouseDown(1) And BCF_MouseOverWindow() = False And BCF_Window(UnitWindow) Then SelectedX = x : SelectedY = y : UpdateUnitTile
If MouseDown(1) And BCF_MouseOverWindow() = False And BCF_Window(BuildingWindow) Then SelectedX = x : SelectedY = y : UpdateBuildingWindow
EndIf
EndIf
If Not CurrentUnitLevel(x,y)\NextUnit = Null
team.Team = FindUnitTeam(CurrentUnitLevel(x,y)\u)
DrawImage team\HasUnitImage, x*32+(( y Mod 2)*16),y*27+3
EndIf
If Not CurrentBuildingLevel(x,y) = Null
team.Team = FindBuildingTeam(CurrentBuildingLevel(x,y))
DrawImage team\HasBuildingImage, x*32+((y Mod 2)*16),y*27
DrawImage CurrentBuildingLevel(x,y)\ImgSm,x*32+((y Mod 2)*16),y*27+3
EndIf
Next
Next
If BCF_Window(UnitWindow) Or BCF_Window(BuildingWindow) Then DrawImage t\hImage,SelectedX*32+(( SelectedY Mod 2)*16),SelectedY*27,0
Origin 0,0
End Function
Function CreateUnitWindow()
If BCF_Window(TileToolWindow) Or BCF_Window(BuildingWindow)
BCF_MsgBox("Warning","You Can Not Open The Unit Editor With The Tile or Building Editor Open",0)
Return
Else If BCF_Window(UnitWindow) = False
UnitWindow = BCF_CreateWindow(GraphicsWidth()/2-200,GraphicsHeight()/2-130,420,255,1,1,"Unit Tool Bar", True, True)
UnitSelectedTileLabel = BCF_CreateLabelText(UnitWindow,10,20,"Selected Tile = ",1,1)
BCF_CreateLabelText(UnitWindow,10,50,"Possible Units",1,1)
TileUnitListBox = BCF_CreateListBox(UnitWindow,250,80,150,120)
UnitListBox = BCF_CreateListBox(UnitWindow,10,80,150,120)
TileUnitTeamComboBox = BCF_CreateComboxBox(UnitWindow,200,20,200,50)
For team.Team = Each Team
BCF_AddComboBoxItem(TileUnitTeamComboBox, team\Name$)
Next
team = First Team
LastTileUnitTeamComboBoxValue$ = team\Name$
BCF_SelectedComboBoxValue(TileUnitTeamComboBox,team\Name$)
For u.Unit = Each Unit
If u\teamID = team\ID Then BCF_AddListBoxItem(UnitListBox,u\Name$ + " : H" + Handle(u))
Next
UnitSelectedLabel = BCF_CreateLabelText(UnitWindow,10,210,"Selected Unit = NONE",1,1)
BCF_CreateLabelText(UnitWindow,260,50,"Units In Current Tile",1,1)
UnitAddButton = BCF_CreateButton(UnitWindow,180,100,60,20," >> ")
UnitSubtractButton = BCF_CreateButton(UnitWindow,180,80+80,60,20," << ")
UnitPropertiesButton = BCF_CreateButton(UnitWindow,310,205,90,20,"Properties")
EndIf
End Function
Function CreateTileToolWindow()
If BCF_Window(UnitWindow)
BCF_MsgBox("Warning","You Can Not Open The Tile Editor With The Unit Editor Open",0)
Return
Else If BCF_Window(TileToolWindow) = False
set.TileSet = First TileSet
TileToolWindow = BCF_CreateWindow(GraphicsWidth()/2-150,GraphicsHeight()/2-100,300,200,1,1,"Tile Tool Bar",True,True)
BCF_CreateLabelText(TileToolWindow,10,20,"Select Tile",1,1)
CurrentTileInput = BCF_CreateComboxBox(TileToolWindow,10,35,120,80)
For i = 0 To set\Number-1
BCF_AddComboBoxItem(CurrentTileInput,CurrentTileSet(i)\Name$)
If i = 0 Then BCF_SelectedComboBoxValue(CurrentTileInput,CurrentTileSet(i)\Name$)
Next
EndIf
End Function
Function DrawTileToolWindow()
If BCF_Window(TileToolWindow)
set.TileSet = First TileSet
Color 255,255,255
WindowX = BCF_GetWindowX(TileToolWindow)
WindowY = BCF_GetWindowY(TileToolWindow)
FH = FontHeight()*5/2
Line WindowX+135,WindowY+67,WindowX+170,WindowY+67
Line WindowX+170,WindowY+67,WindowX+170,WindowY+67-(36/2)
Line WindowX+170,WindowY+67,WindowX+170,WindowY+67+(38/2)
Line WindowX+170,WindowY+67-(36/2),WindowX+170+32,WindowY+67-(36/2)
Line WindowX+170,WindowY+67+(38/2),WindowX+170+32,WindowY+67+(38/2)
DrawImage set\hImage,WindowX+173,WindowY+67-(34/2),GetTileIndex(BCF_TestComboBox$(CurrentTileInput))
Line WindowX+135, WindowY +67,WindowX+135,WindowY + 150
Line WindowX+135,WindowY + 150,WindowX+135+20,WindowY + 150
Line WindowX+135+20,WindowY + 150,WindowX+135+20,WindowY + 150-FH
Line WindowX+135+20,WindowY + 150-FH,WindowX+135+40,WindowY + 150-FH
Line WindowX+135+20,WindowY + 150,WindowX+135+20,WindowY + 150+FH
Line WindowX+135+20,WindowY + 150+FH,WindowX+135+40,WindowY + 150+FH
Text WindowX+135+25,WindowY + 150-FH,"Mountains = " + BoolToString$(CurrentTileSet(GetTileIndex(BCF_TestComboBox$(CurrentTileInput)))\Mountains)
Text WindowX+135+25,WindowY + 150-FH+FontHeight(),"Forest = " + BoolToString$(CurrentTileSet(GetTileIndex(BCF_TestComboBox$(CurrentTileInput)))\Forest)
Text WindowX+135+25,WindowY + 150-FH+FontHeight()*2,"Road = " + BoolToString$(CurrentTileSet(GetTileIndex(BCF_TestComboBox$(CurrentTileInput)))\Road)
Text WindowX+135+25,WindowY + 150-FH+FontHeight()*3,"Water = " + BoolToString$(CurrentTileSet(GetTileIndex(BCF_TestComboBox$(CurrentTileInput)))\Water)
Text WindowX+135+25,WindowY + 150-FH+FontHeight()*4,"Temp# = " + CurrentTileSet(GetTileIndex(BCF_TestComboBox$(CurrentTileInput)))\Temp#
EndIf
End Function
Function CreateMapPositionWindow()
If LoadedLevel = True
MapPositionWindow = BCF_CreateWindow(GraphicsWidth()/2-220/2,GraphicsHeight()/2-220/2,220,150,1,1,"Map Position",True,True)
BCF_CreateLabelText(MapPositionWindow,10,10,"x Position:",1,1)
PositionScrollHorizontal = BCF_CreateScrollBar(MapPositionWindow,10,30,200,20,0,MapWidth,1,"",True)
BCF_CreateLabelText(MapPositionWindow,10,64,"y Position:",1,1)
PositionScrollVerticle = BCF_CreateScrollBar(MapPositionWindow,10,55+25,200,20,0,MapHeight,1,"",True)
PositionWindowOpen = True
Return MapPositionWindow
EndIf
End Function
Function CreatePrefrencesWindow()
If BCF_Window(PrefrencesWindow) = True Then Return
PrefrencesWindow = BCF_CreateWindow(GraphicsWidth()/2-220/2,GraphicsHeight()/2-220/2,220,150,1,1,"Prefrences",True,True)
BCF_CreateLabelText(PrefrencesWindow,10,10,"Gui Style")
GuiStyleList = BCF_CreateComboxBox(PrefrencesWindow,10,30,120,60)
BCF_AddComboBoxItem(GuiStyleList,"1")
BCF_AddComboBoxItem(GuiStyleList,"2")
BCF_AddComboBoxItem(GuiStyleList,"3")
BCF_AddComboBoxItem(GuiStyleList,"4")
BCF_AddComboBoxItem(GuiStyleList,"5")
BCF_SelectedComboBoxValue(GuiStyleList,p\GUIS)
BCF_CreateLabelText(PrefrencesWindow,10,55,"Graphics Mode")
WindowDrivers = BCF_CreateComboxBox(PrefrencesWindow,10,70,120,80)
For i = 1 To CountGfxModes()
BCF_AddComboBoxItem(WindowDrivers,GfxModeWidth(i) + "," + GfxModeHeight(i) + "," + GfxModeDepth(i))
Next
BCF_SelectedComboBoxValue(WindowDrivers,GraphicsWidth() + "," + GraphicsHeight() + "," + GraphicsDepth())
OldDriver$ = GraphicsWidth() + "," + GraphicsHeight() + "," + GraphicsDepth()
WindowedCheckbox = BCF_CreateCheckBox(PrefrencesWindow,10,100,p\GWindowed-1,"Windowed")
End Function
Function LoadTileSetName$(FileName$)
set = ReadFile(FileName$)
If set = 0 Then Return ""
While Not Eof(set)
s$ = ReadLine$(set)
If Instr(s$,"TILESETNAME")
SetName$ = Right$(s$,Len(s$)-(Instr(s$,"=")))
CloseFile(set)
Return SetName$
EndIf
Wend
CloseFile(set)
Return ""
End Function
Function LoadTileSet.TileSet(FileName$)
If TileSetLoaded = True Then RuntimeError "Cannot Load Multiple Tiles Sets at once"
state = 0
count = 0
t.TileSet = New TileSet
set = ReadFile(FileName$)
If set = 0 Then Return Null
While Not Eof(set) Or state = -1
s$ = ReadLine(set)
s$ = EatWhite$(s$)
If state = 0
If Instr(s$,"#BEGIN") Then state = 1
EndIf
If state = 1
If Instr(s$,"#END") Then state = -1
If Instr(s$,"#HEADER") Then state = 2
If Instr(s$,"#CORE") Then state = 3
If Instr(s$,"#TILES") Then state = 4
EndIf
If state = 2
If Instr(s$,"VERSION")
If Not Float#(Right$(s$,Instr(s$,"VERSION")+2))=VS_TILESET Then RuntimeError("File: "+FileName$ + ". Fileversion was Not current" )
EndIf
If Instr(s$,"FILETYPE")
If Right$(s$,Len(s$)-(Instr(s$,"=")))<>"TILEFILE" Then RuntimeError("Not the correct type of file")
EndIf
If Instr(s$,"#ENDHEADER") Then state = 1
EndIf
If state = 3
If Instr(s$,"TILESETNAME")
t\SetName$ = Right$(s$,Len(s$)-(Instr(s$,"=")))
count = count +1
EndIf
If Instr(s$,"TILESETIMAGE")
count = count+1
t\FileName$ = Right$(s$,Len(s$)-(Instr(s$,"=")))
EndIf
If Instr(s$,"NUMTILES")
count = count +1
t\Number = Int(Right$(s$,Len(s$)-(Instr(s$,"="))))
Dim CurrentTileSet.Tile(t\Number)
For i = 0 To t\Number
CurrentTileSet(i) = New Tile
Next
EndIf
If count = 3
t\hImage = LoadAnimImage ("TileSets"+t\FileName$,32,36,0,t\Number)
EndIf
If Instr(s$,"#ENDCORE")
If count<3 Then RuntimeError("Error: Tile Defenitians Invalid")
state = 1
EndIf
EndIf
If state = 4
If Instr(s$,"TILE")
CurrentTileSet(tilecounter)\Name$ = Right$(s$,Len(s$)-((Instr(s$,"TILE")+3)))
CurrentTileSet(tilecounter)\Mountains = False
CurrentTileSet(tilecounter)\Water = False
CurrentTileSet(tilecounter)\Road = False
CurrentTileSet(tilecounter)\Forest = False
EndIf
If Instr(s$,"]")
tilecounter = tilecounter + 1
EndIf
If Instr(s$,"MOUNTAINS")
CurrentTileSet(tilecounter)\Mountains = True
EndIf
If Instr(s$,"WATER")
CurrentTileSet(tilecounter)\Water = True
EndIf
If Instr(s$,"ROAD")
CurrentTileSet(tilecounter)\Road = True
EndIf
If Instr(s$,"FOREST")
CurrentTileSet(tilecounter)\Forest = True
EndIf
If Instr(s$,"TEMP")
CurrentTileSet(tilecounter)\Temp = Float#(Right$(s$,Len(s$)-(Instr(s$,"="))))
EndIf
EndIf
Wend
CloseFile set
TileSetLoaded = True
Return t
End Function
Function LoadUnit.Unit(FileName$)
;If FileName$ = "Engineer.txt" Then WaitKey
ChangeDir "Units"
state = 0
file = False
this.Unit = Null
b.BuildingList = Null
bFirstBuilding = True
in = ReadFile(FileName$)
Local ln$ = ""
While Not ln$ = "#END"
ln$ = EatWhite$(ReadLine$(in))
If Left$(ln$,2) <> "//"
Select(state)
Case 0:
If Instr(ln$,"#HEADER") And file = False Then state = 1
If Instr(ln$,"#CORE") Then state = 2
If Instr(ln$,"#UNITWEAPONS") Then state = 3
If Instr(ln$,"#UNITDATA") Then state = 4
If Instr(ln$,"#UNITBUILDINGS") Then state = 5
Case 1:
If Instr(ln$,"FILETYPE") And file = False
If Right$(ln$,Len(ln$)-(Len("FILETYPE"))-1) = "UNITFILE"
file = True
this = New Unit
this\UnitData = New UnitData
this\NumBuildings = 0
EndIf
EndIf
If Instr(ln$,"VERSION")
If Not Right$(ln$,Len(ln$)-(Len("VERSION"))-1) = VS_UNITFILE Then RuntimeError("File: "+FileName$ + ". Fileversion was not current version = " +Right$(ln$,Len(ln$)-(Len("VERSION"))-1) + " for file " + FileName$)
EndIf
If Instr(ln$,"#ENDHEADER") Then state = 0
Case 2:
If Instr(ln$,"UNITNAME") And file = True
this\Name$ = Right$(ln$,Len(ln$)-(Len("UNITNAME"))-1)
EndIf
If Instr(ln$,"NUMWEAPONS") And file = True
this\NumWeapons = Right$(ln$,Len(ln$)-(Len("NUMWEAPONS"))-1)
this\Weapons = New WeaponList
w.WeaponList = this\Weapons
For i = 1 To this\NumWeapons
w\NextWeapon = New WeaponList
w\AirDamage = -1
w\Damage = -1
w = w\NextWeapon
Next
w = Null
;For i = 1 To NumWeapons
; w = Before w
;Next
;this\Weapons = w
EndIf
If Instr(ln$,"NUMBUILDINGS") And file = True
this\NumBuildings = Right$(ln$,Len(ln$)-(Len("NUMBUILDINGS"))-1)
If this\NumBuildings>0
this\Buildings = New BuildingList
u.BuildingList = this\Buildings
For i = 1 To this\NumBuildings
u\NextBuilding = New BuildingList
u\BuildingName$ = ""
u = u\NextBuilding
Next
u = Null
EndIf
EndIf
If Instr(ln$,"IMGSM") And file = True
this\ImgSm$ = Right$(ln$,Len(ln$)-(Len("IMGSM"))-1) ;LoadImage(Right$(ln$,Len(ln$)-(Len("IMGSM"))-1))
EndIf
If Instr(ln$,"TEAMID") And file = True
this\TeamID = Int(Right$(ln$,Len(ln$)-(Len("TEAMID"))-1))
EndIf
;If Instr(ln$,"IMGLG") And file = True
; this\ImgLg = LoadImage(Right$(ln$,Len(ln$)-(Len("IMGLG"))-1))
;EndIf
If Instr(ln$,"#ENDCORE") Then state = 0
Case 3:
If w.WeaponList = Null Then w.WeaponList = this\Weapons
If Instr(ln$,"WEAPON") And Instr(ln$,"WEAPONS")<=0
w\WeaponName$ = Right$(ln$,Len(ln$)-(Len("WEAPON"))-2)
EndIf
If Instr(ln$,"TYPE")
w\WeaponType$ = Right$(ln$,Len(ln$)-(Len("TYPE"))-1)
EndIf
If Instr(ln$,"DAMAGE") And Instr(ln$,"AIRDAMAGE") = 0
w\Damage = Right$(ln$,Len(ln$)-(Len("DAMAGE"))-1)
EndIf
If Instr(ln$,"SPEED")
w\Speed = Right$(ln$,Len(ln$)-(Len("SPEED"))-1)
EndIf
If Instr(ln$,"AIRDAMAGE")
w\AirDamage = Right$(ln$,Len(ln$)-(Len("AIRDAMAGE"))-1)
EndIf
If Instr(ln$,"RANGE")
w\Range = Right$(ln$,Len(ln$)-(Len("RANGE"))-1)
EndIf
If Instr(ln$,"]")
If Not w\NextWeapon = Null Then w = w\NextWeapon
EndIf
If Instr(ln$,"#ENDUNITWEAPONS") Then state = 0
Case 4:
If Instr(ln$,"SPEED")
this\UnitData\Speed = Right$(ln$,Len(ln$)-(Len("SPEED"))-1)
EndIf
If Instr(ln$,"ARMOR")
this\UnitData\Armor$ = Right$(ln$,Len(ln$)-(Len("ARMOR"))-1)
EndIf
If Instr(ln$,"HEALTH")
this\UnitData\Health = Right$(ln$,Len(ln$)-(Len("HEALTH"))-1)
EndIf
If Instr(ln$,"TYPE")
this\UnitData\UnitType$ = Right$(ln$,Len(ln$)-(Len("TYPE"))-1)
EndIf
If Instr(ln$,"TRANSPORT")
If Right$(ln$,Len(ln$)-(Len("TRANSPORT"))-1) = "TRUE"
this\UnitData\Transport = True
Else
this\UnitData\Transport = False
EndIf
EndIf
If Instr(ln$,"CARGOSPACE")
this\UnitData\TransportSpace = Right$(ln$,Len(ln$)-(Len("CARGOSPACE"))-1)
EndIf
If Instr(ln$,"DETECTOR")
If Right$(ln$,Len(ln$)-(Len("DETECTOR"))-1) = "TRUE"
this\UnitData\Detector = True
Else
this\UnitData\Detector = False
EndIf
EndIf
If Instr(ln$,"BUILDER")
If Right$(ln$,Len(ln$)-(Len("BUILDER"))-1) = "TRUE"
this\UnitData\Builder = True
Else
this\UnitData\Builder = False
EndIf
EndIf
If Instr(ln$,"STEALTH")
If Right$(ln$,Len(ln$)-(Len("STEALTH"))-1) = "TRUE"
this\UnitData\Stealth = True
Else
this\UnitData\Stealth = False
EndIf
EndIf
If Instr(ln$,"FUEL")
this\UnitData\Fuel = Right$(ln$,Len(ln$)-(Len("FUEL"))-1)
EndIf
If Instr(ln$,"COST")
this\UnitData\Cost = Right$(ln$,Len(ln$)-(Len("COST"))-1)
EndIf
If Instr(ln$,"#ENDUNITDATA") Then state = 0
Case 5:
If this\NumBuildings > 0 And Instr(ln$,"#ENDUNITBUILDINGS") = 0 And Instr(ln$,"NONE") = 0
If b.BuildingList = Null Then b.BuildingList = this\Buildings
b\BuildingName$ = ln$
b = b\NextBuilding
EndIf
If Instr(ln$,"#ENDUNITBUILDINGS") Then state = 0
Default:
RuntimeError "Error In Unit File"
End Select
EndIf
Wend
CloseFile in
ChangeDir ".."
Return this
End Function
Function EnumUnitBuildingList()
For b.BuildingList = Each BuildingList
If b\BuildingName$=""
Delete b
Else
b\BuildingType = FindBuilding(b\BuildingName$)
EndIf
Next
End Function
Function GetTileIndex(Name$)
t.TileSet = First TileSet
For i = 0 To t\Number-1
If CurrentTileSet(i)\Name$ = Name$ Then Return i
Next
Return -1
End Function
Function FreeCurrentSet()
For t.TileSet = Each TileSet
FreeImage t\hImage
Delete t
Next
For tile.Tile = Each Tile
Delete tile
Next
TileSetLoaded = False
Delete Each Tile
Dim CurrentTileSet(0)
End Function
Function BoolToString$(i)
If i = 1 Then Return "true"
If i = 0 Then Return "false"
End Function
Function SaveLevel(FileName$)
in = WriteFile(FileName$)
WriteString in, LevelName$
WriteString in,MapTileSet$
WriteInt in,MapWidth
WriteInt in,MapHeight
For y = 0 To MapHeight
For x = 0 To MapWidth
WriteInt in,CurrentLevel(x,y)
Next
Next
CloseFile in
End Function
Function LoadLevel(FileName$)
in = ReadFile(FileName$)
If in = 0 Then Return False
LevelName$ = ReadString$(in)
MapTileSet$ = ReadString$(in)
MapWidth = ReadInt(in)
MapHeight = ReadInt(in)
Dim CurrentLevel(MapWidth,MapHeight)
myDir = ReadDir("TileSets")
While True
file$ = NextFile$(myDir)
If file$ = "" Then Exit
If FileType("TileSets"+file$) = 1
SetName$ = LoadTileSetName$("TileSets"+file$)
If SetName$ = MapTileSet$
If LoadedLevel = True Then FreeCurrentSet
set.TileSet = LoadTileSet("TileSets"+file$)
Exit
EndIf
EndIf
Wend
CloseDir myDir
If Not SetName$ = MapTileSet$
CloseFile in
RuntimeError "Error: Cannot Find Tile Set: " + MapTileSet$
End If
For y = 0 To MapHeight
For x = 0 To MapWidth
CurrentLevel(x,y) = ReadInt(in)
Next
Next
CloseFile in
Return True
End Function
Function Init()
MouseImage = CreateImage(1,1)
SetBuffer ImageBuffer(MouseImage)
Plot 0,0
SetBuffer BackBuffer()
LoadUnits()
LoadTeams()
LoadBuildings()
EnumUnitBuildingList()
End Function
Function LoadUnits()
myDir = ReadDir("Units")
While True
file$ = NextFile$(myDir)
If file$ = "" Then Exit
If FileType("Units"+file$) = 1
LoadUnit(file$)
NumUnit = NumUnit + 1
EndIf
Wend
CloseDir myDir
myDir = 0
End Function
Function FreeUnits()
Delete Each Unit
Delete Each UnitData
Delete Each WeaponList
End Function
Function UpdateUnitTile()
BCF_ClearListBox(TileUnitListBox)
ul.UnitList = CurrentUnitLevel(SelectedX,SelectedY)
If ul = Null Then ul = New UnitList
While Not ul\NextUnit = Null
u.Unit = ul\u
If Not u = Null Then BCF_AddListBoxItem(TileUnitListBox,u\Name$ + " : H" + Handle(ul))
ul = ul\NextUnit
Wend
team.Team = Null
If ul\NextUnit = Null
team = First Team
BCF_SelectedComboBoxValue(TileUnitTeamComboBox,team\Name$)
Else
team = FindUnitTeam(CurrentUnitLevel(SelectedX,SelectedY)\u)
BCF_SelectedComboBoxValue(TileUnitTeamComboBox,team\Name$)
EndIf
End Function
Function AppendUnit(UnitName$,UnitHandle)
ul.UnitList = CurrentUnitLevel(SelectedX,SelectedY)
While Not ul\NextUnit = Null
ul = ul\NextUnit
Wend
ul\NextUnit = New UnitList
ul\u = Object.Unit(UnitHandle)
BCF_AddListBoxItem(TileUnitListBox,UnitName$ + " : H" + Handle(ul))
End Function
Function RemoveUnit(UnitHandle)
ul.UnitList = CurrentUnitLevel(SelectedX,SelectedY)
If Not Handle(ul) = UnitHandle
While Not ul\NextUnit = Null
If Handle(ul\NextUnit) = UnitHandle Then Exit
ul = ul\NextUnit
Wend
EndIf
If ul\NextUnit = Null Then RuntimeError "Fatal Error: No Unit Handle = " + UnitHandle + " Exists"
If Not ul\NextUnit\NextUnit = Null
temp.UnitList = ul\NextUnit
ul\NextUnit = ul\NextUnit\NextUnit
Delete temp
Else
temp.UnitList = ul
CurrentUnitLevel(SelectedX,SelectedY) = ul\NextUnit
Delete temp
EndIf
UpdateUnitTile
End Function
Function CreateUnitPropertiesWindow(unit$)
If BCF_Window(UnitPropertiesWindow)
BCF_MsgBox("Warning","You Can Not Open A New Properties Window While An Old One is Already Opened",0)
Return
EndIf
UnitHandle = GetHandleFromString(unit$)
unit$ = Left$(unit$,Instr(unit$,":")-2)
u.Unit = Object.Unit(UnitHandle)
UnitProperties(0) = UnitHandle
UnitPropertiesWindow = BCF_CreateWindow(GraphicsWidth()/2-200,GraphicsHeight()/2-130,370,520,1,1,"Unit Property Window", True, True)
BCF_CreateImage(UnitPropertiesWindow,10,30,128,128,"Units"+u\ImgSm$)
BCF_CreateLabelText(UnitPropertiesWindow,10,10,unit$,1,2)
BCF_CreateLabelText(UnitPropertiesWindow,145,30,"Number Of Weapons = " + u\NumWeapons)
wl.WeaponList = u\Weapons
UnitProperties(1) = BCF_CreateComboxBox(UnitPropertiesWindow,145,50,200,80)
If wl\NextWeapon = Null
BCF_AddComboBoxItem(UnitProperties(1),"This Unit Has No Weapons")
BCF_SelectedComboBoxValue(UnitProperties(1),"This Unit Has No Weapons")
Else
While Not wl\NextWeapon = Null
BCF_AddComboBoxItem(UnitProperties(1), wl\WeaponName$)
wl = wl\NextWeapon
Wend
BCF_SelectedComboBoxValue(UnitProperties(1),u\Weapons\WeaponName$)
EndIf
offset = 120
OldUnitPropertiesComboBoxValue$=u\Weapons\WeaponName$
UnitProperties(2) = BCF_CreateLabelText(UnitPropertiesWindow,145,80,"Weapon Type = " + u\Weapons\WeaponType$)
If u\Weapons\Damage <> -1
UnitProperties(3) = BCF_CreateLabelText(UnitPropertiesWindow,145,100,"Ground Damage = " + u\Weapons\Damage)
Else
UnitProperties(3) = BCF_CreateLabelText(UnitPropertiesWindow,145,100,"This Weapon Cannot Attack Ground")
EndIf
If u\Weapons\AirDamage <> -1
UnitProperties(4) = BCF_CreateLabelText(UnitPropertiesWindow,145,120,"Air Damage = " + u\Weapons\AirDamage)
Else
UnitProperties(4) = BCF_CreateLabelText(UnitPropertiesWindow,145,120,"This Weapon Cannot Attack Air")
EndIf
offset = offset + 20
UnitProperties(5) = BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Weapon Speed = " + u\Weapons\Speed)
offset = offset + 20
UnitProperties(6) = BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Weapon Range = " + u\Weapons\Range)
offset = offset + 20
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Unit Properties",1,2)
offset = offset+20
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Unit Type = " + u\UnitData\UnitType$)
offset = offset + 20
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Armor Type = " + u\UnitData\Armor$)
offset = offset + 20
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Health = " + u\UnitData\Health)
offset = offset + 20
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Speed = " + u\UnitData\Speed)
offset = offset + 20
If Instr(u\UnitData\UnitType$,"AIR")
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Fuel = " + u\UnitData\Fuel)
offset = offset+20
EndIf
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Cost = " + u\UnitData\Cost + "$")
offset = offset+20
If u\UnitData\Transport = True
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Transprt = TRUE : Cargo Space = " + u\UnitData\TransportSpace)
Else
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Transport = FALSE")
EndIf
offset = offset + 20
If u\UnitData\Detector = True
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Detector = TRUE")
Else
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Detector = FALSE")
EndIf
offset = offset + 20
If u\UnitData\Builder = True
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Builder = TRUE")
Else
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Builder = FALSE")
EndIf
offset = offset+20
team.Team = FindUnitTeam(u)
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Team = " + team\Name$)
offset = offset+20
If u\UnitData\Stealth = True
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Stealth = TRUE")
Else
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Stealth = FALSE")
EndIf
offset = offset + 25
BCF_CreateLabelText(UnitPropertiesWindow,145,offset,"Possible Buildings")
offset = offset + 20
UnitProperties(7) = BCF_CreateComboxBox(UnitPropertiesWindow,145,offset,200,80)
If u\Buildings = Null
BCF_AddComboBoxItem(UnitProperties(7),"This Unit Is NOT a Builder")
BCF_SelectedComboBoxValue(UnitProperties(7),"This Unit Is NOT a Builder")
UnitProperties(9) = False
Else
b.BuildingList = u\Buildings
While b<>Null
BCF_AddComboBoxItem(UnitProperties(7),b\BuildingName$)
b = b\NextBuilding
Wend
BCF_SelectedComboBoxValue(UnitProperties(7),u\Buildings\BuildingName$)
UnitProperties(9) = True
EndIf
offset = offset +30
UnitProperties(8) = BCF_CreateButton(UnitPropertiesWindow,145,offset,115,20,"Properties")
End Function
Function UpdateUnitPropertiesWindow(NewWeaponName$)
u.Unit = Object.Unit(UnitProperties(0))
w.WeaponList = u\Weapons
While w\WeaponName$<>NewWeaponName$ And w\NextWeapon<>Null
w = w\NextWeapon
Wend
BCF_ChangeLabelTextLabel(UnitProperties(2),"Weapon Type = " + w\WeaponType$)
If w\Damage <> -1
BCF_ChangeLabelTextLabel(UnitProperties(3),"Ground Damage = " + w\Damage)
Else
BCF_ChangeLabelTextLabel(UnitProperties(3),"This Weapon Cannot Attack Ground")
EndIf
If w\AirDamage <> -1
BCF_ChangeLabelTextLabel(UnitProperties(4),"Air Damage = " + w\AirDamage)
Else
BCF_ChangeLabelTextLabel(UnitProperties(4),"This Weapon Cannot Attack Air")
EndIf
BCF_ChangeLabelTextLabel(UnitProperties(5),"Weapon Speed = " + w\Speed)
BCF_ChangeLabelTextLabel(UnitProperties(6),"Weapon Range = " + w\Range)
End Function
Function LoadTeams()
myDir = ReadDir("Teams")
While True
file$ = NextFile$(myDir)
If file$ = "" Then Exit
If FileType("Teams"+file$) = 1
LoadTeam(file$)
NumTeam = NumTeam + 1
EndIf
Wend
CloseDir myDir
myDir = 0
i = 0
For t.Team = Each Team
i = 0
For ct.Team = Each Team
If t\ID = ct\ID Then i = i +1
Next
If i >= 2 Then RuntimeError "Multiple Teams With The Same IDs"
Next
End Function
Function LoadTeam(FileName$)
ChangeDir "Teams"
state = 0
file = False
this.Team = Null
in = ReadFile(FileName$)
Local ln$ = ""
While Not ln$ = "#END"
ln$ = EatWhite$(ReadLine$(in))
If Left$(ln$,2) <> "//"
Select(state)
Case 0:
If Instr(ln$,"#HEADER") And file = False Then state = 1
If Instr(ln$,"#CORE") Then state = 2
Case 1:
If Instr(ln$,"FILETYPE") And file = False
If Right$(ln$,Len(ln$)-(Len("FILETYPE"))-1) = "TEAMFILE"
file = True
this = New Team
EndIf
EndIf
If Instr(ln$,"VERSION")
If Not Right$(ln$,Len(ln$)-(Len("VERSION"))-1) = VS_TEAMFILE Then RuntimeError("File: "+FileName$ + ". Fileversion was Not current " +Right$(ln$,Len(ln$)-(Len("VERSION")-1)))
EndIf
If Instr(ln$,"#ENDHEADER") Then state = 0
Case 2:
If Instr(ln$,"TEAMNAME") And Instr(ln$,"SMALL") = 0 And file = True
this\Name$ = Right$(ln$,Len(ln$)-(Len("TEAMNAME"))-1)
EndIf
If Instr(ln$,"TEAMNAMESMALL") And file = True
this\NameSmall$ = Right$(ln$,Len(ln$)-(Len("TEAMNAMESMALL"))-1)
EndIf
If Instr(ln$,"TEAMID") And file = True
this\ID = Int(Right$(ln$,Len(ln$)-(Len("TEAMID"))-1))
EndIf
If Instr(ln$,"TILEHASUNITIMAGE") And file = True
this\HasUnitImage = LoadImage(Right$(ln$,Len(ln$)-(Len("TILEHASUNITIMAGE"))-1))
EndIf
If Instr(ln$,"TILEHASBUILDINGIMAGE") And file = True
this\HasBuildingImage = LoadImage(Right$(ln$,Len(ln$)-(Len("TILEHASBUILDINGIMAGE"))-1))
EndIf
If Instr(ln$,"#ENDCORE") Then state = 0
Default:
RuntimeError "Error In Team File"
End Select
EndIf
Wend
CloseFile in
ChangeDir ".."
End Function
Function FindUnitTeam.Team(u.Unit)
searchID = u\TeamID
ret.Team = Null
For t.Team = Each Team
If t\ID = searchID Then ret = t
Next
If ret = Null Then RuntimeError "Error: Unit " + u\Name$ + "has invalid team id associated"
Return ret
End Function
Function FindBuildingTeam.Team(b.Building)
searchID = b\TeamID
ret.Team = Null
For t.Team = Each Team
If t\ID = searchID Then ret = t
Next
If ret = Null Then RuntimeError "Error: Building " + b\Name$ + "has an invalid team id associated"
Return ret
End Function
Function FindTeam.Team(searchName$)
ret.Team = Null
For t.Team = Each Team
If t\Name$ = searchName$ Then ret = t
Next
If ret = Null Then RuntimeError "Error: Team " + searchName$ + " does not exist"
Return ret
End Function
Function FindUnit.Unit(searchName$)
ret.Unit = Null
For u.Unit = Each Unit
If u\Name$ = searchName$ Then ret = u
Next
If ret = Null Then RuntimeError "Error: Unit " + searchName$ + " does not exist"
Return ret
End Function
Function GetHandleFromString(UnitString$)
OldPos = 0
NewPos = Instr(UnitString$,"H")
While NewPos<>0
OldPos = NewPos
NewPos = Instr(UnitString$,"H",OldPos+1)
Wend
UnitHandle = Right$(UnitString$,Len(UnitString$)-OldPos)
Return UnitHandle
End Function
Function GetNameFromUnit$(UnitHandle)
u.Unit = Object.Unit(UnitHandle)
Return u\Name$
End Function
Function GetUnitFromList(UnitListHandle)
ul.UnitList = Object.UnitList(UnitListHandle)
Return Handle(ul\u)
End Function
Function LoadBuilding.Building(FileName$)
ChangeDir "Buildings"
state = 0
file = False
this.Building = Null
in = ReadFile(FileName$)
Local ln$ = ""
While Not ln$ = "#END"
ln$ = EatWhite$(ReadLine$(in))
If Left$(ln$,2) <> "//"
Select(state)
Case 0:
If Instr(ln$,"#HEADER") And file = False Then state = 1
If Instr(ln$,"#CORE") Then state = 2
If Instr(ln$,"#BUILDINGWEAPONS") Then state = 3
If Instr(ln$,"#BUILDINGUNITS") Then state = 4
If Instr(ln$,"#BUILDINGDATA") Then state = 5
Case 1:
If Instr(ln$,"FILETYPE") And file = False
If Right$(ln$,Len(ln$)-(Len("FILETYPE"))-1) = "BUILDINGFILE"
file = True
this = New Building
EndIf
EndIf
If Instr(ln$,"VERSION")
If Not Right$(ln$,Len(ln$)-(Len("VERSION"))-1) = VS_BUILDINGFILE Then RuntimeError("File: "+FileName$ + ". Fileversion was not current version = " +Right$(ln$,Len(ln$)-(Len("VERSION"))-1) + " for file " + FileName$)
EndIf
If Instr(ln$,"#ENDHEADER") Then state = 0
Case 2:
If Instr(ln$,"BUILDINGNAME") And file = True
this\Name$ = Right$(ln$,Len(ln$)-(Len("BUILDINGNAME"))-1)
EndIf
If Instr(ln$,"NUMWEAPONS") And file = True
this\NumWeapons = Right$(ln$,Len(ln$)-(Len("NUMWEAPONS"))-1)
this\Weapons = New WeaponList
w.WeaponList = this\Weapons
For i = 1 To this\NumWeapons
w\NextWeapon = New WeaponList
w\AirDamage = -1
w\Damage = -1
w = w\NextWeapon
Next
w = Null
EndIf
If Instr(ln$,"NUMUNITS") And file = True
this\NumUnits = Right$(ln$,Len(ln$)-(Len("NUMUNITS"))-1)
this\Units = New UnitList
u.UnitList = this\Units
For i = 1 To this\NumUnits
u\NextUnit = New UnitList
u\u = Null
u = u\NextUnit
Next
u = Null
EndIf
If Instr(ln$,"IMGLG") And file = True
this\ImgLg$ = Right$(ln$,Len(ln$)-(Len("IMGLG"))-1) ;LoadImage(Right$(ln$,Len(ln$)-(Len("IMGSM"))-1))
EndIf
If Instr(ln$,"IMGSM") And file = True
this\ImgSmString$ = Right$(ln$,Len(ln$)-(Len("IMGSM"))-1) ;LoadImage(Right$(ln$,Len(ln$)-(Len("IMGSM"))-1))
this\ImgSm = LoadImage(this\ImgSmString$)
EndIf
If Instr(ln$,"TEAMID") And file = True
this\TeamID = Int(Right$(ln$,Len(ln$)-(Len("TEAMID"))-1))
EndIf
If Instr(ln$,"#ENDCORE") Then state = 0
Case 3:
If w.WeaponList = Null Then w.WeaponList = this\Weapons
If Instr(ln$,"WEAPON") And Instr(ln$,"WEAPONS")<=0
w\WeaponName$ = Right$(ln$,Len(ln$)-(Len("WEAPON"))-2)
EndIf
If Instr(ln$,"TYPE")
w\WeaponType$ = Right$(ln$,Len(ln$)-(Len("TYPE"))-1)
EndIf
If Instr(ln$,"DAMAGE") And Instr(ln$,"AIRDAMAGE") = 0
w\Damage = Right$(ln$,Len(ln$)-(Len("DAMAGE"))-1)
EndIf
If Instr(ln$,"SPEED")
w\Speed = Right$(ln$,Len(ln$)-(Len("SPEED"))-1)
EndIf
If Instr(ln$,"AIRDAMAGE")
w\AirDamage = Right$(ln$,Len(ln$)-(Len("AIRDAMAGE"))-1)
EndIf
If Instr(ln$,"RANGE")
w\Range = Right$(ln$,Len(ln$)-(Len("RANGE"))-1)
EndIf
If Instr(ln$,"]")
If Not w\NextWeapon = Null Then w = w\NextWeapon
EndIf
If Instr(ln$,"#ENDBUILDINGWEAPONS") Then state = 0
Case 4:
If this\NumUnits > 0 And Instr(ln$,"#ENDBUILDINGUNITS") = 0 And Instr(ln$,"NONE") = 0
If u.UnitList = Null Then u.UnitList = this\Units
u\u = FindUnit(ln$)
u = u\NextUnit
EndIf
If Instr(ln$,"#ENDBUILDINGUNITS") Then state = 0
Case 5:
If Instr(ln$,"ARMOR") And Instr(ln$,"ARMORDEFENCE") = 0
this\Armor$ = Right$(ln$,Len(ln$)-(Len("ARMOR"))-1)
EndIf
If Instr(ln$,"HEALTH")
this\Health = Right$(ln$,Len(ln$)-(Len("HEALTH"))-1)
EndIf
If Instr(ln$,"INFANTRYDEFENCE")
this\InfantryDefence = Right$(ln$,Len(ln$)-(Len("INFANTRYDEFENCE"))-1)
EndIf
If Instr(ln$,"ARMORDEFENCE")
this\ArmorDefence = Right$(ln$,Len(ln$)-(Len("ARMORDEFENCE"))-1)
EndIf
If Instr(ln$,"PLANES")
If Right$(ln$,Len(ln$)-(Len("PLANES"))-1) = "TRUE"
this\bAir = True
Else
this\bAir = False
EndIf
EndIf
If Instr(ln$,"REFUEL")
If Right$(ln$,Len(ln$)-(Len("REFUEL"))-1) = "TRUE"
this\bRefuel = True
Else
this\bRefuel = False
EndIf
EndIf
If Instr(ln$,"DETECTOR")
If Right$(ln$,Len(ln$)-(Len("DETECTOR"))-1) = "TRUE"
this\bDetector = True
Else
this\bDetector = False
EndIf
EndIf
If Instr(ln$,"TANKS")
If Right$(ln$,Len(ln$)-(Len("TANKS"))-1) = "TRUE"
this\bArmor = True
Else
this\bArmor = False
EndIf
EndIf
If Instr(ln$,"INFANTRY")
If Right$(ln$,Len(ln$)-(Len("INFANTRY"))-1) = "TRUE"
this\bInfantry = True
Else
this\bInfantry = False
EndIf
EndIf
If Instr(ln$,"SHIPS")
If Right$(ln$,Len(ln$)-(Len("SHIPS"))-1) = "TRUE"
this\bShips = True
Else
this\bShips = False
EndIf
EndIf
If Instr(ln$,"COST")
this\Cost = Right$(ln$,Len(ln$)-(Len("COST"))-1)
EndIf
If Instr(ln$,"#ENDBUILDINGDATA") Then state = 0
Default:
RuntimeError "Error In Unit File"
End Select
EndIf
Wend
CloseFile in
ChangeDir ".."
Return this
End Function
Function LoadBuildings()
myDir = ReadDir("Buildings")
While True
file$ = NextFile$(myDir)
If file$ = "" Then Exit
If FileType("Buildings"+file$) = 1
LoadBuilding(file$)
NumBuildings = NumBuildings + 1
EndIf
Wend
CloseDir myDir
myDir = 0
End Function
Function CreateBuildingWindow()
If BCF_Window(TileToolWindow) Or BCF_Window(UnitWindow)
BCF_MsgBox("Warning","You Can Not Open The Building Editor With The Tile or Unit Editor Open",0)
Return
Else If BCF_Window(BuildingWindow) = False
BuildingWindow = BCF_CreateWindow(GraphicsWidth()/2-200,GraphicsHeight()/2-130,420,255,1,1,"Unit Tool Bar", True, True)
BuildingSelectedTileLabel = BCF_CreateLabelText(BuildingWindow,10,20,"Selected Tile = ",1,1)
BuildingInTileLabel = BCF_CreateLabelText(BuildingWindow,10,40,"Building on Tile = NONE",1,1)
BCF_CreateLabelText(BuildingWindow,200,60,"Possible Buildings",1,1)
TileBuildingTeamComboBox = BCF_CreateComboxBox(BuildingWindow,200,20,200,50)
BuildingListBox = BCF_CreateListBox(BuildingWindow,200,80,150,120)
For team.Team = Each Team
BCF_AddComboBoxItem(TileBuildingTeamComboBox, team\Name$)
Next
team = First Team
LastTileBuildingTeamComboBoxValue$ = team\Name$
BCF_SelectedComboBoxValue(TileBuildingTeamComboBox,team\Name$)
For b.Building = Each Building
If b\teamID = team\ID Then BCF_AddListBoxItem(BuildingListBox,b\Name$ + " : H" + Handle(b))
Next
BuildingSelectedLabel = BCF_CreateLabelText(BuildingWindow,10,90,"Selected Building = NONE",1,1)
BuildingPropertiesButton = BCF_CreateButton(BuildingWindow,10,110,90,20,"Properties")
BuildingChangeBuildingButton = BCF_CreateButton(BuildingWindow,10,60,100,20,"Change Building")
EndIf
End Function
Function UpdateBuildingWindow()
BCF_ChangeLabelTextLabel(BuildingSelectedTileLabel,"Selected Tile = " + SelectedX + " x " + SelectedY)
If CurrentBuildingLevel(SelectedX,SelectedY)<>Null
BCF_ChangeLabelTextLabel(BuildingInTileLabel,"Building on Tile = " + CurrentBuildingLevel(SelectedX,SelectedY)\Name$)
Else
BCF_ChangeLabelTextLabel(BuildingInTileLabel,"Building on Tile = NONE")
EndIf
End Function
Function FreeBuilding(b.Building)
If Not b = Null
FreeImage b\ImgSm
Delete b
EndIf
End Function
Function FreeBuildings()
For b.Building = Each Building
FreeBuilding b
Next
End Function
Function GetNameFromBuilding$(BuildingHandle)
b.Building = Object.Building(BuildingHandle)
Return b\Name$
End Function
Function CreateBuildingPropertiesWindow(Building$)
If BCF_Window(BuildingPropertiesWindow)
BCF_MsgBox("Warning","You Can Not Open A New Properties Window While An Old One is Already Opened",0)
Return
EndIf
BuildingHandle = GetHandleFromString(Building$)
Building$ = Left$(Building$,Instr(Building$,":")-2)
b.Building = Object.Building(BuildingHandle)
BuildingProperties(0) = BuildingHandle
BuildingPropertiesWindow = BCF_CreateWindow(GraphicsWidth()/2-200,GraphicsHeight()/2-130,370,500,1,1,"Building Property Window", True, True)
DebugLog b\ImgSm$
BCF_CreateImage(BuildingPropertiesWindow,10,30,32,32,"Buildings"+b\ImgSmString$)
BCF_CreateImage(BuildingPropertiesWindow,10,80,128,128,"Buildings"+b\ImgLg$)
BCF_CreateLabelText(BuildingPropertiesWindow,10,10,Building$,1,2)
BCF_CreateLabelText(BuildingPropertiesWindow,145,30,"Number Of Weapons = " + b\NumWeapons)
wl.WeaponList = b\Weapons
BuildingProperties(1) = BCF_CreateComboxBox(BuildingPropertiesWindow,145,50,200,80)
If wl\NextWeapon = Null
BCF_AddComboBoxItem(BuildingProperties(1),"This Building Has No Weapons")
BCF_SelectedComboBoxValue(BuildingProperties(1),"This Building Has No Weapons")
Else
While Not wl\NextWeapon = Null
BCF_AddComboBoxItem(BuildingProperties(1), wl\WeaponName$)
wl = wl\NextWeapon
Wend
BCF_SelectedComboBoxValue(BuildingProperties(1),b\Weapons\WeaponName$)
EndIf
offset = 120
OldBuildingPropertiesComboBoxValue$=b\Weapons\WeaponName$
BuildingProperties(2) = BCF_CreateLabelText(BuildingPropertiesWindow,145,80,"Weapon Type = " + b\Weapons\WeaponType$)
If b\Weapons\Damage <> -1
BuildingProperties(3) = BCF_CreateLabelText(BuildingPropertiesWindow,145,100,"Ground Damage = " + b\Weapons\Damage)
Else
BuildingProperties(3) = BCF_CreateLabelText(BuildingPropertiesWindow,145,100,"This Weapon Cannot Attack Ground")
EndIf
If b\Weapons\AirDamage <> -1
BuildingProperties(4) = BCF_CreateLabelText(BuildingPropertiesWindow,145,120,"Air Damage = " + b\Weapons\AirDamage)
Else
BuildingProperties(4) = BCF_CreateLabelText(BuildingPropertiesWindow,145,120,"This Weapon Cannot Attack Air")
EndIf
offset = offset + 20
BuildingProperties(5) = BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Weapon Speed = " + b\Weapons\Speed)
offset = offset + 20
BuildingProperties(6) = BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Weapon Range = " + b\Weapons\Range)
offset = offset + 20
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Building Properties:",1,2)
offset = offset + 20
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Armor Type = " + b\Armor$)
offset = offset + 20
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Infantry Defence = " + b\InfantryDefence)
offset = offset + 20
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Armor Defence = " + b\ArmorDefence)
offset = offset + 20
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Cost = " + b\Cost + "$")
offset = offset+20
If b\bRefuel = True
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Refuel = TRUE")
Else
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Refuel = FALSE")
EndIf
offset = offset + 20
If b\bDetector = True
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Detector = TRUE")
Else
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Detector = FALSE")
EndIf
offset = offset+20
team.Team = FindBuildingTeam(b)
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Team = " + team\Name$)
offset = offset + 20
BCF_CreateLabelText(BuildingPropertiesWindow,10,offset,"Types of units that will be affected by bonuses")
offset = offset + 20
If b\bAir = True
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Planes = TRUE")
Else
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Planes = FALSE")
EndIf
offset = offset+20
If b\bArmor = True
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Tanks = TRUE")
Else
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Tanks = FALSE")
EndIf
offset = offset+20
If b\bInfantry = True
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Infantry = TRUE")
Else
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Infantry = FALSE")
EndIf
offset = offset+20
If b\bShips = True
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Ships = TRUE")
Else
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Ships = FALSE")
EndIf
offset = offset + 25
BCF_CreateLabelText(BuildingPropertiesWindow,145,offset,"Possible Units That Can Be Built:")
offset = offset + 20
BuildingProperties(7) = BCF_CreateComboxBox(BuildingPropertiesWindow,145,offset,200,80)
If b\Units\u = Null
BCF_AddComboBoxItem(BuildingProperties(7),"This Building Is NOT a Builder")
BCF_SelectedComboBoxValue(BuildingProperties(7),"This Building Is NOT a Builder")
BuildingProperties(9)=False
Else
u.UnitList = b\Units
While u<>Null And u\u<>Null
BCF_AddComboBoxItem(BuildingProperties(7),u\u\Name$)
u = u\NextUnit
Wend
BCF_SelectedComboBoxValue(BuildingProperties(7),b\Units\u\Name$)
BuildingProperties(9)=True
EndIf
offset = offset +30
BuildingProperties(8) = BCF_CreateButton(BuildingPropertiesWindow,10,offset-135,128,128,"Unit Properties")
End Function
Function UpdateBuildingPropertiesWindow(NewWeaponName$)
b.Building = Object.Building(BuildingProperties(0))
w.WeaponList = b\Weapons
While w\WeaponName$<>NewWeaponName$ And w\NextWeapon<>Null
w = w\NextWeapon
Wend
BCF_ChangeLabelTextLabel(BuildingProperties(2),"Weapon Type = " + w\WeaponType$)
If w\Damage <> -1
BCF_ChangeLabelTextLabel(BuildingProperties(3),"Ground Damage = " + w\Damage)
Else
BCF_ChangeLabelTextLabel(BuildingProperties(3),"This Weapon Cannot Attack Ground")
EndIf
If w\AirDamage <> -1
BCF_ChangeLabelTextLabel(BuildingProperties(4),"Air Damage = " + w\AirDamage)
Else
BCF_ChangeLabelTextLabel(BuildingProperties(4),"This Weapon Cannot Attack Air")
EndIf
BCF_ChangeLabelTextLabel(BuildingProperties(5),"Weapon Speed = " + w\Speed)
BCF_ChangeLabelTextLabel(BuildingProperties(6),"Weapon Range = " + w\Range)
End Function
Function FindBuilding.Building(searchName$)
ret.Building= Null
For u.Building= Each Building
If u\Name$ = searchName$ Then ret = u
Next
If ret = Null Then RuntimeError "Error: Building " + searchName$ + " does not exist"
Return ret
End Function
you can use the media from the download