forked from akrasuski1/akrOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjob_vessel_stats.ks
120 lines (99 loc) · 2.68 KB
/
job_vessel_stats.ks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
@lazyglobal off.
run lib_navball. // for compass
// add to OS
parameter os_data.
register_program(os_data,"Vessel stats","run_vessel_stats",false).
function run_vessel_stats{
parameter
os_data,
window_index.
local process is list(
make_process_system_struct(
os_data,"update_vessel_stats",window_index,
"Vessel stats"
),
"ag9"
).
return process.
}
function draw_vessel_stats_status{
parameter process.
if not has_focus(process){
return 0.
}
local status is get_status_window(get_process_os_data(process)).
local x is status[0].
local y is status[1].
local w is status[2].
print "This window shows important vessel stats." at (x+2,y+2).
print "Press 9 to quit." at (x+w-17,y+3).
validate_process_status(process).
}
function draw_vessel_stats{
parameter process.
if not is_process_gui(process){
return 0.
}
local window is get_process_window(process).
local x is window[0].
local y is window[1].
print "Vessel stats:" at(x+2,y+2).
print "Latitude: " at(x+2,y+4).
print "Longitude: " at(x+2,y+5).
print "Compass: " at(x+2,y+6).
print "Mass: " at(x+2,y+7).
print "Name: " at(x+2,y+8).
print "Time: " at(x+2,y+9).
print "SAS: " at(x+2,y+10).
print "RCS: " at(x+2,y+11).
print "GEAR: " at(x+2,y+12).
print "LIGHTS: " at(x+2,y+13).
print "PANELS: " at(x+2,y+14).
}
function bool_to_on_off{
parameter bool.
if bool{
return "ON".
}
else{
return "OFF".
}
}
function update_vessel_stats{
parameter process.
if process_needs_redraw(process){
draw_vessel_stats(process).
}
if process_status_needs_redraw(process){
draw_vessel_stats_status(process).
}
if not is_process_gui(process){
return 0. // no point of drawing stuff if I'm backgrounded
}
// input:
local old_ag9 is process[1].
set process[1] to ag9.
local changed_ag9 is old_ag9<>process[1].
if old_ag9="ag9" or not has_focus(process){
set changed_ag9 to false.
}
if changed_ag9{
kill_process(process).
return 0.
}
local wnd is get_process_window(process).
local x is wnd[0].
local y is wnd[1].
print "FOCUS: "+has_focus(process)+" " at(wnd[0]+2,wnd[1]+16).
print round(ship:geoposition:lat,5) at(x+12,y+4).
print round(ship:geoposition:lng,5) at(x+13,y+5).
print round(compass_for(ship),5) at(x+11,y+6).
print round(ship:mass,5) at(x+8, y+7).
print ship:name at(x+8, y+8).
print time:clock at(x+8, y+9).
print bool_to_on_off(sas) at(x+7, y+10).
print bool_to_on_off(rcs) at(x+7, y+11).
print bool_to_on_off(gear) at(x+8, y+12).
print bool_to_on_off(lights) at(x+10,y+13).
print bool_to_on_off(panels) at(x+10,y+14).
}