Jump to content

0.16 Ship Updater | New Version out!


Recommended Posts

Hi!

I wanted to play my old 0.15 Ships on 0.16, so I decided to create a tool which converts the old Ships to 0.16 Ships.

This tool is propably very buggy, but it works with the most of craft files.

Screenshot:

scaled.php?server=39&filename=screen1i.png&res=landing

Download Attached

Code (CAUTION, VERY VERY BAD VB CODE WHICH WAS MADE WITHIN 5 MINUTES :D)

  Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles btn_SelectShip.Click
OpenFileDialog1.ShowDialog()
txb_OldShipPath.Text = OpenFileDialog1.FileName
txb_File.Text = My.Computer.FileSystem.ReadAllText(txb_OldShipPath.Text)
End Sub

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles btn_SelectOutput.Click
SaveFileDialog1.ShowDialog()
txb_OutputPath.Text = SaveFileDialog1.FileName
End Sub
Dim type As String = 'VAB'
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles btn_Convert.Click
txb_OldShipPath.Enabled = False
txb_OutputPath.Enabled = False

Dim lines() As String = txb_File.Lines

Dim verpos As Integer
Dim typepos As Integer

For i As Integer = 0 To lines.Length - 1
If lines(i).Contains('version = ') Then
verpos = i
End If
If lines(i).Contains('type = ') Then
typepos = i
End If
Next


If txb_File.Text.Contains('type = ') Then
txb_File.Text = txb_File.Text.Replace(txb_File.Lines(verpos), 'version = 0.16.0')

txb_File.Text = txb_File.Text.Replace(txb_File.Lines(typepos), 'type = ' & type & vbNewLine & 'PART')
Else
txb_File.Text = txb_File.Text.Replace(txb_File.Lines(verpos), 'version = 0.16.0' & vbNewLine & 'type = ' & type & vbNewLine & 'PART')
End If







txb_File.Text = txb_File.Text.Replace('}' & vbNewLine & '{', '}' & vbNewLine & 'PART' & vbNewLine & '{')

txb_File.Text = txb_File.Text & vbNewLine & '// Converted with deppdepp\'s Ship-Updater'

My.Computer.FileSystem.WriteAllText(txb_OutputPath.Text, txb_File.Text, False)

MsgBox('Ship was updated succesfully!')

txb_File.Clear()
txb_OldShipPath.Clear()
txb_OutputPath.Clear()
txb_OldShipPath.Enabled = True
txb_OutputPath.Enabled = True
End Sub

Private Sub TextBox3_TextChanged(sender As System.Object, e As System.EventArgs) Handles txb_OutputPath.TextChanged
If txb_OutputPath.Text = '' Or txb_OldShipPath.Text = '' Then
btn_Convert.Enabled = False
Else
btn_Convert.Enabled = True
End If
End Sub

Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rdb_VAB.CheckedChanged
If rdb_VAB.Checked = True Then
type = 'VAB'
Else
type = 'SPH'
End If
End Sub

License:

Do whatever you want with it.

Have Fun, you can leave your opinion as a reply :D

- deppdepp

Link to comment
Share on other sites

It threw an unhandled exception error.

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: String cannot be of zero length.
Parameter name: oldValue
at System.String.ReplaceInternal(String oldValue, String newValue)
at System.String.Replace(String oldValue, String newValue)
at KSP_Ship_Converter.Form1.Button3_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.269 (RTMGDR.030319-2600)
CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
KSP Ship Updater
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///Y:/PlayOnLinux\'s%20virtual%20drives/KSP/drive_c/KSP_win/Ships/SPH/KSP%20Ship%20Updater.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 10.0.0.0
Win32 Version: 10.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.269 built by: RTMGDR
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.278 built by: RTMGDR
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.282 built by: RTMGDR
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
Accessibility
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging='true' />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Link to comment
Share on other sites

Ah, the problem is your file.

I made that program within 5 minutes, so bugs like that can happen.

You can fix this if you remove all lines that stand before 'ship' (so that the file begins with 'ship....')

With regards

Florian

Link to comment
Share on other sites

Another idea would be to search for the lines needing edit. Such as the version number.

Like I\'m doing with my mod manager to find out what type of ship it is. If it\'s SPH or VAB.

I think something similar could be done here too.

Here\'s the function I created to use in the mod manager.


Dim CraftFileTxt As String = File.ReadAllText(CraftFile)
Dim location1 As Integer = CraftFileTxt.IndexOf('type = ')

CraftFileTxt = CraftFileTxt.Substring(location1 + 7, 3)
If CraftFileTxt = 'SPH' Then
Return 'SPH'
Else
Return 'VAB'
End If
End Function
Function ReadCraftType(ByVal CraftFile)

Feel to use, modify, redistribute and all that.

Other than that, awesome application. Very useful. :)

Link to comment
Share on other sites

You should place the version number of your program at the end of your title. Even the date of update at the end would help. Also, make the version number easily viewable in your program.

Keep up the good work!

Cheers!

Capt\'n Skunky

KSP Community Manager

Link to comment
Share on other sites

  • 1 month later...

fantastic work for 5 minutes of coding, deppdepp! Successfully brought back a few old ships I had given up for ghosts, was a real pleasure to fly them. I'm sure you have more work to do, but dang man, really nice job for just a few minutes of effort! Thanks for the great tool!

Link to comment
Share on other sites

Hi.

Great to hear that somebody found my tool helpful.

(Yes, I'm deppdepp but it wasn't possible to edit my old profile, to post or to write messages with that profile since the Forum "update")

I'll try to improve my tool if you want that.

Best regards,

deppdepp/fuu

Edited by fuu
Link to comment
Share on other sites

  • 7 months later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...