/* Map Editor - juil.97 - par Sylvain Huet */ typeof Font=ObjFont;; struct MapEdit= [chMEd:Chn,winMEd:ObjWin,bannerMEd:ObjText,textMEd:ObjText, buf8MEd:ObjBitmap8,bufMEd:ObjBitmap,nameMEd:S, okMEd:ObjButton,cancelMEd:ObjButton,chgMEd:ObjButton, endMEd:fun [S] I, lfMEd:[[I I] r1] ]mkMEd;; fun _paintevent(a,b)= _BLTbitmap b.winMEd b.bufMEd 0 50;; fun fmbyxy(f,t)= let f->[x y] in let t->[xt yt] in if x==xt && y==yt then 1 else 0;; fun _OpenBmp(d,b,s)= let _PtoScol s -> name in if name==nil then nil else let _LDbitmap8 b.chMEd s -> newbmp in if newbmp!=nil then let _GETbitmap8Size newbmp -> [w h] in if b.lfMEd!=nil && nil==search_in_list b.lfMEd @fmbyxy [w h] then (_DLGMessageBox b.chMEd b.winMEd "Warning" strcatn "The size of this bitmap <"::(itoa w)::"x"::(itoa h):: "> doesn't match"::nil 0;nil) else (_SETbitmapPalette b.buf8MEd _GETbitmapPalette newbmp; _SCPbitmap8 b.buf8MEd 0 0 255 255 newbmp 0 0 w-1 h-1 nil; _CPbitmap b.bufMEd 0 0 b.buf8MEd 0 0 256 256 nil; _DSbitmap8 newbmp; set b.nameMEd=name; _SETtext b.textMEd strcatn name::" <"::(itoa w)::"x"::(itoa h)::">"::nil; _paintevent nil b ) else let _LDjpeg b.chMEd s -> newbmp in if newbmp==nil then (_DLGMessageBox b.chMEd b.winMEd "Warning" "This is not a bitmap" 0;nil) else let _GETbitmapSize newbmp -> [w h] in if b.lfMEd!=nil && nil==search_in_list b.lfMEd @fmbyxy [w h] then (_DLGMessageBox b.chMEd b.winMEd "Warning" strcatn "The size of this bitmap <"::(itoa w)::"x"::(itoa h):: "> doesn't match"::nil 0;nil) else (_SCPbitmap b.bufMEd 0 0 255 255 newbmp 0 0 w-1 h-1 nil; _DSbitmap newbmp; set b.nameMEd=name; _SETtext b.textMEd strcatn name::" <"::(itoa w)::"x"::(itoa h)::">"::nil; _paintevent nil b );; fun _change(x,b)= _DLGrflopen (_DLGOpenFile b.chMEd b.winMEd nil nil "bitmap (*.bmp,*.jpg)\0*.BMP;*.JPG\0\0") @_OpenBmp b;; fun _ok(x,b)= _DSwindow b.winMEd; _DSbitmap b.bufMEd; _DSbitmap8 b.buf8MEd; exec b.endMEd with [_fooS b.nameMEd];; fun _cancel(x,b)= /*_SAVEjpeg b.bufMEd _getmodifypack "toto.jpg" 75;;*/ _DSwindow b.winMEd; _DSbitmap b.bufMEd; _DSbitmap8 b.buf8MEd; exec b.endMEd with [nil];; fun _destroy(x,b)= _DSbitmap b.bufMEd; _DSbitmap8 b.buf8MEd; exec b.endMEd with [nil];; fun addformat(a,z)= let a->[w h] in let z->[b sizes] in _APPitem b.chMEd sizes ME_ENABLED strcatn "<"::(itoa w)::"x"::(itoa h)::">"::nil;; fun iniMapEdit(ch,father,title,name,end,listformat)= set Font= if Font!=nil then Font else _CRfont ch 14 0 0 "arial"; let [256 256+80] -> [w h] in let _CRwindow ch father nil nil w h WN_MENU+WN_MINBOX title -> win in let _CRtext ch win 5 5 w-10 20 ET_BORDER title -> banner in let _CRtext ch win 5 25 w-10 20 ET_DOWN "" -> text in let _CRbutton ch win 5 h-25 40 20 0 "Ok" -> ok in let _CRbutton ch win 50 h-25 40 20 0 "Cancel" -> cancel in let _CRbutton ch win 95 h-25 40 20 0 "Change" -> change in let _CRbitmap8 ch 256 256 -> buf8 in let _CRbitmap ch 256 256 -> buf in let mkMEd [ch win banner text buf8 buf nil ok cancel change end listformat] -> b in (_CBwinDestroy win @_destroy b; _CBwinPaint win @_paintevent b; let _CRmenu ch win -> menu in let _APPpopup ch menu "Sizes"-> sizes in if listformat==nil then (_APPitem ch sizes ME_ENABLED "no filter";0) else apply_on_list listformat @addformat [b sizes]; _AFFfontText banner Font; _AFFfontText text Font; _AFFfontButton _CBbutton ok @_ok b Font; _AFFfontButton _CBbutton cancel @_cancel b Font; _AFFfontButton _CBbutton change @_change b Font; _OpenBmp nil b _checkpack name; b );; fun _destroyevent(s)=_fooS s;_closemachine;; fun main()= iniMapEdit _channel nil "Map Editor" "trash.bmp" @_destroyevent nil;; /*[256 256]::[64 64]::nil;;*/