Donate and reset password buttons (#3252)
* First version of donation link and password reset buttons The register screen still needs to be tweaked, though the GUI engine seems to be limted here. Maybe dynamicly delete/re-create the widget? * Fix mingw compilation * Remove dead code * minor cleanup * Error handling, tweaks * Fix ifdef for macOS * Disable donate button on Android * Use stk-config * Implement LinkHelper::isSupported, fixes
This commit is contained in:
parent
205d4b5626
commit
5d34488adc
@ -2,11 +2,19 @@
|
|||||||
<stkgui>
|
<stkgui>
|
||||||
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
|
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
|
||||||
|
|
||||||
<div x="2%" y="2%" width="98%" height="96%" layout="vertical-row" >
|
<div x="2%" y="2%" width="96%" height="96%" layout="vertical-row" >
|
||||||
|
|
||||||
<icon id="logo" align="center" proportion="4" width="100%" icon="gui/logo_slim.png"/>
|
<icon id="logo" align="center" proportion="4" width="100%" icon="gui/logo_slim.png"/>
|
||||||
|
|
||||||
<header I18N="Title in credits screen" text="Credits" width="100%" />
|
<div x="0" y="0" width="100%" proportion="1" layout="horizontal-row" >
|
||||||
|
|
||||||
|
<header I18N="Title in credits screen" text="Credits" />
|
||||||
|
|
||||||
|
<spacer proportion="1" />
|
||||||
|
|
||||||
|
<button id="donate" width="fit" align="center" text="Donate to help keep SuperTuxKart going!"/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<box id="animated_area" width="100%" proportion="10" padding="0">
|
<box id="animated_area" width="100%" proportion="10" padding="0">
|
||||||
</box>
|
</box>
|
||||||
|
@ -52,6 +52,9 @@
|
|||||||
<textbox id="email_confirm" proportion="2" height="fit" I18N="In the registration dialog"/>
|
<textbox id="email_confirm" proportion="2" height="fit" I18N="In the registration dialog"/>
|
||||||
</div>
|
</div>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<button id="password_reset" width="fit" text="Reset password"/>
|
||||||
|
|
||||||
<label id="info" height="20%" width="100%" align="center" text_align="center" word_wrap="true"
|
<label id="info" height="20%" width="100%" align="center" text_align="center" word_wrap="true"
|
||||||
I18N="In the registration dialog"
|
I18N="In the registration dialog"
|
||||||
text="You can play without creating an online account by selecting an offline account. Though then you can not connect to friends, vote for addons etc. Please read our privacy statement at http://privacy.supertuxkart.net"/>
|
text="You can play without creating an online account by selecting an offline account. Though then you can not connect to friends, vote for addons etc. Please read our privacy statement at http://privacy.supertuxkart.net"/>
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
I18N="In the user screen" text="Username"/>
|
I18N="In the user screen" text="Username"/>
|
||||||
<textbox id="username" proportion="2" height="fit" I18N="In the user screen"/>
|
<textbox id="username" proportion="2" height="fit" I18N="In the user screen"/>
|
||||||
</div>
|
</div>
|
||||||
<spacer height="10%" width="20"/>
|
<spacer height="5%" width="20"/>
|
||||||
|
|
||||||
<div width="100%" height="fit" layout="horizontal-row" >
|
<div width="100%" height="fit" layout="horizontal-row" >
|
||||||
<label id="label_password" width="40%" height="100%" text_align="left"
|
<label id="label_password" width="40%" height="100%" text_align="left"
|
||||||
@ -47,6 +47,10 @@
|
|||||||
|
|
||||||
<spacer height="5%" width="20"/>
|
<spacer height="5%" width="20"/>
|
||||||
|
|
||||||
|
<button id="password_reset" width="fit" text="Reset password"/>
|
||||||
|
|
||||||
|
<spacer height="5%" width="20"/>
|
||||||
|
|
||||||
<label id="message" width="100%" text_align="center"/>
|
<label id="message" width="100%" text_align="center"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
I18N="In the user screen" text="Username"/>
|
I18N="In the user screen" text="Username"/>
|
||||||
<textbox id="username" proportion="2" height="fit" I18N="In the user screen"/>
|
<textbox id="username" proportion="2" height="fit" I18N="In the user screen"/>
|
||||||
</div>
|
</div>
|
||||||
<spacer height="10%" width="20"/>
|
<spacer height="5%" width="20"/>
|
||||||
|
|
||||||
<div width="100%" height="fit" layout="horizontal-row" >
|
<div width="100%" height="fit" layout="horizontal-row" >
|
||||||
<label id="label_password" width="40%" height="100%" text_align="left"
|
<label id="label_password" width="40%" height="100%" text_align="left"
|
||||||
@ -56,6 +56,10 @@
|
|||||||
|
|
||||||
<spacer height="5%" width="20"/>
|
<spacer height="5%" width="20"/>
|
||||||
|
|
||||||
|
<button id="password_reset" width="fit" text="Reset password"/>
|
||||||
|
|
||||||
|
<spacer height="5%" width="20"/>
|
||||||
|
|
||||||
<label id="message" width="100%" text_align="center"/>
|
<label id="message" width="100%" text_align="center"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -133,6 +133,9 @@
|
|||||||
|
|
||||||
<minimap size="180.0" ai-icon="16.0" player-icon="20.0"/>
|
<minimap size="180.0" ai-icon="16.0" player-icon="20.0"/>
|
||||||
|
|
||||||
|
<urls donate="https://supertuxkart.net/Donate"
|
||||||
|
password-reset="http://addons.supertuxkart.net/password-reset.php" />
|
||||||
|
|
||||||
<!-- Skidmark data: maximum number of skid marks, and
|
<!-- Skidmark data: maximum number of skid marks, and
|
||||||
time for skidmarks to fade out. Maximum number will over
|
time for skidmarks to fade out. Maximum number will over
|
||||||
current number of karts, so the more karts, the less
|
current number of karts, so the more karts, the less
|
||||||
|
@ -201,6 +201,8 @@ void STKConfig::init_defaults()
|
|||||||
m_minimap_size = -100;
|
m_minimap_size = -100;
|
||||||
m_minimap_ai_icon = -100;
|
m_minimap_ai_icon = -100;
|
||||||
m_minimap_player_icon = -100;
|
m_minimap_player_icon = -100;
|
||||||
|
m_donate_url = "";
|
||||||
|
m_password_reset_url = "";
|
||||||
m_network_state_frequeny = -100;
|
m_network_state_frequeny = -100;
|
||||||
m_title_music = NULL;
|
m_title_music = NULL;
|
||||||
m_smooth_normals = false;
|
m_smooth_normals = false;
|
||||||
@ -418,6 +420,12 @@ void STKConfig::getAllData(const XMLNode * root)
|
|||||||
replay_node->get("player-icon", &m_minimap_player_icon );
|
replay_node->get("player-icon", &m_minimap_player_icon );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(const XMLNode *replay_node = root->getNode("urls"))
|
||||||
|
{
|
||||||
|
replay_node->get("donate", &m_donate_url );
|
||||||
|
replay_node->get("password-reset", &m_password_reset_url );
|
||||||
|
}
|
||||||
|
|
||||||
if (const XMLNode *fonts_list = root->getNode("fonts-list"))
|
if (const XMLNode *fonts_list = root->getNode("fonts-list"))
|
||||||
{
|
{
|
||||||
fonts_list->get("normal-ttf", &m_normal_ttf);
|
fonts_list->get("normal-ttf", &m_normal_ttf);
|
||||||
|
@ -184,6 +184,10 @@ public:
|
|||||||
uint16_t m_client_port;
|
uint16_t m_client_port;
|
||||||
uint16_t m_server_port;
|
uint16_t m_server_port;
|
||||||
|
|
||||||
|
/* URLs for donating and reseting the password */
|
||||||
|
std::string m_donate_url;
|
||||||
|
std::string m_password_reset_url;
|
||||||
|
|
||||||
/** Lists of TTF files used in STK. */
|
/** Lists of TTF files used in STK. */
|
||||||
std::vector<std::string> m_normal_ttf;
|
std::vector<std::string> m_normal_ttf;
|
||||||
std::vector<std::string> m_digit_ttf;
|
std::vector<std::string> m_digit_ttf;
|
||||||
|
58
src/online/link_helper.cpp
Normal file
58
src/online/link_helper.cpp
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// SuperTuxKart - A fun racing game with go-karts
|
||||||
|
// Copyright (C) 2017-18 QwertyChouskie
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License
|
||||||
|
// as published by the Free Software Foundation; either version 3
|
||||||
|
// of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
#include "online/link_helper.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
#include <string>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#include <shellapi.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace Online;
|
||||||
|
|
||||||
|
namespace Online
|
||||||
|
{
|
||||||
|
bool LinkHelper::isSupported()
|
||||||
|
{
|
||||||
|
#if defined(_WIN32) || defined(__APPLE__) || (defined(__linux__) && !defined(__ANDROID__))
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinkHelper::openURL (std::string url)
|
||||||
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
std::string command = std::string("open ").append(url);
|
||||||
|
if (system(command.c_str()))
|
||||||
|
{
|
||||||
|
Log::error("OpenURL", "Command returned non-zero exit status");
|
||||||
|
}
|
||||||
|
#elif defined(__linux__) && !defined(__ANDROID__)
|
||||||
|
std::string command = std::string("xdg-open ").append(url);
|
||||||
|
if (system(command.c_str()))
|
||||||
|
{
|
||||||
|
Log::error("OpenURL", "Command returned non-zero exit status");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
Log::error("OpenURL", "Not implemented for this platform!");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
31
src/online/link_helper.hpp
Normal file
31
src/online/link_helper.hpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// SuperTuxKart - A fun racing game with go-karts
|
||||||
|
// Copyright (C) 2017-18 QwertyChouskie
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License
|
||||||
|
// as published by the Free Software Foundation; either version 3
|
||||||
|
// of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
#ifndef HEADER_LINK_HELPER_HPP
|
||||||
|
#define HEADER_LINK_HELPER_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Online
|
||||||
|
{
|
||||||
|
class LinkHelper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static bool isSupported();
|
||||||
|
static void openURL (std::string url);
|
||||||
|
}; //class LinkHelper
|
||||||
|
} // namespace Online
|
||||||
|
#endif // link_helper_HPP
|
@ -29,6 +29,7 @@ using irr::core::stringc;
|
|||||||
#include "guiengine/screen.hpp"
|
#include "guiengine/screen.hpp"
|
||||||
#include "guiengine/widget.hpp"
|
#include "guiengine/widget.hpp"
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
|
#include "online/link_helper.hpp"
|
||||||
#include "states_screens/state_manager.hpp"
|
#include "states_screens/state_manager.hpp"
|
||||||
#include "utils/constants.hpp"
|
#include "utils/constants.hpp"
|
||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
@ -69,7 +70,7 @@ public:
|
|||||||
{
|
{
|
||||||
m_entries[m_entries.size()-1].m_subentries.push_back(subEntryString);
|
m_entries[m_entries.size()-1].m_subentries.push_back(subEntryString);
|
||||||
}
|
}
|
||||||
}; // CreditdsSection
|
}; // CreditsSection
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -189,13 +190,13 @@ void CreditsScreen::loadedFromFile()
|
|||||||
StringUtils::split(translators_credits, '\n');
|
StringUtils::split(translators_credits, '\n');
|
||||||
|
|
||||||
m_sections.push_back( new CreditsSection("Translations"));
|
m_sections.push_back( new CreditsSection("Translations"));
|
||||||
for(unsigned int i = 1; i < translator.size(); i = i + MAX_PER_SCREEN)
|
for (unsigned int i = 1; i < translator.size(); i = i + MAX_PER_SCREEN)
|
||||||
{
|
{
|
||||||
line = stringw(translations->getCurrentLanguageName().c_str());
|
line = stringw(translations->getCurrentLanguageName().c_str());
|
||||||
CreditsEntry entry(line);
|
CreditsEntry entry(line);
|
||||||
getCurrentSection()->addEntry( entry );
|
getCurrentSection()->addEntry( entry );
|
||||||
|
|
||||||
for(unsigned int j = 0; i + j < translator.size() && j < MAX_PER_SCREEN; j ++)
|
for (unsigned int j = 0; i + j < translator.size() && j < MAX_PER_SCREEN; j ++)
|
||||||
{
|
{
|
||||||
getCurrentSection()->addSubEntry(translator[i + j]);
|
getCurrentSection()->addSubEntry(translator[i + j]);
|
||||||
}
|
}
|
||||||
@ -206,6 +207,10 @@ void CreditsScreen::loadedFromFile()
|
|||||||
m_sections.swap( m_sections.size() - 1, m_sections.size() - 2 );
|
m_sections.swap( m_sections.size() - 1, m_sections.size() - 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Online::LinkHelper::isSupported())
|
||||||
|
{
|
||||||
|
getWidget("donate")->setVisible(false);
|
||||||
|
}
|
||||||
} // loadedFromFile
|
} // loadedFromFile
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -393,6 +398,11 @@ void CreditsScreen::eventCallback(GUIEngine::Widget* widget,
|
|||||||
{
|
{
|
||||||
StateManager::get()->escapePressed();
|
StateManager::get()->escapePressed();
|
||||||
}
|
}
|
||||||
|
if (name == "donate")
|
||||||
|
{
|
||||||
|
// Open donation page
|
||||||
|
Online::LinkHelper::openURL(stk_config->m_donate_url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -20,10 +20,12 @@
|
|||||||
#include "config/player_manager.hpp"
|
#include "config/player_manager.hpp"
|
||||||
#include "config/user_config.hpp"
|
#include "config/user_config.hpp"
|
||||||
#include "audio/sfx_manager.hpp"
|
#include "audio/sfx_manager.hpp"
|
||||||
|
#include "guiengine/widgets/button_widget.hpp"
|
||||||
#include "guiengine/widgets/check_box_widget.hpp"
|
#include "guiengine/widgets/check_box_widget.hpp"
|
||||||
#include "guiengine/widgets/label_widget.hpp"
|
#include "guiengine/widgets/label_widget.hpp"
|
||||||
#include "guiengine/widgets/ribbon_widget.hpp"
|
#include "guiengine/widgets/ribbon_widget.hpp"
|
||||||
#include "guiengine/widgets/text_box_widget.hpp"
|
#include "guiengine/widgets/text_box_widget.hpp"
|
||||||
|
#include "online/link_helper.hpp"
|
||||||
#include "online/xml_request.hpp"
|
#include "online/xml_request.hpp"
|
||||||
#include "states_screens/dialogs/registration_dialog.hpp"
|
#include "states_screens/dialogs/registration_dialog.hpp"
|
||||||
#include "states_screens/dialogs/message_dialog.hpp"
|
#include "states_screens/dialogs/message_dialog.hpp"
|
||||||
@ -192,6 +194,8 @@ void RegisterScreen::makeEntryFieldsVisible()
|
|||||||
getWidget<TextBoxWidget>("email_confirm")->setVisible(new_account);
|
getWidget<TextBoxWidget>("email_confirm")->setVisible(new_account);
|
||||||
getWidget<LabelWidget >("label_email_confirm")->setVisible(new_account);
|
getWidget<LabelWidget >("label_email_confirm")->setVisible(new_account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getWidget<ButtonWidget >("password_reset")->setVisible(LinkHelper::isSupported() && (online && !new_account));
|
||||||
} // makeEntryFieldsVisible
|
} // makeEntryFieldsVisible
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -444,6 +448,11 @@ void RegisterScreen::eventCallback(Widget* widget, const std::string& name,
|
|||||||
onEscapePressed();
|
onEscapePressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (name == "password_reset")
|
||||||
|
{
|
||||||
|
// Open password reset page
|
||||||
|
Online::LinkHelper::openURL(stk_config->m_password_reset_url);
|
||||||
|
}
|
||||||
else if (name == "back")
|
else if (name == "back")
|
||||||
{
|
{
|
||||||
m_existing_player = NULL;
|
m_existing_player = NULL;
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "guiengine/widgets/label_widget.hpp"
|
#include "guiengine/widgets/label_widget.hpp"
|
||||||
#include "guiengine/widgets/list_widget.hpp"
|
#include "guiengine/widgets/list_widget.hpp"
|
||||||
#include "guiengine/widgets/text_box_widget.hpp"
|
#include "guiengine/widgets/text_box_widget.hpp"
|
||||||
|
#include "online/link_helper.hpp"
|
||||||
#include "online/request_manager.hpp"
|
#include "online/request_manager.hpp"
|
||||||
#include "states_screens/dialogs/message_dialog.hpp"
|
#include "states_screens/dialogs/message_dialog.hpp"
|
||||||
#include "states_screens/dialogs/kart_color_slider_dialog.hpp"
|
#include "states_screens/dialogs/kart_color_slider_dialog.hpp"
|
||||||
@ -251,6 +252,7 @@ void BaseUserScreen::selectUser(int index)
|
|||||||
{
|
{
|
||||||
m_password_tb->setVisible(false);
|
m_password_tb->setVisible(false);
|
||||||
getWidget<LabelWidget>("label_password")->setVisible(false);
|
getWidget<LabelWidget>("label_password")->setVisible(false);
|
||||||
|
getWidget<ButtonWidget>("password_reset")->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // selectUser
|
} // selectUser
|
||||||
@ -286,11 +288,13 @@ void BaseUserScreen::makeEntryFieldsVisible()
|
|||||||
// saved session, don't show the password field.
|
// saved session, don't show the password field.
|
||||||
getWidget<LabelWidget>("label_password")->setVisible(false);
|
getWidget<LabelWidget>("label_password")->setVisible(false);
|
||||||
m_password_tb->setVisible(false);
|
m_password_tb->setVisible(false);
|
||||||
|
getWidget<ButtonWidget>("password_reset")->setVisible(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getWidget<LabelWidget>("label_password")->setVisible(online);
|
getWidget<LabelWidget>("label_password")->setVisible(online);
|
||||||
m_password_tb->setVisible(online);
|
m_password_tb->setVisible(online);
|
||||||
|
getWidget<ButtonWidget>("password_reset")->setVisible(Online::LinkHelper::isSupported() && online);
|
||||||
// Is user has no online name, make sure the user can enter one
|
// Is user has no online name, make sure the user can enter one
|
||||||
if (player->getLastOnlineName().empty())
|
if (player->getLastOnlineName().empty())
|
||||||
m_username_tb->setActive(true);
|
m_username_tb->setActive(true);
|
||||||
@ -375,6 +379,11 @@ void BaseUserScreen::eventCallback(Widget* widget,
|
|||||||
}
|
}
|
||||||
makeEntryFieldsVisible();
|
makeEntryFieldsVisible();
|
||||||
}
|
}
|
||||||
|
else if (name == "password_reset")
|
||||||
|
{
|
||||||
|
// Open password reset page
|
||||||
|
Online::LinkHelper::openURL(stk_config->m_password_reset_url);
|
||||||
|
}
|
||||||
else if (name == "options")
|
else if (name == "options")
|
||||||
{
|
{
|
||||||
const std::string &button =
|
const std::string &button =
|
||||||
|
Loading…
Reference in New Issue
Block a user