Add error dialogs for open path/url buttons
parent
4905abe30b
commit
5f76722ecb
|
@ -172,6 +172,20 @@ msgstr ""
|
|||
msgid "This menu is for userlevels from mods, but you didn't install any"
|
||||
msgstr ""
|
||||
|
||||
msgid "Could not open the file explorer!"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "The path %s could not be opened in a file explorer."
|
||||
msgstr ""
|
||||
|
||||
msgid "Could not open the web browser!"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "The address %s could not be opened in a web browser."
|
||||
msgstr ""
|
||||
|
||||
msgid "Keyword help(\\key cbot;)"
|
||||
msgstr ""
|
||||
|
||||
|
|
14
po/cs.po
14
po/cs.po
|
@ -440,6 +440,12 @@ msgstr "Kopírovat"
|
|||
msgid "Copy (Ctrl+C)"
|
||||
msgstr "Kopírovat (Ctrl+C)"
|
||||
|
||||
msgid "Could not open the file explorer!"
|
||||
msgstr ""
|
||||
|
||||
msgid "Could not open the web browser!"
|
||||
msgstr ""
|
||||
|
||||
msgid "Current mission saved"
|
||||
msgstr "Současná mise uložena"
|
||||
|
||||
|
@ -1555,6 +1561,10 @@ msgstr "Filtrování textur\\Filtrování textur"
|
|||
msgid "Textures"
|
||||
msgstr "Textury"
|
||||
|
||||
#, c-format
|
||||
msgid "The address %s could not be opened in a web browser."
|
||||
msgstr ""
|
||||
|
||||
msgid "The battle has ended"
|
||||
msgstr "Souboj skončil"
|
||||
|
||||
|
@ -1567,6 +1577,10 @@ msgstr "Funkce nevrátila žádnou hodnotu"
|
|||
msgid "The mission is not accomplished yet (press \\key help; for more details)"
|
||||
msgstr "Mise ještě nebyla splněna (pro podrobnosti stiskněte \\key help;)"
|
||||
|
||||
#, c-format
|
||||
msgid "The path %s could not be opened in a file explorer."
|
||||
msgstr ""
|
||||
|
||||
msgid "The types of the two operands are incompatible"
|
||||
msgstr "Operaci nelze provést s operandy těchto dvou typů"
|
||||
|
||||
|
|
14
po/de.po
14
po/de.po
|
@ -441,6 +441,12 @@ msgstr "Kopieren"
|
|||
msgid "Copy (Ctrl+C)"
|
||||
msgstr "Kopieren (Ctrl+C)"
|
||||
|
||||
msgid "Could not open the file explorer!"
|
||||
msgstr ""
|
||||
|
||||
msgid "Could not open the web browser!"
|
||||
msgstr ""
|
||||
|
||||
msgid "Current mission saved"
|
||||
msgstr "Mission gespeichert"
|
||||
|
||||
|
@ -1572,6 +1578,10 @@ msgstr "Texturfilterung\\Texturfilterung"
|
|||
msgid "Textures"
|
||||
msgstr "Texturen"
|
||||
|
||||
#, c-format
|
||||
msgid "The address %s could not be opened in a web browser."
|
||||
msgstr ""
|
||||
|
||||
msgid "The battle has ended"
|
||||
msgstr ""
|
||||
|
||||
|
@ -1584,6 +1594,10 @@ msgstr "Die Funktion hat kein Ergebnis zurückgegeben"
|
|||
msgid "The mission is not accomplished yet (press \\key help; for more details)"
|
||||
msgstr "Mission noch nicht beendet (Drücken Sie auf \\key help; für weitere Informationen)"
|
||||
|
||||
#, c-format
|
||||
msgid "The path %s could not be opened in a file explorer."
|
||||
msgstr ""
|
||||
|
||||
msgid "The types of the two operands are incompatible"
|
||||
msgstr "Die zwei Operanden sind nicht kompatibel"
|
||||
|
||||
|
|
14
po/fr.po
14
po/fr.po
|
@ -443,6 +443,12 @@ msgstr "Copier"
|
|||
msgid "Copy (Ctrl+C)"
|
||||
msgstr "Copier (Ctrl+C)"
|
||||
|
||||
msgid "Could not open the file explorer!"
|
||||
msgstr ""
|
||||
|
||||
msgid "Could not open the web browser!"
|
||||
msgstr ""
|
||||
|
||||
msgid "Current mission saved"
|
||||
msgstr "Enregistrement effectué"
|
||||
|
||||
|
@ -1574,6 +1580,10 @@ msgstr "Filtrage de textures\\Filtrage de textures"
|
|||
msgid "Textures"
|
||||
msgstr "Textures"
|
||||
|
||||
#, c-format
|
||||
msgid "The address %s could not be opened in a web browser."
|
||||
msgstr ""
|
||||
|
||||
msgid "The battle has ended"
|
||||
msgstr "La bataille est terminée"
|
||||
|
||||
|
@ -1586,6 +1596,10 @@ msgstr "La fonction n'a pas retourné de résultat"
|
|||
msgid "The mission is not accomplished yet (press \\key help; for more details)"
|
||||
msgstr "La mission n'est pas terminée (appuyez sur \\key help; pour plus de détails)"
|
||||
|
||||
#, c-format
|
||||
msgid "The path %s could not be opened in a file explorer."
|
||||
msgstr ""
|
||||
|
||||
msgid "The types of the two operands are incompatible"
|
||||
msgstr "Les deux opérandes ne sont pas de types compatibles"
|
||||
|
||||
|
|
14
po/pl.po
14
po/pl.po
|
@ -439,6 +439,12 @@ msgstr "Kopiuj"
|
|||
msgid "Copy (Ctrl+C)"
|
||||
msgstr "Kopiuj (Ctrl+C)"
|
||||
|
||||
msgid "Could not open the file explorer!"
|
||||
msgstr "Nie udało się otworzyć przeglądarki plików!"
|
||||
|
||||
msgid "Could not open the web browser!"
|
||||
msgstr "Nie udało się otworzyć przeglądarki internetowej!"
|
||||
|
||||
msgid "Current mission saved"
|
||||
msgstr "Bieżąca misja zapisana"
|
||||
|
||||
|
@ -1554,6 +1560,10 @@ msgstr "Filtrowanie tekstur\\Filtrowanie tekstur"
|
|||
msgid "Textures"
|
||||
msgstr "Tekstury"
|
||||
|
||||
#, c-format
|
||||
msgid "The address %s could not be opened in a web browser."
|
||||
msgstr "Nie udało się otworzyć adresu %s w przeglądarce internetowej."
|
||||
|
||||
msgid "The battle has ended"
|
||||
msgstr "Bitwa zakończyła się"
|
||||
|
||||
|
@ -1566,6 +1576,10 @@ msgstr "Funkcja nie zwróciła żadnej wartości"
|
|||
msgid "The mission is not accomplished yet (press \\key help; for more details)"
|
||||
msgstr "Misja nie jest wypełniona (naciśnij \\key help; aby uzyskać szczegóły)"
|
||||
|
||||
#, c-format
|
||||
msgid "The path %s could not be opened in a file explorer."
|
||||
msgstr "Nie udało się otworzyć ścieżki %s w przeglądarce plików."
|
||||
|
||||
msgid "The types of the two operands are incompatible"
|
||||
msgstr "Niezgodne typy operatorów"
|
||||
|
||||
|
|
35
po/pt.po
35
po/pt.po
|
@ -438,6 +438,12 @@ msgstr "Copiar"
|
|||
msgid "Copy (Ctrl+C)"
|
||||
msgstr "Copiar (Ctrl+C)"
|
||||
|
||||
msgid "Could not open the file explorer!"
|
||||
msgstr ""
|
||||
|
||||
msgid "Could not open the web browser!"
|
||||
msgstr ""
|
||||
|
||||
msgid "Current mission saved"
|
||||
msgstr "Missão atual salva"
|
||||
|
||||
|
@ -843,12 +849,18 @@ msgstr "Lista das missões salvas"
|
|||
msgid "Load a saved mission"
|
||||
msgstr "Carregar uma missão salva"
|
||||
|
||||
msgid "Load\\Load Mod"
|
||||
msgstr ""
|
||||
|
||||
msgid "Load\\Load a saved mission"
|
||||
msgstr "Carregar\\Carregar uma missão salva"
|
||||
|
||||
msgid "Load\\Loads the selected mission"
|
||||
msgstr "Carregar\\Carrega a missão selecionada"
|
||||
|
||||
msgid "Loaded Mods:"
|
||||
msgstr ""
|
||||
|
||||
msgid "Loading basic level settings"
|
||||
msgstr "Carregando configurações de nível básico"
|
||||
|
||||
|
@ -917,6 +929,9 @@ msgstr "Lista de missões neste planeta:"
|
|||
msgid "Missions\\Select mission"
|
||||
msgstr "Missões\\Selecione uma missão"
|
||||
|
||||
msgid "Mods\\Manage installed mods"
|
||||
msgstr ""
|
||||
|
||||
msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis"
|
||||
msgstr "Inversão de mouse X\\Inverte a direção da rolagem no eixo X"
|
||||
|
||||
|
@ -1085,6 +1100,9 @@ msgstr "Abrir"
|
|||
msgid "Open (Ctrl+O)"
|
||||
msgstr "Abrir (Ctrl+O)"
|
||||
|
||||
msgid "Open Directory\\Open Mods directory"
|
||||
msgstr ""
|
||||
|
||||
msgid "Opening brace missing"
|
||||
msgstr "Chave de abertura ausente"
|
||||
|
||||
|
@ -1557,6 +1575,10 @@ msgstr "Filtragem de textura\\Filtragem de textura"
|
|||
msgid "Textures"
|
||||
msgstr "Texturas"
|
||||
|
||||
#, c-format
|
||||
msgid "The address %s could not be opened in a web browser."
|
||||
msgstr ""
|
||||
|
||||
msgid "The battle has ended"
|
||||
msgstr "A batalha acabou"
|
||||
|
||||
|
@ -1569,6 +1591,10 @@ msgstr "A função não retornou nenhum valor"
|
|||
msgid "The mission is not accomplished yet (press \\key help; for more details)"
|
||||
msgstr "A missão não foi completada ainda (pressione \\key help; para mais detalhes)"
|
||||
|
||||
#, c-format
|
||||
msgid "The path %s could not be opened in a file explorer."
|
||||
msgstr ""
|
||||
|
||||
msgid "The types of the two operands are incompatible"
|
||||
msgstr "Os tipos dos dois operandos são incompativeis"
|
||||
|
||||
|
@ -1705,6 +1731,12 @@ msgstr "Sequência de escape desconhecidade"
|
|||
msgid "Unknown function"
|
||||
msgstr "Função desconhecida"
|
||||
|
||||
msgid "Unload\\Unload Mod"
|
||||
msgstr ""
|
||||
|
||||
msgid "Unloaded Mods:"
|
||||
msgstr ""
|
||||
|
||||
msgid "Up (\\key gup;)"
|
||||
msgstr "Cima (\\key gup;)"
|
||||
|
||||
|
@ -1780,6 +1812,9 @@ msgstr "Farejador alado"
|
|||
msgid "Withdraw shield (\\key action;)"
|
||||
msgstr "Retirar escudo (\\key action;)"
|
||||
|
||||
msgid "Workshop\\Open Workshop to search Mods"
|
||||
msgstr ""
|
||||
|
||||
msgid "Worm"
|
||||
msgstr "Verme"
|
||||
|
||||
|
|
14
po/ru.po
14
po/ru.po
|
@ -446,6 +446,12 @@ msgstr "Копировать"
|
|||
msgid "Copy (Ctrl+C)"
|
||||
msgstr "Копировать (Ctrl+C)"
|
||||
|
||||
msgid "Could not open the file explorer!"
|
||||
msgstr ""
|
||||
|
||||
msgid "Could not open the web browser!"
|
||||
msgstr ""
|
||||
|
||||
msgid "Current mission saved"
|
||||
msgstr "Текущая миссия сохранена"
|
||||
|
||||
|
@ -1585,6 +1591,10 @@ msgstr "Фильтрация текстур\\Фильтрация текстур
|
|||
msgid "Textures"
|
||||
msgstr "Текстуры"
|
||||
|
||||
#, c-format
|
||||
msgid "The address %s could not be opened in a web browser."
|
||||
msgstr ""
|
||||
|
||||
msgid "The battle has ended"
|
||||
msgstr ""
|
||||
|
||||
|
@ -1597,6 +1607,10 @@ msgstr "Функция не возвратила значения"
|
|||
msgid "The mission is not accomplished yet (press \\key help; for more details)"
|
||||
msgstr "Миссия еще не выполнена (нажмите \\key help; для более подробной информации)"
|
||||
|
||||
#, c-format
|
||||
msgid "The path %s could not be opened in a file explorer."
|
||||
msgstr ""
|
||||
|
||||
msgid "The types of the two operands are incompatible"
|
||||
msgstr "Типы операндов несовместимы"
|
||||
|
||||
|
|
|
@ -111,6 +111,10 @@ void InitializeRestext()
|
|||
stringsText[RT_DIALOG_OK] = TR("OK");
|
||||
stringsText[RT_DIALOG_NOUSRLVL_TITLE] = TR("No userlevels installed!");
|
||||
stringsText[RT_DIALOG_NOUSRLVL_TEXT] = TR("This menu is for userlevels from mods, but you didn't install any");
|
||||
stringsText[RT_DIALOG_OPEN_PATH_FAILED_TITLE] = TR("Could not open the file explorer!");
|
||||
stringsText[RT_DIALOG_OPEN_PATH_FAILED_TEXT] = TR("The path %s could not be opened in a file explorer.");
|
||||
stringsText[RT_DIALOG_OPEN_WEBSITE_FAILED_TITLE] = TR("Could not open the web browser!");
|
||||
stringsText[RT_DIALOG_OPEN_WEBSITE_FAILED_TEXT] = TR("The address %s could not be opened in a web browser.");
|
||||
|
||||
stringsText[RT_STUDIO_LISTTT] = TR("Keyword help(\\key cbot;)");
|
||||
stringsText[RT_STUDIO_COMPOK] = TR("Compilation ok (0 errors)");
|
||||
|
|
|
@ -105,6 +105,10 @@ enum ResTextType
|
|||
RT_DIALOG_OK = 110,
|
||||
RT_DIALOG_NOUSRLVL_TITLE = 111,
|
||||
RT_DIALOG_NOUSRLVL_TEXT = 112,
|
||||
RT_DIALOG_OPEN_PATH_FAILED_TITLE = 113,
|
||||
RT_DIALOG_OPEN_PATH_FAILED_TEXT = 114,
|
||||
RT_DIALOG_OPEN_WEBSITE_FAILED_TITLE = 115,
|
||||
RT_DIALOG_OPEN_WEBSITE_FAILED_TEXT = 116,
|
||||
|
||||
RT_STUDIO_LISTTT = 120,
|
||||
RT_STUDIO_COMPOK = 121,
|
||||
|
|
|
@ -216,12 +216,12 @@ std::string CSystemUtils::GetEnvVar(const std::string& name)
|
|||
return "";
|
||||
}
|
||||
|
||||
void CSystemUtils::OpenPath(std::string path)
|
||||
bool CSystemUtils::OpenPath(const std::string& path)
|
||||
{
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
void CSystemUtils::OpenWebsite(std::string website)
|
||||
bool CSystemUtils::OpenWebsite(const std::string& url)
|
||||
{
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -146,10 +146,12 @@ public:
|
|||
virtual std::string GetEnvVar(const std::string &name);
|
||||
|
||||
//! Opens a path with default file browser
|
||||
virtual void OpenPath(std::string path);
|
||||
/** \returns true if successful */
|
||||
virtual bool OpenPath(const std::string& path);
|
||||
|
||||
//! Opens a website with default web browser
|
||||
virtual void OpenWebsite(std::string website);
|
||||
/** \returns true if successful */
|
||||
virtual bool OpenWebsite(const std::string& url);
|
||||
|
||||
//! Sleep for given amount of microseconds
|
||||
virtual void Usleep(int usecs) = 0;
|
||||
|
|
|
@ -150,26 +150,26 @@ std::string CSystemUtilsLinux::GetEnvVar(const std::string& name)
|
|||
return "";
|
||||
}
|
||||
|
||||
void CSystemUtilsLinux::OpenPath(std::string path)
|
||||
bool CSystemUtilsLinux::OpenPath(const std::string& path)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = system(("xdg-open \""+path+"\"").c_str());
|
||||
if (result == -1)
|
||||
int result = system(("xdg-open \"" + path + "\"").c_str());
|
||||
if (result != 0)
|
||||
{
|
||||
GetLogger()->Error("Failed to open path: %s\n", path.c_str());
|
||||
GetLogger()->Error("Failed to open path: %s, error code: %i\n", path.c_str(), result);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSystemUtilsLinux::OpenWebsite(std::string website)
|
||||
bool CSystemUtilsLinux::OpenWebsite(const std::string& url)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = system(("xdg-open \""+website+"\"").c_str());
|
||||
if (result == -1)
|
||||
int result = system(("xdg-open \"" + url + "\"").c_str());
|
||||
if (result != 0)
|
||||
{
|
||||
GetLogger()->Error("Failed to open website: %s\n", website.c_str());
|
||||
GetLogger()->Error("Failed to open website: %s, error code: %i\n", url.c_str(), result);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSystemUtilsLinux::Usleep(int usec)
|
||||
|
|
|
@ -48,8 +48,8 @@ public:
|
|||
|
||||
std::string GetEnvVar(const std::string& name) override;
|
||||
|
||||
void OpenPath(std::string path) override;
|
||||
void OpenWebsite(std::string website) override;
|
||||
bool OpenPath(const std::string& path) override;
|
||||
bool OpenWebsite(const std::string& url) override;
|
||||
|
||||
void Usleep(int usec) override;
|
||||
|
||||
|
|
|
@ -119,26 +119,26 @@ std::string CSystemUtilsMacOSX::GetEnvVar(const std::string& str)
|
|||
return std::string();
|
||||
}
|
||||
|
||||
void CSystemUtilsLinux::OpenPath(std::string path)
|
||||
bool CSystemUtilsMacOSX::OpenPath(const std::string& path)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = system(("open \""+path+"\"").c_str()); // TODO: Test on macOS
|
||||
if (result == -1)
|
||||
int result = system(("open \"" + path + "\"").c_str()); // TODO: Test on macOS
|
||||
if (result != 0)
|
||||
{
|
||||
GetLogger()->Error("Failed to open path: %s\n", path.c_str());
|
||||
GetLogger()->Error("Failed to open path: %s, error code: %i\n", path.c_str(), result);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSystemUtilsLinux::OpenWebsite(std::string website)
|
||||
bool CSystemUtilsMacOSX::OpenWebsite(const std::string& url)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = system(("open \""+website+"\"").c_str()); // TODO: Test on macOS
|
||||
if (result == -1)
|
||||
int result = system(("open \"" + url + "\"").c_str()); // TODO: Test on macOS
|
||||
if (result != 0)
|
||||
{
|
||||
GetLogger()->Error("Failed to open website: %s\n", website.c_str());
|
||||
GetLogger()->Error("Failed to open website: %s, error code: %i\n", website.c_str(), result);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSystemUtilsMacOSX::Usleep(int usec)
|
||||
|
|
|
@ -38,8 +38,8 @@ public:
|
|||
|
||||
std::string GetEnvVar(const std::string& name) override;
|
||||
|
||||
void OpenPath(std::string path) override;
|
||||
void OpenWebsite(std::string website) override;
|
||||
bool OpenPath(const std::string& path) override;
|
||||
bool OpenWebsite(const std::string& url) override;
|
||||
|
||||
void Usleep(int usec) override;
|
||||
|
||||
|
|
|
@ -44,16 +44,6 @@ long long int CSystemUtilsOther::TimeStampExactDiff(SystemTimeStamp* before, Sys
|
|||
return (after->sdlTicks - before->sdlTicks) * 1000000ll;
|
||||
}
|
||||
|
||||
void CSystemUtilsOther::OpenPath(std::string path)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CSystemUtilsOther::OpenWebsite(std::string website)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CSystemUtilsOther::Usleep(int usec)
|
||||
{
|
||||
SDL_Delay(usec / 1000); // close enough
|
||||
|
|
|
@ -50,9 +50,6 @@ public:
|
|||
void GetCurrentTimeStamp(SystemTimeStamp *stamp) override;
|
||||
long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
|
||||
|
||||
void OpenPath(std::string path) override;
|
||||
void OpenWebsite(std::string website) override;
|
||||
|
||||
void Usleep(int usec) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "common/logger.h"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
@ -152,26 +153,26 @@ std::string CSystemUtilsWindows::GetEnvVar(const std::string& name)
|
|||
}
|
||||
}
|
||||
|
||||
void CSystemUtilsWindows::OpenPath(std::string path)
|
||||
bool CSystemUtilsWindows::OpenPath(const std::string& path)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = system(("explorer \""+path+"\"").c_str()); // TODO: Test on macOS
|
||||
if (result == -1)
|
||||
int result = system(("start explorer \"" + boost::filesystem::path(path).make_preferred().string() + "\"").c_str());
|
||||
if (result != 0)
|
||||
{
|
||||
GetLogger()->Error("Failed to open path: %s\n", path.c_str());
|
||||
GetLogger()->Error("Failed to open path: %s, error code: %i\n", path.c_str(), result);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSystemUtilsWindows::OpenWebsite(std::string website)
|
||||
bool CSystemUtilsWindows::OpenWebsite(const std::string& url)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = system(("rundll32 url.dll,FileProtocolHandler \""+website+"\"").c_str()); // TODO: Test on macOS
|
||||
if (result == -1)
|
||||
int result = system(("rundll32 url.dll,FileProtocolHandler \"" + url + "\"").c_str());
|
||||
if (result != 0)
|
||||
{
|
||||
GetLogger()->Error("Failed to open website: %s\n", website.c_str());
|
||||
GetLogger()->Error("Failed to open website: %s, error code: %i\n", url.c_str(), result);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSystemUtilsWindows::Usleep(int usec)
|
||||
|
|
|
@ -46,8 +46,8 @@ public:
|
|||
|
||||
std::string GetEnvVar(const std::string& name) override;
|
||||
|
||||
void OpenPath(std::string path) override;
|
||||
void OpenWebsite(std::string website) override;
|
||||
bool OpenPath(const std::string& path) override;
|
||||
bool OpenWebsite(const std::string& url) override;
|
||||
|
||||
void Usleep(int usec) override;
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ CMainUserInterface::CMainUserInterface()
|
|||
m_screenSetupDisplay = MakeUnique<CScreenSetupDisplay>();
|
||||
m_screenSetupGame = MakeUnique<CScreenSetupGame>();
|
||||
m_screenSetupGraphics = MakeUnique<CScreenSetupGraphics>();
|
||||
m_screenSetupMods = MakeUnique<CScreenSetupMods>();
|
||||
m_screenSetupMods = MakeUnique<CScreenSetupMods>(m_dialog.get());
|
||||
m_screenSetupSound = MakeUnique<CScreenSetupSound>();
|
||||
m_screenMainMenu = MakeUnique<CScreenMainMenu>();
|
||||
m_screenPlayerSelect = MakeUnique<CScreenPlayerSelect>(m_dialog.get());
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "common/config.h"
|
||||
#include "common/logger.h"
|
||||
#include "common/settings.h"
|
||||
#include "common/stringutils.h"
|
||||
|
||||
#include "common/resources/resourcemanager.h"
|
||||
#include "level/parser/parser.h"
|
||||
|
@ -48,7 +49,8 @@ using namespace boost::filesystem;
|
|||
namespace Ui
|
||||
{
|
||||
|
||||
CScreenSetupMods::CScreenSetupMods()
|
||||
CScreenSetupMods::CScreenSetupMods(CMainDialog* mainDialog)
|
||||
: m_dialog(mainDialog)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -131,7 +133,9 @@ bool CScreenSetupMods::EventProcess(const Event &event)
|
|||
CWindow* pw;
|
||||
CButton* pb;
|
||||
CList* pl;
|
||||
std::string modName, modPath, website = "https://www.moddb.com/games/colobot-gold-edition";
|
||||
std::string modName;
|
||||
const std::string website = "https://www.moddb.com/games/colobot-gold-edition";
|
||||
const std::string modDir = CResourceManager::GetSaveLocation() + "/" + "mods";
|
||||
auto systemUtils = CSystemUtils::Create(); // platform-specific utils
|
||||
|
||||
if (!CScreenSetup::EventProcess(event)) return false;
|
||||
|
@ -139,33 +143,28 @@ bool CScreenSetupMods::EventProcess(const Event &event)
|
|||
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
|
||||
if ( pw == nullptr ) return false;
|
||||
|
||||
if (event.type == EVENT_INTERFACE_LOAD)
|
||||
{
|
||||
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_MODS_UNLOADED));
|
||||
if ( pl == nullptr ) return false;
|
||||
modName = pl->GetItemName(pl->GetSelect());
|
||||
LoadMod(modName);
|
||||
|
||||
m_app->Reload();
|
||||
m_main->ChangePhase(PHASE_SETUPm);
|
||||
}
|
||||
if (event.type == EVENT_INTERFACE_UNLOAD)
|
||||
{
|
||||
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_MODS_LOADED));
|
||||
if ( pl == nullptr ) return false;
|
||||
modName = pl->GetItemName(pl->GetSelect());
|
||||
UnloadMod(modName);
|
||||
|
||||
m_app->Reload();
|
||||
m_main->ChangePhase(PHASE_SETUPm);
|
||||
}
|
||||
if (event.type == EVENT_INTERFACE_MODS_DIR)
|
||||
{
|
||||
modPath = CResourceManager::GetSaveLocation() + "/" + "mods";
|
||||
systemUtils->OpenPath(modPath);
|
||||
}
|
||||
switch (event.type)
|
||||
{
|
||||
case EVENT_INTERFACE_LOAD:
|
||||
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_MODS_UNLOADED));
|
||||
if (pl == nullptr) return false;
|
||||
modName = pl->GetItemName(pl->GetSelect());
|
||||
LoadMod(modName);
|
||||
|
||||
m_app->Reload();
|
||||
m_main->ChangePhase(PHASE_SETUPm);
|
||||
break;
|
||||
|
||||
case EVENT_INTERFACE_UNLOAD:
|
||||
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_MODS_LOADED));
|
||||
if (pl == nullptr) return false;
|
||||
modName = pl->GetItemName(pl->GetSelect());
|
||||
UnloadMod(modName);
|
||||
|
||||
m_app->Reload();
|
||||
m_main->ChangePhase(PHASE_SETUPm);
|
||||
break;
|
||||
|
||||
case EVENT_INTERFACE_MODS_UNLOADED:
|
||||
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_MODS_LOADED));
|
||||
if ( pl == nullptr ) break;
|
||||
|
@ -194,9 +193,31 @@ bool CScreenSetupMods::EventProcess(const Event &event)
|
|||
pb->SetState(STATE_ENABLE);
|
||||
break;
|
||||
|
||||
case EVENT_INTERFACE_WORKSHOP:
|
||||
systemUtils->OpenWebsite(website);
|
||||
case EVENT_INTERFACE_MODS_DIR:
|
||||
if (!systemUtils->OpenPath(modDir))
|
||||
{
|
||||
std::string title, text;
|
||||
GetResource(RES_TEXT, RT_DIALOG_OPEN_PATH_FAILED_TITLE, title);
|
||||
GetResource(RES_TEXT, RT_DIALOG_OPEN_PATH_FAILED_TEXT, text);
|
||||
|
||||
// Workaround for how labels treat the \\ character on Windows
|
||||
std::string modDirWithoutBackSlashes = modDir;
|
||||
std::replace(modDirWithoutBackSlashes.begin(), modDirWithoutBackSlashes.end(), '\\', '/');
|
||||
|
||||
m_dialog->StartInformation(title, title, StrUtils::Format(text.c_str(), modDirWithoutBackSlashes.c_str()));
|
||||
}
|
||||
break;
|
||||
|
||||
case EVENT_INTERFACE_WORKSHOP:
|
||||
if (!systemUtils->OpenWebsite(website))
|
||||
{
|
||||
std::string title, text;
|
||||
GetResource(RES_TEXT, RT_DIALOG_OPEN_WEBSITE_FAILED_TITLE, title);
|
||||
GetResource(RES_TEXT, RT_DIALOG_OPEN_WEBSITE_FAILED_TEXT, text);
|
||||
m_dialog->StartInformation(title, title, StrUtils::Format(text.c_str(), website.c_str()));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "ui/maindialog.h"
|
||||
#include "ui/screen/screen_setup.h"
|
||||
|
||||
#include <vector>
|
||||
|
@ -31,7 +32,7 @@ namespace Ui
|
|||
class CScreenSetupMods : public CScreenSetup
|
||||
{
|
||||
public:
|
||||
CScreenSetupMods();
|
||||
CScreenSetupMods(CMainDialog* mainDialog);
|
||||
void SetActive() override;
|
||||
|
||||
void CreateInterface() override;
|
||||
|
@ -44,6 +45,8 @@ protected:
|
|||
void UpdateLoadedModList();
|
||||
|
||||
protected:
|
||||
CMainDialog* m_dialog;
|
||||
|
||||
CPathManager* m_pathManager;
|
||||
std::vector<std::string> m_unloadedModList;
|
||||
std::vector<std::string> m_loadedModList;
|
||||
|
|
Loading…
Reference in New Issue