Resource Files (Standard or Custom) NEED HELP Please

spraypaint

New member
Joined
Jul 11, 2006
Messages
1
Programming Experience
3-5
I am using a Stand Alone Resource File, although I would much rather use a custom binary file. I understand how the custom binary works for VB 6, however most if not all the commands have been upgraded in VB.NET 2005, I have been able to store files useing the tutorial, I have not been able to read the files from it :< here is a link to the tutorial http://gpwiki.org/index.php/VB:Tutorials:Custom_Resource_Files

What I need is either the correct info on the tutorial for VB.NET 2005 basically the same tutorial that WORKS for vb.net 2005 or some code bits for the flow charts show below. I cant seem to store text files in the resource file, I know theres a way, I'm just overlooking it. Having spent 2 weeks on this part of the game, I'm now getting upset and need a fresh pair of eyes to help with the problem :>

The Resource File is using Standard ResourceWriter and RW.AddResource to place and then ResourceManager and RM.GetResource to pull it back out, and as I have not figured out how to store the text file im not sure how to read it back, I would prefer that durring the game's run-time no files be wrote to the users system I would rather they all be read from the file to memory and worked with in memory, still hazy on how that is accomplished.


Game Editor's Flow Chart

User Edits Details (Done)
User Saves Details (Done)
User Compiles Details (Need Help)
Images Renamed and Sorted (Done)
Images Stored in Resource File (Done)
Detail File Re-Saved With Renamed and Sorted Info (Done)
Store New Detail File In Resource File (Need Help) (File is a Flat Text File)
Resource File Closed
Ini File Created (Done)
User Notified Compile Finished (Done)
Exit Editor (Done)



Game (File Loading) Flow Chart

User Selects File To Load (Done)
File Loading (Not Started)
Read Ini File (Not Started)
Read and Load Data From Resource File (Need Help)
User Plays Game (Done)
Game Ends (Done)
 
Here is your steps to starting to learn the resource file format for .NET 2005.

1. Load a new project or an existing project into the Development Environment.
2. Find the item labeled MyProject in the solution explorer and double click. This will open the MyProject settings editor with tabs along the left hand side of that window.
3. Click on the settings tab. If you create a setting here you can access it from anywhere in your program with
My.Settings.SettingNameYouUsed. If your scope is left to User you can modify it at will using standard assignment commands.
4. To make your setting persist from session to session of your program call the My.Settings.Save() method and the settings will be flushed to an XML file created in the root of your programs binary path. In this manner you can eliminate the need for INI files and the capability is built in making the task LOADS easier.

Now thats the INI and Registry side of things, the My.Settings class is designed to replace reliance on the system registry and upon INI files and is in keeping with microsofts vision of the future Everything XML.

In the same window where you found the settings tab you will find a tab labeled Resources. Yes, this does create a flat resource file, but the resource file is encoded such that being a flat file does not really give you that big a performance hit unless you are putting thousands of things into it. The file is output as XML and you can read the images and strings placed in the resource file in the following manner

For images: my.Resources.imageyounamedtheresource
This structure for images returns a system.drawing.bitmap.

For Strings
My.Resources.WhatYouNameYourString
This structure returns String.

For Icons
My.Resources.WhatYouNamedYourIcon
This structure returns System.Drawing.Icon

You can use the same structure for Audio and Text Files in addition to the three I have listed. Since by definiation a resource file is static, you do not need to save it or open it, it is saved and opended by the programming langauage for you when you call for it in code. Since you mentioned saving resource files specifically in code I am assuming that you are attempting to build a resource file in memory and then use it. My suggestion is that you build a resource file using the resource editor as provided and then consume that resource file later in your code. If you must have a dynamic resource file I cannot assist as I have never it that way before myself.

Hope this helps in some small way. If you have specific questions about what I have wrote don't hesitate to ask, if you want to see code Blocks with this in action, let me know and I will see what I can dig up for you.
Cheers.
 
Back
Top