home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / sourcecode / general / 3d_requester.amos / 3d_requester.amosSourceCode
Encoding:
AMOS Source Code  |  1993-01-06  |  3.7 KB  |  189 lines

  1. '
  2. ' *** REQUESTER ROUTINE ***
  3. '
  4. ' * The variable Q must be global, or this routine will not work.
  5. '
  6. Global AN,Q
  7. '
  8. ' * These are just some lines to test the requesters.
  9. '
  10. ALERT["UP TO 5 BUTTONS","0123456789|ABCDEFGHIJ|abcdefghij|Haaarrgh !|>>> ** <<<"]
  11. ALERT["SMALL !","YO !"]
  12. ALERT["********** THIS IS A VERY VERY VERY VERY VERY VERY LONG LINE O.K ! **********","YEP !"]
  13. ALERT["MULTIBLE|TEXT|IS|THAT|OK!","YEP|NO|PROBLEM|MATEY|!!!"]
  14. ALERT["PRESS A BUTTON !","1|2|3|4|5"]
  15. '
  16. ' * Print button that was pressed in last requester. 
  17. '
  18. Print "Button";Q;" was pressed."
  19. '
  20. ' * The character | seperates lnes and buttons e.g.
  21. '
  22. ' * You are only allowed five lines of text with a width of 77 each. 
  23. '
  24. Q$="LINE ONE|LINE TWO|LINE THREE"
  25. '
  26. ' * You are only allowed five buttons with a width of 10 each. 
  27. '
  28. W$="BUTTON ONE|BUTTON TWO"
  29. '
  30. ' * Try requester. 
  31. '
  32. ALERT[Q$,W$]
  33. '
  34. Direct 
  35. '
  36. ' * This is the 3D-Button routine. 
  37. '
  38. Procedure B[X1,Y1,X2,Y2,A$,IN,BC,FC]
  39.    If IN=1
  40.       C1=2
  41.       C2=3
  42.    Else 
  43.       C1=3
  44.       C2=2
  45.    End If 
  46.    Ink BC
  47.    If IN<2
  48.       Bar X1,Y1 To X2,Y2
  49.       Ink C1
  50.       Box X1,Y1 To X2,Y2
  51.       Ink C2
  52.       Polyline X1,Y2 To X2,Y2 To X2,Y1
  53.       If IN=1
  54.          Plot X1+1,Y1+1,1
  55.       End If 
  56.    Else 
  57.       Bar X1+1,Y1+1 To X2-1,Y2-1
  58.    End If 
  59.    If A$<>""
  60.       WID=Text Length(A$)
  61.       X7=(((X2-X1)/2)+X1)-(WID/2)
  62.       Gr Writing 0
  63.       Ink 3,BC
  64.       Text X7+1,((Y2-Y1)/2)+Y1+3,A$
  65.       Text X7-1,((Y2-Y1)/2)+Y1+3,A$
  66.       Text X7,((Y2-Y1)/2)+Y1+4,A$
  67.       Text X7,((Y2-Y1)/2)+Y1+2,A$
  68.       Ink FC,BC
  69.       Text X7,((Y2-Y1)/2)+Y1+3,A$
  70.       Gr Writing 1
  71.    End If 
  72. End Proc
  73. '
  74. ' * This is the button push routine. 
  75. '
  76. Procedure R[X1,Y1,X2,Y2]
  77.    X3=X Screen(X Mouse)
  78.    Y3=Y Screen(Y Mouse)
  79.    M=Mouse Key
  80.    AN=0
  81.    If(X3<X1 or X3>X2 or Y3<Y1 or Y3>Y2) or M=0
  82.       Pop Proc
  83.    End If 
  84.    '   Bell 96
  85.    AN=M
  86.    Wait Vbl 
  87. End Proc
  88. '
  89. Procedure ALERT[M$,B$]
  90.    '
  91.    ' * Define and cut up strings for buttons & text.
  92.    '
  93.    '
  94.    ' * Variable Q holds the button number that was pressed
  95.    '
  96.    Dim B$(4),M$(4)
  97.    I=0
  98.    IO=0
  99.    B=0
  100.    While I<Len(B$)
  101.       I=Instr(B$,"|",I+1)
  102.       If I=0
  103.          I=Len(B$)+1
  104.       End If 
  105.       B$(B)=Left$(Mid$(B$,IO+1,I-IO-1),10)
  106.       IO=I
  107.       Inc B
  108.    Wend 
  109.    I=0
  110.    IO=0
  111.    L=0
  112.    While I<Len(M$)
  113.       I=Instr(M$,"|",I+1)
  114.       If I=0
  115.          I=Len(M$)+1
  116.       End If 
  117.       M$(L)=Left$(Mid$(M$,IO+1,I-IO-1),77)
  118.       IO=I
  119.       Inc L
  120.    Wend 
  121.    '
  122.    ' * Open screen 7 and place it in the middle of the screen.
  123.    '
  124.    Screen Open 7,640,41+(L*8),8,Hires
  125.    Screen Display 7,,130-((L*8)/2),,
  126.    Curs Off 
  127.    Flash Off 
  128.    Cls 0
  129.    Palette $0,$0,$0,$0,$0,$0,$0,$0
  130.    '
  131.    ' * Figure out if the text or buttons are widest, then set the requester 
  132.    ' * to suit. 
  133.    '
  134.    L1=(Len(M$)*8)+16
  135.    L2=(B*100)+16
  136.    If L1>L2
  137.       OL=L1
  138.    Else 
  139.       OL=L2
  140.    End If 
  141.    '
  142.    BL=320-(OL/2)
  143.    OFF=L*8
  144.    '
  145.    B[BL,0,BL+OL,39+OFF,"",1,7,1]
  146.    '
  147.    ' * Place text on screen.
  148.    '
  149.    Gr Writing 0
  150.    For A=0 To L-1
  151.       Ink 3,7
  152.       Text 320-(Len(M$(A))*8/2)-1,A*10+14,M$(A)
  153.       Text 320-(Len(M$(A))*8/2)+1,A*10+14,M$(A)
  154.       Text 320-(Len(M$(A))*8/2),A*10+13,M$(A)
  155.       Text 320-(Len(M$(A))*8/2),A*10+15,M$(A)
  156.       Ink 1,7
  157.       Text 320-(Len(M$(A))*8/2),A*10+14,M$(A)
  158.    Next A
  159.    Gr Writing 1
  160.    '
  161.    ' * Place buttons on screen
  162.    '
  163.    D2=327-((B*100)/2)
  164.    For A=0 To B-1
  165.       B[D2+100*A,22+OFF,D2+100*A+86,36+OFF,B$(A),1,5,1]
  166.    Next A
  167.    '
  168.    ' * Fade requester into view 
  169.    '
  170.    Fade 1,$AA,$FFF,$DDD,$333,$888,$F54,$FF0,$5AC
  171.    Q=0
  172.    '
  173.    ' * Wait for button to be pressed. 
  174.    '
  175.    While Q=0
  176.       For A=0 To B-1
  177.          R[D2+100*A,22+OFF,D2+8+100*A+58,36+OFF]
  178.          If AN>0
  179.             Q=A+1
  180.          End If 
  181.       Next A
  182.    Wend 
  183.    '
  184.    ' * Fade requester out of view and close screen 7. 
  185.    '
  186.    Fade 1
  187.    Wait 15
  188.    Screen Close 7
  189. End Proc