Portal 2 Extras Menu Patcher 1.0

Avatar
Haapavuo
30 Posts
Posted Apr 29, 2011
Drag & drop custom maps to add them to the Portal 2 Extras menu (for easy loading without console)!

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

Click here to download Portal 2 Extras Menu Patcher

&

Advertisement
Registered users don't see ads! Register now!
Avatar
Beer-Me
137 Posts
Posted Apr 29, 2011
Replied 2 hours later
Great work so far, I think you should add another implementation.

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.

Avatar
Nightgunner5
75 Posts
Posted Apr 29, 2011
Replied 39 minutes later

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)

Avatar
Beer-Me
137 Posts
Posted Apr 29, 2011
Replied 1 minutes later
Do you have the .NET 3.0 runtimes installed?
Avatar
Nightgunner5
75 Posts
Posted Apr 29, 2011
Replied 27 minutes later

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.

Avatar
Beer-Me
137 Posts
Posted Apr 29, 2011
Replied 15 minutes later
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)

Avatar
Haapavuo
30 Posts
Posted Apr 29, 2011
Replied 34 minutes later

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...

Avatar
Nightgunner5
75 Posts
Posted Apr 29, 2011
Replied 1 hour later
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.

Avatar
Haapavuo
30 Posts
Posted Apr 29, 2011
Replied 36 minutes later

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?

Avatar
Nightgunner5
75 Posts
Posted Apr 29, 2011
Replied 1 minutes later

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.

Avatar
Haapavuo
30 Posts
Posted Apr 29, 2011
Replied 1 hour later
Ok. My program now supports drag & dropping .exp and .txt files. An example comes with the program.

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.

Avatar
Haapavuo
30 Posts
Posted May 01, 2011
Replied 2 days later
I improved the drag & dropping capabilities and fixed a couple of bugs. I also added an ability to use command line arguments (you can now drag & drop a map or .exp/.txt file on the program (.exe file) even it is not opened.

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!

Avatar
thearcticcat
3 Posts
Posted May 02, 2011
Replied 23 hours later
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.
Avatar
Zurg
1 Posts
Posted May 03, 2011
Replied 7 hours later
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?
Avatar
Haapavuo
30 Posts
Posted May 03, 2011
Replied 2 hours later

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.

Avatar
thearcticcat
3 Posts
Posted May 04, 2011
Replied 21 hours later
DELETED

(ACCIDENTAL DOUBLE POST)

Avatar
thearcticcat
3 Posts
Posted May 04, 2011
Replied 1 minutes later
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?

Avatar
Haapavuo
30 Posts
Posted May 04, 2011
Replied 3 hours later

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

Avatar
Hober
1,180 Posts
Posted May 04, 2011
Replied 8 hours later
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.

Advertisement
Registered users don't see ads! Register now!
Avatar
Haapavuo
30 Posts
Posted May 04, 2011
Replied 3 hours later

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.