SBSPSS/Utils/MkLevel/Main.cpp

112 lines
2.6 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;
//***************************************************************************
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-04-27 18:16:23 +02:00
case 'm':
TpStr= CheckFileString(String);
Level.AddModel(TpStr);
break;
2001-04-17 18:42:07 +02:00
case 'q':
StripLength=4;
break;
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-04-27 18:16:23 +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-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-04-17 18:42:07 +02:00
Level.Init(Files[0],OutStr,TPBase,TPW,TPH);
Level.Load();
Level.Process();
Level.Write();
return 0;
}