Revert "Initial check-in of MP groups function"
This reverts commit e9113980449fe50eb186a3b2e26bc88dc613d841.
This commit is contained in:
parent
36cb5227e1
commit
bb9e21f6e6
4 changed files with 13 additions and 143 deletions
|
@ -7,24 +7,19 @@
|
||||||
# 2) Display a complete history of chat via dialog.
|
# 2) Display a complete history of chat via dialog.
|
||||||
#
|
#
|
||||||
# 3) Allow chat messages to be written by the user.
|
# 3) Allow chat messages to be written by the user.
|
||||||
#
|
|
||||||
# 4) Pilot list dialog, including ability to hide aircraft
|
|
||||||
|
|
||||||
var is_active = func getprop("/sim/multiplay/txport") or getprop("/sim/multiplay/rxport");
|
var is_active = func getprop("/sim/multiplay/txport") or getprop("/sim/multiplay/rxport");
|
||||||
|
|
||||||
# Hashes of last message and aircraft visibility.
|
|
||||||
var lastmsg = {};
|
|
||||||
var visibility = {};
|
|
||||||
|
|
||||||
# Constants for the visibility hash
|
var lastmsg = {};
|
||||||
var HIDDEN = 0;
|
var ignore = {};
|
||||||
var VISIBLE = 1;
|
|
||||||
|
|
||||||
var check_messages = func {
|
var check_messages = func {
|
||||||
foreach (var mp; values(model.callsign)) {
|
foreach (var mp; values(model.callsign)) {
|
||||||
var msg = mp.node.getNode("sim/multiplay/chat", 1).getValue();
|
var msg = mp.node.getNode("sim/multiplay/chat", 1).getValue();
|
||||||
if (msg and msg != lastmsg[mp.callsign]) {
|
if (msg and msg != lastmsg[mp.callsign]) {
|
||||||
if (visibility[mp.callsign] == VISIBLE)
|
if (!contains(ignore, mp.callsign))
|
||||||
echo_message(mp.callsign, msg);
|
echo_message(mp.callsign, msg);
|
||||||
lastmsg[mp.callsign] = msg;
|
lastmsg[mp.callsign] = msg;
|
||||||
}
|
}
|
||||||
|
@ -154,80 +149,6 @@ var handle_key = func(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Determine the visibility of an MP aircraft
|
|
||||||
# based on previous ignore/show settings and the
|
|
||||||
# class of the aircraft
|
|
||||||
determineVisibility = func(callsign, ai_node) {
|
|
||||||
|
|
||||||
if (! contains(visibility, callsign)) {
|
|
||||||
# Not previously seen. Look at class
|
|
||||||
|
|
||||||
var class = ai_node.getNode("sim/multiplay/usage-class-hash", 1).getValue();
|
|
||||||
|
|
||||||
if ((class == nil) or (class == "")) {
|
|
||||||
# Default to "Default"
|
|
||||||
class = string.hash("Default");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
foreach (var n; props.globals.getNode("/sim/multiplay/display").getChildren("usage-class")) {
|
|
||||||
var h = n.getNode("hash", 1);
|
|
||||||
var visible = n.getNode("visible", 1).getBoolValue();
|
|
||||||
|
|
||||||
if ((h == nil) or (h.getValue() == nil) or (h.getValue() == 0)) {
|
|
||||||
# No hash found, generate one.
|
|
||||||
var name = n.getNode("name", 1).getValue();
|
|
||||||
h.setValue(string.hash(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (h.getValue() == class) {
|
|
||||||
# Class found. Determine whether visible or not
|
|
||||||
if (visible) {
|
|
||||||
ai_node.getNode("controls/invisible", 1).setValue(0);
|
|
||||||
visibility[callsign] = VISIBLE;
|
|
||||||
} else {
|
|
||||||
ai_node.getNode("controls/invisible", 1).setValue(1);
|
|
||||||
visibility[callsign] = HIDDEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
found_usage = 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found_usage) {
|
|
||||||
# If we don't recognize the class, don't display.
|
|
||||||
ai_node.getNode("controls/invisible", 1).setValue(1);
|
|
||||||
visibility[callsign] = HIDDEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (visibility[callsign] == HIDDEN) {
|
|
||||||
# Previously seen and set to invisible.
|
|
||||||
ai_node.getNode("controls/invisible", 1).setValue(1);
|
|
||||||
} else if (visibility[callsign] == VISIBLE) {
|
|
||||||
# Previously seen and shown
|
|
||||||
ai_node.getNode("controls/invisible", 1).setValue(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check all aircraft visibility based on class. To be used when
|
|
||||||
# the set of visible classes change.
|
|
||||||
resetVisibility = func() {
|
|
||||||
|
|
||||||
visibility = {};
|
|
||||||
|
|
||||||
foreach (var n; props.globals.getNode("ai/models", 1).getChildren("multiplayer")) {
|
|
||||||
if (!n.getNode("valid").getValue())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((var callsign = n.getNode("callsign")) == nil or !(callsign = callsign.getValue()))
|
|
||||||
continue;
|
|
||||||
if (!(callsign = string.trim(callsign)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
determineVisibility(callsign, n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# multiplayer.dialog.show() -- displays pilot list dialog
|
# multiplayer.dialog.show() -- displays pilot list dialog
|
||||||
|
@ -364,7 +285,7 @@ var dialog = {
|
||||||
"distance-to-km": distance / 1000.0,
|
"distance-to-km": distance / 1000.0,
|
||||||
"distance-to-nm": distance * M2NM,
|
"distance-to-nm": distance * M2NM,
|
||||||
"position/altitude-m": n.getNode("position/altitude-ft").getValue() * FT2M,
|
"position/altitude-m": n.getNode("position/altitude-ft").getValue() * FT2M,
|
||||||
"controls/invisible": (visibility[mp.callsign] == HIDDEN),
|
"controls/invisible": contains(ignore, mp.callsign),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (PILOTSDLG_RUNNING)
|
if (PILOTSDLG_RUNNING)
|
||||||
|
@ -393,10 +314,10 @@ var dialog = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggle_ignore: func (callsign) {
|
toggle_ignore: func (callsign) {
|
||||||
if (visibility[callsign] == VISIBLE) {
|
if (contains(ignore, callsign)) {
|
||||||
visibility[callsign] = HIDDEN;
|
delete(ignore, callsign);
|
||||||
} else {
|
} else {
|
||||||
visibility[callsign] = VISIBLE;
|
ignore[callsign] = 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
close: func {
|
close: func {
|
||||||
|
@ -503,9 +424,6 @@ var model = {
|
||||||
var data = { node: n, callsign: callsign, model: model, root: root,
|
var data = { node: n, callsign: callsign, model: model, root: root,
|
||||||
sort: string.lc(callsign), available: available };
|
sort: string.lc(callsign), available: available };
|
||||||
|
|
||||||
# Control visibility
|
|
||||||
determineVisibility(callsign, n);
|
|
||||||
|
|
||||||
me.data[root] = data;
|
me.data[root] = data;
|
||||||
me.callsign[callsign] = data;
|
me.callsign[callsign] = data;
|
||||||
append(available ? me.available : me.unavailable, data);
|
append(available ? me.available : me.unavailable, data);
|
||||||
|
|
|
@ -75,18 +75,7 @@ var uc = func(str) {
|
||||||
var icmp = func(a, b) cmp(lc(a), lc(b));
|
var icmp = func(a, b) cmp(lc(a), lc(b));
|
||||||
var imatch = func(a, b) match(lc(a), lc(b));
|
var imatch = func(a, b) match(lc(a), lc(b));
|
||||||
|
|
||||||
##
|
|
||||||
# Very simple hash function
|
|
||||||
#
|
|
||||||
var hash = func(str) {
|
|
||||||
var hash_val = 0;
|
|
||||||
if (str != nil) {
|
|
||||||
for (var i = 0; i < size(str); i += 1) {
|
|
||||||
hash_val += math.mod(str[i], 2*(i+1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return int(hash_val);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -248,7 +248,7 @@
|
||||||
<script>setprop("/autopilot/route-manager/input", "@previous")</script>
|
<script>setprop("/autopilot/route-manager/input", "@previous")</script>
|
||||||
</binding>
|
</binding>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<label>Next Waypoint</label>
|
<label>Next Waypoint</label>
|
||||||
<binding>
|
<binding>
|
||||||
|
@ -267,7 +267,7 @@
|
||||||
</script>
|
</script>
|
||||||
</binding>
|
</binding>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<label>Map</label>
|
<label>Map</label>
|
||||||
<binding>
|
<binding>
|
||||||
|
@ -335,7 +335,7 @@
|
||||||
<dialog-name>local_weather</dialog-name>
|
<dialog-name>local_weather</dialog-name>
|
||||||
</binding>
|
</binding>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<label>Local Weather Tiles</label>
|
<label>Local Weather Tiles</label>
|
||||||
<binding>
|
<binding>
|
||||||
|
@ -442,7 +442,6 @@
|
||||||
</binding>
|
</binding>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<label>Scenario</label>
|
<label>Scenario</label>
|
||||||
<binding>
|
<binding>
|
||||||
|
@ -480,15 +479,6 @@
|
||||||
</binding>
|
</binding>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
|
||||||
<label>Usage Class</label>
|
|
||||||
<binding>
|
|
||||||
<command>dialog-show</command>
|
|
||||||
<dialog-name>mp-display</dialog-name>
|
|
||||||
</binding>
|
|
||||||
</item>
|
|
||||||
|
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<label>MPCarrier selection</label>
|
<label>MPCarrier selection</label>
|
||||||
<binding>
|
<binding>
|
||||||
|
|
|
@ -601,33 +601,6 @@ Started September 2000 by David Megginson, david@megginson.com
|
||||||
<chat-menu include="ATC/chat-menu-entries.xml"/>
|
<chat-menu include="ATC/chat-menu-entries.xml"/>
|
||||||
<write-message-log type="bool">false</write-message-log>
|
<write-message-log type="bool">false</write-message-log>
|
||||||
<default-model type="string">Models/Geometry/glider.ac</default-model>
|
<default-model type="string">Models/Geometry/glider.ac</default-model>
|
||||||
<usage-class type="string">Default</usage-class>
|
|
||||||
<display>
|
|
||||||
<usage-class>
|
|
||||||
<name type="string">Default</name>
|
|
||||||
<visible type="bool">true</visible>
|
|
||||||
</usage-class>
|
|
||||||
<usage-class>
|
|
||||||
<name type="string">Newbie</name>
|
|
||||||
<visible type="bool">true</visible>
|
|
||||||
</usage-class>
|
|
||||||
<usage-class>
|
|
||||||
<name type="string">Student</name>
|
|
||||||
<visible type="bool">true</visible>
|
|
||||||
</usage-class>
|
|
||||||
<usage-class>
|
|
||||||
<name type="string">FGCom</name>
|
|
||||||
<visible type="bool">true</visible>
|
|
||||||
</usage-class>
|
|
||||||
<usage-class>
|
|
||||||
<name type="string">Dogfight</name>
|
|
||||||
<visible type="bool">false</visible>
|
|
||||||
</usage-class>
|
|
||||||
<usage-class>
|
|
||||||
<name type="string">Ignore</name>
|
|
||||||
<visible type="bool">false</visible>
|
|
||||||
</usage-class>
|
|
||||||
</display>
|
|
||||||
</multiplay>
|
</multiplay>
|
||||||
|
|
||||||
<user>
|
<user>
|
||||||
|
@ -710,7 +683,7 @@ Started September 2000 by David Megginson, david@megginson.com
|
||||||
<scenario>
|
<scenario>
|
||||||
<name>Marginal VFR</name>
|
<name>Marginal VFR</name>
|
||||||
<metar>XXXX 012345Z 23010KT 5000 SHRA SCT012 BKN018 OVC060 15/11 Q1010</metar>
|
<metar>XXXX 012345Z 23010KT 5000 SHRA SCT012 BKN018 OVC060 15/11 Q1010</metar>
|
||||||
<description>After the storm - limited visibility and some showers.
|
<description>After the storm - limited visibility and some showers.
|
||||||
Go or No-Go?</description>
|
Go or No-Go?</description>
|
||||||
</scenario>
|
</scenario>
|
||||||
<scenario>
|
<scenario>
|
||||||
|
|
Loading…
Add table
Reference in a new issue