How does this look?
Anything I should change/add/remove?
Type Texture Global textures:TMap Function Load:TImage( filename:String ) If Not textures Then textures = New TMap If Not textures.ValueForKey(filename) Then ' Not found, load it. Local img:TImage = LoadImage( filename ) If Not img Then Throw "Unable to load "+filename textures.insert( filename, img ) Print "New texture loaded. "+filename Return img Else ' get the texture and return it Print "Texture reused. "+filename Return TImage(textures.ValueForKey(filename)) EndIf EndFunction ' Call this after you have changed the graphics mode to reload all textures Function Reload() If Not textures Then Return ' Nothing to reload Local templist:TMap = New TMap Local nodeenum:TNodeEnum=textures.ObjectEnumerator() While nodeenum.HasNext() Local temp:TNode=TNode(nodeenum.NextObject()) Print("Reloading texture "+temp.Key().ToString()) 'Print("VAL: "+item(temp.Value()).val) templist.insert( temp.Key().ToString(), LoadImage( temp.Key().ToString() ) ) Wend textures = templist EndFunction Function Clear() textures.clear() EndFunction EndType
Anything I should change/add/remove?