Portal 2 Extras Menu Patcher 1.0
It is very easy to use: It will automatically get your portal2.exe path & map name in the folder where the patcher is. Just set the title and subtitle. You can also set a picture for your map (not necessary).
The program can save default settings to an ini file to make patching even easier. It also supports drag & dropping .bsp, .vtf, .txt and .exp files. .txt and .exp have to be in the example format. You can easily create such files with the program and release them with your maps.
It can also copy map files to the portal2\maps folder. Try drag & dropping your map file onto the program to easily patch extras.txt and copy the map file to Portal 2!
The program will also notice if the map already exists in the extras.txt and will ask the user if he wants to update the information.
You can now also patch version 7.5 .vtf files to version 7.4!
The program is made using Visual C# 2010 Express so it'll need the .NET Runtime to be installed.
Thanks for reading & testing the program! Please report if you encounter any problems with it!
File Name: Portal2ExtrasPatcher.zip
File Size: 74.7 KiB
Suggestion 1
You create a file format that map makers will use to create a custom text file that has the relevant map info (Map ID, filename, title, subtitle, picture etc). Therefore each map released could include one of these files.
You then drag + drop that text file, into your application. The app will then parse the new file type, grabbing relevant information. It will then open up the default extras.txt and add the new map data.
Suggestion 2
You create a folder in the Portal 2 directory called Extra Maps, inside of this will store each of the custom map extra files I described earlier. Your app will then loop through all the txt files within that folder and create a new extras.txt based on that information. This is incase you delete your extas.txt file, your app will still be able to generate a new one with the relevant map information.
I just started it up and was greeted with a fatal error.
************** Exception Text **************
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Portal2ExtrasMod.Form1.Form1_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Beer-Me wrote:
Do you have the .NET 3.0 runtimes installed?
Yes, I have .NET 3.0, as well as 3.5 and 4 for that matter.
Looking at the source code, the area that it is likely to occur is within:
string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.bsp");
if (files != null)
{
files[0] = Path.GetFileName(files[0]);
files[0] = files[0].Remove(files[0].Length - 4);
this.txt_mapfile.Text = files[0];
this.txt_ID.Text = files[0];
}
He really needs to check whether files[0] is not empty (null). Hes checking to see if the array is empty, its not but the array elements are.
You should really use if (files.length > 0)
Beer-Me wrote:
The error usually occurs when an array is accessed at an invalid index location, making it outside of the index's bounds.Looking at the source code, the area that it is likely to occur is within:
```
string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.bsp");
if (files != null)
{
files[0] = Path.GetFileName(files[0]);
files[0] = files[0].Remove(files[0].Length - 4);
this.txt_mapfile.Text = files[0];
this.txt_ID.Text = files[0];
}```
He really needs to check whether files[0] is not empty (null). Hes checking to see if the array is empty, its not but the array elements are.
You should really use if (files.length > 0)
Thanks for your replies! I think I've fixed it now.
I will try to make the implementations you mentioned earlier...
//include_maps:n5_sequential01.bsp:n5_sequential02.bsp:n5_sequential03.bsp
//include_materials/vgui/extras:n5_sequential01.vmt:n5_sequential01.vtf
"n5_sequential01"
{
"title" "Sequential"
"subtitle" "A custom map by Nightgunner5"
"pic" "vgui/extras/n5_sequential01"
"map" "n5_sequential01"
}
Onto your program and have it automatically install everything that is needed.
Nightgunner5 wrote:
It would be cool if it was possible to click and drag a file like this:
//include_maps:n5_sequential01.bsp:n5_sequential02.bsp:n5_sequential03.bsp //include_materials/vgui/extras:n5_sequential01.vmt:n5_sequential01.vtf "n5_sequential01" { "title" "Sequential" "subtitle" "A custom map by Nightgunner5" "pic" "vgui/extras/n5_sequential01" "map" "n5_sequential01" }
Onto your program and have it automatically install everything that is needed.
I'll try to make that possible.
What are those commented lines? Are those important?
Haapavuo wrote:
Nightgunner5 wrote:It would be cool if it was possible to click and drag a file like this:
//include_maps:n5_sequential01.bsp:n5_sequential02.bsp:n5_sequential03.bsp //include_materials/vgui/extras:n5_sequential01.vmt:n5_sequential01.vtf "n5_sequential01" { "title" "Sequential" "subtitle" "A custom map by Nightgunner5" "pic" "vgui/extras/n5_sequential01" "map" "n5_sequential01" }
Onto your program and have it automatically install everything that is needed.I'll try to make that possible.
What are those commented lines? Are those important?
That's actually a working configuration file for my patcher. The commented lines tell it files to copy.
EDIT: I just found out that I had failed. The ID cannot be the same as map file name. This has now been fixed by adding "_id" to the end of the id name. I also added an ability to copy map files to portal2\maps folder.
EDIT2: Now the program supports drag & dropping of .bsp files also! Try it.
Program will now also check if the map already exists in the extras.txt file.
Please comment to this thread if you like it or not! 
EDIT: The program can now update existing map information in the extras.txt file (without adding a duplicate). It will also send "-console" argument as user presses "Launch Portal 2" button. There is also an ability to add all maps to extras.txt automatically!
thearcticcat wrote:
i am having issues dragging and dropping! i have the latest build (1.5) but it just gives me the circle with the line through it when i try to drag and drop... Any ideas???? Thanks.
You can only drag & drop .bsp, .txt and .exp files. None else will work.
Zurg wrote:
I can not, for the life of me figure out how to add a thumbnail to show up. Am I overlooking something? How do I make the thumbnail show up in the Extras menu?
If you want pictures to show up, they must be found in "portal2\materials" folder & they must be in .vtf/.vmt format (.vmt is not neccessary). For example the Super 8 (e1912) pic is "vgui/extras/e1912" because it is located in a .vpk file and it will have a path "portal2\materials\vgui\extras\e1912.vtf" when executed.
You can easily create .vtf files with VTFEdit: http://nemesis.thewavelength.net/index.php?c=178#p178.
EDIT: I released a minor update which makes patching all maps a bit more clear (custom, sp_a & mp_coop).
EDIT2: The program now supports uppercase file extensions.
(ACCIDENTAL DOUBLE POST)
Ideas?
thearcticcat wrote:
That's what I meant. I tried all three of those file extensions to no avail. It would only work if I dragged the file to the actual icon of your executable and clicked "open with". It won't however let me drag any of those files directly into the window once open.Ideas?
Do you have the newest .NET framework installed? Try to install this (v4): http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=9cfb2d51-5ff4-4491-b0e5-b386f32c0992
Retract grumbling because I don't have the time to write the script myself and therefore have no room to complain. This free ice cream is the wrong flavor.
Hober wrote:
Insert grumbling about needing to install the latest .NET (not just any version) to do a task that a good shell script could do.Retract grumbling because I don't have the time to write the script myself and therefore have no room to complain. This free ice cream is the wrong flavor.
Good point, if I got it right. 
Did you mean that I should write a script that detects which .NET version is installed?
My english is not good enough to fully understand you.