Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports Microsoft.VisualBasic.FileIO.FileSystem
- Imports System
- Imports System.IO
- Public Class frm_load_or_new
- Public projectDirectory As String = ""
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- End Sub
- Private Sub btn_new_Click(sender As Object, e As EventArgs) Handles btn_new.Click
- Dim strPath As String = ""
- Dim folderName As String = ""
- FolderBrowserDialog1.ShowDialog()
- strPath = FolderBrowserDialog1.SelectedPath
- folderName = InputBox("What should your project be called?", "PySIDE", "MyProject")
- If strPath <> "" And folderName <> "" Then
- projectDirectory = My.Computer.FileSystem.CombinePath(strPath, folderName)
- End If
- If strPath <> "" And folderName <> "" And Not My.Computer.FileSystem.FileExists(My.Computer.FileSystem.CombinePath(projectDirectory, folderName & ".pyside")) Then
- 'build project
- My.Computer.FileSystem.CreateDirectory(projectDirectory)
- My.Computer.FileSystem.CopyDirectory(My.Computer.FileSystem.CombinePath(Directory.GetCurrentDirectory, "stellar"), projectDirectory)
- Dim assetPath As String = My.Computer.FileSystem.CombinePath(projectDirectory, "assets")
- My.Computer.FileSystem.CreateDirectory(assetPath)
- My.Computer.FileSystem.CreateDirectory(My.Computer.FileSystem.CombinePath(assetPath, "fonts"))
- My.Computer.FileSystem.CreateDirectory(My.Computer.FileSystem.CombinePath(assetPath, "sprites"))
- My.Computer.FileSystem.CreateDirectory(My.Computer.FileSystem.CombinePath(assetPath, "sounds"))
- Dim S As New IO.StreamWriter(projectDirectory + "/" + "main.py")
- S.Write(
- "#!python2
- #This is the Main file you run for your game project.
- import pygame
- import stellar
- # Create new game.
- game = stellar.base.Base()
- # Add an initial room.
- game.add_room(""menu"", stellar.rooms.Room())
- game.set_room(""menu"")
- # Launch the game (no duh)
- game.start()"
- )
- S.Close()
- Dim W As New IO.StreamWriter(projectDirectory + "/" + folderName + ".pyside")
- W.Write(
- "#This file will contain information needed for the IDE. WIP - Ramaraunt
- [project]
- version=""alpha .1""
- main=""main.py""
- nodes=""nodes.py""
- sprites=""sprites.py""
- fonts=""fonts.py""
- "
- )
- W.Close()
- Dim A As New IO.StreamWriter(projectDirectory + "/" + "nodes.py")
- A.Write(
- "#!python2
- #Nodes go here!"
- )
- A.Close()
- Dim K As New IO.StreamWriter(projectDirectory + "/" + "sprites.py")
- K.Write(
- "#!python2
- #Sprites go here!"
- )
- Dim F As New IO.StreamWriter(projectDirectory + "/" + "fonts.py")
- F.Write(
- "#!python2
- #Fonts go here!"
- )
- K.Close()
- Me.Visible = False
- frm_project_main.ShowDialog()
- ElseIf My.Computer.FileSystem.FileExists(My.Computer.FileSystem.CombinePath(projectDirectory, folderName & ".pyside")) Then
- MsgBox("Failed to create project because a project already exists in thei directory!")
- End If
- End Sub
- Private Sub btn_load_Click(sender As Object, e As EventArgs) Handles btn_load.Click
- OpenFileDialog1.ShowDialog()
- If OpenFileDialog1.CheckFileExists() Then
- projectDirectory = OpenFileDialog1.FileName
- Me.Visible = False
- frm_project_main.ShowDialog()
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement