summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tileweb.cc
diff options
context:
space:
mode:
authorPekka Lampila <pekka.lampila@iki.fi>2013-12-06 06:08:12 +0200
committerPekka Lampila <pekka.lampila@iki.fi>2013-12-11 21:30:27 +0200
commit8c392e7901cca0e6e60b529b4e59208180df99aa (patch)
treea94f4ff529f477f6ecce46c1fcec1d5bf7e3f175 /crawl-ref/source/tileweb.cc
parent250cf21fd0d13af38329c5d6fdf7ee592de3c09f (diff)
downloadcrawl-ref-8c392e7901cca0e6e60b529b4e59208180df99aa.tar.gz
crawl-ref-8c392e7901cca0e6e60b529b4e59208180df99aa.zip
Send some rc file options to the WebTiles client
Player's options are always sent on the game start, by the process itself. They are also sent to any joining spectators. Spectators also receive their own config which is generated by running --print-webtiles-options. Also added a simple options module to JavaScript. Since all the options are received on game start the code can assume that the values are always there and have been validated by the server side code.
Diffstat (limited to 'crawl-ref/source/tileweb.cc')
-rw-r--r--crawl-ref/source/tileweb.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/crawl-ref/source/tileweb.cc b/crawl-ref/source/tileweb.cc
index ce2f222554..85ab9ed4d6 100644
--- a/crawl-ref/source/tileweb.cc
+++ b/crawl-ref/source/tileweb.cc
@@ -153,6 +153,7 @@ bool TilesFramework::initialise()
_await_connection();
_send_version();
+ _send_options();
m_cursor[CURSOR_MOUSE] = NO_CURSOR;
m_cursor[CURSOR_TUTORIAL] = NO_CURSOR;
@@ -164,6 +165,11 @@ bool TilesFramework::initialise()
return true;
}
+string TilesFramework::get_message()
+{
+ return m_msg_buf;
+}
+
void TilesFramework::write_message(const char *format, ...)
{
char buf[2048];
@@ -329,6 +335,8 @@ wint_t TilesFramework::_handle_control_message(sockaddr_un addr, string data)
}
else if (msgtype == "spectator_joined")
{
+ flush_messages();
+ _send_options();
_send_everything();
flush_messages();
}
@@ -449,6 +457,15 @@ void TilesFramework::_send_version()
send_message("{\"msg\":\"version\",\"text\":\"%s\"}", title.c_str());
}
+void TilesFramework::_send_options()
+{
+ json_open_object();
+ json_write_string("msg", "options");
+ Options.write_webtiles_options("options");
+ json_close_object();
+ finish_message();
+}
+
void TilesFramework::push_menu(Menu* m)
{
MenuInfo mi;