1
0
Fork 0

Modified Files:

preferences.xml gui/menubar.xml gui/dialogs/rendering.xml
Added Files:
	Nasal/multiplayer.nas gui/dialogs/chat.xml
	gui/dialogs/chat_full.xml:
	the data part of Stuarts multiplayer/chat patch
This commit is contained in:
frohlich 2006-10-10 05:23:38 +00:00
parent 73878fc6b2
commit 9c52cbf4ac
6 changed files with 277 additions and 0 deletions

85
Nasal/multiplayer.nas Normal file
View file

@ -0,0 +1,85 @@
# Multiplayer Chat
# ================
#
# 1) Display chat messages from other aircraft to
# the screen using screen.nas
#
# 2) Display a complete history of chat via dialog.
#
# 3) Allow chat messages to be written by the user.
var messages = {};
check_messages = func
{
var mp = props.globals.getNode("/ai/models").getChildren("multiplayer");
foreach (i; mp)
{
var lmsg = getprop(i.getPath() ~ "/sim/multiplay/chat");
var lcallsign = getprop(i.getPath() ~ "/callsign");
if ((lmsg != nil) and (lmsg != "") and (lcallsign != nil) and (lcallsign != ""))
{
#print("Call Sign: " ~ lcallsign);
#print("lmsg: " ~ lmsg);
#print("Freq: " ~ ltransmitfreq);
if ((! contains(messages, lcallsign)) or (lmsg != messages[lcallsign]))
{
# Indicate we've seen this message.
messages[lcallsign] = lmsg;
echo_message(lmsg, lcallsign);
}
}
}
# Check for new messages every couple of seconds.
settimer(check_messages, 3);
}
echo_message = func(msg, callsign)
{
if (callsign != nil)
{
msg = callsign ~ ": " ~ msg;
}
var ldisplay = getprop("/sim/multiplay/chat_display");
if ((ldisplay != nil) and (ldisplay == "1"))
{
# Only display the message to screen if configured.
setprop("/sim/messages/ai-plane", msg);
}
# Add the chat to the chat history.
var lchat = getprop("/sim/multiplay/chat_history");
if (lchat == nil)
{
setprop("/sim/multiplay/chat_history", msg);
}
else
{
if (substr(lchat, size(lchat) -1, 1) != "\n")
{
lchat = lchat ~ "\n";
}
setprop("/sim/multiplay/chat_history", lchat ~ msg);
}
}
settimer(func {
# Call-back to ensure we see our own messages.
setlistener("/sim/multiplay/chat", func{ echo_message(cmdarg().getValue(), getprop("/sim/multiplay/callsign")); });
# check for new messages
check_messages();
}, 1);

71
gui/dialogs/chat.xml Normal file
View file

@ -0,0 +1,71 @@
<?xml version="1.0"?>
<PropertyList>
<name>chat</name>
<modal>false</modal>
<layout>vbox</layout>
<group>
<layout>hbox</layout>
<input>
<name>compose</name>
<pref-width>500</pref-width>
<stretch>true</stretch>
<halign>fill</halign>
<length>50</length>
<property>/sim/multiplay/chat_compose</property>
</input>
<button>
<legend>Send</legend>
<default>true</default>
<key>Enter</key>
<binding>
<command>dialog-apply</command>
</binding>
<binding>
<command>nasal</command>
<script>
var lchat = getprop("/sim/multiplay/chat_compose");
if (lchat != "")
{
setprop("/sim/multiplay/chat", lchat);
setprop("/sim/multiplay/chat_compose", "");
fgcommand("dialog-update", props.Node.new({"object-name": "compose",
"dialog-name": "chat"}));
}
</script>
</binding>
</button>
</group>
<group>
<layout>hbox</layout>
<empty><stretch>true</stretch></empty>
<button>
<legend>Close</legend>
<default>true</default>
<key>Esc</key>
<binding>
<command>dialog-close</command>
</binding>
</button>
<button>
<legend>More v</legend>
<default>false</default>
<binding>
<command>dialog-show</command>
<dialog-name>chat_full</dialog-name>
</binding>
<binding>
<command>dialog-close</command>
</binding>
</button>
<empty><stretch>true</stretch></empty>
</group>
</PropertyList>

98
gui/dialogs/chat_full.xml Normal file
View file

@ -0,0 +1,98 @@
<?xml version="1.0"?>
<PropertyList>
<name>chat_full</name>
<modal>false</modal>
<layout>vbox</layout>
<text>
<label>Multiplayer Chat</label>
</text>
<hrule><dummy/></hrule>
<textbox>
<halign>fill</halign>
<pref-width>550</pref-width>
<pref-height>120</pref-height>
<slider>20</slider>
<live>true</live>
<wrap>true</wrap>
<editable>false</editable>
<property>/sim/multiplay/chat_history</property>
</textbox>
<text>
<label></label>
</text>
<group>
<layout>hbox</layout>
<input>
<name>compose</name>
<stretch>true</stretch>
<halign>fill</halign>
<length>50</length>
<pref-width>500</pref-width>
<property>/sim/multiplay/chat_compose</property>
</input>
<button>
<legend>Send</legend>
<default>true</default>
<key>Enter</key>
<binding>
<command>dialog-apply</command>
</binding>
<binding>
<command>nasal</command>
<script>
var lchat = getprop("/sim/multiplay/chat_compose");
if (lchat != "")
{
setprop("/sim/multiplay/chat", lchat);
setprop("/sim/multiplay/chat_compose", "");
fgcommand("dialog-update", props.Node.new({"object-name": "compose",
"dialog-name": "chat_full"}));
}
</script>
</binding>
</button>
</group>
<text>
<label></label>
</text>
<group>
<layout>hbox</layout>
<empty><stretch>true</stretch></empty>
<button>
<legend>Close</legend>
<default>true</default>
<key>Esc</key>
<binding>
<command>dialog-close</command>
</binding>
</button>
<button>
<legend>Less ^</legend>
<default>false</default>
<binding>
<command>dialog-show</command>
<dialog-name>chat</dialog-name>
</binding>
<binding>
<command>dialog-close</command>
</binding>
</button>
<empty><stretch>true</stretch></empty>
</group>
</PropertyList>

View file

@ -24,6 +24,15 @@
</binding>
</checkbox>
<checkbox>
<halign>left</halign>
<label>Show chat messages</label>
<property>/sim/multiplay/chat_display</property>
<binding>
<command>dialog-apply</command>
</binding>
</checkbox>
<checkbox>
<halign>left</halign>
<label>Sun/Moon horizon effect</label>

View file

@ -152,6 +152,15 @@
</binding>
</item>
<item>
<label>Chat</label>
<binding>
<command>dialog-show</command>
<dialog-name>chat</dialog-name>
</binding>
</item>
</menu>
<menu>

View file

@ -12,6 +12,11 @@ Started September 2000 by David Megginson, david@megginson.com
<!-- General simulation preferences -->
<sim>
<!-- Multiplayer chat requires that these properties be defined -->
<multiplay>
<chat type="string">Hello</chat>
<transmission-freq-hz type="string">118500000</transmission-freq-hz>
</multiplay>
<!-- hide some development tools, such as parts of the HUD adjustment dialog -->
<devel type="bool">false</devel>