home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ANews 3
/
AnewsCD3.iso
/
DP
/
Programmation
/
PureBasic_Demo
/
Examples
/
Sources
/
WildManager.pb
< prev
next >
Wrap
Text File
|
1999-10-10
|
13KB
|
633 lines
;
;
; ----------> <------
; Wild Manager V1.01
; ------------> <--------
;
; © 1999 - Fantaisie Software - Coded by AlphaSND
;
;
; Description: Preference front-end for the WILD 3D package from 'Pyper'
;
;
; NOTE:
; -----
;
; A String in a linked list must not be to NULL for the listview, else
; we got an enforcer hit (AmigaOS 'bug') !
;
;
WBStartup()
InitScreen(0)
InitWindow(0)
InitGadget(0)
InitFile (0)
If InitRequester() = 0
End
EndIf
*TagList = InitTagList(10) ; Note you can use TagListID() but using a variable is smaller/faster
Mode.s
Structure PBScreenInfo
DisplayID.l ; Display mode ID
Width.l ; Width of display in pixels
Height.l ; Height of display in pixels
Depth.w ; Number of bit-planes of display
OverscanType.w ; Type of overscan of display
AutoScroll.b
EndStructure
Structure NLVList
Pad.w
Item.s
Command.s
Processors.b
Rendering.b
Warp3D.b
Width.w
Height.w
ScreenID.l
Changed.b
AGA.b
EndStructure
NewList PL.NLVList()
;
; Read pref file..
;
;LoadPref
If ReadFile(0, "PROGDIR:WildManager.pref")
a$ = ReadString()
If a$ = "WildManagerPref1"
NbProg = ReadWord()
For k=0 To NbProg-1
If AddElement(PL())
PL()\Item = ReadString()
PL()\Command = ReadString()
PL()\Processors = ReadByte()
PL()\Rendering = ReadByte()
PL()\Warp3D = ReadByte()
PL()\Width = ReadWord()
PL()\Height = ReadWord()
PL()\ScreenID = ReadLong()
PL()\AGA = ReadByte()
EndIf
a$ = ReadString() ; "WAM_End_WAM"
Next
EndIf
CloseFile(0)
Else
NoPref = 1
EndIf
If NbProg<1 OR NoPref
AddElement(PL())
PL()\Item = "Program 1"
NbProg = 1
EndIf
FirstElement(PL())
Dim Language.s(8)
*MyScreen = FindScreen(0,"Workbench")
;
; Now, create all the windows gadgets
;
If CreateGadgetList(0, ScreenID())
HG = 20
HFont = ScreenFontHeight()
HFont3 = HFont+3
HFont6 = HFont+6
Top = HG
ResetTagList(#GTST_MaxChars,100)
AddTag(#GA_Immediate, 1)
AddTag(#GTST_String, PL()\Item)
StringGadget(1, 210, HG, 200, HFont6, "Name:", *TagList) : HG=HG+HFont6+2
a$ = "Fountain.exe"
ResetTagList(#GTST_MaxChars,1000)
AddTag(#GTST_String, PL()\Command)
AddTag(#GA_Immediate, 1)
StringGadget(2, 210, HG, 180, HFont6, "Program:", *TagList)
ButtonGadget(16, 390, HG, 20, HFont6, "?" , 0) : HG=HG+HFont6+10
Dim WildProcessor.s(2)
WildProcessor(0) = "680x0"
WildProcessor(1) = "PowerPC"
ResetTagList(#GTCY_Labels, WildProcessor())
AddTag(#GTCY_Active, PL()\Processors)
SetGadgetFlags(#PLACETEXT_LEFT)
CycleGadget (7, 210, HG, 100, HFont6, "Amiga:", *TagList) : HG=HG+HFont6+2
Dim WildRender.s(4)
WildRender(0) = "WireFrame"
WildRender(1) = "Flat"
WildRender(2) = "Gouraud"
WildRender(3) = "Textured"
ResetTagList(#GTCY_Labels, WildRender())
AddTag(#GTCY_Active, PL()\Rendering)
SetGadgetFlags(#PLACETEXT_LEFT)
CycleGadget(8, 210, HG, 100, HFont6, "Rendering:", *TagList) : HG=HG+HFont6+2
ResetTagList(#GTCB_Scaled, 1)
AddTag(#GTCB_Checked, PL()\Warp3D)
SetGadgetFlags(#PLACETEXT_LEFT)
CheckBoxGadget(13, 210, HG, HFont6, HFont6, "Warp3D:", *TagList) : HG=HG+HFont6+2
TextGadget(11, 210, HG, 0, HFont6, "Screen:" , 0)
SetGadgetFlags(#PLACETEXT_IN)
TextGadget(20, 330, HG, 80, HFont6, "" , 0)
Dim WildScreen.s(2)
WildScreen(0) = "CGFX"
WildScreen(1) = "AGA"
ResetTagList (#GTCY_Labels, WildScreen())
AddTag (#GTCY_Active, PL()\AGA)
CycleGadget (21, 210, HG, 60, HFont6, "", *TagList)
ButtonGadget (10, 272, HG, 50, HFont6, "Set", 0) : HG=HG+HFont6+HFont
If PL()\Command = ""
a=1
Else
a=0
Endif
ResetTagList (#GA_Disabled, a)
ButtonGadget (17, 210, HG, 200, HFont6, "-> Launch IT ! <-" , *TagList)
*RealList = ListBase(PL())
ResetTagList (#GTLV_Labels, *RealList)
AddTag (#GTLV_ShowSelected, 0)
AddTag (#GTLV_Selected, 0)
SetGadgetFlags (#PLACETEXT_ABOVE)
*a.Gadget = ListViewGadget(9, 12, Top+HFont+7, 100, HG-Top-(HFont+7), "Programs:", *TagList)
ListViewGadget(9, 12, Top+HFont+7, 100, HG-Top-(HFont+7), "Programs:", *TagList)
real = Top+HFont+9+*a\Height
SetGadgetFlags (#PLACETEXT_IN)
ButtonGadget (14, 12, real, 49, HFont6, "Add", 0)
ButtonGadget (15, 63, real, 49, HFont6, "Del", 0) : HG=HG+HFont6+16
SetGadgetFlags (#PLACETEXT_IN)
ButtonGadget (4, 12, HG, 125, HFont6+2, "Save" , 0)
ButtonGadget (5, 148, HG, 125, HFont6+2, "Use" , 0)
ButtonGadget (6, 285, HG, 125, HFont6+2, "Cancel" , 0)
EndIf
;
; Open our window and attach gadgets & menus..
;
WinTitle$ = "Wild Manager V1.00"
ScreenTitle$ = "Wild Manager - © 1999 Fantaisie Software"
ResetTagList (#WA_Title, @WinTitle$)
AddTag (#WA_CustomScreen, ScreenID())
AddTag (#WA_ScreenTitle, @ScreenTitle$)
WHeight = HG+HFont+2
If OpenWindow(0, ScreenWidth()/2-210, HFont+20, 416, WHeight, #WFLG_CLOSEGADGET | #WFLG_DRAGBAR | #WFLG_DEPTHGADGET | #WFLG_ACTIVATE | #WFLG_RMBTRAP, *TagList)
BevelBox(WindowBorderLeft(),WindowBorderTop(),WindowInnerWidth(),WindowInnerHeight(),0)
BevelBox(WindowBorderLeft()-1,HG-7,WindowInnerWidth()+2,2,1)
AttachGadgetList(0, WindowID())
Gosub DisableWarp3D
Gosub DisableDel
Gosub RefreshScreenMode
MainLoop:
Repeat
Repeat
VWait()
IDCMP.l = WindowEvent()
Until IDCMP
; Special for mouseclick when editing a String !
;
;
If MustBeRefreshed
If MustBeRefreshed = 1
Gosub String1
Else
Gosub String2
EndIf
MustBeRefreshed = 0
EndIf
Gadget = EventGadget()
Code = EventCode()
If IDCMP = #IDCMP_GADGETUP OR IDCMP = #IDCMP_GADGETDOWN ; A gadget has been pushed
Select Gadget
Case 1
Gosub String1
MustBeRefreshed = 1
Case 2
Gosub String2
MustBeRefreshed = 2
Case 4 ; 'Save'
Gosub SavePrefs
IDCMP = #IDCMP_CLOSEWINDOW
Case 5 ; 'Use'
IDCMP = #IDCMP_CLOSEWINDOW
Case 6 ; 'Cancel'
IDCMP = #IDCMP_CLOSEWINDOW
Case 7
PL()\Processors = Code
PL()\Changed = 1
Case 8
PL()\Rendering = Code
PL()\Changed = 1
Gosub DisableWarp3D
Case 9
ResetList(PL())
For k=0 To Code
NextElement(PL())
Next
Gosub RefreshWindow
Case 10
ResetTagList (#ASLSM_DoWidth , 1)
AddTag (#ASLSM_DoHeight , 1)
AddTag (#ASLSM_DoOverscanType , 1)
AddTag (#ASLSM_InitialDisplayID , PL()\ScreenID)
If PL()\Width
AddTag (#ASLSM_InitialDisplayWidth , PL()\Width)
AddTag (#ASLSM_InitialDisplayHeight , PL()\Height)
EndIf
*sm.PBScreenInfo = ScreenRequester(*TagList)
If *sm
PL()\Width = *sm\Width
PL()\Height = *sm\Height
PL()\ScreenID = *sm\DisplayID
EndIf
Gosub RefreshScreenMode
PL()\Changed = 1
Case 13 ; 'Warp3D - On/Off'
PL()\Warp3D = Code
PL()\Changed = 1
Case 14 ; 'Add'
NbProg = NbProg+1
AddElement(PL())
PL()\Item = ""
GadgetAttrs(9, #GTLV_Labels, *RealList)
GadgetAttrs(9, #GTLV_Selected, ListIndex(PL()))
RefreshGadget(9)
Gosub RefreshWindow
ActivateGadget(1)
Case 15 ; 'Del'
KillElement(PL())
NbProg = NbProg-1
GadgetAttrs(9, #GTLV_Labels, *RealList)
RefreshGadget(9)
NextElement(PL())
Gosub RefreshWindow
Case 16
b$ = PL()\Command
file$ = GetFilePart(b$)