SBSPSS/Utils/MkLevel/Main.cpp

135 lines
3.2 KiB
C++
Raw Normal View History

2001-04-17 18:42:07 +02:00
/*******************************/
/*** SpongeBob Level Creator ***/
/*******************************/
#include "stdio.h"
#include <misc.hpp>
#include <vector>
#include <DaveLib.h>
#include <GFName.hpp>
#include "MkLevel.h"
//***************************************************************************
CMkLevel Level;
int TPBase=-1,TPW=-1,TPH=-1;
2001-05-23 18:03:10 +02:00
GString IncDir;
2001-06-25 17:54:07 +02:00
int PakW=0,PakH=0;
2001-06-28 19:48:30 +02:00
bool LocalGeom=false;
2001-04-17 18:42:07 +02:00
//***************************************************************************
char * CycleCommands(char *String,int Num)
{
char Text[256],*TextPtr;
int Count;
if (String[0]=='-' || String[0]=='/')
{
GString TpStr;
TpStr= String;
TpStr.Upper();
switch (String[1])
{// Switches
case 'o':
OutStr = CheckFileString(String);
break;
case 'd':
DebugOn =true;
break;
case 's':
TpStr= CheckFileString(String);
Scale=atof(TpStr);
break;
case 't':
TpStr= CheckFileString(String);
TextPtr=Text;
strcpy(TextPtr,TpStr);
Count=ZeroAndCountCommas(TextPtr);
if (Count!=2)
GObject::Error(ERR_FATAL,"Problem with option %s\n",String);
TPBase=atol(TextPtr);
TextPtr+=strlen(TextPtr)+1;
TPW=atol(TextPtr);
TextPtr+=strlen(TextPtr)+1;
TPH=atol(TextPtr);
break;
2001-06-28 19:48:30 +02:00
// case 'm':
// TpStr= CheckFileString(String);
// Level.AddModel(TpStr);
// break;
2001-05-23 18:03:10 +02:00
case 'i':
IncDir= CheckFileString(String);
IncDir.Upper();
IncDir.Append('\\');
break;
2001-04-17 18:42:07 +02:00
case 'q':
StripLength=4;
break;
2001-06-28 19:48:30 +02:00
case 'l':
LocalGeom=true;
break;
2001-06-25 17:54:07 +02:00
case 'p':
TpStr= CheckFileString(String);
TextPtr=Text;
strcpy(TextPtr,TpStr);
Count=ZeroAndCountCommas(TextPtr);
if (Count!=1)
GObject::Error(ERR_FATAL,"Problem with option %s\n",String);
PakW=atol(TextPtr);
TextPtr+=strlen(TextPtr)+1;
PakH=atol(TextPtr);
break;
2001-04-17 18:42:07 +02:00
default:
GObject::Error(ERR_FATAL,"Unknown switch %s",String);
break;
}
}
else
{
GString UpperName(String);
UpperName.Upper();
MyFiles.AddFile(UpperName);
}
return(String);
}
//***************************************************************************
void Usage(char *ErrStr)
{
printf("\nMkLevel: by Dave\n");
printf("Usage: MkLevel <file> [ <file>.. ] [ switches.. ]\n");
printf("Switches:\n");
printf(" -o:[FILE] Set output File (AND Dir)\n");
printf(" -s:nn Set Scaling value\n");
printf(" -t:p,w,h Set TPage No,Width,Height\n");
2001-06-28 19:48:30 +02:00
// printf(" -m: Add Model\n");
2001-04-17 18:42:07 +02:00
printf(" -d: Enable Debug output\n");
2001-04-27 18:16:23 +02:00
printf(" -q: Enable Quadding\n");
2001-06-28 19:48:30 +02:00
printf(" -l: Enable Local Geom\n");
2001-04-17 18:42:07 +02:00
GObject::Error(ERR_FATAL,ErrStr);
}
//***************************************************************************
int main(int argc, char *argv[])
{
CommandLine(argc,argv,CycleCommands);
std::vector<GString> const &Files = MyFiles.GetFileInfoVector();
if (Files.size()==0) Usage("No Levels specified\n");
if (Files.size()>1) Usage("Too many Levels specified\n");
2001-04-19 17:12:21 +02:00
Level.SetAppDir(argv[0]);
2001-06-28 19:48:30 +02:00
Level.Init(Files[0],OutStr,IncDir,TPBase,TPW,TPH,PakW,PakH,LocalGeom);
2001-04-17 18:42:07 +02:00
Level.Load();
Level.Process();
Level.Write();
return 0;
}