diff --git a/init/rocket.ks b/init/rocket.ks index eefdeaa..ca2020a 100644 --- a/init/rocket.ks +++ b/init/rocket.ks @@ -1,6 +1,7 @@ runoncepath("/lib/navigation"). runoncepath("/lib/throttle"). runoncepath("/lib/stabilize_rocket"). +runoncepath("/lib/ui"). clearguis(). @@ -21,120 +22,110 @@ function launchButtonPressed { } // Main UI. -local interface is gui(250, 300). -set interface:X to 200. -set interface:Y to 700. +local iface is gui(250, 300). +set iface:X to 200. +set iface:Y to 700. // Main menu elements in here. -local y is interface:AddVLayout(). -local x is y:AddHLayout(). +local top is iface:AddVLayout(). +local row is makeRow(top). -local btn is x:AddButton("TERM"). +local btn is row:AddButton("TERM"). set btn:TOGGLE to true. set btn:ONTOGGLE to { - parameter activate. + parameter d. - if activate { + if d { CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Open Terminal"). } else { CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Close Terminal"). } }. -set x:AddButton("CONF"):onClick to { - stk:ShowOnly(confMenu). -}. +makeButton(row, "CONF", { stk:ShowOnly(panes["conf"]). }). -set x to y:AddHLayout(). +set row to makeRow(top). -set x:AddButton("HOVER"):onClick to { - Hover(). -}. +makeButton(row, "HOVER", { Hover(). }). +makeButton(row, "LAND", { Land(). }). -set x:AddButton("LAND"):onClick to { - Land(). -}. +set row to makeRow(top). -set x to y:AddHLayout(). +makeButton(row, "LNCH", { stk:ShowOnly(panes["launch"]). }). -set x:AddButton("LNCH"):onClick to { - stk:ShowOnly(launchmenu). -}. -set x:AddButton("NODE"):onClick to { +makeButton(row, "NODE", { set nodeDV:TEXT to NEXTNODE:DELTAV:MAG:ToString. set nodeBT:TEXT to BurnTime(NEXTNODE:DELTAV:MAG):ToString. - stk:ShowOnly(nodeMenu). -}. + stk:ShowOnly(panes["node"]). +}). -set x:AddButton("TWR"):onClick to { - stk:ShowOnly(twrMenu). -}. +makeButton(row, "TWR", { stk:ShowOnly(panes["twr"]). }). -local stk is interface:AddStack(). +local stk is iface:AddStack(). +local panes is Lex(). // Build launch menu -local launchMenu is stk:AddVLayout(). +local top is stk:AddVLayout(). +panes:Add("launch", top). -local launchConfig is launchMenu:AddScrollBox(). +local box is launchMenu:AddScrollBox(). -set sbox to launchConfig:AddHLayout(). -sbox:AddLabel("Target Apoapsis"). -local targetApo is sbox:AddTextField("80000"). +set row to makeRow(box). +row:AddLabel("Target Apoapsis"). +local targetApo is row:AddTextField("80000"). // todo: config params should go into a nested lexicon -set sbox to launchConfig:AddHLayout(). -sbox:AddLabel("Atmo TWR"). -local targetTWR is sbox:AddTextField("1.6"). +set row to makeRow(box). +row:AddLabel("Atmo TWR"). +local targetTWR is row:AddTextField("1.6"). -set sbox to launchConfig:AddHLayout(). -sbox:AddLabel("Initial Pitch"). -local initialPitch is sBox:AddTextField("85"). +set row to makeRow(box). +row:AddLabel("Initial Pitch"). +local initialPitch is row:AddTextField("85"). -set sbox to launchConfig:AddHLayout(). -sbox:AddLabel("Minimum Pitch"). -local minimumPitch is sbox:AddTextField("5"). +set row to makeRow(box). +row:AddLabel("Minimum Pitch"). +local minimumPitch is row:AddTextField("5"). -set sbox to launchConfig:AddHLayout(). -sbox:AddLabel("Gravity Turn Alt"). -local gravTurnStart is sbox:AddTextField("8000"). +set row to makeRow(box). +row:AddLabel("Gravity Turn Alt"). +local gravTurnStart is row:AddTextField("8000"). -set sbox to launchConfig:AddHLayout(). -sbox:AddLabel("Gravity Turn Pitch"). -local gravPitch is sbox:AddTextField("75"). - -set btn to launchMenu:AddButton("Execute"). -set btn:onClick to launchButtonPressed@. +set row to makeRow(box). +row:AddLabel("Gravity Turn Pitch"). +local gravPitch is row:AddTextField("75"). +set top:AddButton("Execute"):onClick to launchButtonPressed@. // End Launch Menu // Build conf menu -local confMenu is stk:AddVLayout(). +local top is stk:AddVLayout(). +panes:Add("conf", top). -local confBox is confMenu:AddScrollbox(). +set box to top:AddScrollbox(). -set sbox to confBox:AddHLayout(). -sbox:AddLabel("Torque Epsilon Max"). -local maxEpsilon is sbox:AddTextField("0.001"). +set row to makeRow(box). +row:AddLabel("Torque Epsilon Max"). +local maxEpsilon is row:AddTextField("0.001"). -set sbox to confBox:AddHLayout(). -sbox:AddLabel("Max Stopping Time"). -local maxStopTime is sbox:AddTextField("2.0"). +set row to makeRow(box). +row:AddLabel("Max Stopping Time"). +local maxStopTime is row:AddTextField("2.0"). -set btn to confMenu:AddButton("Apply"). -set btn:onClick to { +set top:AddButton("Apply"):onClick to { set STEERINGMANAGER:TORQUEEPSILONMAX to maxEpsilon:TEXT:ToNumber(). set STEERINGMANAGER:MAXSTOPPINGTIME to maxStopTime:TEXT:ToNumber(). }. - // end conf menu // twr menu -local twrMenu is stk:AddVLayout(). +local top is stk:AddVLayout(). +panes:Add("twr", top). -set sbox to twrMenu:AddHLayout(). -sbox:AddLabel("Target TWR"). -local twrLock is sbox:AddTextField("1.6"). +set row to makeRow(top). +row:AddLabel("Target TWR"). +local twrLock is row:AddTextField("1.6"). -set twrMenu:AddButton("Lock TWR"):onClick to { +set top:AddButton("Lock TWR"):onClick to { local done is false. on AG9 { set done to true. @@ -146,27 +137,25 @@ set twrMenu:AddButton("Lock TWR"):onClick to { wait until done. print "Throttle unlocked.". }. - // end twr menu // node menu -local nodeMenu is stk:AddVLayout(). -local nodeBox is nodeMenu:AddScrollBox(). +local top is stk:AddVLayout(). +panes:Add("node", top). +local box is nodeMenu:AddScrollBox(). -set sbox to nodeBox:AddHLayout(). -sbox:AddLabel("Node dV"). -local nodeDV is sbox:AddLabel(). +set row to makeRow(top). +row:AddLabel("Node dV"). +local nodeDV is row:AddLabel(). -set sbox to nodeBox:AddHLayout(). -sbox:AddLabel("Node Burn Time"). -local nodeBT is sbox:AddLabel(). +set row to makeRow(top). +row:AddLabel("Node Burn Time"). +local nodeBT is row:AddLabel(). -set nodeMenu:AddButton("Execute"):onClick to { +set top:AddButton("Execute"):onClick to { run "/execnode". }. - // end node menu -interface:show(). - +iface:show(). wait until false. diff --git a/lib/navigation.ks b/lib/navigation.ks index 9045e1f..eb0bc74 100644 --- a/lib/navigation.ks +++ b/lib/navigation.ks @@ -1,5 +1,4 @@ // functions for calculating steering values. -@lazyglobal off. function GetPitch { parameter v is SHIP:FACING:FOREVECTOR. diff --git a/lib/throttle.ks b/lib/throttle.ks index 4ad9c26..3ab0db7 100644 --- a/lib/throttle.ks +++ b/lib/throttle.ks @@ -1,7 +1,5 @@ // Functions for calculating values related to throttle and thrust. -@lazyglobal off. - // point gravity for TWR calculations. local G is 0. lock G to SHIP:BODY:MU / ((SHIP:BODY:RADIUS+SHIP:ALTITUDE)^2).