summaryrefslogtreecommitdiff
path: root/help.bmx
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-12-05 00:59:34 +0000
committerIan C <ianc@noddybox.co.uk>2005-12-05 00:59:34 +0000
commitcf0e1b5f3422dc1adc60b1684591ab0962c441bb (patch)
tree8c69f5fe70d39475e1dc31ef994f719948c70621 /help.bmx
parent2432acd3b0cc49fb71cfee5b32e14e0eac773619 (diff)
Updates and added help page
Diffstat (limited to 'help.bmx')
-rw-r--r--help.bmx209
1 files changed, 209 insertions, 0 deletions
diff --git a/help.bmx b/help.bmx
new file mode 100644
index 0000000..df2e80b
--- /dev/null
+++ b/help.bmx
@@ -0,0 +1,209 @@
+' Hardwire
+'
+' Copyright 2005 Ian Cowburn
+'
+' $Id$
+'
+Strict
+Import "types.bmx"
+
+Import noddybox.bitmapfont
+Import noddybox.gfxmenu
+
+
+' Included binaries
+'
+Incbin "HELP/help.txt"
+Incbin "HELP/pit.png"
+Incbin "HELP/piece.png"
+Incbin "HELP/wire1.png"
+Incbin "HELP/wire2.png"
+Incbin "HELP/wire3.png"
+Incbin "HELP/loop1.png"
+Incbin "HELP/bomb.png"
+Incbin "HELP/twister.png"
+
+Type THelp
+ Const TOP:Int=50
+ Const BOTTOM:Int=550
+ Field list:TList
+ Field pos:Int
+ Field item:TLink
+ Field del:Int
+
+ Method New()
+ Local str:TStream=ReadStream("incbin::HELP/help.txt")
+
+ Assert str,"Unable to open help file"
+
+ list=CreateList()
+
+ While Not str.Eof()
+ Local line:String=str.ReadLine()
+
+ If line.length And line[0]=Asc("#")
+ list.AddLast(THelpImage.Create(line[1..]))
+ Else
+ list.AddLast(THelpText.Create(line))
+ EndIf
+ Wend
+
+ item=list.LastLink()
+ pos=TOP-Current().Height()
+ End Method
+
+ Method Draw()
+ Local y:Int=pos
+ Local i:TLink=item
+
+ While y<BOTTOM
+ Local h:THelpItem=THelpItem(i.Value())
+ h.Draw(y)
+ y:+h.Height()
+ i=i.NextLink()
+ If Not i
+ i=list.FirstLink()
+ EndIf
+ Wend
+
+ SetColor(0,0,0)
+ DrawRect(0,0,GraphicsWidth(),TOP)
+ DrawRect(0,BOTTOM,GraphicsWidth(),GraphicsHeight()-BOTTOM)
+ For Local f:Int=0 To 8
+ SetAlpha(1.0-f*0.125)
+ DrawLine(0,TOP+f,GraphicsWidth(),TOP+f)
+ DrawLine(0,BOTTOM-f,GraphicsWidth(),BOTTOM-f)
+ Next
+ SetAlpha(1)
+ SetColor(128,128,128)
+ DrawLine(0,TOP-1,GraphicsWidth(),TOP-1)
+ DrawLine(0,TOP+1,GraphicsWidth(),TOP+1)
+ DrawLine(0,BOTTOM-1,GraphicsWidth(),BOTTOM-1)
+ DrawLine(0,BOTTOM+1,GraphicsWidth(),BOTTOM+1)
+ SetColor(255,255,255)
+ DrawLine(0,TOP,GraphicsWidth(),TOP)
+ DrawLine(0,BOTTOM,GraphicsWidth(),BOTTOM)
+
+ GameGFX.large.Centre("HOW TO PLAY HARDWIRE",0,255,255,0)
+ GameGFX.large.Centre("USE UP/DOWN CURSORS TO SCROLL",BOTTOM+10,255,255,0)
+ GameGFX.large.Centre("ESCAPE TO EXIT",BOTTOM+30,255,255,0)
+ End Method
+
+ Method Current:THelpItem()
+ Return THelpItem(item.Value())
+ End Method
+
+ Method Show()
+ Local done:Int=False
+
+ While Not done
+ Cls
+
+ Draw()
+
+ If KeyDown(KEY_DOWN)
+ del=Min(del+1,200)
+ pos:-del/4+1
+ While pos<TOP-Current().Height()
+ pos:+Current().Height()
+ item=item.NextLink()
+ If Not item
+ item=list.FirstLink()
+ EndIf
+ Wend
+ ElseIf KeyDown(KEY_UP)
+ del=Min(del+1,200)
+ pos:+del/4+1
+ While pos>TOP
+ item=item.PrevLink()
+ If Not item
+ item=list.LastLink()
+ EndIf
+ pos:-Current().Height()
+ Wend
+ ElseIf KeyHit(KEY_ESCAPE)
+ FlushKeys()
+ done=True
+ Else
+ del=0
+ EndIf
+
+ Flip
+ Wend
+
+ SetColor(255,255,255)
+ End Method
+End Type
+
+Type THelpItem Abstract
+ Method Height:Int() Abstract
+ Method Draw(y:Int) Abstract
+End Type
+
+Type THelpText Extends THelpItem
+ Field txt:String
+ Field r:Int
+ Field g:Int
+ Field b:Int
+ Field sc:Int
+
+ Function Create:THelpItem(txt:String)
+ Local o:THelpText=New THelpText
+
+ Select txt[0]
+ Case Asc("@")
+ o.sc=2
+ o.r=255
+ o.g=255
+ o.b=0
+ o.txt=txt[1..]
+ Case Asc("!")
+ o.sc=1
+ o.r=255
+ o.g=255
+ o.b=0
+ o.txt=txt[1..]
+ Default
+ o.sc=1
+ o.r=255
+ o.g=255
+ o.b=255
+ o.txt=txt
+ End Select
+
+ Return THelpItem(o)
+ End Function
+
+ Method Height:Int()
+ Return GameGFX.large.MaxHeight()*sc
+ End Method
+
+ Method Draw(y:Int)
+ SetScale(sc,sc)
+ GameGFX.large.Centre(txt,y,r,g,b)
+ SetScale(1,1)
+ End Method
+End Type
+
+
+Type THelpImage Extends THelpItem
+ Field img:TImage
+ Field x:Int
+
+ Function Create:THelpItem(url:String)
+ Local o:THelpImage=New THelpImage
+ o.img=LoadImage(url)
+ Assert o,"Failed to load help image " + url
+ o.x=(GraphicsWidth()-ImageWidth(o.img))/2
+ Return THelpItem(o)
+ End Function
+
+ Method Height:Int()
+ Return ImageHeight(img)
+ End Method
+
+ Method Draw(y:Int)
+ SetColor(255,255,255)
+ DrawImage(img,x,y)
+ End Method
+End Type \ No newline at end of file