Advertisement
Ramaraunt1

visual basic code

May 3rd, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. Imports Microsoft.VisualBasic.FileIO.FileSystem
  2. Imports System
  3. Imports System.IO
  4.  
  5. Public Class frm_load_or_new
  6. Public projectDirectory As String = ""
  7. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  8.  
  9. End Sub
  10.  
  11. Private Sub btn_new_Click(sender As Object, e As EventArgs) Handles btn_new.Click
  12. Dim strPath As String = ""
  13. Dim folderName As String = ""
  14. FolderBrowserDialog1.ShowDialog()
  15. strPath = FolderBrowserDialog1.SelectedPath
  16. folderName = InputBox("What should your project be called?", "PySIDE", "MyProject")
  17. If strPath <> "" And folderName <> "" Then
  18. projectDirectory = My.Computer.FileSystem.CombinePath(strPath, folderName)
  19. End If
  20. If strPath <> "" And folderName <> "" And Not My.Computer.FileSystem.FileExists(My.Computer.FileSystem.CombinePath(projectDirectory, folderName & ".pyside")) Then
  21.  
  22. 'build project
  23. My.Computer.FileSystem.CreateDirectory(projectDirectory)
  24. My.Computer.FileSystem.CopyDirectory(My.Computer.FileSystem.CombinePath(Directory.GetCurrentDirectory, "stellar"), projectDirectory)
  25. Dim assetPath As String = My.Computer.FileSystem.CombinePath(projectDirectory, "assets")
  26. My.Computer.FileSystem.CreateDirectory(assetPath)
  27. My.Computer.FileSystem.CreateDirectory(My.Computer.FileSystem.CombinePath(assetPath, "fonts"))
  28. My.Computer.FileSystem.CreateDirectory(My.Computer.FileSystem.CombinePath(assetPath, "sprites"))
  29. My.Computer.FileSystem.CreateDirectory(My.Computer.FileSystem.CombinePath(assetPath, "sounds"))
  30. Dim S As New IO.StreamWriter(projectDirectory + "/" + "main.py")
  31. S.Write(
  32. "#!python2
  33. #This is the Main file you run for your game project.
  34. import pygame
  35. import stellar
  36.  
  37. # Create new game.
  38. game = stellar.base.Base()
  39.  
  40. # Add an initial room.
  41. game.add_room(""menu"", stellar.rooms.Room())
  42. game.set_room(""menu"")
  43.  
  44. # Launch the game (no duh)
  45. game.start()"
  46. )
  47. S.Close()
  48. Dim W As New IO.StreamWriter(projectDirectory + "/" + folderName + ".pyside")
  49. W.Write(
  50. "#This file will contain information needed for the IDE. WIP - Ramaraunt
  51. [project]
  52. version=""alpha .1""
  53. main=""main.py""
  54. nodes=""nodes.py""
  55. sprites=""sprites.py""
  56. fonts=""fonts.py""
  57. "
  58. )
  59. W.Close()
  60. Dim A As New IO.StreamWriter(projectDirectory + "/" + "nodes.py")
  61. A.Write(
  62. "#!python2
  63. #Nodes go here!"
  64. )
  65. A.Close()
  66. Dim K As New IO.StreamWriter(projectDirectory + "/" + "sprites.py")
  67. K.Write(
  68. "#!python2
  69. #Sprites go here!"
  70. )
  71. Dim F As New IO.StreamWriter(projectDirectory + "/" + "fonts.py")
  72. F.Write(
  73. "#!python2
  74. #Fonts go here!"
  75. )
  76. K.Close()
  77.  
  78. Me.Visible = False
  79. frm_project_main.ShowDialog()
  80. ElseIf My.Computer.FileSystem.FileExists(My.Computer.FileSystem.CombinePath(projectDirectory, folderName & ".pyside")) Then
  81. MsgBox("Failed to create project because a project already exists in thei directory!")
  82. End If
  83.  
  84. End Sub
  85.  
  86.  
  87. Private Sub btn_load_Click(sender As Object, e As EventArgs) Handles btn_load.Click
  88. OpenFileDialog1.ShowDialog()
  89. If OpenFileDialog1.CheckFileExists() Then
  90. projectDirectory = OpenFileDialog1.FileName
  91. Me.Visible = False
  92. frm_project_main.ShowDialog()
  93. End If
  94. End Sub
  95. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement