home *** CD-ROM | disk | FTP | other *** search
/ Doom I/II Collection / DM12.ISO / edit / dhtk100 / spritevi.pas < prev    next >
Pascal/Delphi Source File  |  1994-05-26  |  2KB  |  88 lines

  1. unit SpriteView;
  2.  
  3. interface
  4.  
  5. uses Wad,Waddecl,Things,DOOMGUI,ThingDef,GuiObj,Graph;
  6.  
  7. Type     PSpriteViewer=^TSpriteViewer;
  8.         TSpriteViewer=object(TGraphGroup)
  9.             ViewerFlags:byte;
  10.             ViewWindow:PGraphWindow;
  11.             TheSprite:PWadThing;
  12.             WDir:PWadDirectory;
  13.             constructor Init(ThingID:word;WadDir:PWadDirectory);
  14.             procedure Draw; virtual;
  15.             destructor Done; virtual;
  16.         end;
  17.  
  18. implementation
  19.  
  20. var    In256ColorMode:boolean;
  21.  
  22. Constructor TSpriteViewer.Init(ThingID:word;WadDir:PWadDirectory);
  23.  
  24.     var     ThingDefNum:word;
  25.             R:TGraphRect;
  26.             TempStr:string;
  27.             SpritePictID:ObjNameStr;
  28.  
  29.     begin
  30.         ViewerFlags:=0;
  31.         WDir:=WadDir;
  32.         R.Assign(320,240,640,480);
  33.         Bounds:=R;
  34.         ViewWindow:=New(PGraphWindow, Init(R));
  35.         ThingDefNum:=GetThingDefFromID(ThingID);
  36.         R.Assign(5,5,635,15);
  37.         ViewWindow^.Insert(New(PGraphText, Init(R,'Description: '+ThingDefs^[ThingDefNum].Desc)));
  38.         R.Assign(5,20,635,35);
  39.         ViewWindow^.Insert(New(PGraphText, Init(R,'Sprite ID: '+ThingDefs^[ThingDefNum].PictID)));
  40.         Str(ThingDefs^[ThingDefNum].Num,TempStr);
  41.         R.Assign(5,35,635,50);
  42.         ViewWindow^.Insert(New(PGraphText, Init(R,'Thing ID Number: '+TempStr)));
  43.         ThingDefNum:=CrossRefThingDef(ThingID,WDir);
  44.         Move(WDir^.DirEntry^[ThingDefNum].ObjName,SpritePictID,8);
  45.         if ThingDefNum<>0 then
  46.             TheSprite:=New(PWadThing, Init(WDir, SpritePictID))
  47.         else
  48.             TheSprite:=Nil;
  49.     end;
  50.  
  51. Procedure TSpriteViewer.Draw;
  52.  
  53.     var     ThingDefNum:word;
  54.             R:TGraphRect;
  55.             TempStr:string;
  56.             SubView:PGraphView;
  57.  
  58.     begin
  59.         if (ViewerFlags and 1) = 1 then
  60.             exit;
  61.         ViewWindow^.Draw;
  62.         if TheSprite <> Nil then begin
  63.             SetFillStyle(SolidFill,wcBlack);
  64.             Bar(335,295,570,470);
  65.             TheSprite^.Draw(100,340,300);
  66.          end
  67.         else begin
  68.             SetColor(0);
  69.             OutTextXY(340,300,'No Sprite View Available');
  70.         end;
  71.     end;
  72.  
  73. Destructor TSpriteViewer.Done;
  74.  
  75.     begin
  76.         ViewWindow^.Done;
  77.         Dispose(ViewWindow);
  78.         if TheSprite<>Nil then begin
  79.             TheSprite^.Done;
  80.             Dispose(TheSprite);
  81.         end;
  82.     end;
  83.  
  84. begin
  85. {$IFDEF DFE}
  86.     writeln('SysSpriteView_Init');
  87. {$ENDIF}
  88. end.