XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

XML Content Processor in the RPG starter kit problem

Last post 07-20-2008 9:44 AM by LaViMa SoN. 1 replies.
  • 07-19-2008 10:21 PM

    XML Content Processor in the RPG starter kit problem

    So I'm trying to add xml content support for my game the same way the RPG starter kit is doing it. I have my content processor in a seperate project called GameContentProcessor, my temp data structures and contenttypereaders in a second project called GameContentData then from my game project called TestNet the game content project links to the content processor the game links to the GameContentData(which is an XNA game library windows) project and everything runs fine in windows.

    On xbox I have a fourth project called GameContentDataXBox which is a duplicate of the windows GameContentData project built for XBox. Then the TestNetXBox game links to GameContentDataXBox project. Everything builds fine but when it runs I get ye olde "ContentTypeReader cannot be found" error when it tries to load an xml file.

    I've been scouring the RPG starter kit for info but I can't find any difference between the way I do it and the way they're doing it. (other than mine doesn't work)

     Any ideas what I'm doing wrong?

  • 07-20-2008 9:44 AM In reply to

    Re: XML Content Processor in the RPG starter kit problem

    This is probably a stupid question, but anyway: Have you implemented the GetRuntimeReader in the same fashion as in the starter kit?
    public override string GetRuntimeReader(TargetPlatform targetPlatform)
    {
    	Type type = typeof(T);
    
    	string readerText = type.FullName;
    	string shortTypeName = type.Name;
    	if (shortTypeName.EndsWith("`1"))
    	{
    		// build the name of a templated type
    		shortTypeName = shortTypeName.Substring(0, shortTypeName.Length - 2);
    		readerText = readerText.Insert(readerText.IndexOf("`1") + 2, "+" +
    			shortTypeName + "Reader");
    	}
    	else
    	{
    		// build the name of a non-templated type
    		readerText += "+" + shortTypeName + "Reader";
    	}
    	readerText += ", RolePlayingGameDataWindows";
    
    	// replace the suffix name on the Xbox 360
    	// -- since the processor runs on Windows, it needs to reference 
    	//    RolePlayingGameDataWindows.  However, this means that type.FullName
    	//    will specify RolePlayingGameWindows in the interior type of templates
    	if (targetPlatform == TargetPlatform.Xbox360)
    	{
    		readerText = readerText.Replace("Windows", "Xbox");
    	}
    
    	System.Diagnostics.Debug.WriteLine("Reader:  " + readerText);
    
    	return readerText;
    }
    
    The most important part is the place where it exchanges "Windows" with "Xbox" when the target platform is the 360. This will have to match the names you are using in your project.
Page 1 of 1 (2 items) Previous Next