MEDIA MANAGER 0.3 beta 2 2/3 (An AGS Editor Plugin)

Started by edmundito, Sun 06/02/2005 03:34:19

Previous topic - Next topic

Pumaman

Did you do the AutoDual attribute thing to try and get it to automatically pick up the AGS_InitPane and related functions? I'm sure it must be possible to get it working as-is with .net, although an interface could be added if necessary (I didn't want to because it means you have to implement all the methods).

edmundito

#21
Okay, boys and girls, I made a change on this, and let's see if it works:
http://monkeygames.mixnmojo.com/ags/AGS_MediaMan_NET_03beta3.zip

I hope it does. Don't forget to unload the plugin from the game if you saved the game with the plugin loaded and you get the magic white background! And please, as soon as you notice that it works/doesn't work, let everyone (and myself) know by posting a reply!

For the record, and Chris, someone should try to interpret this mumbo-jumbo on the ClassInterface attribute:

Quote from: Microsoft Visual Studio.net Help
You can apply this attribute to assemblies or classes.

This attribute controls whether a class interface is generated for the attributed class. While class interfaces can be useful for testing purposes, their use in production applications is strongly discouraged because they present versioning problems.

Class interfaces are useful for testing managed types from COM because they free you from having to explicitly define interfaces for each class. A class interface carries the same name as the class itself, but is prefixed with an underscore. The class interface contains all the public, non static (Shared in Visual Basic) members of the managed class, including members inherited from its base class. Managed classes cannot access the class interface, but do not need to as they can access the class members directly. The type library exporter generates the interface and a unique IID for the class interface.

The downside to class interfaces is that they allow clients to bind to a specific interface layout that is subject to change as the class evolves. This problem is obscured by managed applications that bind directly to class and do not exhibit the same versioning problems. Unmanaged clients are subject to failure while the managed clients are unaffected.

Consider a managed class that exposes a class interface to COM clients. Version 1 of the class contains methods A() and B(). The unmanaged clients bind to the class interface that has method A() as the first method in the class interface and method B() as the second method. Now consider version 2 of the class which has a new method C() added between methods A() and B(). Clients that try to bind to the new class through the old class interface end up calling method C() when they intend to call method B() because the method position in the interface has changed. The problem is compounded when you consider that the class interface also include methods of any base classes. Changes in the layout of one class affects the layout of the class interface for all derived classes. Due to the versioning problems described, the use of class interfaces in strongly discouraged.

Class interfaces are only generated when the ClassInterfaceAttrribute is set to ClassInterfaceType.AutoDual. Use of this setting is strongly discouraged, it should only be used when the versioning limitations are known to be acceptable.

Fritos

Unfortunately I still get the white background. I tried it in 2.62 and in the current beta. I'm really looking forward to this feature, so don't dispair. If I knew any ounce of programming, we'll you know how that goes.

Thanks again for your efforts!!  ;D

Vel


edmundito

Thanks for the help guys... at least I can confirm that my computer has somehow been rigged to work no matter what I do to it, which is rather odd... I've done so much to make it work in the beggining that I must have permanently (until I reinstall)  fixed my computer.

Anyway, I'm messing with the debug tools, and I'm pretty sure that the once you I add the panel to the editor, then it is unable to find AGS_InitPane()... therefore, it never finds those methods. On my computer it does find it, which is rather odd. I'll dig my registry for answers... or at least try to.

Man, I wish some expert would come and help us all out.

Pumaman

Can you provide an example code snippet from your plugin, showing which COM attributes you've attached to things?

I created a test VB.net plugin, and the AGS_InitPane method did get called.

However, I had to run tlbexp on the dll as well as regasm to get it to work.

So, I tried running tlbexp on your plugin but that didn't fix it for me, so I'm wondering if there's some sort of attribute that you need for it to pick up the methods.

edmundito

Puma, can you e-mail me the source of your test plugin? (Check your messages)

Pumaman

I've uploaded it here:
http://www.adventuregamestudio.co.uk/testnetplugin.zip

Note that this is in no way meant as a template plugin or anything like that, it's just a quick test I whipped up for this specific issue.

edmundito

#28
Well, the only difference I can see is that I didn't have a ProgId("AGS_MediaMan_NET.AGSPanel") in my code, so I added that... it looks like I don't have tlbexp on my compy (weird) so I uploaded these files so you, Pumaman, can play with them:

http://monkeygames.mixnmojo.com/ags/AGS_MediaMan_NET_tests.zip

There's two files: one inherits a class interface that contains all of your AGS controls:
Code: ags

	public interface IAGSControlMethods
	{
		void AGS_InitPane(Object pData);
		void AGS_SelectPane();
		void AGS_DeselectPane();
		void AGS_GameChanged();
		void AGS_SaveUpdates();
	}

	[ProgId("AGS_MediaMan_NET.AGSPanel"), ClassInterface(ClassInterfaceType.AutoDual)]
	public class AGSPanel : System.Windows.Forms.UserControl, IAGSControlMethods
        {}


I can't remember why I did this... I think I was just playing around to see if it worked.

Anyway, the other does not have an interface  (the one with NI at the end):

Code: ags

	[ProgId("AGS_MediaMan_NET.AGSPanel"), ClassInterface(ClassInterfaceType.AutoDual)]
	public class AGSPanel : System.Windows.Forms.UserControl
        {}


If you can make it work, let me know how tlbexp affects it, and what do I need to do in the future.

Pumaman

You must have tlbexp, it's part of the .net SDK (you probably need to use a Visual Studio Command Prompt in order for it to find it).

Anyway, have you put some sort of message box in AGS_INitPane so that we can check whether it's being called? If not, there's no easy way to tell whether that's the problem or not.

edmundito

#30
The way it's telling whethere's it is working or not has to do with the background color, because I have a variable set on AGS_InitPane() that fixes the white background issue.. so if the background color is correct, it means that the method has been called successfully...!

Yeah, I found the tlbexp thing... I don't use the magical visual studio "command prompt".. I just go straight from cmd, so I added the location of it to the PATH variable.

Edit: So, how do I use tlbexp?

Edit 2: Good news, I broke the Media Manager on my computer.. it doesn't work here either! :)

Pumaman

I would suggest you don't use the seperate interface, and just put the methods directly in your UserControl class.

You use tlbexp to generate a .tlb file, and then the user has to run  regtlib  to register it -- a bit like the reg file, but slightly more cumbersome.

edmundito

alright, looks like regtlib is part of visual studio 6, and I have something laying around, but reagsm AGS_MediaMan_NET.dll /tlb seems to actually fix what I just broke. Now, how in the world do I output that to a REG file so that people can use it?

Pumaman

I'm not sure if you can convert a tlb to a reg file, I think you just have to distribute the tlb and get people to run regtlib on it.

edmundito

Hey Chris, in the sample code you uploaded, how'd you generate the GUID in the assemblyinfo file? That's the only thing I don't have....

The good news is that I now have another computer, so I can test the plugin there since in that one it behaves as it is (in other works, it doesn't work!)

Pumaman

I dunno, I guess Visual Studio generated it automatically.

SMF spam blocked by CleanTalk