Add the ability to display chat messages when joining the lobby and quickly mostly update the options window to the new UI style.

This was SVN commit r14679.
This commit is contained in:
JoshuaJB 2014-01-26 05:39:55 +00:00
parent a8fbe4eedc
commit 39fef5c299
10 changed files with 64 additions and 35 deletions

View File

@ -360,3 +360,4 @@ lobby.server = "lobby.wildfiregames.com" ; Address of lobby server
lobby.xpartamupp = "wfgbot16" ; Name of the server-side xmpp client that manage games
lobby.chattimestamp = false ; Show time chat message was posted
lobby.room = "arena16" ; Default MUC room to join
lobby.history = 0 ; Number of past messages to display on join

View File

@ -30,13 +30,14 @@ function lobbyStart()
var password = Engine.GetGUIObjectByName("connectPassword").caption;
var feedback = Engine.GetGUIObjectByName("feedback");
var room = Engine.ConfigDB_GetValue("user", "lobby.room");
var history = Number(Engine.ConfigDB_GetValue("user", "lobby.history"));
feedback.caption = "Connecting....";
// If they enter a different password, re-encrypt.
if (password != g_EncrytedPassword.substring(0, 10))
g_EncrytedPassword = Engine.EncryptPassword(password, username);
// We just use username as nick for simplicity.
Engine.StartXmppClient(username, g_EncrytedPassword, room, username);
Engine.StartXmppClient(username, g_EncrytedPassword, room, username, history);
g_LobbyIsConnecting = true;
Engine.ConnectXmppClient();
}

View File

@ -7,58 +7,73 @@
-->
<objects>
<script file="gui/common/functions_civinfo.js"/>
<script file="gui/options/options.js"/>
<script file="gui/common/functions_civinfo.js"/>
<script file="gui/options/options.js"/>
<!-- Add a translucent black background to fade out the menu page -->
<object type="image" z="0" style="TranslucentPanel"/>
<object type="image" z="0" style="TranslucentPanel"/>
<!-- Settings Window -->
<object name="options" type="image" style="StoneDialog" size="50%-466 50%-316 50%+466 50%+316">
<object name="options" type="image" style="ModernDialog" size="50%-466 50%-316 50%+466 50%+316">
<object style="TitleText" type="text" size="50%-128 0%-16 50%+128 16">Game Options</object>
<object name="SystemSettings" type="image" sprite="BackgroundIndentFillDark" size="16 16 316 100%-16">
<object name="SystemSettings" type="image" sprite="ModernDarkBoxGold" size="16 16 316 100%-16">
<object style="TitleText" type="text" size="0 5 100% 25">System Settings</object>
<object size="0 25 65% 50" type="text" style="RightLabelText" ghost="true">Windowed Mode</object>
<object name="WindowedCFGLate" size="70% 30 70%+25 55" type="checkbox" style="StoneCrossBox">
<object size="0 25 65% 50" type="text" style="ModernLabelText" text_align="right">Windowed Mode</object>
<object name="WindowedCFGLate" size="70% 30 70%+25 55" type="checkbox" style="ModernTickBox">
<action on="Load">Engine.ConfigDB_GetValue("user", "windowed") === "true" ? this.checked = true : this.checked = false;</action>
<action on="Press">Engine.ConfigDB_CreateValue("user", "windowed", String(this.checked));</action>
</object>
<object size="0 50 65% 75" type="text" style="RightLabelText" ghost="true">Background Pause</object>
<object name="PauseCFGNow" size="70% 55 70%+25 80" type="checkbox" style="StoneCrossBox">
<object size="0 50 65% 75" type="text" style="ModernLabelText" text_align="right">Background Pause</object>
<object name="PauseCFGNow" size="70% 55 70%+25 80" type="checkbox" style="ModernTickBox">
<action on="Load">Engine.ConfigDB_GetValue("user", "pauseonfocusloss") === "true" ? this.checked = true : this.checked = false;</action>
<action on="Press">Engine.ConfigDB_CreateValue("user", "pauseonfocusloss", String(this.checked));</action>
</object>
</object>
<object name="GraphicsSettings" type="image" sprite="BackgroundIndentFillDark" size="316 16 616 100%-16">
<object name="GraphicsSettings" type="image" sprite="ModernDarkBoxGold" size="316 16 616 100%-16">
<object style="TitleText" type="text" size="0 5 100% 25">Graphics Settings</object>
<object size="0 25 65% 50" type="text" style="RightLabelText" ghost="true">Enable Shadows</object>
<object name="ShadowsCFG" size="70% 30 70%+25 55" type="checkbox" style="StoneCrossBox">
<object size="0 25 65% 50" type="text" style="ModernLabelText" text_align="right">Enable Shadows</object>
<object name="ShadowsCFG" size="70% 30 70%+25 55" type="checkbox" style="ModernTickBox">
<action on="Load">this.checked = Engine.Renderer_GetShadowsEnabled();</action>
<action on="Press">Engine.Renderer_SetShadowsEnabled(this.checked);</action>
</object>
<object size="0 50 65% 75" type="text" style="RightLabelText" ghost="true">Enable Shadow Filtering</object>
<object name="ShadowPCFCFGNow" size="70% 55 70%+25 80" type="checkbox" style="StoneCrossBox">
<object size="0 50 65% 75" type="text" style="ModernLabelText" text_align="right">Enable Shadow Filtering</object>
<object name="ShadowPCFCFGNow" size="70% 55 70%+25 80" type="checkbox" style="ModernTickBox">
<action on="Load">this.checked = Engine.Renderer_GetShadowPCFEnabled();</action>
<action on="Press">Engine.Renderer_SetShadowPCFEnabled(this.checked);</action>
</object>
</object>
<object name="SoundSettings" type="image" sprite="BackgroundIndentFillDark" size="616 16 916 100%-16">
<object name="SoundSettings" type="image" sprite="ModernDarkBoxGold" size="616 16 916 50%">
<object style="TitleText" type="text" size="0 5 100% 25">Sound Settings</object>
<object size="0 25 65% 50" type="text" style="RightLabelText" ghost="true">Master Gain</object>
<object name="SMasterCFG" size="70% 25 70%+35 50" type="input" style="StoneInput">
<object size="0 25 65% 50" type="text" style="ModernLabelText" text_align="right">Master Gain</object>
<object name="SMasterCFG" size="70% 25 70%+35 50" type="input" style="ModernInput">
<action on="Load">this.caption = Engine.ConfigDB_GetValue("user", "sound.mastergain");</action>
</object>
<object size="70%+35 25 70%+75 50" type="button" style="StoneButton">Save
<object size="70%+40 25 70%+85 50" type="button" style="StoneButton">Save
<action on="Press">Engine.ConfigDB_CreateValue("user", "sound.mastergain", String(Engine.GetGUIObjectByName("SMasterCFG").caption));</action>
</object>
<object size="0 50 65% 75" type="text" style="RightLabelText" ghost="true">Music Gain</object>
<object name="SMusicCFG" size="70% 50 70%+35 75" type="input" style="StoneInput">
<object size="0 50 65% 75" type="text" style="ModernLabelText" text_align="right">Music Gain</object>
<object name="SMusicCFG" size="70% 50 70%+35 75" type="input" style="ModernInput">
<action on="Load">this.caption = Engine.ConfigDB_GetValue("user", "sound.musicgain");</action>
</object>
<object size="70%+35 50 70%+75 75" type="button" style="StoneButton">Save
<object size="70%+40 25 70%+85 50" type="button" style="StoneButton">Save
<action on="Press">Engine.ConfigDB_CreateValue("user", "sound.musicgain", String(Engine.GetGUIObjectByName("SMusicCFG").caption));</action>
</object>
</object>
<object name="LobbySettings" type="image" sprite="ModernDarkBoxGold" size="616 50% 916 100%-16">
<object style="TitleText" type="text" size="0 5 100% 25">Lobby Settings</object>
<object size="0 25 65% 50" type="text" style="ModernLabelText" text_align="right">Amount of Chat History</object>
<object name="LHistoryCFG" size="70% 25 70%+35 50" type="input" style="ModernInput">
<action on="Load">this.caption = Engine.ConfigDB_GetValue("user", "lobby.history");</action>
</object>
<object size="70%+40 25 70%+85 50" type="button" style="StoneButton">Save
<action on="Press">Engine.ConfigDB_CreateValue("user", "lobby.history", String(Engine.GetGUIObjectByName("LHistoryCFG").caption));</action>
</object>
<object size="0 50 65% 75" type="text" style="ModernLabelText" text_align="right">Show Chat Timestamp</object>
<object name="LChatTSCFG" size="70% 55 70%+25 80" type="checkbox" style="ModernTickBox">
<action on="Load">this.checked = Engine.ConfigDB_GetValue("user", "lobby.showchattimestamp");</action>
<action on="Press">Engine.ConfigDB_CreateValue("user", "lobby.showchattimestamp", String(Engine.GetGUIObjectByName("LChatTSCFG").checked));</action>
</object>
</object>
<!--
Settings / shadows
<object size="0 10 100%-80 35" type="text" style="RightLabelText" ghost="true">Enable Shadows</object>

View File

@ -8,5 +8,10 @@
<include>common/global.xml</include>
<include>common/common_sprites.xml</include>
<include>common/common_styles.xml</include>
<include>common/modern/styles.xml</include>
<include>common/modern/setup.xml</include>
<include>common/modern/sprites.xml</include>
<include>options/options.xml</include>
</page>

View File

@ -889,7 +889,7 @@ void GuiScriptingInit(ScriptInterface& scriptInterface)
// Lobby functions
scriptInterface.RegisterFunction<bool, &JSI_Lobby::HasXmppClient>("HasXmppClient");
#if CONFIG2_LOBBY // Allow the lobby to be disabled
scriptInterface.RegisterFunction<void, std::wstring, std::wstring, std::wstring, std::wstring, &JSI_Lobby::StartXmppClient>("StartXmppClient");
scriptInterface.RegisterFunction<void, std::wstring, std::wstring, std::wstring, std::wstring, int, &JSI_Lobby::StartXmppClient>("StartXmppClient");
scriptInterface.RegisterFunction<void, std::wstring, std::wstring, &JSI_Lobby::StartRegisterXmppClient>("StartRegisterXmppClient");
scriptInterface.RegisterFunction<void, &JSI_Lobby::StopXmppClient>("StopXmppClient");
scriptInterface.RegisterFunction<void, &JSI_Lobby::ConnectXmppClient>("ConnectXmppClient");

View File

@ -25,7 +25,7 @@ class CScriptValRooted;
class IXmppClient
{
public:
static IXmppClient* create(const std::string& sUsername, const std::string& sPassword, const std::string& sRoom, const std::string& sNick, bool regOpt = false);
static IXmppClient* create(const std::string& sUsername, const std::string& sPassword, const std::string& sRoom, const std::string& sNick, const int historyRequestSize = 0, bool regOpt = false);
virtual ~IXmppClient() {}
virtual void connect() = 0;

View File

@ -60,15 +60,22 @@ static std::string tag_name(const glooxwrapper::IQ& iq)
return ret;
}
IXmppClient* IXmppClient::create(const std::string& sUsername, const std::string& sPassword, const std::string& sRoom, const std::string& sNick, bool regOpt)
IXmppClient* IXmppClient::create(const std::string& sUsername, const std::string& sPassword, const std::string& sRoom, const std::string& sNick, const int historyRequestSize,bool regOpt)
{
return new XmppClient(sUsername, sPassword, sRoom, sNick, regOpt);
return new XmppClient(sUsername, sPassword, sRoom, sNick, historyRequestSize, regOpt);
}
/**
* Construct the xmpp client
* Construct the XMPP client.
*
* @param sUsername Username to login with of register.
* @param sPassword Password to login with or register.
* @param sRoom MUC room to join.
* @param sNick Nick to join with.
* @param historyRequestSize Number of stanzas of room history to request.
* @param regOpt If we are just registering or not.
*/
XmppClient::XmppClient(const std::string& sUsername, const std::string& sPassword, const std::string& sRoom, const std::string& sNick, bool regOpt)
XmppClient::XmppClient(const std::string& sUsername, const std::string& sPassword, const std::string& sRoom, const std::string& sNick, const int historyRequestSize, bool regOpt)
: m_client(NULL), m_mucRoom(NULL), m_registration(NULL), m_username(sUsername), m_password(sPassword), m_nick(sNick)
{
// Read lobby configuration from default.cfg
@ -118,8 +125,8 @@ XmppClient::XmppClient(const std::string& sUsername, const std::string& sPasswor
{
// Create a Multi User Chat Room
m_mucRoom = new glooxwrapper::MUCRoom(m_client, roomJid, this, 0);
// Disable the history because its anoying
m_mucRoom->setRequestHistory(0, gloox::MUCRoom::HistoryMaxStanzas);
// Get room history.
m_mucRoom->setRequestHistory(historyRequestSize, gloox::MUCRoom::HistoryMaxStanzas);
}
else
{

View File

@ -51,7 +51,7 @@ private:
public:
//Basic
XmppClient(const std::string& sUsername, const std::string& sPassword, const std::string& sRoom, const std::string& sNick, bool regOpt = false);
XmppClient(const std::string& sUsername, const std::string& sPassword, const std::string& sRoom, const std::string& sNick, const int historyRequestSize = 0, const bool regOpt = false);
virtual ~XmppClient();
//Network

View File

@ -34,12 +34,12 @@ bool JSI_Lobby::HasXmppClient(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
#if CONFIG2_LOBBY
void JSI_Lobby::StartXmppClient(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), std::wstring username, std::wstring password, std::wstring room, std::wstring nick)
void JSI_Lobby::StartXmppClient(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), std::wstring username, std::wstring password, std::wstring room, std::wstring nick, int historyRequestSize)
{
ENSURE(!g_XmppClient);
g_XmppClient = IXmppClient::create(utf8_from_wstring(username), utf8_from_wstring(password),
utf8_from_wstring(room), utf8_from_wstring(nick));
utf8_from_wstring(room), utf8_from_wstring(nick), historyRequestSize);
g_rankedGame = true;
}

View File

@ -27,7 +27,7 @@ namespace JSI_Lobby
bool HasXmppClient(ScriptInterface::CxPrivate* pCxPrivate);
#if CONFIG2_LOBBY
void StartXmppClient(ScriptInterface::CxPrivate* pCxPrivate, std::wstring username, std::wstring password, std::wstring room, std::wstring nick);
void StartXmppClient(ScriptInterface::CxPrivate* pCxPrivate, std::wstring username, std::wstring password, std::wstring room, std::wstring nick, int historyRequestSize);
void StartRegisterXmppClient(ScriptInterface::CxPrivate* pCxPrivate, std::wstring username, std::wstring password);
void StopXmppClient(ScriptInterface::CxPrivate* pCxPrivate);
void ConnectXmppClient(ScriptInterface::CxPrivate* pCxPrivate);