Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bin/languageLauncher-en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ startINIMH = "Settings: Multiplayer Hub "
startDOC = "Documentation "
user = "Open user folder "
leave = "Exit "
copy = "Copy"
copyUserFolder = "Do you want to copy\nscenarios and settings\nfrom the previous version?"
2 changes: 2 additions & 0 deletions bin/languageLauncher-es.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ startINIMH = "Configuración: Hub multijugador "
startDOC = "Manuales "
user = "Carpeta del usuario "
leave = "Salir "
copy = "Copiar"
copyUserFolder = "¿Desea copiar los escenario\ny la configuración de la\nversión anterior?"
2 changes: 2 additions & 0 deletions bin/languageLauncher-fr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ startINIMH = "Paramètres : Hub multijoueurs "
startDOC = "Documentation "
user = "Ouvrir le répertoire utilisateur "
leave = "Quitter "
copy = "Copier"
copyUserFolder = "Souhaitez-vous copier les\nscénarios et les paramètres\ndel la version précédente?"
1 change: 1 addition & 0 deletions src/Constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const irr::f32 RAD_PER_S_IN_DEG_PER_MINUTE = 180.0/PI * 60 ;

//general definitions
const std::string LONGNAME = "Bridge Command 5.11.0-alpha.1";
const std::string PREV_VERSION = "5.10";
const std::string VERSION = "5.11";
const std::string LONGVERSION = "5.11.0-alpha.1";
#endif
61 changes: 36 additions & 25 deletions src/Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,9 @@
#include <windows.h>
#include <Shellapi.h>
#else // _WIN32
#ifdef __APPLE__
#include <copyfile.h>
#include <sys/stat.h>
#else
#include <dirent.h>
#include <sys/stat.h>
#include <fstream>
#endif
#endif // __APPLE__

namespace Utilities
Expand Down Expand Up @@ -225,6 +220,18 @@ namespace Utilities
return userFolder;
}

std::string getPrevUserDir() {
std::string userFolder = getUserDirBase();

if (userFolder.length() > 0) {
userFolder.append(PREV_VERSION);
userFolder.append("/");
}

return userFolder;
}


bool pathExists(std::string filePath) {

if (filePath.empty()) {
Expand All @@ -249,6 +256,10 @@ namespace Utilities
int copyDir(std::string source, std::string dest)
{

if (source.empty() || dest.empty()) {
return -1;
}

//Copy contents of source dir into dest dir

#ifdef _WIN32
Expand All @@ -265,19 +276,22 @@ namespace Utilities

return SHFileOperation(&fileOp);
#else
#ifdef __APPLE__
//Apple version: Requires that dest dir exists
copyfile_state_t s;
s = copyfile_state_alloc();
//use copyfile here to do recursive copy
int returnValue = copyfile(source.c_str(), dest.c_str(), s, COPYFILE_DATA | COPYFILE_RECURSIVE);
copyfile_state_free(s);
return returnValue;
#else // __APPLE__
//Other posix
//Note: Not implemented yet for other posix: need to implement recursive directory copy.
// Strip trailing slash if present
if (dest.back() == '/') {
dest.pop_back();
}
if (source.back() == '/') {
source.pop_back();
}

// Try to make dest dir if it doesn't exist.
// Won't help if the parent doesn't exist, but will help in many cases
if (!pathExists(dest)) {
mkdir(dest.c_str(), 0755);
}

//Requires that dest dir exists
//std::cout << "Copying from:" << source << " to:" << dest << std::endl;
std::cout << "Copying dir from:" << source << " to:" << dest << std::endl;
if (!Utilities::pathExists(dest)) {
return -1;
}
Expand All @@ -290,7 +304,7 @@ namespace Utilities
if (entry->d_type == DT_DIR && entry->d_name[0] != '.') {
std::string newDir = dest;

newDir.append(source);
//newDir.append(source);
newDir.append("/");
newDir.append(entry->d_name);
//newDir.append("/");
Expand All @@ -303,9 +317,7 @@ namespace Utilities
fromDir.append("/");
fromDir.append(entry->d_name);

std::string toDir = dest;

copyDir(fromDir, toDir);
copyDir(fromDir, newDir);
}
else {
return -1;
Expand All @@ -315,7 +327,7 @@ namespace Utilities
//Copy file
//entry->d_name;
std::string newFile = dest;
newFile.append(source);
//newFile.append(source);
newFile.append("/");
newFile.append(entry->d_name);

Expand All @@ -327,6 +339,7 @@ namespace Utilities

std::ifstream fromStream(fromFile.c_str(), std::ios::binary);
std::ofstream destStream(newFile.c_str(), std::ios::binary);
std::cout << "Copying from " << fromFile << " to " << newFile << std::endl;
if (fromStream && destStream) {
destStream << fromStream.rdbuf();
}
Expand All @@ -338,11 +351,9 @@ namespace Utilities

//For each file at root level, create the file and copy contents


#endif // __APPLE__
#endif // _WIN32

return -1;
return 0;
}

ScenarioData getScenarioDataFromFile(std::string scenarioPath, std::string scenarioName) //Read a scenario from ini files
Expand Down
1 change: 1 addition & 0 deletions src/Utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace Utilities
std::vector<std::string> split(const std::string &inputString, char delim);
std::string getUserDirBase(); //Returns the directory path (absolute, with trailing slash) for a user read/writable directory, the first level folder in the user's filesystem (eg %appdata%/Bridge Command/ on windows)
std::string getUserDir(); //Returns the directory path (absolute, with trailing slash) for a user read/writable directory (eg %appdata%/Bridge Command/VERSIONUMBER/ on windows)
std::string getPrevUserDir(); // Returns the same a getUserDir, but for the previous program version
bool pathExists(std::string filePath);
int copyDir(std::string source, std::string dest);
ScenarioData getScenarioDataFromFile(std::string scenarioPath, std::string scenarioName); //Read a scenario from ini files
Expand Down
7 changes: 2 additions & 5 deletions src/editor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ void checkUserScenarioDir(void)

if (!Utilities::pathExists(userFolder + scenarioPath)) {

#ifdef _WIN32
std::cout << "Copying scenario files into " << userFolder + scenarioPath << std::endl;
#ifdef _WIN32
Utilities::copyDir("Scenarios", userFolder + scenarioPath);
#else
//Make sure destination folder for scenarios exists. Not needed on windows as the copy method creates the output folder and directories above it.
Expand All @@ -281,11 +281,8 @@ void checkUserScenarioDir(void)
std::string pathToMake = Utilities::getUserDir() + "Scenarios";
mkdir(pathToMake.c_str(),0755);
}
std::cout << "Copying scenario files into " << userFolder << std::endl;
Utilities::copyDir("Scenarios", userFolder);
Utilities::copyDir("Scenarios", userFolder + scenarioPath);
#endif // __APPLE__


}
}

Expand Down
35 changes: 28 additions & 7 deletions src/iniEditor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ int main (int argc, char ** argv)
iniFilename = "repeater.ini";
}

bool autoMode = false;
if (((argc > 1) && (strcmp(argv[1], "-auto") == 0)) ||
((argc > 2) && (strcmp(argv[2], "-auto") == 0))) {
autoMode = true;
}

//Mac OS:
//Find starting folder
#ifdef __APPLE__
Expand Down Expand Up @@ -388,16 +394,25 @@ int main (int argc, char ** argv)
}
}

//If not, find the corresponding tab, or fall back to the first tab
//If not, find the corresponding tab, or add a new tab and add there
if (!found) {
//Add to corresponding tab
int whichTab = 0;
int whichTab = -1;
for (int i = 0; i < iniFileStructure.size(); i++) {
if (currentTabName.compare(iniFileStructure.at(i).tabName) == 0) {
whichTab = i;
}
}
iniFileStructure.at(whichTab).settings.push_back(thisEntry);
if (whichTab < 0) {
// Tab not found, create a new one
IniFileTab newTab;
newTab.tabName = currentTabName;
newTab.settings.push_back(thisEntry);
iniFileStructure.push_back(newTab);
} else {
// Found existing tab, use this
iniFileStructure.at(whichTab).settings.push_back(thisEntry);
}
}

}
Expand Down Expand Up @@ -525,10 +540,16 @@ int main (int argc, char ** argv)
Receiver receiver(device, environment, tabbedPane, iniFilename);
device->setEventReceiver(&receiver);

while (device->run()) {
driver->beginScene();
device->getGUIEnvironment()->drawAll();
driver->endScene();
if (autoMode) {
// Automatically save and close. This mode is used to ensure we have user settings file updated with any new global ini settings
saveFile(device, iniFilename, tabbedPane);
}
else {
while (device->run()) {
driver->beginScene();
device->getGUIEnvironment()->drawAll();
driver->endScene();
}
}
return(0);
}
Loading
Loading