| 08-23-2009, 03:30 AM | #1 |
Well, Id be very happy if I could get feedback on this library. Would you use this as a replacement for the native API provided by Blizzard? If not, what features are you missing? If yes, is there any way this library could be improved? Images:library Images uses ARGB // Credits: // - Vexorian for ARGB and JassHelper // - Pipedream for grimoire // - MindWorX and Pitzermike for JassNewGenPack // - SFilip for TESH globals private constant integer MAX_IMAGES = 50000 // actually, having more than this many should lag a players PC to hell and back constant integer IMAGE_TYPE_SHADOW = 0 // lowest // higher types are rendered above lower types constant integer IMAGE_TYPE_SELECTION = 1 constant integer IMAGE_TYPE_INDICATOR = 2 constant integer IMAGE_TYPE_OCCLUSION_MASK = 3 constant integer IMAGE_TYPE_UBERSPLAT = 4 constant integer IMAGE_TYPE_TOPMOST = 5 // highest private constant boolean RENDER_BY_DEFAULT = true private constant integer DEFAULT_IMAGE_TYPE = IMAGE_TYPE_TOPMOST private ARGB DEFAULT_COLOR = 0xFFFFFFFF endglobals struct imagex[MAX_IMAGES] private image img private string Path private real SizeX private real SizeY private real X private real Y private real Z private ARGB Color private boolean Show private boolean Render private integer Type static method create takes string path, real sizeX, real sizeY, real posX, real posY, real posZ, boolean show returns thistype local thistype s=.allocate() set s.img=CreateImage(path, sizeX, sizeY, 0, posX - (sizeX / 2), posY - (sizeY / 2), posZ, 0, 0, 0, DEFAULT_IMAGE_TYPE) call SetImageRenderAlways(s.img, RENDER_BY_DEFAULT) call ShowImage(s.img, show) set s.Path=path set s.SizeX=sizeX set s.SizeY=sizeY set s.X=posX set s.Y=posY set s.Z=posZ set s.Color=DEFAULT_COLOR set s.Show=show set s.Render=RENDER_BY_DEFAULT set s.Type=DEFAULT_IMAGE_TYPE return s endmethod method onDestroy takes nothing returns nothing call DestroyImage(.img) set .img=null endmethod // Get Methods method operator path takes nothing returns string return .Path endmethod method operator sizeX takes nothing returns real return .SizeX endmethod method operator sizeY takes nothing returns real return .SizeY endmethod method operator x takes nothing returns real return .X endmethod method operator y takes nothing returns real return .Y endmethod method operator z takes nothing returns real return .Z endmethod method operator red takes nothing returns integer return .Color.red endmethod method operator green takes nothing returns integer return .Color.green endmethod method operator blue takes nothing returns integer return .Color.blue endmethod method operator alpha takes nothing returns integer return .Color.alpha endmethod method operator color takes nothing returns ARGB return .Color endmethod method operator show takes nothing returns boolean return .Show endmethod method operator render takes nothing returns boolean return .Render endmethod method operator type takes nothing returns integer return .Type endmethod // Private Proxies private method NewPosition takes nothing returns nothing call SetImagePosition(.img, .x-.sizeX/2, .y-.sizeY/2, .z) endmethod private method Recolor takes nothing returns nothing call SetImageColor(.img, .red, .green, .blue, .alpha) endmethod private method Recreate takes nothing returns nothing call DestroyImage(.img) set .img=CreateImage(.path, .sizeX, .sizeY, 0, .x - (.sizeX / 2), .y - (.sizeY / 2), .z, 0, 0, 0, .type) call SetImageRenderAlways(.img, .render) call ShowImage(.img, .show) endmethod // Set Methods // Set the image's filepath method operator path= takes string path returns nothing set .Path=path call .Recreate() endmethod // Set the size of the image method operator sizeX= takes real sizex returns nothing set .SizeX=sizex call .Recreate() endmethod method operator sizeY= takes real sizey returns nothing set .SizeY=sizey call .Recreate() endmethod method setSize takes real sizex, real sizey returns nothing set .SizeX=sizex set .SizeY=sizey call .Recreate() endmethod // Set the position of the image method operator x= takes real x returns nothing set .X=x call .NewPosition() endmethod method operator y= takes real y returns nothing set .Y=y call .NewPosition() endmethod method operator z= takes real z returns nothing set .Z=z call .NewPosition() endmethod method setPosition takes real x, real y, real z returns nothing set .X=x set .Y=y set .Z=z call .NewPosition() endmethod // Set the color of the image method operator red= takes integer red returns nothing set .Color.red=red call .Recolor() endmethod method operator green= takes integer green returns nothing set .Color.green=green call .Recolor() endmethod method operator blue= takes integer blue returns nothing set .Color.blue=blue call .Recolor() endmethod method operator alpha= takes integer alpha returns nothing set .Color.alpha=alpha call .Recolor() endmethod method operator color= takes ARGB new returns nothing set .Color=new call .Recolor() endmethod // Do you want to display the image? method operator show= takes boolean show returns nothing set .Show=show call ShowImage(.img, .show) endmethod // Do you want to rener the image? method operator render= takes boolean render returns nothing set .Render=render call SetImageRenderAlways(.img, render) endmethod // On which layer should the image be rendered? method operator type= takes integer imageType returns nothing set .Type=imageType call SetImageType(.img, imageType) endmethod endstruct endlibrary Any (valid, constructive) feedback is appreciated. Deaod Edit: Updated. |
| 08-23-2009, 11:39 AM | #2 |
Cool. Im too lazy to check that ARGB code, but is there any desync issues if I different colour values for different players? |
| 08-23-2009, 12:51 PM | #3 |
images are pseudo handles, so there shouldnt be any desync if the stack for images is out of sync. Naturally, changing colors shouldnt desnyc as well. |
