Game Development Community

Changing .cs to .ts

by Jody Byrd · in Torque Game Engine · 08/26/2006 (11:06 pm) · 12 replies

The Goal:

1) Change the default TorqueScript file extension from ".cs" to something VS2005 friendly like ".ts"


The Reason:

1) Let's face it, Microsoft C# is here to stay. and I use C# almost daily.

2) I'm tired of using extra editors when I got one of the biggest and baddest IDE's on the market.


The Approach:

1) Use a clean copy of TGE 1.4, no patches from the HEAD.

2) I'm using VS 2005 Pro. with the free May 2006 MSDN library

#1
08/26/2006 (11:23 pm)
//solution setup

Step 1: copy the entire tge 1.4 code into a new folder

Step 2: remove the tools from the solution

Step 3: do a "Find in Files" search on the solution for ".cs" and then for ".dso"

//Changing main.cs

Step 4: in main.cc

inside runEntryScript()

const char*  defaultScriptName = "main.cs";

to

const char*  defaultScriptName = "main.ts";

Step 5: in winOGLVideo.cc

change:

static SettingProfile sSettingProfiles[] =
{
    {  33, "LowProfile.cs" },
    {  66, "MediumProfile.cs" },
    { 100, "HighProfile.cs" },
};

to

{  33, "LowProfile.ts" },
    {  66, "MediumProfile.ts" },
    { 100, "HighProfile.ts" },

In the "profileSystem()" function:

change:

//execScript("CardProfiles.cs");
execScript("CardProfiles.ts");

and

//dSprintf(osProfiles,64,"%s%sCardProfiles.cs",arch,os);
dSprintf(osProfiles,64,"%s%sCardProfiles.ts",arch,os);

and

//dSprintf(settings,64,"%s.cs",proFile);
dSprintf(settings,64,"%s.ts",proFile);

//changing .dso to .tso

Step 6: in consoleFunctions.cc

under "ccompile()"

change

//dSprintf(nameBuffer, sizeof(nameBuffer), "%s.dso", scriptFilenameBuffer);
dSprintf(nameBuffer, sizeof(nameBuffer), "%s.tso", scriptFilenameBuffer);

and

//dStrcpyl(nameBuffer, sizeof(nameBuffer), scriptFileName, ".dso", NULL);
dStrcpyl(nameBuffer, sizeof(nameBuffer), scriptFileName, ".tso", NULL);

//viewing TorqueScript files within the solution

Step 7: I added an empty c++ project called "Example" to my solution. I made sure it pointed to the "example" folder. I switch to "Show all files" and everything shows up as non project files.

Step 8: I renamed "main.cs" to "main.ts"

Step 9: I set VS2005 as the default editor for my ".ts" files.

Step 10: recompile, run.


That should do it. Happy scripting.
Jody
#2
08/27/2006 (12:13 am)
OK I'm confused by a couple things....

#1. Why change .dso to .tso?
#2. You did all this so you could use VS2005 as the editor for TorqueScript files... perhapse I'm confused... but wouldn't you have been able to do that without changing anything since .cs files would be set to open in VS2005 anyway?
#3
08/27/2006 (6:10 am)
1) Why change .dso? Simply, because I could. And I wanted to know how embedded that half of the compiler was.

2) Yes.

VS2005 thinks of the .cs as C#,period. So does the folding editor, syntax highlighting, syntax checker, auto tabbing, and the compiler. And so does the desktop. Open a .cs file and VS should open. Because I actually use C# for my business and pleasure applications, I can not afford to change the .cs associations from C# to Torquescript.

And, I'm tired of using multiple IDE's when my main IDE is enough.
#4
08/27/2006 (6:42 pm)
Wow thats a really good idea. Is that all thats needed to be done?
#5
08/27/2006 (7:32 pm)
As far as I can tell. Most of the .cs files are called from within the scripts. IIRC, you could already rename those to dot whatever, since the console parser passes the whole filename to the compiler (which in turn appends the .dso to the output)
#6
08/27/2006 (7:49 pm)
I think that this should be stock now. With TorqueX using .cs (C#) files it would only make sense. Just my opinion.
#7
08/27/2006 (8:41 pm)
Maybe MS should have asked GG and not walked all over a file extension that already existed. : )
Just a thought: You have one of the "greatest" IDEs in the world and you can't configure it to recognize a cs script file from a C# file?

BTW, good job on walking down the compile sequence. This kind of information is very useful when obfiscating your source.
#8
08/28/2006 (1:45 am)
I broke out the VS 2005 SDK. Thinking I might be able to tweak the MyC example enough.

I don't know enough about the vs sdk if a custom language service can have overlapping file type with another language. The two langauge examples both define their own file types.

I came to realize that this is a dragon's liar that I'm not comfortable venturing into. So I opted for the simpler direct route.
#9
08/28/2006 (9:33 am)
VS is a pretty nice IDE, but for TorqueScript, nothing beats Torsion.
#10
08/28/2006 (2:48 pm)
Does anyone else feel weird whenever they say the name of that one?
#11
08/28/2006 (3:17 pm)
Torsion is awesome..
reminds me of the Torsion bars I replaced on my muscle car.
#12
08/28/2006 (3:36 pm)
Torsion is very good, I love it... But I have to say this idea is still good, even if you don't use the VS IDE to manipulate torque script files, it still is annoying to double click on one and have it be popped into VS as a C# file. I suppose if you didn't have Visual studio installed on your system it wouldn't matter, but I bet a lot of people do if nothing else than to compile the engine with.

Anyway, awesome idea, I'm going to impliment this one!