Tag Archives: custom project

Visual TorqueScript #3.75

Another minor update, which I'm mostly using to publish a useful patch.
I've forgotten to mention that I've already created a custom settings page for my Visual TorqueScript projects. Yesterday night (before going to bed) I decided to add a configuration dependent page, too.
As you'll see it's very Torsion-esque, which is intentional and I plan to support .torsion files directly (as project files) later-on.

The main reason is that Torsion rocks and there is no reason to have yet another project file format for TorqueScript projects.

I hope that it will also be an incentive for people to give my plugin a try (if I ever release it).

A few notes (programatically so to speak :D ):

  • Again the managed project framework is awesome and once you figure out where to look for things you'll certainly find eternal bliss, too..
  • I generally derive from SettingsPage directly, because I don't want any of the regular faff in my project.
  • Don't forget to publish your pages via ProvideObject (or ProvideClass from my previous post)
  • You don't need to create your own GUIDs for everything. Classses are automatically provided with a unique GUID - try it and access typeof(SomeClassWithoutGuidAttribute).GUID and it'll still work.
    (If I said something wrong, please correct me..)
  • SettingsPage has an IsDirty property which you have to set, when a property is changed (to update the Apply button state).
    It results in pretty ugly copy'n'paste code, because you can't use default property accessors anymore.
    To fix this I spent an hour or two and I've come up with an elegant (in my opinion) patch to fix the issue:

    Index: ProjectBase/SettingsPage.cs
    ===================================================================
    --- ProjectBase/SettingsPage.cs	(revision 10)
    +++ ProjectBase/SettingsPage.cs	(working copy)
    @@ -27,7 +27,26 @@
    
     namespace Microsoft.VisualStudio.Package
     {
    +    // Added to make it easier to edit pages [9/10/2008 Andreas]
    
    +    class SettingsPagePropertyDescriptor : DesignPropertyDescriptor
    +    {
    +        public SettingsPagePropertyDescriptor(PropertyDescriptor prop)
    +            : base(prop)
    +        {
    +        }
    +
    +        public override void SetValue(object component, object value)
    +        {
    +            if (component is SettingsPage)
    +            {
    +                SettingsPage page = (SettingsPage)component;
    +                page.IsDirty = true;
    +            }
    +            base.SetValue(component, value);
    +        }
    +    }
    +
         /// <summary>
         /// The base class for property pages.
         /// </summary>
    @@ -78,7 +97,7 @@
                 get { return this.grid; }
             }
    
    -        protected bool IsDirty
    +        protected internal bool IsDirty
             {
                 get
                 {
    @@ -203,6 +222,13 @@
    
             #endregion
    
    +        #region overriden methods.
    +        public override DesignPropertyDescriptor CreateDesignPropertyDescriptor(PropertyDescriptor propertyDescriptor)
    +        {
    +            return new SettingsPagePropertyDescriptor(propertyDescriptor);
    +        }
    +        #endregion
    +
             #region IPropertyPage methods.
             public virtual void Activate(IntPtr parent, RECT[] pRect, int bModal)
             {
    @@ -410,6 +436,8 @@
                     try
                     {
                         Marshal.WriteIntPtr(ppUnk, p);
    +                    // Reset IsDirty before rebinding all properties [9/10/2008 Andreas]
    +                    IsDirty = false;
                         this.BindProperties();
                         // BUGBUG -- this is really bad casting a pointer to "int"...
                         this.grid.SetSelectedObjects(1, ppUnk.ToInt32());
    

    It also contains a one-line fix to reset IsDirty when reloading the page or switching configurations (ie. any time the properties are reset to their old value).

Cheers,
Black

Visual TorqueScript #2

I haven't found time to add IntelliSense to the language service yet, so I've only added a basic parser and enabled brace highlighting/matching which was easier to do.

I've been told that a working debugger would be the most important feature, so I try to get started with it, but before I can do that I have to add a custom project type to support the standard .cs extension for TorqueScript and to offer a specialized debug options property page for Torque's telnet debugger.

Here you can see the progress I've made so far:
I've added a new custom project type and changed everything to support TorqueScript files that use the usual .cs extension. There is no conflict with C# whatsoever. (At least from what I know..)

Next I'll look into removing the MSBuild faff (if possible at all) and adding the debug configuration page.

Last but not least I've found another neat tool that I can only recommend and want to share with whoever might read this:
It's called VSSDK Assist and it's a so-called Guidance Package - it provides you with a neat assistance window that helps you do common tasks using the Visual Studio SDK in the preferred way (it supplies you with lots of dialog-based wizards for all kinds of things like custom pages/tools/editors/projects/...).

You can grab it here.

More to come.
Cheers,
Black