This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 21846 for ps


Ignore:
Timestamp:
06/08/18 15:39:52 (7 years ago)
Author:
elexis
Message:

Lobby register/login dialog cleanup.

Move JS code from XML files to JS files.
Move all terms data to one JS object.
Unify duplicate Terms dialog opening code.
Update the checkbox enabled property only upon dialog close, not onTick.

Location:
ps/trunk/binaries/data/mods/public/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/data/mods/public/gui/manual/manual.xml

    r21804 r21846  
    2020        <object type="button" style="ModernButtonRed" tooltip_style="snToolTip" size="100%-408 100%-52 100%-218 100%-24" hotkey="cancel">
    2121            <translatableAttribute id="caption">Close</translatableAttribute>
    22             <action on="Press"><![CDATA[closeManual();]]></action>
     22            <action on="Press">closeManual();</action>
    2323        </object>
    2424        <object name="url" type="button" style="ModernButtonRed" size="100%-214 100%-52 100%-24 100%-24" hidden="true">
  • ps/trunk/binaries/data/mods/public/gui/prelobby/prelobby.js

    r21311 r21846  
    22var g_EncryptedPassword = "";
    33var g_PasswordInputIsHidden = false;
    4 var g_TermsOfServiceRead = false;
    5 var g_TermsOfUseRead = false;
    64var g_DisplayingSystemMessage = false;
    75
     6var g_Terms = {
     7    "Service": {
     8        "title": translate("Terms of Service"),
     9        "instruction": translate("Please read the Terms of Service"),
     10        "file": "prelobby/Terms_of_Service",
     11        "read": false
     12    },
     13    "Use": {
     14        "title": translate("Terms of Use"),
     15        "instruction": translate("Please read the Terms of Use"),
     16        "file": "prelobby/Terms_of_Use",
     17        "read": false
     18    }
     19};
     20
    821function init()
    922{
     23    let username = Engine.ConfigDB_GetValue("user", "lobby.login");
     24    g_EncryptedPassword = Engine.ConfigDB_GetValue("user", "lobby.password");
     25
     26    // We only show 10 characters to make it look decent.
     27    Engine.GetGUIObjectByName("connectUsername").caption = username;
     28    Engine.GetGUIObjectByName("connectPassword").caption = g_EncryptedPassword.substring(0, 10);
     29
    1030    Engine.GetGUIObjectByName("rememberPassword").checked =
    1131        Engine.ConfigDB_GetValue("user", "lobby.rememberpassword") == "true";
    12     g_EncryptedPassword = Engine.ConfigDB_GetValue("user", "lobby.password");
    13     if (Engine.ConfigDB_GetValue("user", "lobby.login") && g_EncryptedPassword)
     32
     33    if (username && g_EncryptedPassword)
    1434        switchPage("connect");
    1535}
     
    130150    }
    131151    // Check that they read the Terms of Service.
    132     else if (!g_TermsOfServiceRead)
    133     {
    134         continueButton.enabled = false;
    135         feedback.caption = translate("Please read the Terms of Service");
     152    else if (!g_Terms.Service.read)
     153    {
     154        continueButton.enabled = false;
     155        feedback.caption = g_Terms.Service.instruction;
    136156    }
    137157    // Check that they read the Terms of Use.
    138     else if (!g_TermsOfUseRead)
    139     {
    140         continueButton.enabled = false;
    141         feedback.caption = translate("Please read the Terms of Use");
     158    else if (!g_Terms.Use.read)
     159    {
     160        continueButton.enabled = false;
     161        feedback.caption = g_Terms.Use.instruction;
    142162    }
    143163    // Check that they agree to the terms of service and use.
     
    258278    }
    259279}
    260 function openTermsOfService()
    261 {
    262     g_TermsOfServiceRead = true;
     280
     281function openTerms(terms)
     282{
     283    g_Terms[terms].read = true;
     284
     285    Engine.GetGUIObjectByName("registerAgreeTerms").enabled = g_Terms.Service.read && g_Terms.Use.read;
     286
    263287    Engine.PushGuiPage("page_manual.xml", {
    264         "page": "prelobby/Terms_of_Service",
    265         "title": translate("Terms of Service"),
     288        "page": g_Terms[terms].file,
     289        "title": g_Terms[terms].title
    266290    });
    267291}
    268292
    269 function openTermsOfUse()
    270 {
    271     g_TermsOfUseRead = true;
    272     Engine.PushGuiPage("page_manual.xml", {
    273         "page": "prelobby/Terms_of_Use",
    274         "title": translate("Terms of Use"),
    275     });
     293function prelobbyConnect()
     294{
     295    if (!Engine.GetGUIObjectByName("pageConnect").hidden)
     296        lobbyStartConnect();
     297    else if (!Engine.GetGUIObjectByName("pageRegister").hidden)
     298        lobbyStartRegister();
    276299}
    277300
  • ps/trunk/binaries/data/mods/public/gui/prelobby/prelobby.xml

    r21311 r21846  
    1818    <object name="dialog" type="image" style="ModernDialog" size="50%-230 50%-130 50%+230 50%+130">
    1919
    20         <action on="Tick">
    21             onTick();
    22         </action>
     20        <action on="Tick">onTick();</action>
    2321
    2422        <object style="ModernLabelText" type="text" size="50%-128 -18 50%+128 14">
     
    4341                <translatableAttribute id="caption">Login:</translatableAttribute>
    4442            </object>
    45             <object name="connectUsername" type="input" size="50%+10 40 100%-20 64" style="ModernInput">
    46                 <action on="Load">
    47                     this.caption = Engine.ConfigDB_GetValue("user", "lobby.login");
    48                 </action>
    49             </object>
     43            <object name="connectUsername" type="input" size="50%+10 40 100%-20 64" style="ModernInput"/>
     44
    5045            <object name="connectPasswordLabel" type="text" size="20 80 50% 110" style="ModernRightLabelText">
    5146                <translatableAttribute id="caption">Password:</translatableAttribute>
    5247            </object>
    5348            <object name="connectPassword" type="input" size="50%+10 80 100%-20 104" style="ModernInput" mask="true" mask_char="*">
    54                 <action on="Load">
    55                     // We only show 10 characters to make it look decent.
    56                     this.caption = Engine.ConfigDB_GetValue("user", "lobby.password").substring(0, 10);
    57                 </action>
    58                 <action on="Press">
    59                     lobbyStartConnect();
    60                 </action>
     49                <action on="Press">lobbyStartConnect();</action>
    6150            </object>
    6251            <object name="rememberPassword" type="checkbox" size="50%-19 115 50% 135" style="ModernTickBox">
    63                 <action on="Press">
    64                     toggleRememberPassword();
    65                 </action>
     52                <action on="Press">toggleRememberPassword();</action>
    6653            </object>
    6754            <object type="text" size="50%+10 115 100%-20 135" style="ModernLeftLabelText">
     
    6956            </object>
    7057        </object>
     58
    7159        <object name="pageRegister" size="0 32 100% 100%" hidden="true">
    7260
     
    9280            <object type="button" size="20 160 100%-20 188" style="ModernButtonRed">
    9381                <translatableAttribute id="caption">Terms of Service</translatableAttribute>
    94                 <action on="Press">openTermsOfService();</action>
     82                <action on="Press">openTerms("Service");</action>
    9583            </object>
    9684
    9785            <object type="button" size="20 200 100%-20 228" style="ModernButtonRed">
    9886                <translatableAttribute id="caption">Terms of Use</translatableAttribute>
    99                 <action on="Press">openTermsOfUse();</action>
     87                <action on="Press">openTerms("Use");</action>
    10088            </object>
    10189
     
    10391                <translatableAttribute id="caption">I have read and agree to the Terms of Service and Terms of Use:</translatableAttribute>
    10492            </object>
    105             <object name="registerAgreeTerms" type="checkbox" size="100%-60 245 100%-20 270" style="ModernTickBox" enabled="false">
    106                 <action on="Tick"><![CDATA[this.enabled = g_TermsOfServiceRead && g_TermsOfUseRead;]]></action>
    107             </object>
     93
     94            <object name="registerAgreeTerms" type="checkbox" size="100%-60 245 100%-20 270" style="ModernTickBox" enabled="false"/>
    10895
    10996        </object>
     97
    11098        <object name="feedback" type="text" size="50 100%-110 100%-50 100%-50" style="ModernLabelText" textcolor="red"/>
    11199        <object name="cancel" type="button" size="18 100%-45 50%-5 100%-17" style="ModernButtonRed" hotkey="cancel">
     
    115103        <object name="continue" hotkey="confirm" type="button" size="50%+5 100%-45 100%-18 100%-17" style="ModernButtonRed" enabled="false" hidden="true">
    116104            <translatableAttribute id="caption">Connect</translatableAttribute>
    117             <action on="Press">
    118                 if (!Engine.GetGUIObjectByName("pageConnect").hidden)
    119                     lobbyStartConnect();
    120                 else if (!Engine.GetGUIObjectByName("pageRegister").hidden)
    121                     lobbyStartRegister();
    122             </action>
     105            <action on="Press">prelobbyConnect();</action>
    123106        </object>
    124107
Note: See TracChangeset for help on using the changeset viewer.