home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / sourcecode / various / rob's_alert_box2.amos / rob's_alert_box2.amosSourceCode
AMOS Source Code  |  1990-06-13  |  9KB  |  254 lines

  1. '                          AN ALERT BOX ROUTINE
  2. '                          ~~~~~~~~~~~~~~~~~~~~
  3. '                            by Robert Iwancz
  4. '
  5. '   Have you seen the alert boxes used in the programs that come with Amos,
  6. ' like the Sprite Editor?  Stupid aren't they?  Disapointing, plain, and 
  7. ' boring, aren't they?  Maybe I've just got this obsession with alert boxes, 
  8. ' and maybe I'm just making a big deal about nothing.  But I'd be ashamed to 
  9. ' use an alert box like that in the Sprite Editor.  Wouldn't you?
  10. '   If your answer is yes to all the above questions then you will probably
  11. ' understand my reason for writing this routine.  This routine is the result 
  12. ' of my absolute loathing for Aaron Fothergil's alert box (no offense Aaron) 
  13. ' and of my craving for a better alert box.  A proper alert box, not just a  
  14. ' bunch of lines and boxes and BORDER$((ZONE$)).  I feel a great emptyness 
  15. ' within me.  There is a great hole in my heart and soul which can only be 
  16. ' filled by a truly great alert box. This routine has only begun to fill that
  17. ' emptyness in my life, that dark chasm.  This is not the perfect alert box. 
  18. '   THE ULTIMATE ALERT BOX IS YET TO BE WRITTEN!  (I'm an idiot, aren't I?!) 
  19. '
  20. '   O.K.  Seriously now.  Please feel free to use this procedure in your own 
  21. ' programs.  If you do, PLEASE give me a mention (if you do, PLEASE spell my 
  22. ' surname right!  I know it's hard). 
  23. '   The main difference between this alert box and others I've seen is that
  24. ' this one opens its own (hires) screen.  The screen number can be changed 
  25. ' if screen 4 doesn't suit you.  After the procedure call make sure you make 
  26. ' the screen you were working with the current screen (E.g.: Screen 2).
  27. ' The number of the button that has been selected is returned in the variable
  28. ' GADGET.  If you want you can make GADGET a parameter instead of a Global 
  29. ' variable.
  30. '   This alert box has many disadvantages.  You cannot specify the colours 
  31. ' used or size of the alert box in the parameters, as you can with Aaron's.
  32. ' You can only have a maximum of 6 lines and 3 buttons.  When the procedure
  33. ' is called, colour 1 is turned into a rainbow.  If this is an advantage 
  34. ' or disadvantage is a matter of personal preference (run this program to
  35. ' see what I mean).
  36. '   It is entirely up to you if the advantages outweigh the disadvantages. 
  37. '
  38. ' USAGE:  ALERT[NB,NL,U,TITLE$l
  39. '       Where NB is the number of buttons,  NL is the number of lines, 
  40. '       U I'll explain in a moment, and TITLE$ is a title (e.g HELLO or
  41. '       SYSTEM MESSAGE, etc) 
  42. '       If U is 0 then the lines are CENTREd, otherwise they are PRINTed.
  43. '  
  44. '----------------------------------------------------------------------------- 
  45. '----------------------------------------------------------------------------- 
  46. '
  47. '** IMPORTANT!!!--These two arrays must be dimensioned and made global before
  48. 'the procedure is called(at the begining of the program would be a good idea). 
  49. Dim LINE$(5),BUTTON$(3)
  50. Global LINE$(),BUTTON$(),GADGET
  51. '----------------------------------------------------------------------------- 
  52. ' A bit of setting up so we have a functional demo of the procedure. 
  53. Screen Open 0,320,256,16,Lowres
  54. Curs Off : Flash Off 
  55. Cls 2
  56. Locate ,15
  57. Reserve Zone 1
  58. Pen 4 : Paper 5
  59. Centre Border$(Zone$("Click here to see the alert box",1),2)
  60. 'Main Loop 
  61. Repeat 
  62.    Inc CNT
  63.    Repeat : Until Mouse Key<>0 and Mouse Zone<>0
  64.    Proc DISPLAY_BOX[CNT]
  65.    If CNT=5 Then STUFFED=-1
  66. Until STUFFED
  67. ' This procedure demonstrates how to use this alert box. 
  68. Procedure DISPLAY_BOX[NUM]
  69.    If NUM=1
  70.       LINE$(0)="AN ALERT BOX ROUTINE"
  71.       LINE$(1)="~~~~~~~~~~~~~~~~~~~~"
  72.       LINE$(2)="---���>>> by Robert Iwancz <<<���---"
  73.       LINE$(3)="----------------"
  74.       LINE$(4)="December 1991"
  75.       LINE$(5)="��� Written in AMOS ï¿½ï¿½ï¿½"
  76.       BUTTON$(0)="  OK  "
  77.       ALERT[1,6,0,"SYSTEM MESSAGE"]
  78.       Screen 0
  79.       Cls 1
  80.       Pen 0 : Paper 2
  81.       Locate ,10
  82.       Centre "Cls 1.  Now note the rainbow."
  83.       Locate ,15
  84.       Pen 4 : Paper 5
  85.       Centre Border$(Zone$("Please click here again.",1),2)
  86.    End If 
  87.    If NUM=2
  88.       LINE$(0)="See what happens when the"
  89.       LINE$(1)="screen is filled with colour 1"
  90.       BUTTON$(0)="Yes"
  91.       BUTTON$(1)="No"
  92.       Repeat 
  93.          ALERT[2,2,1,"MESSAGE FROM ROB"]
  94.       Until GADGET=1
  95.       Screen 0
  96.       Cls 2
  97.       Pen 0 : Paper 2
  98.       Locate ,10
  99.       Centre "Let's try that with colour 2 (white)"
  100.       Locate ,15
  101.       Pen 4 : Paper 5
  102.       Centre Border$(Zone$("Please click here again.",1),2)
  103.    End If 
  104.    If NUM=3
  105.       LINE$(0)=""
  106.       LINE$(1)=""
  107.       LINE$(2)="See the difference?"
  108.       BUTTON$(0)="Yes"
  109.       BUTTON$(1)="No"
  110.       Repeat 
  111.          ALERT[2,3,1,"MESSAGE FROM ROB"]
  112.       Until GADGET=1
  113.       Screen 0
  114.       Cls 2
  115.       Pen 0 : Paper 2
  116.       Locate ,10
  117.       Centre "Next, U = 0"
  118.       Locate ,15
  119.       Pen 4 : Paper 5
  120.       Centre Border$(Zone$("Please click here again.",1),2)
  121.    End If 
  122.    If NUM=4
  123.       LINE$(0)="Notice"
  124.       LINE$(1)="how"
  125.       LINE$(2)="this"
  126.       LINE$(3)="text "
  127.       LINE$(4)="is"
  128.       LINE$(5)="centered?"
  129.       BUTTON$(0)="Yes"
  130.       BUTTON$(1)="Yes"
  131.       BUTTON$(2)="Yes"
  132.       ALERT[3,6,0,"MESSAGE FROM ROB"]
  133.       Screen 0
  134.       Cls 2
  135.       Pen 0 : Paper 2
  136.       Locate ,10
  137.       Centre "Now, U = 1   "
  138.       Locate ,15
  139.       Pen 4 : Paper 5
  140.       Centre Border$(Zone$("Click here for the last time.",1),2)
  141.    End If 
  142.    If NUM=5
  143.       LINE$(0)="Notice"
  144.       LINE$(1)="how"
  145.       LINE$(2)="this"
  146.       LINE$(3)="text "
  147.       LINE$(4)="is NOT"
  148.       LINE$(5)="centered?"
  149.       BUTTON$(0)="Yes"
  150.       BUTTON$(1)="Yes"
  151.       BUTTON$(2)="Yes"
  152.       ALERT[3,6,1,"MESSAGE FROM ROB"]
  153.       Screen 0
  154.       Cls 0
  155.       Pen 0 : Paper 2
  156.       Locate ,10
  157.       Centre "THE END"
  158.       Locate ,15
  159.       Pen 4 : Paper 5
  160.       Centre Border$(Zone$("Please DON'T click here again.",1),2)
  161.    End If 
  162. End Proc
  163. '
  164. '----------------------------------------------------------------------------- 
  165. 'HERE IT IS! The actual routine! This is what all the fuss above is all about! 
  166. '
  167. '----------------------------------------------------------------------------- 
  168. Rem --------------------------------------------------------------------------   
  169. '********************************    
  170. '**      Rob's Alert Box       **      
  171. '**  ------------------------  **      
  172. '**  Written by Robert Iwancz  **        
  173. '**  ----- Version 1.1 ------  **    
  174. '********************************    
  175. Procedure ALERT[NB,NL,U,TITLE$]
  176.    Auto View Off 
  177.    W=320 : H=103 : X=160 : Y=10
  178.    GADGET=0
  179.    On Menu Off : Menu Off 
  180.    Volume 63
  181.    Play 1,13,0 : Play 2,25,0
  182.    Screen Open 4,640,150,8,Hires
  183.    Palette ,,,,$7,$DB,$FF0,$F00
  184.    Screen Display 4,140,100,,0
  185.    Set Rainbow 0,1,30,"(1,1,5)(1,-1,5)","(1,1,15)(1,-1,15)","(1,1,15)(1,-1,15)"
  186.    Rainbow 0,0,99,152
  187.    Channel 0 To Rainbow 0
  188.    Amal 0,"Loop: For RA=0 To 29; Let X=RA; P;P;P;P;P; Next RA; Jump Loop"
  189.    Amal On 
  190.    Curs Off : Cls 1
  191.    Pen 0 : Locate ,0 : Centre TITLE$
  192.    Paper 4 : Pen 5
  193.    Ink 0 : Bar X+30,Y+30 To X+W+30,Y+H+30
  194.    Ink 4,,5 : Set Paint 1
  195.    Polygon X+1,Y+H+1 To X+15,Y+H+15 To X+W+15,Y+H+15 To X+W+15,Y+15 To X+W+1,Y+1
  196.    Wind Open 1,X,Y,40,13 : Curs Off 
  197.    Ink 5 : Box X,Y To X+W,Y+H
  198.    Draw X+W+15,Y+H+15 To X+W,Y+H
  199.    If U=1
  200.       Locate ,1
  201.       For L=1 To NL
  202.          Locate 1, : Print LINE$(L-1)
  203.       Next L
  204.    Else 
  205.       For L=1 To NL
  206.          Locate ,L : Centre LINE$(L-1)
  207.       Next L
  208.    End If 
  209.    ' Now we finally get to the buttons! 
  210.    Reserve Zone NB
  211.    D=0 : S=40/(NB+1)
  212.    While D<>NB
  213.       XX=(S*(D+1)-1)-Len(BUTTON$(D))/2 : YY=9
  214.       Pen 0 : Paper 0 : Locate XX+1,YY+1
  215.       Print Border$(BUTTON$(D),2)
  216.       Pen 7 : Paper 6 : Locate XX,YY
  217.       Print Border$(Zone$(BUTTON$(D),D+1),2)
  218.       Inc D
  219.    Wend 
  220.    Auto View On 
  221.    For D=1 To 150 Step 3
  222.       Screen Display 4,140,100,,D
  223.       Wait Vbl 
  224.    Next D
  225.    Screen Display 4,140,100,640,150
  226.    Change Mouse 1 : Screen 4 : Limit Mouse 
  227.    Repeat 
  228.       Z=Mouse Zone : K=Mouse Key
  229.       If Z<>OLDZ
  230.          If OLDZ>0 : HI=True : B=OLDZ-1 : OLDZ=-1 : Gosub A_HILITE : End If 
  231.          If Z>0 : OLDZ=Z : HI=False : B=Z-1 : Gosub A_HILITE : End If 
  232.       End If 
  233.    Until K<>0 and Z<>0
  234.    GADGET=Z
  235.    Volume 63
  236.    Play 1,70,0 : Play 2,30,0
  237.    Play 3,70,0 : Play 4,30,0
  238.    For D=150 To 1 Step -3
  239.       Screen Display 4,140,100,,D
  240.       Wait Vbl 
  241.    Next D
  242.    Wind Close 
  243.    Amal Off : Rainbow Del 
  244.    Reset Zone : Reserve Zone 
  245.    Screen Close 4
  246.    Pop Proc
  247.    A_HILITE:
  248.    XX=(S*(B+1)-1)-Len(BUTTON$(B))/2 : YY=9
  249.    If HI=False Then Inverse On Else Inverse Off 
  250.    Locate XX,YY : Print Border$(BUTTON$(B),2)
  251.    Return 
  252. End Proc
  253. '********************************  
  254. Rem --------------------------------------------------------------------------