further isolate any terminal-related function from console

This commit is contained in:
EverythingWindows 2022-11-17 13:36:07 +07:00
parent 9d0b741e7b
commit 4beaaa1988
7 changed files with 89 additions and 83 deletions

View file

@ -3,6 +3,82 @@
Public AdvancedCommand As Boolean
Public RawCommand As String
Public Sub InitializeTerminal()
Strings.OnceInfo(1) = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\ShiftFS"
Strings.OnceInfo(4) = "!"
Strings.OnceInfo(7) = Console.Width
Strings.OnceInfo(8) = Console.Height
If Strings.IsFree = True Then
Strings.ComputerInfo(0) = "shiftos"
Strings.ComputerInfo(1) = "user"
Terminal_CheckFeature()
Terminal_PrintPrompt()
Terminal_AssignPrompt()
Else
If Console.StayAtChapter = True Then
LoadGame()
Terminal_CheckFeature()
Terminal_PrintPrompt()
Terminal_AssignPrompt()
Else
If Strings.ComputerInfo(3) = "0" Then
Console.TextBox1.ReadOnly = True
Console.StayAtChapter = True
Console.StoryOnlyTimer.Start()
Else
LoadGame()
Terminal_CheckFeature()
Terminal_PrintPrompt()
Terminal_AssignPrompt()
End If
End If
End If
Console.CurrentDirectory = Strings.OnceInfo(1)
Console.Pseudodir = Console.CurrentDirectory.Replace(Strings.OnceInfo(1), "!\")
Console.CurrentInterpreter = "terminal"
TextRebind()
End Sub
Public Sub Terminal_CheckFeature()
If Strings.AvailableFeature(4) = "1" Then
If Console.ToolBarUse = True Then
If Strings.OnceInfo(2) = "True" Then
Console.InfoBarTimer.Start()
Console.TextBox1.Dock = DockStyle.None
Console.ToolBar.Visible = True
Console.ToolBar.SendToBack()
Console.InfoBar.Visible = True
Console.InfoBar.SendToBack()
Console.TextBox1.Dock = DockStyle.Fill
Else
Console.TextBox1.Dock = DockStyle.None
Console.InfoBar.Visible = False
Console.ToolBar.Visible = True
Console.ToolBar.SendToBack()
Console.TextBox1.Dock = DockStyle.Fill
End If
Else
If Strings.OnceInfo(2) = "True" Then
Console.InfoBarTimer.Start()
Console.TextBox1.Dock = DockStyle.None
Console.InfoBar.Visible = True
Console.InfoBar.SendToBack()
Console.ToolBar.Visible = False
Console.TextBox1.Dock = DockStyle.Fill
Else
Console.TextBox1.Dock = DockStyle.None
Console.InfoBar.Visible = False
Console.ToolBar.Visible = False
Console.TextBox1.Dock = DockStyle.Fill
End If
End If
Else
Console.TextBox1.Dock = DockStyle.None
Console.InfoBar.Visible = False
Console.TextBox1.Dock = DockStyle.Fill
End If
End Sub
Public Sub Terminal_ExecuteInput()
Terminal_ReadCommand()
If Strings.AvailableFeature(18) = 1 Then
@ -152,7 +228,7 @@
AdvancedCommand = False
NormalCommand()
SaveGame()
Console.InitializeTerminal()
InitializeTerminal()
Case "shiftorium"
NewLine(My.Resources.man_shiftorium)
AdvancedCommand = False

View file

@ -31,7 +31,7 @@
Console.TextBox1.ReadOnly = False
Strings.ComputerInfo(0) = "shiftos"
Strings.ComputerInfo(1) = "user"
Console.CheckFeature()
Terminal_CheckFeature()
Terminal_PrintPrompt()
Terminal_AssignPrompt()
TextRebind()

View file

@ -28,6 +28,7 @@ Partial Class Console
Me.InfoBar = New System.Windows.Forms.TextBox()
Me.InfoBarTimer = New System.Windows.Forms.Timer(Me.components)
Me.ToolBar = New System.Windows.Forms.TextBox()
Me.ShortcutHandler = New System.ComponentModel.BackgroundWorker()
Me.SuspendLayout()
'
'TextBox1
@ -102,4 +103,5 @@ Partial Class Console
Friend WithEvents InfoBar As TextBox
Friend WithEvents InfoBarTimer As Timer
Friend WithEvents ToolBar As TextBox
Friend WithEvents ShortcutHandler As System.ComponentModel.BackgroundWorker
End Class

View file

@ -123,4 +123,7 @@
<metadata name="InfoBarTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>153, 17</value>
</metadata>
<metadata name="ShortcutHandler.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>274, 17</value>
</metadata>
</root>

View file

@ -7,7 +7,7 @@ Public Class Console
Public DisplayStory As Integer 'Keep record for displaying the DevX's or other's monologue
Public StoryToTell As String 'Which chapter that you're going to be in
Public ChangeInterpreter As Boolean = False 'Default interpreter is Terminal, if it's changed to True, there'll be other program used by Console
Public CurrentInterpreter As String = "terminal" 'Shows what program is using Console
Public CurrentInterpreter As String 'Shows what program is using Console
Public CurrentDirectory As String 'Current Directory for ShiftOS Explorer
Public Pseudodir As String 'Pseudo-directory for ShiftFS
Public StayAtChapter As Boolean = False 'If this set to true, then intro for chapters are mostly going to be in
@ -21,81 +21,6 @@ Public Class Console
InitializeTerminal()
End Sub
Public Sub InitializeTerminal()
Strings.OnceInfo(1) = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\ShiftFS"
Strings.OnceInfo(4) = "!"
Strings.OnceInfo(7) = Width
Strings.OnceInfo(8) = Height
If Strings.IsFree = True Then
Strings.ComputerInfo(0) = "shiftos"
Strings.ComputerInfo(1) = "user"
CheckFeature()
Terminal_PrintPrompt()
Terminal_AssignPrompt()
Else
If StayAtChapter = True Then
LoadGame()
CheckFeature()
Terminal_PrintPrompt()
Terminal_AssignPrompt()
Else
If Strings.ComputerInfo(3) = "0" Then
TextBox1.ReadOnly = True
StayAtChapter = True
StoryOnlyTimer.Start()
Else
LoadGame()
CheckFeature()
Terminal_PrintPrompt()
Terminal_AssignPrompt()
End If
End If
End If
CurrentDirectory = Strings.OnceInfo(1)
Pseudodir = CurrentDirectory.Replace(Strings.OnceInfo(1), "!\")
TextRebind()
End Sub
Public Sub CheckFeature()
If Strings.AvailableFeature(4) = "1" Then
If ToolBarUse = True Then
If Strings.OnceInfo(2) = "True" Then
InfoBarTimer.Start()
TextBox1.Dock = DockStyle.None
ToolBar.Visible = True
ToolBar.SendToBack()
InfoBar.Visible = True
InfoBar.SendToBack()
TextBox1.Dock = DockStyle.Fill
Else
TextBox1.Dock = DockStyle.None
InfoBar.Visible = False
ToolBar.Visible = True
ToolBar.SendToBack()
TextBox1.Dock = DockStyle.Fill
End If
Else
If Strings.OnceInfo(2) = "True" Then
InfoBarTimer.Start()
TextBox1.Dock = DockStyle.None
InfoBar.Visible = True
InfoBar.SendToBack()
ToolBar.Visible = False
TextBox1.Dock = DockStyle.Fill
Else
TextBox1.Dock = DockStyle.None
InfoBar.Visible = False
ToolBar.Visible = False
TextBox1.Dock = DockStyle.Fill
End If
End If
Else
TextBox1.Dock = DockStyle.None
InfoBar.Visible = False
TextBox1.Dock = DockStyle.Fill
End If
End Sub
Private Sub txtterm_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
KeyInput = e.KeyData
InputKey = e.KeyData

View file

@ -56,7 +56,7 @@ Module TerminalExternalApps
Console.DefaultPrompt = Nothing
Console.TextBox1.Text = Nothing
Console.ToolBarUse = True
Console.CheckFeature()
Terminal_CheckFeature()
Console.CurrentInterpreter = "textpad"
TextPad_CheckExist(command)
Console.ToolBar.Text = "TextPad - " & command & Environment.NewLine & "Ctrl-Q Exit | Ctrl-N New | Ctrl-O Open | Ctrl-S Save | F12 Save As"
@ -98,7 +98,7 @@ Module TerminalExternalApps
Console.ChangeInterpreter = False
Console.ReleaseCursor = False
Console.CurrentInterpreter = "terminal"
Console.CheckFeature()
Terminal_CheckFeature()
Terminal_AssignPrompt()
Terminal_PrintPrompt()
TextRebind()
@ -107,7 +107,7 @@ Module TerminalExternalApps
Console.ChangeInterpreter = False
Console.ReleaseCursor = False
Console.CurrentInterpreter = "terminal"
Console.CheckFeature()
Terminal_CheckFeature()
Terminal_AssignPrompt()
Terminal_PrintPrompt()
TextRebind()

View file

@ -6,12 +6,12 @@
Select Case infobarcommand
Case "on"
Strings.OnceInfo(2) = "True"
Console.CheckFeature()
Terminal_CheckFeature()
NormalCommand()
advancedtool = False
Case "off"
Strings.OnceInfo(2) = "False"
Console.CheckFeature()
Terminal_CheckFeature()
NormalCommand()
advancedtool = False
End Select