From 26c98ba56e72beaf8a99eafbedd2b0c64ac13954 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sat, 27 May 2006 23:24:02 +0000 Subject: Updates --- help.bmx | 598 +++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 309 insertions(+), 289 deletions(-) (limited to 'help.bmx') diff --git a/help.bmx b/help.bmx index ccf3aaa..479bc6a 100644 --- a/help.bmx +++ b/help.bmx @@ -1,289 +1,309 @@ -' Hardwire -' -' Copyright 2005 Ian Cowburn -' -' $Id$ -' -Strict -Import brl.pngloader - -Import noddybox.bitmapfont -Import noddybox.gfxmenu - -Import "types.bmx" - - -' 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" -Incbin "HELP/nuke.png" -Incbin "HELP/cross.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 - Select line[0] - Case Asc("#") - list.AddLast(THelpImage.Create(line[1..])) - Case Asc("$") - list.AddLast(THelpAnimImage.Create(line[1..],False)) - Case Asc("~~") - list.AddLast(THelpAnimImage.Create(line[1..],True)) - Default - list.AddLast(THelpText.Create(line)) - End Select - Else - list.AddLast(THelpBlankLine.Create(line)) - EndIf - Wend - - item=list.LastLink() - pos=TOP-Current().Height() - End Method - - Method Draw() - Local y:Int=pos - Local i:TLink=item - - While yTOP - 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 - - If fade - If fade.Fade() - fade.Draw() - Else - fade=Null - EndIf - 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 THelpBlankLine Extends THelpItem - Function Create:THelpItem(txt:String) - Local o:THelpBlankLine=New THelpBlankLine - Return THelpItem(o) - End Function - - Method Height:Int() - Return GameGFX.large.MaxHeight() - End Method - - Method Draw(y:Int) - 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.img,"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 - - -Type THelpAnimImage Extends THelpItem - Field img:TImage - Field x:Int - Field frame:Int - Field framei:Int - Field framed:Int - Field pong:Int - - Function Create:THelpItem(url:String,pong:Int) - Local o:THelpAnimImage=New THelpAnimImage - o.img=LoadAnimImage(url,32,32,0,4) - Assert o.img,"Failed to load help anim image " + url - o.x=(GraphicsWidth()-32)/2 - o.frame=0 - o.framed=5 - o.framei=1 - o.pong=pong - 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,frame) - framed:-1 - If framed=0 - framed=5 - If pong - frame:+framei - If frame=0 Or frame=3 - framei=-framei - EndIf - Else - frame=(frame+1) Mod 4 - EndIf - EndIf - End Method -End Type \ No newline at end of file +' Hardwire +' +' Copyright (C) 2005 Ian Cowburn (ianc@noddybox.co.uk) +' +' This program is free software; you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation; either version 2 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License +' along with this program; if not, write to the Free Software +' Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +' +' ------------------------------------------------------------------------- +' +' $Id$ +' +Strict +Import brl.pngloader + +Import noddybox.bitmapfont +Import noddybox.gfxmenu + +Import "types.bmx" + + +' 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" +Incbin "HELP/nuke.png" +Incbin "HELP/cross.png" + +Type THelp + Const TOP:Int=50 + Const BOTTOM:Int=550 + Field list:TList + Field pos:Int + Field item:TLink + Field del:Int + Field bd:TGameBackdrop + + 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 + Select line[0] + Case Asc("#") + list.AddLast(THelpImage.Create(line[1..])) + Case Asc("$") + list.AddLast(THelpAnimImage.Create(line[1..],False)) + Case Asc("~~") + list.AddLast(THelpAnimImage.Create(line[1..],True)) + Default + list.AddLast(THelpText.Create(line)) + End Select + Else + list.AddLast(THelpBlankLine.Create(line)) + EndIf + Wend + + bd=New TGameBackdrop + item=list.LastLink() + pos=TOP-Current().Height() + End Method + + Method Draw() + bd.Draw() + + Local y:Int=pos + Local i:TLink=item + + While yTOP + 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 + + If fade + If fade.Fade() + fade.Draw() + Else + fade=Null + EndIf + 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 THelpBlankLine Extends THelpItem + Function Create:THelpItem(txt:String) + Local o:THelpBlankLine=New THelpBlankLine + Return THelpItem(o) + End Function + + Method Height:Int() + Return GameGFX.large.MaxHeight() + End Method + + Method Draw(y:Int) + 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,0) + Assert o.img,"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 + + +Type THelpAnimImage Extends THelpItem + Field img:TImage + Field x:Int + Field frame:Int + Field framei:Int + Field framed:Int + Field pong:Int + + Function Create:THelpItem(url:String,pong:Int) + Local o:THelpAnimImage=New THelpAnimImage + o.img=LoadAnimImage(url,32,32,0,4,0) + Assert o.img,"Failed to load help anim image " + url + o.x=(GraphicsWidth()-32)/2 + o.frame=0 + o.framed=5 + o.framei=1 + o.pong=pong + 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,frame) + framed:-1 + If framed=0 + framed=5 + If pong + frame:+framei + If frame=0 Or frame=3 + framei=-framei + EndIf + Else + frame=(frame+1) Mod 4 + EndIf + EndIf + End Method +End Type -- cgit v1.2.3