kOS/ui/rocket.ks

73 lines
1.7 KiB
Plaintext

function launchButtonPressed {
run "launch"(
targetApo:TEXT:ToNumber(),
gravTurnStart:TEXT:ToNumber(),
gravPitch:TEXT:ToNumber(),
initialPitch:TEXT:ToNumber(),
minimumPitch:TEXT:ToNumber()
).
}
function nodeButtonPressed {
run "execnode".
}
local termOn is false.
function terminalButtonPressed {
if termOn {
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Close Terminal").
set termOn to false.
} else {
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Open Terminal").
set termOn to true.
}
}
// Main UI.
local interface is gui(200).
set interface:X to 200.
set interface:Y to 800.
// Launch button
local hBox is interface:AddHBox().
hBox:AddLabel("Initial Pitch").
local initialPitch is hBox:AddTextField("85").
local hBox is interface:AddHBox().
hBox:AddLabel("Minimum Pitch").
local minimumPitch is hBox:AddTextField("5").
local hBox is interface:AddHBox().
hBox:AddLabel("Gravity Turn @").
local gravTurnStart is hBox:AddTextField("8000").
local hBox is interface:AddHBox().
hBox:AddLabel("Gravity Pitch").
local gravPitch is hBox:AddTextField("75").
local hBox is interface:AddHBox().
hBox:AddLabel("Target Apoapsis").
local targetApo is hBox:AddTextField("80000").
local launchButton is interface:AddButton("Launch").
set launchButton:onClick to launchButtonPressed@.
local nodeButton is interface:AddButton("Execute Node").
set nodeButton:onClick to nodeButtonPressed@.
local termButton is interface:AddButton("Terminal").
set termButton:onClick to terminalButtonPressed@.
// debug
function circButtonPressed {
runpath("/lib/navigation").
AddCircularizationNode().
}
local cButton is interface:AddButton("Circularize").
set cButton:onClick to circButtonPressed@.
// end debug
interface:show().
wait until false.