home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the DOOM Programming Gurus / Tricks_of_the_Doom_Programming_Gurus.iso / bonus / editors / deth / source / names.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-02  |  4.8 KB  |  250 lines

  1. /*
  2.    Doom Editor Utility, by Brendon Wyber and RaphaĆ«l Quinet.
  3.    
  4.    If you use any part of this code in one of your programs,
  5.    please make it clear that you borrowed it from here...
  6.    
  7.    NAMES.C - Object name and type routines.
  8.    */
  9.  
  10. /* the includes */
  11. #include "deu.h"
  12.  
  13. sector_class *Sector_classes = (sector_class *)NULL;
  14. ld_class *Linedef_classes = (ld_class *)NULL;
  15.  
  16. /*
  17.    get the name of an object type
  18.    */
  19.  
  20. char *GetObjectTypeName( BCINT objtype)
  21. {
  22.     switch (objtype) {
  23.     
  24.     case OBJ_THINGS:
  25.     return "Thing";
  26.     case OBJ_LINEDEFS:
  27.     return "LineDef";
  28.     case OBJ_SIDEDEFS:
  29.     return "SideDef";
  30.     case OBJ_VERTEXES:
  31.     return "Vertex";
  32.     case OBJ_SEGS:
  33.     return "Segment";
  34.     case OBJ_SSECTORS:
  35.     return "SSector";
  36.     case OBJ_NODES:
  37.     return "Node";
  38.     case OBJ_SECTORS:
  39.     return "Sector";
  40.     case OBJ_REJECT:
  41.     return "Reject";
  42.     case OBJ_BLOCKMAP:
  43.     return "Blockmap";
  44.     }
  45.     return "< Bug! >";
  46. }
  47.  
  48.  
  49.  
  50. /*
  51.    what are we editing?
  52.    */
  53.  
  54. char *GetEditModeName( BCINT objtype)
  55. {
  56.     switch (objtype) {
  57.     
  58.     case OBJ_THINGS:
  59.     return "Things";
  60.     case OBJ_LINEDEFS:
  61.     case OBJ_SIDEDEFS:
  62.     return "LineDefs & SideDefs";
  63.     case OBJ_VERTEXES:
  64.     return "Vertices";
  65.     case OBJ_SEGS:
  66.     return "Segments";
  67.     case OBJ_SSECTORS:
  68.     return "Seg-Sectors";
  69.     case OBJ_NODES:
  70.     return "Nodes";
  71.     case OBJ_SECTORS:
  72.     return "Sectors";
  73.     }
  74.     return "< Bug! >";
  75. }
  76.  
  77.  
  78. BCINT ldt_index[141];
  79.  
  80. void index_ld_types()
  81. {
  82. /*    BCINT i;
  83.     for(i = 0; ld_types[i].type != -1; i++)
  84.     ldt_index[ ld_types[i].type ] = i; */
  85. }
  86.  
  87. /*
  88.    get a short (2 + 13 char.) description of the type of a linedef
  89.    */
  90.  
  91. char *GetLineDefTypeName( BCINT type)
  92. {
  93.     ld_class *c;
  94.     ld_type *t;
  95.  
  96.     for(c = Linedef_classes; c; c = c->next)
  97.         for(t = c->types; t; t = t->next)
  98.             if(t->type == type)
  99.                 return t->shortname;
  100.  
  101.     return("Unknown LineDef");
  102. }
  103.  
  104.  
  105.  
  106. /*
  107.    get a long description of the type of a linedef
  108.    */
  109.  
  110. char *GetLineDefTypeLongName( BCINT type)
  111. {
  112.     ld_class *c;
  113.     ld_type *t;
  114.  
  115.     for(c = Linedef_classes; c; c = c->next)
  116.         for(t = c->types; t; t = t->next)
  117.             if(t->type == type)
  118.                 return t->longname;
  119.  
  120.     return("Unknown LineDef");
  121. }
  122.  
  123.  
  124. /* is a linedef type only available in Doom 2 ? */
  125. Bool LinedefIsDoom2Only( BCINT type )
  126. {
  127.     return 0;
  128. }
  129.  
  130. /*
  131.    get a short description of the flags of a linedef
  132.    */
  133.  
  134. char *GetLineDefFlagsName( BCINT flags)
  135. {
  136.     static char temp[ 20];
  137.     
  138.     if (flags & 0x0100)
  139.     strcpy( temp, "Ma"); /* Already on the map */
  140.     else
  141.     strcpy( temp, "-");
  142.     if (flags & 0x80)
  143.     strcat( temp, "In"); /* Invisible on the map */
  144.     else
  145.     strcat( temp, "-");
  146.     if (flags & 0x40)
  147.     strcat( temp, "So"); /* Blocks sound */
  148.     else
  149.     strcat( temp, "-");
  150.     if (flags & 0x20)
  151.     strcat( temp, "Se"); /* Secret (normal on the map) */
  152.     else
  153.     strcat( temp, "-");
  154.     if (flags & 0x10)
  155.     strcat( temp, "Lo"); /* Lower texture offset changed */
  156.     else
  157.     strcat( temp, "-");
  158.     if (flags & 0x08)
  159.     strcat( temp, "Up"); /* Upper texture offset changed */
  160.     else
  161.     strcat( temp, "-");
  162.     if (flags & 0x04)
  163.     strcat( temp, "2S"); /* Two-sided */
  164.     else
  165.     strcat( temp, "-");
  166.     if (flags & 0x02)
  167.     strcat( temp, "Mo"); /* Monsters can't cross this line */
  168.     else
  169.     strcat( temp, "-");
  170.     if (flags & 0x01)
  171.     strcat( temp, "Im"); /* Impassible */
  172.     else
  173.     strcat( temp, "-");
  174.     if (strlen( temp) > 13) {
  175.     temp[13] = '|';
  176.     temp[14] = '\0';
  177.     }
  178.     return temp;
  179. }
  180.  
  181.  
  182.  
  183. /*
  184.    get a long description of one linedef flag
  185.    */
  186.  
  187. char *GetLineDefFlagsLongName( BCINT flags)
  188. {
  189.     if (flags & 0x0100)
  190.     return "Already on the map at startup";
  191.     if (flags & 0x80)
  192.     return "Invisible on the map";
  193.     if (flags & 0x40)
  194.     return "Blocks sound";
  195.     if (flags & 0x20)
  196.     return "Secret (shown as normal on the map)";
  197.     if (flags & 0x10)
  198.     return "Lower texture is \"unpegged\"";
  199.     if (flags & 0x08)
  200.     return "Upper texture is \"unpegged\"";
  201.     if (flags & 0x04)
  202.     return "Two-sided (may be transparent)";
  203.     if (flags & 0x02)
  204.     return "Monsters cannot cross this line";
  205.     if (flags & 0x01)
  206.     return "Impassible";
  207.     return "UNKNOWN";
  208. }
  209.  
  210.  
  211.  
  212. /*
  213.    get a short (19 char.) description of the type of a sector
  214.    */
  215.  
  216. char *GetSectorTypeName( BCINT type)
  217. {
  218.     sector_class *c;
  219.     sector_type *t;
  220.  
  221.     for(c = Sector_classes; c; c = c->next)
  222.         for(t = c->types; t; t = t->next)
  223.             if(type == t->type)
  224.                 return t->shortname;
  225.  
  226.     return "DO NOT USE!";
  227. }
  228.  
  229.  
  230.  
  231. /*
  232.    get a long description of the type of a sector
  233.    */
  234.  
  235. char *GetSectorTypeLongName( BCINT type)
  236. {
  237.     sector_class *c;
  238.     sector_type *t;
  239.  
  240.     for(c = Sector_classes; c; c = c->next)
  241.         for(t = c->types; t; t = t->next)
  242.             if(type == t->type)
  243.                 return t->longname;
  244.  
  245.     return "DO NOT USE!";
  246. }
  247.  
  248. /* end of file */
  249.  
  250.