Sorry, resurrecting an old topic, and posting a slightly OT response...
For those with MaxGui, you could probably create a decent cross-platform technique based on the HTML gadget, for use in Roguelike games. Eg:
SuperStrict
Framework MaxGUI.Drivers
Import BRL.Timer
Import BRL.Retro
SeedRnd MilliSecs()
Global Terminal:THTMLTerm = THTMLTerm.Create("Roguelike Experiment", -1, -1, 800, 600, 60, 20)
AddHook EmitEventHook, ProcessEvent
Repeat
WaitSystem
Forever
End
Function ProcessEvent:Object(id:Int, data:Object, context:Object)
Local ev:TEvent = TEvent(data)
Return Terminal.CheckEvent(ev)
EndFunction
Type THTMLTerm
Function Create:THTMLTerm(title:String = Null, x:Int = -1, y:Int = -1, ..
w:Int = 640, h:Int = 400, ccols:Int = 70, crows:Int = 25)
Local term:THTMLTerm = New THTMLTerm
If Not title Then title = AppArgs[0]
Local flags:Int = WINDOW_TITLEBAR | WINDOW_RESIZABLE
If x < 0 And y < 0 Then flags = WINDOW_TITLEBAR | WINDOW_CENTER | WINDOW_RESIZABLE
term.Window = CreateWindow(title, x, y, w, h, Null, flags)
term.HTMLView = CreateHTMLView(0, 0, ClientWidth(term.Window), ClientHeight(term.Window), ..
term.Window, HTMLVIEW_NOCONTEXTMENU | HTMLVIEW_NONAVIGATE)
term.Panel = CreatePanel(0, 0, ClientWidth(term.Window), ClientHeight(term.Window), ..
term.Window, PANEL_ACTIVE)
term.Timer = CreateTimer(60)
HideGadget term.panel
term.URL = AppDir + "/temp.html"
term.CharTable = TCharTable.Create(ccols, crows)
term.CharTable.exportHTML term.URL
HtmlViewGo term.HTMLView, term.URL
Return term
EndFunction
Field URL:String
Field Window:TGadget
Field HTMLView:TGadget
Field Panel:TGadget
Field Timer:TTimer
Field CharTable:TCharTable
Method CheckEvent:TEvent(ev:TEvent)
Select ev.id
Case EVENT_TIMERTICK
If ev.Source = Timer Then ActivateGadget Panel
Case EVENT_KEYDOWN
If ev.Source = Panel
Select ev.data
Case KEY_ESCAPE
EmitEvent CreateEvent(EVENT_APPTERMINATE)
Case KEY_SPACE
CharTable.test URL
HtmlViewRun HTMLView, "window.location.reload();"
EndSelect
EndIf
Case EVENT_WINDOWSIZE
resize
Case EVENT_WINDOWCLOSE
If ev.Source = Window Then EmitEvent CreateEvent(EVENT_APPTERMINATE)
Case EVENT_APPTERMINATE
End
EndSelect
Return ev
EndMethod
Method resize()
SetGadgetShape HTMLView, 0, 0, ClientWidth(Window), ClientHeight(Window)
SetGadgetShape Panel, 0, 0, ClientWidth(Window), ClientHeight(Window)
EndMethod
EndType
Const STYLE_NORMAL:Byte = 0
Const STYLE_ITALIC:Byte = 1
Const STYLE_OBLIQUE:Byte = 2
Const WEIGHT_NORMAL:Byte = 0
Const WEIGHT_BOLD:Byte = 1
Const DECOR_NONE:Byte = 0
Const DECOR_UNDERLINE:Byte = 1
Const DECOR_OVERLINE:Byte = 2
Const DECOR_LINETHROUGH:Byte = 3
Type TCharTable
Field FFamily:String 'Any valid CSS text applicable to "font-family"
Field FSize:String 'Any valid CSS text applicable to "font-size"
Field BodyBGColor:String 'Any valid CSS text applicable to "background-color"
Field Cells:TCharCell[,]
Field Cols:Int, Rows:Int
Function Create:TCharTable(cs:Int, rs:Int, url:String = "temp.html")
Local tbl:TCharTable = New TCharTable
tbl.Cols = cs
tbl.Rows = rs
tbl.Cells = New TCharCell[tbl.Cols, tbl.Rows]
For Local r:Int = 0 To tbl.Rows - 1
For Local c:Int = 0 To tbl.Cols - 1
tbl.Cells[c, r] = New TCharCell
Next
Next
tbl.setCSSFont "courier, monospace", "1.5em"
tbl.setBodyBGColor $000000, True
'tbl.initAllCells Asc("."), $FFFFFF, $000000, STYLE_NORMAL, WEIGHT_NORMAL, DECOR_NONE
tbl.test url
'tbl.exportHTML url
Return tbl
EndFunction
Method setCSSFont(family:String = "courier, monospace", size:String = "1em")
FFamily = family
FSize = size
EndMethod
Method setBodyBGColor(color:Int, allchars:Int = False)
BodyBGColor = "#" + Right(Hex(color), 6) + ";"
If allchars
For Local c:Int = 0 To Cols - 1
For Local r:Int= 0 To Rows - 1
Cells[c, r].setBGColor color
Next
Next
EndIf
EndMethod
Method setCellChar(col:Int, row:Int, ch:Int)
Cells[col, row].setChar ch
EndMethod
Method setCellFGColor(col:Int, row:Int, fgc:Int)
Cells[col, row].setFGColor fgc
EndMethod
Method setCellBGColor(col:Int, row:Int, bgc:Int)
Cells[col, row].setBGColor bgc
EndMethod
Method setCellWeight(col:Int, row:Int, wgt:Int)
Cells[col, row].setWeight wgt
EndMethod
Method setCellStyle(col:Int, row:Int, styl:Int)
Cells[col, row].setStyle styl
EndMethod
Method setCellDecor(col:Int, row:Int, dec:Int)
Cells[col, row].setDecor dec
EndMethod
Method initAllCells(ch:Byte, bgc:Int= $000000, fgc:Int= $FFFFFF, ..
styl:Byte = STYLE_NORMAL, wgt:Byte = WEIGHT_NORMAL, dec:Byte = DECOR_NONE)
For Local c:Int = 0 To Cols - 1
For Local r:Int = 0 To Rows - 1
Cells[c, r].setBGColor bgc
Cells[c, r].setFGColor fgc
Cells[c, r].setChar ch
Cells[c, r].setStyle styl
Cells[c, r].setWeight wgt
Cells[c, r].setDecor dec
Next
Next
EndMethod
Method writeText(txt:String, col:Int, row:Int, bgc:Int = $000000, fgc:Int = $FFFFFF)
For Local n:Int = 0 To txt.length - 1
If (col + n) < Cols
setCellChar col + n, row, txt[n]
setCellBGColor col + n, row, bgc
setCellFGColor col + n, row, fgc
EndIf
Next
EndMethod
Method exportHTML(url:String)
If Not CreateFile(url)
Notify "Could not create HTML file."
End
EndIf
Local fh:TStream = OpenFile(url)
WriteLine fh, "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/Strict.dtd'>"
WriteLine fh, "<html><head><style type='text/css'>body{background-color: " + BodyBGColor + ..
"; font-family: " + FFamily + "; font-size: " + FSize + ";} " + ..
"}</style><title>Roguelike Experiment</title></head><body>" + ..
"<code>"
For Local r:Int = 0 To Rows - 1
Local row:String = ""
For Local c:Int = 0 To Cols - 1
row :+ Cells[c, r].getCSS()
Next
WriteLine fh, (row + "<br>")
Next
WriteLine fh, "</code></body></html>"
CloseFile fh
EndMethod
'***************** DEBUG ************************
Method test(URL:String)
Local ch:Int = Rand(32, 255)
For Local r:Int = 0 To Rows - 1
For Local c:Int = 0 To Cols - 1
setCellChar c, r, ch
setCellFGColor c, r, Int((Rand(0, 255) Shl 16) | (Rand(0, 255) Shl 8) | Rand(0, 255))
If Not Rand(0, 32)
setCellBGColor c, r, Int((Rand(0, 255) Shl 16) | (Rand(0, 255) Shl 8) | Rand(0, 255))
Else
setCellBGColor c, r, $000000
EndIf
If Not Rand(0, 32)
setCellWeight c, r, Rand(WEIGHT_NORMAL, WEIGHT_BOLD)
setCellDecor c, r, Rand(DECOR_NONE, DECOR_LINETHROUGH)
setCellStyle c, r, Rand(STYLE_NORMAL, STYLE_OBLIQUE)
EndIf
Next
Next
exportHTML URL
EndMethod
'************************************************
EndType
Type TCharCell
Function Create:TCharCell()
Local cell:TCharCell = New TCharCell
cell.Char = 32
cell.FGColor = $FFFFFF
cell.BGColor = $000000
cell.Style = STYLE_NORMAL
cell.Weight = WEIGHT_NORMAL
cell.Decor = DECOR_NONE
Return cell
EndFunction
'###### FIELDS ######
Field Char:Byte
Field FGColor:Int, BGColor:Int
Field Style:Byte, Weight:Byte, Decor:Byte
'###### SETTERS ######
Method setChar(ch:Byte)
Char = ch
EndMethod
Method setFGColor(clr:Int)
FGColor = clr
EndMethod
Method setFGColorRGB(r:Byte, g:Byte, b:Byte)
FGColor = Int((r Shl 16) | (g Shl 8) | b)
EndMethod
Method setBGColor(clr:Int)
BGColor = clr
EndMethod
Method setBGColorRGB(r:Byte, g:Byte, b:Byte)
BGColor = Int((r Shl 16) | (g Shl 8) | b)
EndMethod
Method setStyle(styl:Byte)
Style = styl
EndMethod
Method setWeight(wgt:Byte)
Weight = wgt
EndMethod
Method setDecor(dec:Byte)
Decor = dec
EndMethod
'###### GETTERS ######
Method getCSS:String()
Local str:String
str :+ "<span style='background-color:#" + Right(Hex(BGColor), 6) + ..
"; color:#" + Right(Hex(FGColor), 6) + "; "
Select Style
Case STYLE_NORMAL
str :+ "font-style: normal; "
Case STYLE_ITALIC
str :+ "font-style: italic; "
Case STYLE_OBLIQUE
str :+ "font-style: oblique; "
EndSelect
If Weight = WEIGHT_NORMAL Then str :+ "font-weight: normal;" Else ..
str :+ "font-weight: bold;"
Select Decor
Case DECOR_NONE
str :+ "text-decoration: none; "
Case DECOR_UNDERLINE
str:+ "text-decoration: underline; "
Case DECOR_OVERLINE
str:+ "text-decoration: overline; "
Case DECOR_LINETHROUGH
str:+ "text-decoration: line-through; "
EndSelect
str :+ "'>"
If Char = 32 Then str :+ " " Else str :+ Chr(Char)
str :+ "</span>"
Return str
EndMethod
EndType
Seems to work okay on WindowsXP and Mac OS10.5.4..