diff --git a/CMakeLists.txt b/CMakeLists.txt index e7db5d55..f9b81bee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,53 +1,86 @@ # Settings passed on the command line: # -# PROJECT_LIBS_DIR = the directory which all external libraries may be referenced from. # PROJECT_ARCH = the build architecture -# PROJECT_LINK = whether to build a static or dynamic library. +# LIBESPM_ROOT = the path to the root of the libespm source. ############################## # General Settings ############################## cmake_minimum_required (VERSION 2.8.9) -project (boss) +project (LOOT) -set (BOSS_SRC "${CMAKE_SOURCE_DIR}/src/backend/metadata.cpp" +option(BUILD_SHARED_LIBS "Build a shared library" OFF) +option(PROJECT_STATIC_RUNTIME "Build with static runtime libs (/MT)" ON) + +IF (NOT DEFINED PROJECT_ARCH) + set (PROJECT_ARCH "32") +ENDIF () + +IF (NOT DEFINED ALPHANUM_ROOT) + set (ALPHANUM_ROOT "../../alphanum") +ENDIF () + +IF (NOT DEFINED LIBESPM_ROOT) + set (LIBESPM_ROOT "../../libespm") +ENDIF () + +IF (NOT DEFINED LIBGIT2_ROOT) + set (LIBGIT2_ROOT "../../libgit2") +ENDIF () + +IF (NOT DEFINED LIBLOADORDER_ROOT) + set (LIBLOADORDER_ROOT "../../libloadorder") +ENDIF () + +IF (NOT DEFINED YAMLCPP_ROOT) + set (YAMLCPP_ROOT "../../yaml-cpp") +ENDIF () + +IF (NOT DEFINED CEF_ROOT) + set (CEF_ROOT "../../cef") +ENDIF () + +set (Boost_USE_STATIC_LIBS ON) +set (Boost_USE_MULTITHREADED ON) +set (Boost_USE_STATIC_RUNTIME PROJECT_STATIC_RUNTIME) + +set (LOOT_SRC "${CMAKE_SOURCE_DIR}/src/backend/metadata.cpp" "${CMAKE_SOURCE_DIR}/src/backend/game.cpp" "${CMAKE_SOURCE_DIR}/src/backend/helpers.cpp" - "${CMAKE_SOURCE_DIR}/src/backend/network.cpp" "${CMAKE_SOURCE_DIR}/src/backend/globals.cpp" - "${CMAKE_SOURCE_DIR}/src/backend/graph.cpp" - "${PROJECT_LIBS_DIR}/pugixml/src/pugixml.cpp") + "${CMAKE_SOURCE_DIR}/src/backend/generators.cpp" + "${CMAKE_SOURCE_DIR}/src/backend/graph.cpp") -set (BOSS_GUI_SRC ${BOSS_SRC} - "${CMAKE_SOURCE_DIR}/src/gui/ids.cpp" - "${CMAKE_SOURCE_DIR}/src/gui/main.cpp" - "${CMAKE_SOURCE_DIR}/src/gui/settings.cpp" - "${CMAKE_SOURCE_DIR}/src/gui/editor.cpp" - "${CMAKE_SOURCE_DIR}/src/gui/viewer.cpp" - "${CMAKE_SOURCE_DIR}/src/gui/misc.cpp" +set (LOOT_GUI_SRC ${LOOT_SRC} + # Code the API doesn't need. + "${CMAKE_SOURCE_DIR}/src/backend/git.cpp" + # Actual GUI code. + "${CMAKE_SOURCE_DIR}/src/gui/main_win.cpp" + "${CMAKE_SOURCE_DIR}/src/gui/handler.cpp" + "${CMAKE_SOURCE_DIR}/src/gui/app.cpp" "${CMAKE_SOURCE_DIR}/src/resource.rc") -set (BOSS_API_SRC ${BOSS_SRC} +set (LOOT_API_SRC ${LOOT_SRC} "${CMAKE_SOURCE_DIR}/src/api/api.cpp") +find_package(Boost REQUIRED COMPONENTS log log_setup locale thread chrono date_time filesystem system regex iostreams) + # Include source and library directories. include_directories ("${CMAKE_SOURCE_DIR}/src" - "${PROJECT_LIBS_DIR}/alphanum" - "${PROJECT_LIBS_DIR}/boost" - "${PROJECT_LIBS_DIR}/yaml-cpp/include" - "${PROJECT_LIBS_DIR}/libloadorder/src" - "${PROJECT_LIBS_DIR}/libespm" - "${PROJECT_LIBS_DIR}/zlib" - "${PROJECT_LIBS_DIR}/pugixml/src" - "${PROJECT_LIBS_DIR}/libgit2/include" - "${PROJECT_LIBS_DIR}/wxWidgets/include") + ${ALPHANUM_ROOT} + "${YAMLCPP_ROOT}/include" + "${LIBLOADORDER_ROOT}/src" + "${LIBGIT2_ROOT}/include" + ${CEF_ROOT} + ${LIBESPM_ROOT} + ${Boost_INCLUDE_DIRS}) -link_directories ("${PROJECT_LIBS_DIR}/libloadorder/build" - "${PROJECT_LIBS_DIR}/zlib/build" - "${PROJECT_LIBS_DIR}/libgit2/build" - "${PROJECT_LIBS_DIR}/yaml-cpp/build" - "${PROJECT_LIBS_DIR}/boost/stage-${PROJECT_ARCH}/lib") +link_directories ("${LIBLOADORDER_ROOT}/build" + "${LIBGIT2_ROOT}/build" + "${YAMLCPP_ROOT}/build" + "${CEF_ROOT}/Release" + "${CEF_ROOT}/out/Release/lib") ############################## @@ -57,24 +90,21 @@ link_directories ("${PROJECT_LIBS_DIR}/libloadorder/build" # Settings when compiling for Windows. Since it's a Windows-only app this is always true, but useful to check for copy/paste into other projects. IF (CMAKE_SYSTEM_NAME MATCHES "Windows") add_definitions (-DUNICODE -D_UNICODE -D__WXMSW__ -DNDEBUG -DLIBLO_STATIC -DWIN32 -D_WINDOWS) - IF (${PROJECT_LINK} MATCHES "STATIC") - add_definitions (-DBOSS_STATIC) + IF (BUILD_SHARED_LIBS) + add_definitions (-DLOOT_EXPORT) ELSE () - add_definitions (-DBOSS_EXPORT) + add_definitions (-DLOOT_STATIC) ENDIF () ENDIF () # MinGW settings. IF (MINGW) - include_directories("${PROJECT_LIBS_DIR}/wxWidgets/lib/wx/include/${COMPILER_PREFIX}-msw-unicode-static-3.0") - link_directories("${PROJECT_LIBS_DIR}/openssl" - "${PROJECT_LIBS_DIR}/wxWidgets/lib") set (CMAKE_C_FLAGS "-m${PROJECT_ARCH} -O3") set (CMAKE_CXX_FLAGS "-m${PROJECT_ARCH} -O3") set (CMAKE_EXE_LINKER_FLAGS "-static-libstdc++ -static-libgcc -Wl,--subsystem,windows") set (CMAKE_SHARED_LINKER_FLAGS "-static-libstdc++ -static-libgcc -Wl,--subsystem,windows") set (CMAKE_MODULE_LINKER_FLAGS "-static-libstdc++ -static-libgcc -Wl,--subsystem,windows") - set (BOSS_LIBS ${BOSS_LIBS} + set (LOOT_LIBS ${LOOT_LIBS} yaml-cpp boost_log_setup boost_log @@ -86,52 +116,44 @@ IF (MINGW) boost_system boost_regex version - git2 - zlibstatic loadorder${PROJECT_ARCH} ssl crypto ws2_32) - set (BOSS_GUI_LIBS ${BOSS_LIBS} - wx_mswu_webview-3.0-${COMPILER_PREFIX} - wx_mswu_core-3.0-${COMPILER_PREFIX} - wx_baseu-3.0-${COMPILER_PREFIX} - wx_mswu_adv-3.0-${COMPILER_PREFIX} - wxpng-3.0-${COMPILER_PREFIX} - wxzlib-3.0-${COMPILER_PREFIX} + set (LOOT_GUI_LIBS ${LOOT_LIBS} + git2 + cef_sandbox + libcef + libcef_dll_wrapper + rpcrt4 + shlwapi comctl32) ELSEIF (MSVC) - IF (MSVC_VERSION EQUAL 1800) - set (CMAKE_GENERATOR_TOOLSET "v120_xp" CACHE STRING "Platform Toolset" FORCE) + + # Force static C++ runtime linkage. + IF (PROJECT_STATIC_RUNTIME) + FOREACH(flag + CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT + CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT) + STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}") + SET("${flag}" "${${flag}} /EHsc") + ENDFOREACH() ENDIF () - include_directories("${PROJECT_LIBS_DIR}/wxWidgets/lib/vc_lib/mswu") - link_directories("${PROJECT_LIBS_DIR}/wxWidgets/lib/vc_lib") - set (CMAKE_CXX_FLAGS "/EHsc") - set (CMAKE_EXE_LINKER_FLAGS "/SUBSYSTEM:WINDOWS") - set (BOOST_SUFFIX "-vc120-mt-1_55") - set (BOSS_LIBS ${BOSS_LIBS} - libyaml-cppmd - libboost_log_setup${BOOST_SUFFIX} - libboost_log${BOOST_SUFFIX} - libboost_locale${BOOST_SUFFIX} - libboost_thread${BOOST_SUFFIX} - libboost_chrono${BOOST_SUFFIX} - libboost_date_time${BOOST_SUFFIX} - libboost_filesystem${BOOST_SUFFIX} - libboost_system${BOOST_SUFFIX} - libboost_regex${BOOST_SUFFIX} + + set (CMAKE_EXE_LINKER_FLAGS "/SUBSYSTEM:WINDOWS /LARGEADDRESSAWARE") + set (LOOT_LIBS libyaml-cppmt version - git2 - zlibstatic loadorder${PROJECT_ARCH} ws2_32) - set (BOSS_GUI_LIBS ${BOSS_LIBS} - wxmsw30u_webview - wxmsw30u_adv - wxmsw30u_core - wxbase30u - wxpng - wxzlib + set (LOOT_GUI_LIBS ${LOOT_LIBS} + git2 + cef_sandbox + libcef + libcef_dll_wrapper + rpcrt4 + shlwapi comctl32) ENDIF () @@ -141,14 +163,25 @@ ENDIF () ############################## # Build API. -add_library (boss${PROJECT_ARCH} ${PROJECT_LINK} ${BOSS_API_SRC}) -target_link_libraries (boss${PROJECT_ARCH} ${BOSS_LIBS}) +add_library (loot${PROJECT_ARCH} ${LOOT_API_SRC}) +target_link_libraries (loot${PROJECT_ARCH} ${Boost_LIBRARIES} ${LOOT_LIBS}) # Build application. -add_executable (BOSS ${BOSS_GUI_SRC}) -target_link_libraries (BOSS ${BOSS_GUI_LIBS}) +add_executable (LOOT ${LOOT_GUI_SRC}) +target_link_libraries (LOOT ${Boost_LIBRARIES} ${LOOT_GUI_LIBS}) -# Build converter. -add_executable (masterlist-converter ${BOSS_SRC} "${CMAKE_SOURCE_DIR}/src/converter.cpp") -target_link_libraries (masterlist-converter ${BOSS_LIBS}) +# Copy CEF DLLs. +FOREACH(cef_dll d3dcompiler_43.dll d3dcompiler_46.dll libEGL.dll libGLESv2.dll libcef.dll) + add_custom_command(TARGET LOOT POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_SOURCE_DIR}/${CEF_ROOT}/$/${cef_dll}" + $) +ENDFOREACH() +# Copy CEF resources. +FOREACH(cef_resource cef.pak cef_100_percent.pak cef_200_percent.pak devtools_resources.pak icudtl.dat) + add_custom_command(TARGET LOOT POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_SOURCE_DIR}/${CEF_ROOT}/Resources/${cef_resource}" + $) +ENDFOREACH() diff --git a/README.md b/README.md index 56e0f83b..45f4d919 100644 --- a/README.md +++ b/README.md @@ -1,87 +1,43 @@ -# BOSSv3 +# LOOT ## Introduction -BOSS is a plugin load order optimiser for TES IV: Oblivion, TES V: Skyrim, Fallout 3 and Fallout: New Vegas. It is designed to assist mod users in avoiding detrimental conflicts, by automatically calculating a load order that satisfies all plugin dependencies and maximises each plugin's impact on the user's game. +LOOT is a plugin load order optimiser for TES IV: Oblivion, TES V: Skyrim, Fallout 3 and Fallout: New Vegas. It is designed to assist mod users in avoiding detrimental conflicts, by automatically calculating a load order that satisfies all plugin dependencies and maximises each plugin's impact on the user's game. -BOSS also provides some load order error checking, including checks for requirements, incompatibilities and cyclic dependencies. In addition, it provides a large number of plugin-specific usage notes, bug wawrnings and Bash Tag suggestions. +LOOT also provides some load order error checking, including checks for requirements, incompatibilities and cyclic dependencies. In addition, it provides a large number of plugin-specific usage notes, bug warnings and Bash Tag suggestions. -Although BOSS is able to calculate the correct load order positions for the vast majority of mods without any user input, some plugins are designed to load at certain positions in a load order, and BOSS may be unable to determine this from the plugins themselves. As such, BOSS provides a mechanism for supplying additional plugin metadata so that it may sort them correctly. +Although LOOT is able to calculate the correct load order positions for the vast majority of mods without any user input, some plugins are designed to load at certain positions in a load order, and LOOT may be unable to determine this from the plugins themselves. As such, LOOT provides a mechanism for supplying additional plugin metadata so that it may sort them correctly. -BOSS is intended to make using mods easier, and mod users should still possess a working knowledge of mod load ordering. See the "Introduction To Load Orders" section of the BOSS readme for an overview. +LOOT is intended to make using mods easier, and mod users should still possess a working knowledge of mod load ordering. See the "Introduction To Load Orders" section of the LOOT readme for an overview. -## Downloading BOSS +## Building LOOT -At the moment, BOSSv3 is in beta testing, and so is not recommended for use unless for testing purposes. The load orders it produces should not be used in-game unless found to be valid by manual checking beforehand. Any releases can be found by clicking on the releases button above the coloured bar on the repository homepage. - - -## About This Repository - -This repository holds the source code and documentation for BOSS v3. The masterlists for v3 are stored in separate repostories on [GitHub](https://github.com/boss-developers). The source code, documentation and masterlists for previous versions of BOSS are stored on [Google Code](http://code.google.com/p/better-oblivion-sorting-software/). - - -## Building BOSS - -BOSS uses [CMake](http://cmake.org) v2.8.9 or later for cross-platform building support, as though it is a Windows application, development has taken place on Windows and Linux. - -BOSS requires the following libraries (version numbers used in latest development revision given): +LOOT uses [CMake](http://cmake.org) to generate build files, and requires the following libraries (version numbers used in latest development revision given): * [Alphanum](http://www.davekoelle.com/files/alphanum.hpp) -* [Boost](http://www.boost.org) v1.55.0. +* [Boost](http://www.boost.org) v1.56.0 +* [Chromium Embedded Framework](https://code.google.com/p/chromiumembedded/) branch 2062 * [Libespm](http://github.com/WrinklyNinja/libespm) -* [Libgit2](https://github.com/libgit2) v0.20.0. +* [Libgit2](http://libgit2.github.com/) v0.21.1 * [Libloadorder](http://github.com/WrinklyNinja/libloadorder) -* [OpenSSL](https://www.openssl.org) - only if HTTPS support in libgit2 is required using compilers other than MSVC. -* [PugiXML](http://code.google.com/p/pugixml/) v1.2. -* [wxWidgets](http://www.wxwidgets.org) v3.0.0. -* [yaml-cpp](http://github.com/WrinklyNinja/yaml-cpp). -* [zlib](http://zlib.net) v1.2.8. +* [yaml-cpp](http://github.com/WrinklyNinja/yaml-cpp) -BOSS expects all libraries' folders to be present alongside the BOSS repository folder that contains this readme, or otherwise installed such that the compiler and linker used can find them without suppling additional paths. All paths below are relative to the folder(s) containing the libraries and BOSS. +Alphanum and Libespm do not require any additional setup. The rest of the libraries must be built separately. Instructions for building them and LOOT itself using MSVC or MinGW are given in [docs/BUILD.MSVC.md](docs/BUILD.MSVC.md) and [docs/BUILD.MinGW.md](docs/BUILD.MinGW.md) respectively. -Alphanum, Libespm and PugiXML do not require any additional setup. The rest of the libraries must be built separately. Instructions for building them and BOSS itself using MSVC or MinGW are given in `docs/BUILD.MSVC.md` and `docs/BUILD.MinGW.md` respectively. - - -## Using The Masterlist Converter - -The masterlist converter is a command line utility that takes two optional command line arguments: - -``` -masterlist-converter.exe [v2 masterlist input file] [v3 masterlist output file] -``` - -If only one argument is given, or if no arguments are given, the converter assumes it was called as - -``` -masterlist-converter.exe masterlist.txt masterlist.yaml -``` - -On encountering an error, it will print an error message to the console, and will not output a v3 masterlist. - -The converter does not perform a lossless conversion. The following do not get transferred into the new masterlist: - -* Silent comments. (Search regex: `^(/\*|//)`) -* Plugin conditions. (Search regex: `^IF(NOT)?.+MOD:`) -* Requirement messages containing plugin filenames. (Search regex: `REQ:.+(\.esp|\.esm)`) -* Dirty message content. The ITM, UDR and Navmesh counts, along with CRCs and the dirty utility referenced are transferred, but any additional content, such as links to additional instructions, are lost. (Search regex: `DIRTY:`.) - -In addition, while other data is retained, it needs some manual adjustment, eg. translated messages need are converted as separate messages and should be placed into message content objects. +Although LOOT uses a cross-platform build system and cross-platform libraries, it does rely on some Windows API functionality. Anyone wishing to port LOOT to other platforms will need to ensure equivalent functionality is implemented for their target platform. The Windows API code is wrapped in `#ifdef _WIN32` blocks so that it can be easily identified. ## Packaging Releases -Installer and zip archive releases for the main BOSS application can be handled by running the scripts `installer.nsi` and `archive.py` in the `src` folder respectively. The installer script requires [NSIS 3](http://nsis.sourceforge.net/Main_Page) to be installed, while the archive script requires [Python](http://www.python.org/) to be installed. +Installer and zip archive releases for the main LOOT application can be handled by running the scripts `installer.nsi` and `archive.py` in the `src` folder respectively. The installer script requires [Unicode NSIS](http://www.scratchpaper.com/), while the archive script requires [Python](http://www.python.org/). -The installer and Python script both require the built BOSS.exe to be at `build\BOSS.exe`, and the installer also requires the MSVC 2013 Redistributable (x86) to be at `build\vcredist_x86.exe`. +## Adding Translations -## Adding Translations To BOSS +If a translation for a new language is provided, here's what needs changing to make LOOT use that translation. -If a translation for a new language is provided, here's what needs changing in the code to make BOSS use that translation. - -* Add constants for the language in `api.h` and `globals.h`. -* In `helpers.cpp`, update `Language::Language(const std::string& nameOrISOCode)` and `Language::Construct(const unsigned int code). -* In `helpers.h`, update `Language::Names()`. -* In `main.cpp`, update `BossGUI::OnInit` to set the correct `wxLANGUAGE_`. -* In `archive.py`, add the language folder to the inline list on line 68. -* In `installer.nsi`, add entries for the language folder to the install and uninstall sections. If there's an installer translation, also add its string definitions beside all the other language string definitions, and insert its macro beside all the other language macros. +* In [helpers.h](src/backend/helpers.h), add a constant for the language to the `Language` class, and update `Language::Names()`. +* In [helpers.cpp](src/backend/helpers.cpp), update `Language::Language(const std::string& nameOrCode)` and `Language::Construct(const unsigned int code)`. +* Add constants for the language in [api.h](src/api/api.h) and [api.cpp](src/api/api.cpp). +* In [archive.py](src/archive.py), add the language folder to the inline list on line 68. +* In [installer.nsi](src/installer.nsi), add entries for the language folder to the install and uninstall sections. If there's an installer translation, also add its string definitions beside all the other language string definitions, and insert its macro beside all the other language macros. * The readmes should be updated with a link to the translation in the repository in the main readme, and the language's code in the metadata syntax readme. diff --git a/docs/BUILD.MSVC.md b/docs/BUILD.MSVC.md index 1e30bf9d..a6a71162 100644 --- a/docs/BUILD.MSVC.md +++ b/docs/BUILD.MSVC.md @@ -1,50 +1,67 @@ # Build Instructions using Microsoft Visual C++ -These instructions were used to build BOSS using Microsoft Visual Studio Express 2013 for Desktop, though they should also apply to other versions of MSVC. BOSS's CMake configuration builds an executable that can be run on Windows XP, but this support has only been implemented for MSVC 2013 - other versions may require editing of BOSS's `CMakeLists.txt` file. +These instructions were used to build LOOT using Microsoft Visual Studio 2012 and Microsoft Visual Studio Express 2013 for Desktop, though they should also apply to other versions of MSVC. #### Boost ``` bootstrap.bat -b2 toolset=msvc-12.0 threadapi=win32 link=static variant=release address-model=32 --with-log --with-date_time --with-thread --with-filesystem --with-locale --with-regex --with-system --with-iostreams --stagedir=stage-32 +b2 toolset=msvc threadapi=win32 link=static runtime-link=static variant=release address-model=32 --with-log --with-date_time --with-thread --with-filesystem --with-program_options --with-locale --with-regex --with-system --with-iostreams ``` -#### wxWidgets +`link`, `runtime-link` and `address-model` can all be modified if shared linking or 64 bit builds are desired. LOOT uses statically-linked Boost libraries by default: to change this, edit [CMakeLists.txt](../CMakeLists.txt). -Just build the solution provided by wxWidgets. +#### Chromium Embedded Framework -#### zlib - -1. Add `/safeseh` to both lines in `contrib\masmx86\bld_ml32.bat`. -2. Build the solution in `contrib\vstudio`. -3. Copy `build\zconf.h` to `.\zconf.h`. +Most of the required binaries are pre-built, but the libcef_dll_wrapper dynamic library must be built. Just open its project file and build it with the `Release` configuration. #### yaml-cpp -1. Set CMake up so that it builds the binaries in the `build` subdirectory of the yaml-cpp folder. -2. Define `BOOST_ROOT` to point to where the Boost folder is. -3. Configure CMake, then generate a build system for Visual Studio 12. -4. Open the generated solution file, and build it. +1. Configure CMake and generate a build system for Visual Studio by running: + ``` + mkdir build + cd build + cmake.exe .. -G "Visual Studio 12" -DBOOST_ROOT={BOOST_ROOT} -DMSVC_SHARED_RT=OFF + ``` + Adapt the commands as necessary for your particular setup. +2. Open the generated solution file, and build it with `Release` configuration. #### Libloadorder Follow the instructions in libloadorder's README.md to build it as a static library. +Example CMake keys: `-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=build -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=build` + #### Libgit2 -1. Set CMake up so that it builds the binaries in the `build` subdirectory of the libgit2 folder. -2. Configure CMake. -3. Undefine `BUILD_SHARED_LIBS`. -4. Generate a build system for Visual Studio 12. -5. Open the generated solution file, and build it. +1. Configure CMake and generate a build system for Visual Studio by running: + ``` + mkdir build + cd build + cmake.exe .. -G "Visual Studio 12" -DBUILD_SHARED_LIBS=OFF -DSTATIC_CRT=ON + ``` + Adapt the commands as necessary for your particular setup. +2. Open the generated solution file, and build it with `Release` configuration. -You may need to make sure that the configuration properties for the Visual Studio project are set to use the multithreaded DLL runtime library (C/C++->Code Generation). +#### LOOT -#### BOSS +LOOT uses the following CMake variables to set build parameters: -1. Set CMake up so that it builds the binaries in the `build` subdirectory of the BOSS folder. -2. Define `PROJECT_ARCH=32` or `PROJECT_ARCH=64` to build 32 or 64 bit executables respectively. -3. Define `PROJECT_LINK=STATIC` to build a static API, or `PROJECT_LINK=SHARED` to build a DLL API. -4. Define `PROEJCT_LIBS_DIR` to point to the folder holding all the required libraries' folders. -5. Configure CMake, then generate a build system for Visual Studio 12. -6. Open the generated solution file, and build it. \ No newline at end of file +Parameter | Values | Default |Description +----------|--------|---------|----------- +`BUILD_SHARED_LIBS` | `ON`, `OFF` | `OFF` | Whether or not to build a shared libloot. +`PROJECT_STATIC_RUNTIME` | `ON`, `OFF` | `ON` | Whether to link the C++ runtime statically or not. This also affects the Boost libraries used. +`PROJECT_ARCH` | `32`, `64` | `32` | Whether to build 32 or 64 bit LOOT binaries. +`ALPHANUM_ROOT` | path | `../../alphanum` | Path to the folder containing `alphanum.hpp`. +`CEF_ROOT` | path | `../../cef` | Path to the root of the Chromium Embedded Framework folder. +`LIBESPM_ROOT` | path | `../../libespm` | Path to the root of the libespm repository folder. +`LIBGIT2_ROOT` | path | `../../libgit2` | Path to the root of the libgit2 repository folder. +`LIBLOADORDER_ROOT` | path | `../../libloadorder` | Path to the root of the libloadorder repository folder. +`YAMLCPP_ROOT` | path | `../../yaml-cpp` | Path to the root of the yaml-cpp folder. + +The default paths given in the table above are relative to LOOT's `CMakeLists.txt`. + +1. Set CMake up so that it builds the binaries in the `build` subdirectory of the LOOT folder. +2. Define any necessary parameters. +3. Configure CMake, then generate a build system for Visual Studio 12. +4. Open the generated solution file, and build it. diff --git a/docs/BUILD.MinGW.md b/docs/BUILD.MinGW.md index cab68e24..bffb5073 100644 --- a/docs/BUILD.MinGW.md +++ b/docs/BUILD.MinGW.md @@ -1,35 +1,23 @@ # Build Instructions using MinGW -These instructions were used to build BOSS using mingw-w64 on Ubuntu and Debian linux, though they should also apply to other similar environments. +These instructions were used to build LOOT using mingw-w64 on Ubuntu and Debian linux, though they should also apply to other similar environments. #### Boost ``` ./bootstrap.sh echo "using gcc : 4.6.3 : i686-w64-mingw32-g++ : i686-w64-mingw32-windres i686-w64-mingw32-ar i686-w64-mingw32-ranlib ;" > tools/build/v2/user-config.jam -./b2 toolset=gcc-4.6.3 target-os=windows threadapi=win32 link=static runtime-link=static variant=release address-model=32 cxxflags=-fPIC --with-log --with-date_time --with-thread --with-filesystem --with-locale --with-regex --with-system --with-iostreams --stagedir=stage-32 +./b2 toolset=gcc-4.6.3 target-os=windows threadapi=win32 link=static runtime-link=static variant=release address-model=32 cxxflags=-fPIC --with-log --with-date_time --with-thread --with-filesystem --with-program_options --with-locale --with-regex --with-system --with-iostreams ``` -#### wxWidgets +#### Chromium Embedded Framework -``` -./configure --host=i686-w64-mingw32 --disable-shared --enable-stl -make -``` - -#### zlib - -``` -mkdir build && cd build -cmake .. -DCMAKE_C_FLAGS=-m32 -DPROJECT_ARCH=32 -DCMAKE_TOOLCHAIN_FILE=../BOSSv3/mingw-toolchain.cmake -make -cp zconf.h ../zconf.h -``` +Most of the required binaries are pre-built, but the libcef_dll_wrapper dynamic library must be built. #### yaml-cpp ``` -cmake . -DCMAKE_C_FLAGS=-m32 -DPROJECT_ARCH=32 -DCMAKE_TOOLCHAIN_FILE=../BOSSv3/mingw-toolchain.cmake -DBOOST_ROOT=../boost +cmake . -DCMAKE_C_FLAGS=-m32 -DPROJECT_ARCH=32 -DCMAKE_TOOLCHAIN_FILE=../LOOT/mingw-toolchain.cmake -DBOOST_ROOT=../boost make ``` @@ -37,23 +25,15 @@ make Follow the instructions in libloadorder's README.md to build it as a static library. -#### OpenSSL - -``` -./Configure --cross-compile-prefix=i686-w64-mingw32- mingw -make -``` - #### Libgit2 ``` mkdir build && cd build -cmake .. -DBUILD_SHARED_LIBS=OFF -DOPENSSL_ROOT_DIR=../openssl -DCMAKE_C_FLAGS=-m32 -DPROJECT_ARCH=32 -DCMAKE_TOOLCHAIN_FILE=../BOSSv3/mingw-toolchain.cmake +cmake .. -DBUILD_SHARED_LIBS=OFF -DOPENSSL_ROOT_DIR=../openssl -DCMAKE_C_FLAGS=-m32 -DPROJECT_ARCH=32 -DCMAKE_TOOLCHAIN_FILE=../LOOT/mingw-toolchain.cmake make ``` -If building with SSL support using OpenSSL, also pass ``. -#### BOSS +#### LOOT ``` mkdir build && cd build diff --git a/docs/Doxyfile b/docs/Doxyfile index 8b2f0f8b..286fac13 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -14,334 +14,334 @@ # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need # to put quotes around the project name if it contains spaces. -PROJECT_NAME = "BOSS API" +PROJECT_NAME = "LOOT API" -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer # a quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = "A load order optimisation tool for various games by Bethesda." -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. -PROJECT_LOGO = /home/oliver/Code/BOSSv3/resources/icon.ico +PROJECT_LOGO = ../resources/icon.ico -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = +OUTPUT_DIRECTORY = -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" -ABBREVIATE_BRIEF = +ABBREVIATE_BRIEF = -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the # path to strip. -STRIP_FROM_PATH = +STRIP_FROM_PATH = -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO -# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. -ALIASES = +ALIASES = -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the # itcl::class meaning. -TCL_SUBST = +TCL_SUBST = -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this -# tag. The format is ext=language, where ext is a file extension, and language -# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, -# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions # you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. -EXTENSION_MAPPING = +EXTENSION_MAPPING = -# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all -# comments according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you -# can mix doxygen, HTML, and XML commands with Markdown formatting. +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. # Disable only in case of backward compatibilities issues. MARKDOWN_SUPPORT = YES -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO -# If you use Microsoft's C++/CLI language, you should set this option to YES to +# If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or # section (for LaTeX and RTF). INLINE_GROUPED_CLASSES = NO -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man # pages) or section (for LaTeX and RTF). INLINE_SIMPLE_STRUCTS = NO -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. SYMBOL_CACHE_SIZE = 0 -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. LOOKUP_CACHE_SIZE = 0 @@ -350,14 +350,14 @@ LOOKUP_CACHE_SIZE = 0 # Build related configuration options #--------------------------------------------------------------------------- -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO @@ -367,461 +367,461 @@ EXTRACT_PRIVATE = NO EXTRACT_PACKAGE = NO -# If the EXTRACT_STATIC tag is set to YES all static members of a file +# If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default # anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = NO -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = YES -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen # will still accept a match between prototype and implementation in such cases. STRICT_PROTO_MATCHING = NO -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES -# The ENABLED_SECTIONS tag can be used to enable conditional +# The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. -ENABLED_SECTIONS = +ENABLED_SECTIONS = -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. This will remove the Namespaces entry from the Quick Index +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. -LAYOUT_FILE = +LAYOUT_FILE = -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this # feature you need bibtex and perl available in the search path. -CITE_BIB_FILES = +CITE_BIB_FILES = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- -# The QUIET tag can be used to turn on/off the messages that are generated +# The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written # to stderr. -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = ../src/api/api.h \ api_index.dox -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl -FILE_PATTERNS = +FILE_PATTERNS = -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# Note that relative paths are relative to the directory from which doxygen is +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = +EXCLUDE = -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = +EXAMPLE_PATH = -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left # blank all files are included. -EXAMPLE_PATTERNS = +EXAMPLE_PATTERNS = -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see # the \image command). -IMAGE_PATH = +IMAGE_PATH = -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. -INPUT_FILTER = +INPUT_FILTER = -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if # non of the patterns match the file name, INPUT_FILTER is applied. -FILTER_PATTERNS = +FILTER_PATTERNS = -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when # FILTER_SOURCE_FILES is enabled. -FILTER_SOURCE_PATTERNS = +FILTER_SOURCE_PATTERNS = #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO -# Setting the INLINE_SOURCES tag to YES will include the body +# Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code # fragments. Normal C, C++ and Fortran comments will always remain visible. STRIP_CODE_COMMENTS = YES -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES @@ -830,160 +830,160 @@ VERBATIM_HEADERS = YES # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is advised to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when # changing the value of configuration settings such as GENERATE_TREEVIEW! -HTML_HEADER = +HTML_HEADER = -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a # standard footer. -HTML_FOOTER = +HTML_FOOTER = -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own # style sheet in the HTML output directory as well, or it will be erased! -HTML_STYLESHEET = +HTML_STYLESHEET = -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that # the files will be copied as-is; there are no commands or markers available. -HTML_EXTRA_FILES = +HTML_EXTRA_FILES = -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the style sheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 220 -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the # page has loaded. HTML_DYNAMIC_SECTIONS = NO -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of -# entries shown in the various tree structured indices initially; the user -# can expand and collapse entries dynamically later on. Doxygen will expand -# the tree to such a level that at most the specified number of entries are -# visible (unless a fully collapsed tree already exceeds this amount). -# So setting the number of entries 1 will produce a full collapsed tree by -# default. 0 is a special value representing an infinite number of entries +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries # and will result in a full expanded tree by default. HTML_INDEX_NUM_ENTRIES = 100 -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher @@ -992,215 +992,215 @@ DOCSET_PUBLISHER_ID = org.doxygen.Publisher DOCSET_PUBLISHER_NAME = Publisher -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be # written to the html output directory. -CHM_FILE = +CHM_FILE = -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. -HHC_LOCATION = +HHC_LOCATION = -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. -CHM_INDEX_ENCODING = +CHM_INDEX_ENCODING = -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO -# The TOC_EXPAND flag can be set to YES to add extra items for group members +# The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. -QCH_FILE = +QCH_FILE = -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters -QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_NAME = -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# # Qt Help Project / Custom Filters. -QHP_CUST_FILTER_ATTRS = +QHP_CUST_FILTER_ATTRS = -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# # Qt Help Project / Filter Attributes. -QHP_SECT_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. -QHG_LOCATION = +QHG_LOCATION = -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project -# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) -# at top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. Since the tabs have the same information as the -# navigation tree you can set this option to NO if you already set +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set # GENERATE_TREEVIEW to YES. DISABLE_INDEX = NO -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. -# Since the tree basically has the same information as the tab index you +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you # could consider to set DISABLE_INDEX to NO when enabling this option. GENERATE_TREEVIEW = NO -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum # values from appearing in the overview section. ENUM_VALUES_PER_LINE = 4 -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you may also need to install MathJax separately and +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you may also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to -# the MathJax Content Delivery Network so you can quickly see the result without -# installing MathJax. However, it is strongly recommended to install a local +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. However, it is strongly recommended to install a local # copy of MathJax from http://www.mathjax.org before deployment. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension # names that should be enabled during MathJax rendering. -MATHJAX_EXTENSIONS = +MATHJAX_EXTENSIONS = -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = YES -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvantages are that it is more difficult to setup +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup # and does not have live searching capabilities. SERVER_BASED_SEARCH = NO @@ -1209,97 +1209,97 @@ SERVER_BASED_SEARCH = NO # configuration options related to the LaTeX output #--------------------------------------------------------------------------- -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = YES -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = latex -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, letter, legal and +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4 -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. -EXTRA_PACKAGES = +EXTRA_PACKAGES = -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! -LATEX_HEADER = +LATEX_HEADER = -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for -# the generated latex document. The footer should contain everything after -# the last chapter. If it is left blank doxygen will generate a +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a # standard footer. Notice: only use this tag if you know what you are doing! -LATEX_FOOTER = +LATEX_FOOTER = -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO -# The LATEX_BIB_STYLE tag can be used to specify the style to use for the -# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See # http://en.wikipedia.org/wiki/BibTeX for more info. LATEX_BIB_STYLE = plain @@ -1308,68 +1308,68 @@ LATEX_BIB_STYLE = plain # configuration options related to the RTF output #--------------------------------------------------------------------------- -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO -# Load style sheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = -# Set optional variables used in the generation of an rtf document. +# Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. -RTF_EXTENSIONS_FILE = +RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man -# The MAN_EXTENSION tag determines the extension that is added to +# The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO @@ -1378,33 +1378,33 @@ MAN_LINKS = NO # configuration options related to the XML output #--------------------------------------------------------------------------- -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_SCHEMA = +XML_SCHEMA = -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_DTD = +XML_DTD = -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES @@ -1413,10 +1413,10 @@ XML_PROGRAMLISTING = YES # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO @@ -1425,97 +1425,97 @@ GENERATE_AUTOGEN_DEF = NO # configuration options related to the Perl module output #--------------------------------------------------------------------------- -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = YES -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = YES -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # pointed to by INCLUDE_PATH will be searched when a #include is found. SEARCH_INCLUDES = YES -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by # the preprocessor. -INCLUDE_PATH = +INCLUDE_PATH = -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. -INCLUDE_FILE_PATTERNS = +INCLUDE_FILE_PATTERNS = -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = BOSS_API= +PREDEFINED = LOOT_API= -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition that +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that # overrules the definition found in the source code. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all references to function-like macros -# that are alone on a line, have an all uppercase name, and do not end with a +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a # semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES @@ -1524,37 +1524,37 @@ SKIP_FUNCTION_MACROS = YES # Configuration::additions related to external references #--------------------------------------------------------------------------- -# The TAGFILES option can be used to specify one or more tagfiles. For each -# tag file the location of the external documentation should be added. The -# format of a tag file without this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths -# or URLs. Note that each tag file must have a unique name (where the name does -# NOT include the path). If a tag file is not located in the directory in which +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which # doxygen is run, you must also specify the path to the tagfile here. -TAGFILES = +TAGFILES = -# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. -GENERATE_TAGFILE = +GENERATE_TAGFILE = -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES -# The PERL_PATH should be the absolute path and name of the perl script +# The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl @@ -1563,222 +1563,222 @@ PERL_PATH = /usr/bin/perl # Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = NO -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. -MSCGEN_PATH = +MSCGEN_PATH = -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 0 -# By default doxygen will use the Helvetica font for all dot files that -# doxygen generates. When you want a differently looking font you can specify -# the font name using DOT_FONTNAME. You need to make sure dot is able to find -# the font, which can be done by putting it in a standard location or by setting -# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the # directory containing the font. DOT_FONTNAME = Helvetica -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 -# By default doxygen will tell dot to use the Helvetica font. -# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to # set the path where dot can find it. -DOT_FONTPATH = +DOT_FONTPATH = -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the # CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO -# If the UML_LOOK tag is enabled, the fields and methods are shown inside -# the class node. If there are many fields or methods and many nodes the -# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS -# threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be # exceeded by 50% before the limit is enforced. UML_LIMIT_NUM_FIELDS = 10 -# If set to YES, the inheritance and collaboration graphs will show the +# If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES -# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are svg, png, jpg, or gif. -# If left blank png will be used. If you choose svg you need to set -# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible in IE 9+ (other browsers do not have this requirement). DOT_IMAGE_FORMAT = png -# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to -# enable generation of interactive SVG images that allow zooming and panning. -# Note that this requires a modern browser other than Internet Explorer. -# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you -# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible. Older versions of IE do not have SVG support. INTERACTIVE_SVG = NO -# The tag DOT_PATH can be used to specify the path where the dot tool can be +# The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. -DOT_PATH = +DOT_PATH = -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the # \dotfile command). -DOTFILE_DIRS = +DOTFILE_DIRS = -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the # \mscfile command). -MSCFILE_DIRS = +MSCFILE_DIRS = -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = YES -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES diff --git a/docs/BOSS Metadata Syntax.html b/docs/LOOT Metadata Syntax.html similarity index 80% rename from docs/BOSS Metadata Syntax.html rename to docs/LOOT Metadata Syntax.html index a82b1cd3..1d8c0880 100644 --- a/docs/BOSS Metadata Syntax.html +++ b/docs/LOOT Metadata Syntax.html @@ -1,6 +1,6 @@ -BOSS Metadata Syntax +LOOT Metadata Syntax - -

BOSS Metadata Syntax

+

LOOT Metadata Syntax

Contents

    @@ -83,7 +83,6 @@ h3{
  1. Dirty Info Data Structure
  2. Plugin Data Structure
-
  • URL Hyperlinking
  • Condition Strings
    1. Functions @@ -92,10 +91,11 @@ h3{
  • Language Codes
  • License +
  • Feature Support

    Introduction

    -

    As of BOSS v3, the metadata syntax is what BOSS's masterlists and userlists are written in. If you know YAML, good news: the syntax is essentially just YAML 1.2. If you don't know YAML, then its Wikipedia page is a good introduction. All you really need to know is: +

    The metadata syntax is what LOOT's masterlists and userlists are written in. If you know YAML, good news: the syntax is essentially just YAML 1.2. If you don't know YAML, then its Wikipedia page is a good introduction. All you really need to know is:

    • How lists and associative arrays (key-value maps) are written.
    • That whitespace is important, and that only normal spaces (ie. no non-breaking spaces or tabs) count as such. @@ -103,34 +103,34 @@ h3{
    • That YAML files must be written in a Unicode encoding.
    • That each key in a key-value map must only appear once per map object.
    -

    Some important points that are more specific to how BOSS uses YAML: +

    Some important points that are more specific to how LOOT uses YAML:

      -
    • BOSS's support for YAML syntax is incomplete. A list of known limitations can be found here. The only major missing piece is support for merge keys (<<:). +
    • LOOT's support for YAML syntax is incomplete. A list of known limitations can be found here. The only major missing piece is support for merge keys (<<:).
    • Strings are case-sensitive, apart from file paths, regular expressions and checksums.
    -

    Some properties of file paths as used by BOSS: +

    Some properties of file paths as used by LOOT:

    • They are evaluated as paths relative to the game's Data folder.
    • They cannot reference a path outside of the game's folder structure, ie. they cannot contain the substring ../../. -
    • Regular expression file paths must be written in the Perl syntax. -
    • Only the filename of a regex file path may contain non-literal regex syntax, ie. if the filename part of the regex file path is removed, the remainder must be an exact folder path (though with the regex syntax special characters escaped). For example, given the regex file path Meshes\\Resources(1|2)\\(upperclass)?table.nif, BOSS will look for a file named table.nif or upperclasstable.nif in the Meshes\Resources(1|2) folder, rather than looking in the Meshes\Resources1 and Meshes\Resources2 folders. +
    • Regular expression file paths must be written in the EMCAScript syntax. +
    • Only the filename of a regex file path may contain non-literal regex syntax, ie. if the filename part of the regex file path is removed, the remainder must be an exact folder path (though with the regex syntax special characters escaped). For example, given the regex file path Meshes\\Resources(1|2)\\(upperclass)?table.nif, LOOT will look for a file named table.nif or upperclasstable.nif in the Meshes\Resources(1|2) folder, rather than looking in the Meshes\Resources1 and Meshes\Resources2 folders.
    -

    Please test any changes you make before uploading them. One way of doing this is to run BOSS, another is to copy/paste what you've changed into here, though it won't catch condition syntax errors and doesn't use the same parser as BOSS so may give different results. +

    Please test any changes you make before uploading them. One way of doing this is to run LOOT, another is to copy/paste what you've changed into here, though it won't catch condition syntax errors and doesn't use the same parser as LOOT so may give different results.

    Metadata File Contents

    -

    The root of a metadata file is a key-value map. BOSS will recognise the following keys, none of which are required: +

    The root of a metadata file is a key-value map. LOOT will recognise the following keys, none of which are required:
    Key NameValue TypeNotes
    globalsmessage listA list of message data structures for messages that are displayed independently of any plugin.
    pluginsplugin listA list of plugin data structures, holding all the plugin metadata within the file.
    -

    Other keys may also be present, but are not processed by BOSS. The message and plugin data structures are detailed in the next section. +

    Other keys may also be present, but are not processed by LOOT. The message and plugin data structures are detailed in the next section.

    An example metadata file: globals: - type: say - content: 'You are using the latest version of BOSS.' - condition: 'version("BOSS", "3.0.0.0", ==)' + content: 'You are using the latest version of LOOT.' + condition: 'version("LOOT", "0.5.0.0", ==)' plugins: - name: 'Armamentarium.esm' tag: @@ -148,10 +148,10 @@ plugins:

    Data Structures

    -

    BOSS expects metadata to be laid out using a certain set of data structures, described in this section. +

    LOOT expects metadata to be laid out using a certain set of data structures, described in this section.

    Tag Data Structure

    -

    BOSS metadata files can contain suggestions for the addition or removal of Bash Tags, and this is the structure used for them. It has two forms: the first is a simple string, and the second is a key-value map. All values in the map are strings. +

    LOOT metadata files can contain suggestions for the addition or removal of Bash Tags, and this is the structure used for them. It has two forms: the first is a simple string, and the second is a key-value map. All values in the map are strings.

    The simple form: tag

    where tag is the Bash Tag, preceded by a minus sign if it is suggested for removal. @@ -179,7 +179,7 @@ condition: 'file("Mart''s Monster Mod for OOO.esm") or file("FCOM_Convergence.es Key NameRequiredNotes name✓An exact (ie. not regex) file path or name. - display✗A substitute string to be displayed instead of the file path in any generated messages, eg. the name of the mod the file belongs to. Double-quoted URLs will be hyperlinked in the BOSS report. See URL Hyperlinking for details. + display✗A substitute string to be displayed instead of the file path in any generated messages, eg. the name of the mod the file belongs to. condition✗A condition string that is evaluated to determine whether this file data should be used: if it evaluates to true, the data is used, otherwise it is ignored. See Condition Strings for details. @@ -199,6 +199,7 @@ display: 'OBSE v18+' typestring✓The type string can be one of three keywords, see the table below for their semantics. contentstring or localised content list✓Either simply a string, or a list of localised content data structures. If the latter, one of the structures must be for English. conditionstring✗A condition string that is evaluated to determine whether the message should be displayed: if it evaluates to true, the message is displayed, otherwise it is not. See Condition Strings for details. + subslist of strings✗A list of strings to be substituted into the message content string. The content string must use numbered specifiers (%1%, %2%, etc.), where the numbers correspond to the position of the substitution string in this list to use, to denote where these strings are to be substituted.

    There are three message types: @@ -213,27 +214,25 @@ display: 'OBSE v18+' -
    Key NameRequiredNotes
    strThe actual message content string. Double-quoted URLs will be hyperlinked in the BOSS report. See URL Hyperlinking for details. -
    langThe language that str is written in, given as a POSIX language code. The languages BOSS supports are given in Language Codes. +
    strThe actual message content string. +
    langThe language that str is written in, given as a POSIX language code. The languages LOOT supports are given in Language Codes.
    +

    LOOT supports formatting of messages using GitHub Flavored Markdown. Support is provided by the Marked library (v0.3.2). Strings that get substituted into messages, such as file display names and dirty info utility strings, also support the same formatting options. -

    BOSS handles messages and languages as follows: +

    LOOT handles messages and languages as follows:

    1. If a message's content value is a string, the message will use the string as its content if displayed. -
    2. If a message's content value is a list of localised content structures, then the first structure with a language that matches BOSS's current language will be used as the message's content if displayed. If there are no matches, then the first structure in English will be used. +
    3. If a message's content value is a list of localised content structures, then the first structure with a language that matches LOOT's current language will be used as the message's content if displayed. If there are no matches, then the first structure in English will be used.
    -

    Examples (translations by Google): type: say condition: 'file("foo.esp")' content: - - lang: eng + - lang: en str: 'An example link: <http://www.example.com>' - - lang: rus + - lang: ru str: 'Это пример ссылки: <http://www.example.com>' - - lang: ger - str: 'Ein Beispiel-Link: <http://www.example.com>' would be displayed as

    @@ -247,10 +246,21 @@ would be displayed as
    отмечать: An alternative example link, with no translations.
    +In English, +type: say +content: 'A newer version of %1% [is available](%2%). +subs: + - 'this plugin' + - 'http://www.example.com' + +would be displayed as +
    +Note: A newer version of this plugin is available. +

    Location Data Structure

    -

    This data structure is used to hold information on where a plugin is hosted online. It is not currently used by BOSS, but it was suggested that since the BOSS team receives a considerable number of plugin URLs, they should be recorded in a standard format, as there is no existing store of such information and it could prove useful in the future. +

    This data structure is used to hold information on where a plugin is hosted online. It is not currently used by LOOT, but it was suggested that since the LOOT team receives a considerable number of plugin URLs, they should be recorded in a standard format, as there is no existing store of such information and it could prove useful in the future.

    The data structure has two forms: the first is a simple string, and the second is a key-value map. The first form should be used for a URL without any associated version data, such as when it is not clear which version is found there, or when it is the only known hosting location for the plugin and as such hosts all available versions. The second form should be used when version data can be associated with the URL, such as when the URL only hosts a subset of the available versions of the plugin.

    The simple form: URL @@ -275,8 +285,8 @@ ver: -
    Key NameData TypeRequiredNotes
    crchexadecimal integerThe CRC checksum of the dirty plugin, before cleaning. BOSS displays the CRCs of installed plugins in its report. The 8-character CRC should be preceded by 0x so that it is correctly interpreted. -
    utilstringThe utility that should be used to clean the plugin. This field supports URL Hyperlinking, and it is recommended that a URL to the game's cleaning guide is supplied. +
    crchexadecimal integerThe CRC checksum of the dirty plugin, before cleaning. LOOT displays the CRCs of installed plugins in its report. The 8-character CRC should be preceded by 0x so that it is correctly interpreted. +
    utilstringThe utility that should be used to clean the plugin.
    itmintegerThe number of identical-to-master records reported for the dirty plugin. If the number is unknown, this field should not be supplied. If the number is known and zero, this field should be supplied.
    udrintegerThe number of undeleted records reported for the dirty plugin. If the number is unknown, this field should not be supplied. If the number is known and zero, this field should be supplied.
    navintegerThe number of deleted navmeshes reported for the dirty plugin. If the number is unknown, this field should not be supplied. If the number is known and zero, this field should be supplied. @@ -297,19 +307,25 @@ nav: 0
    namestringCan be an exact plugin filename or a regular expression plugin filename. If the period that precedes the file extension has been escaped (eg. \.esp, \.esm), the string is treated as a regular expression, otherwise it is treated as an exact filename.
    enabledbooleanEnables or disables use of the plugin object. Used for user rules, but no reason to use it in the masterlist. If unspecified, defaults to true. -
    priorityintegerModifies plugin position relative to others that change one or more of the same records, but which are otherwise unrelated (ie. neither plugin lists the other as a master, requirement, or in its after list). An exception is made for plugins that contain only a header record: these plugins have their priorities compared against all unrelated plugins. A plugin with a higher priority value will load after a plugin with a lower priority value. Value can be anything in the range -2000000000 to 2000000000, and if unspecified defaults to 0. +
    priorityintegerModifies plugin position relative to others that change one or more of the same records, but which are otherwise unrelated (ie. neither plugin lists the other as a master, requirement, or in its after list). Plugins that don't change any of the same records are not compared, unless: +
      +
    • One of the plugins is a "dummy" plugin, containing only a header record. +
    • One of the plugins has a priority greater than or equal to 1,000,000. In this case, only the modulo (ie. remainder when divided) with 1,000,000 is used when comparing plugin priority values – the rest is only used to signify that the plugin should be compared against all others. +
    +

    For example, priority: 153000352 and priority: 352 have equal values when compared, but a plugin with the first priority will be compared against all others, while a (non-dummy) plugin with the second priority will be compared against only those it conflicts with. +

    A plugin with a higher priority value will load after a plugin with a lower priority value. Value can be anything in the range -2000000000 to 2000000000, and if unspecified defaults to 0.

    afterfile listAn unordered list of plugins that this plugin must load after, but which are not dependencies. Used for resolving specific compatibility issues and by user rules for specifying custom plugin positions. -
    reqfile listAn unordered list of files that this plugin requires to be present. This plugin will load after any plugins listed. If any of these files are missing, an error message will be displayed. Intended for use specifying implicit dependencies, as BOSS will detect a plugin's explicit masters itself. +
    reqfile listAn unordered list of files that this plugin requires to be present. This plugin will load after any plugins listed. If any of these files are missing, an error message will be displayed. Intended for use specifying implicit dependencies, as LOOT will detect a plugin's explicit masters itself.
    incfile listAn unordered list of files that this plugin is incompatible with. If any of these files are present, an error message will be displayed.
    msgmessage listThe messages attached to this plugin. The messages will be displayed in the order that they are listed.
    tagtag listAn unordered list of Bash Tags suggested for this plugin. If a Bash Tag is suggested for both addition and removal, the latter will override the former when the list is evaluated. -
    urllocation listAn unordered list of locations for this plugin. If the same version can be found at multiple locations, only one location should be recorded. This metadata is not currently used by BOSS. +
    urllocation listAn unordered list of locations for this plugin. If the same version can be found at multiple locations, only one location should be recorded. This metadata is not currently used by LOOT.
    dirtydirty info listAn unordered list of dirty info structures for this plugin.

    Example: name: 'Oscuro''s_Oblivion_Overhaul.esm' req: - - 'Oblivion.esm' # Don't do this, Oblivion.esm is a master of Oscuro's_Oblivion_Overhaul.esm, so BOSS already knows it's required. + - 'Oblivion.esm' # Don't do this, Oblivion.esm is a master of Oscuro's_Oblivion_Overhaul.esm, so LOOT already knows it's required. - name: 'example.esp' display: '[Example Mod](http://www.example.com)' condition: 'version("Oscuro''s_Oblivion_Overhaul.esm", "15.0", ==)' @@ -327,27 +343,11 @@ msg: content: 'Do not clean. "Dirty" edits are intentional and required for the mod to function.' - -

    -

    File display strings and message content strings (including the strings in localised content structures) that contain recognised URLs have them displayed as hyperlinks in the BOSS report. -

    URLs must begin with file:, http: or https:, and be written according to the following subset of Markdown syntax. Note that BOSS does not recognise additional Markdown syntaxes to those given below. -

    For labelled URLs, the syntax is [label](url). A single optional space may be included between the closing square bracket and the opening parenthesis, ie. [label] (url). -

    For unlabelled URLs, the syntax is <url>. The URL shall be used as its own label. -

    Note that the URLs given as part of a location data structure should not be labelled or enclosed in less-than or greater-than signs, as they consist of raw URL data, rather than text to be displayed in a message. -

    Examples: -'This [string](https://en.wikipedia.org/wiki/String_(computer_science)) contains a labelled hyperlink.' -would be displayed as -

    This string contains a labelled hyperlink.
    -

    While -'This string (see: <https://en.wikipedia.org/wiki/String_(computer_science)>) contains an unlabelled hyperlink.' -both get displayed as -

    This string (see: https://en.wikipedia.org/wiki/String_(computer_science)) contains an unlabelled hyperlink.
    -

    Condition Strings

    -

    Condition strings can be used to ensure that data is only acted on by BOSS under certain circumstances. They are very similar to boolean conditional expressions in programming languages such as Python, though more limited. Their EBNF grammar is: +

    Condition strings can be used to ensure that data is only acted on by LOOT under certain circumstances. They are very similar to boolean conditional expressions in programming languages such as Python, though more limited. Their EBNF grammar is: [ negator ], function, { junctor, [ negator ], function } ;

    The [ negator ], function grammar is referred to as a condition, and two conditions joined by an operator, ie. condition, operator, condition is referred to as a compound condition. -

    Unlike previous versions of BOSS, BOSS v3 caches the results of condition evaluations, so performance is not really an issue. A regular expression check will still take longer than a file check though, so use the former only when appropriate to do so. +

    LOOT caches the results of condition evaluations, so performance is not really an issue. A regular expression check will still take longer than a file check though, so use the former only when appropriate to do so.

    Functions

    There are several conditions that can be tested for using the functions detailed in the table below. @@ -365,10 +365,10 @@ both get displayed as -
    Variable TypeDescription
    filepathA Windows file path, or BOSS, which references the BOSS executable being run. +
    filepathA Windows file path, or LOOT, which references the LOOT executable being run.
    regexA regular expression string to match file paths to. -
    checksumA string of hexadecimal digits representing an unsigned integer that is the data checksum of a file. BOSS displays the checksums of plugins in its user interface after running. -
    versionA string of characters representing the version of a plugin or executable. BOSS displays the versions of plugins in its user interface after running. +
    checksumA string of hexadecimal digits representing an unsigned integer that is the data checksum of a file. LOOT displays the checksums of plugins in its user interface after running. +
    versionA string of characters representing the version of a plugin or executable. LOOT displays the versions of plugins in its user interface after running.
    comparatorA comparison operator, ie. one of ==, !=, <, >, <= or >=, meaning "is equal to", "is not equal to", "is less than", "is greater than", "is less than or equal to" and "is greater than or equal to" respectively.
    @@ -431,20 +431,35 @@ both get displayed as

    You can also explicitly enclose any condition in brackets to override the evaluation order, eg. C and ( C or C ) is evaluated as C and ( C or C ), in contrast to the unbracketed string above.

    Language Codes

    -

    BOSS supports the following languages and language codes: +

    LOOT supports the following languages and language codes:
    LanguagePOSIX Code
    Chinesezh_CN
    Englishen +
    Finnishfi
    Frenchfr
    Polishpl
    Brazilian Portuguesept_BR
    Russianru
    Spanishes +
    Germande

    License

    -

    This document is part of the BOSS documentation.
    +

    This document is part of the LOOT documentation.
    Copyright (C) 2012—2014 WrinklyNinja
    -See the file BOSS ReadMe.html for copying conditions. +See the file LOOT ReadMe.html for copying conditions. + +

    Feature Support

    +

    Different versions of LOOT may have varying levels of support for the syntax detailed in this document. Such variation in support is detailed in the table below. Unless otherwise noted, all syntax changes are backwards-compatible (ie. you can use the features without breaking the masterlist for users on older versions). + + + + +
    LOOT Version +
    Feature<= 0.6 0.7 +
    GitHub Flavored Markdown message formattingOnly URL hyperlinking is supported, for file:, http: and https: URLs, using the [label](url) and <url> syntaxes.LOOT uses the Marked library (v0.3.2) to provide support for most of GitHub Flavored Markdown, minus the GitHub-specific features (like @mentions, issue/repo linking and emoji). +
    Message string substitution (ie. sub:)Not supported.Support planned, but not yet implemented in the latest alpha release. +
    YAML merge keys (ie. <<:)Not supported.Support planned, but not yet implemented in the latest alpha release. +
    diff --git a/docs/BOSS Readme.html b/docs/LOOT Readme.html similarity index 53% rename from docs/BOSS Readme.html rename to docs/LOOT Readme.html index 4d668105..6d6d54b2 100644 --- a/docs/BOSS Readme.html +++ b/docs/LOOT Readme.html @@ -1,6 +1,6 @@ -BOSS Readme +LOOT Readme - -

    BOSS

    +

    LOOT

    Contents

    1. Introduction
    2. Installation & Uninstallation -
    3. Using BOSS +
    4. Using LOOT
      1. Sorting Plugins
      2. The Results Report -
      3. Customising BOSS's Results +
      4. Customising LOOT's Results
      5. Editing Settings
    5. Troubleshooting -
    6. Contributing To BOSS -
    7. Translating BOSS +
    8. Contributing To LOOT +
    9. Translating LOOT
    10. Credits
    11. License
    12. Appendices @@ -105,134 +105,138 @@ h3{
    13. Introduction To Load Orders
    14. Dirty Edits, Mod Cleaning & CRCs
    15. File Permissions -
    16. Differences between BOSS v2 and v3
  • Version History

    Introduction

    -

    BOSS is a plugin load order optimiser for TES IV: Oblivion, TES V: Skyrim, Fallout 3 and Fallout: New Vegas. It is designed to assist mod users in avoiding detrimental conflicts, by automatically calculating a load order that satisfies all plugin dependencies and maximises each plugin's impact on the user's game. +

    LOOT is a plugin load order optimiser for TES IV: Oblivion, TES V: Skyrim, Fallout 3 and Fallout: New Vegas. It is designed to assist mod users in avoiding detrimental conflicts, by automatically calculating a load order that satisfies all plugin dependencies and maximises each plugin's impact on the user's game. -

    BOSS also provides some load order error checking, including checks for requirements, incompatibilities and cyclic dependencies. In addition, it provides a large number of plugin-specific usage notes, bug warnings and Bash Tag suggestions for Wrye Bash. +

    LOOT also provides some load order error checking, including checks for requirements, incompatibilities and cyclic dependencies. In addition, it provides a large number of plugin-specific usage notes, bug warnings and Bash Tag suggestions for Wrye Bash. -

    While BOSS is able to calculate correct load order positions for the vast majority of plugins using only their content, it cannot do so for all plugins. As such, BOSS provides a mechanism for supplying additional plugin metadata so that it may sort them correctly. +

    While LOOT is able to calculate correct load order positions for the vast majority of plugins using only their content, it cannot do so for all plugins. As such, LOOT provides a mechanism for supplying additional plugin metadata so that it may sort them correctly. -

    BOSS is intended to make using mods easier, and mod users should still possess a working knowledge of mod load ordering. See Introduction To Load Orders for an overview. +

    LOOT is intended to make using mods easier, and mod users should still possess a working knowledge of mod load ordering. See Introduction To Load Orders for an overview.

    Installation & Uninstallation

    -
    Version 3 is incompatible with earlier versions, which should be removed. Any existing user rules must be manually recreated in BOSS's user interface. Some plugins sorted correctly in v2 may be sorted incorrectly by v3 until their metadata has been recorded. Please notify the team if you observe any load order issues.
    +

    LOOT does not support Windows XP or earlier. -

    BOSS requires Windows Vista, 7 or 8. BOSS can be installed either using its automated installer or manually. To install BOSS manually: -

      -
    1. Install the Visual C++ Redistributable for Visual Studio 2013 (x86). -
    2. Extract the downloaded archive to a location of your choice. -
    -

    If BOSS was installed using the installer, then use the uninstaller linked to in the Start Menu to uninstall BOSS. If BOSS was installed manually: +

    LOOT can be installed either using its automated installer or manually. To install LOOT manually, extract the downloaded archive to a location of your choice. + +

    If LOOT was installed using the installer, then use the uninstaller linked to in the Start Menu to uninstall LOOT. If LOOT was installed manually:

    1. Delete the files you extracted from the location you chose. -
    2. Delete the BOSS folder in your local application data folder, which can be accessed by entering %LOCALAPPDATA% into Windows' File Explorer. +
    3. Delete the LOOT folder in your local application data folder, which can be accessed by entering %LOCALAPPDATA% into Windows' File Explorer.
    -

    Using BOSS

    -

    When BOSS is run, it will attempt to detect which of the supported games are installed, and set itself to run for the first game detected, unless a default game has been set, in which case it will set itself to run for that game. Once a game has been set, the main window will be displayed. +

    Using LOOT

    +

    When LOOT is run, it will attempt to detect which of the supported games are installed. If a default game has been set, LOOT will run for it, otherwise it will run for the same game as it last ran for. If the relevant game cannot be detected, if there is no record of the last game LOOT ran for, it will run for the first detected game. +

    LOOT can also be launched with the LOOT.exe [--game=<game folder name>] command line parameter to set the game to run for. If the supplied game folder name is valid, the default and last game values are ignored. The default folder names are Oblivion, Skyrim, Fallout3 and FalloutNV. +

    Once a game has been set, the main window will be displayed.

    - BOSS's main window -
    BOSS's main window. The title bar displays which game BOSS is running for.
    + LOOT's main window +
    LOOT's main window. The title bar displays which game LOOT is running for.
    -

    Clicking the Edit Metadata button will open BOSS's metadata editor, where you can make changes to the metadata BOSS uses to sort plugins, the messages that get displayed for plugins, and any Bash Tag suggestions BOSS makes. -

    Clicking the Sort Plugins button will begin the plugin sorting process. This will sort your plugins, allow you to make any changes to the load order it produces, then display a report that details the results of BOSS's activity. -

    Clicking the View Last Report button will display the report generated the last time BOSS sorted your plugins for the current game. -

    The File menu provides menu items for sorting plugins, viewing the debug log and the last report BOSS generated, and quitting BOSS. The menu's Redate Plugins option is provided so that Skyrim modders may set the load order for the Creation Kit. It is only enabled for Skyrim, and changes the timestamps of the plugins in its Data folder to match their current load order. A side effect of changing the timestamps is that any Steam Workshop mods installed will be re-downloaded. -

    The Edit menu provides menu items for accessing BOSS's metadata editor and the settings window. -

    The Game menu allows you to change which game BOSS is running for. Games that BOSS cannot find are greyed out, and the the one BOSS is running for is marked with a bullet point. To change the active game, simply select another game in the list. -

    The Help menu provides a link to this readme and an about page that contains the version of BOSS being run, some legal information and a link to the project homepage. +

    Clicking the Edit Metadata button will open LOOT's metadata editor, where you can make changes to the metadata LOOT uses to sort plugins, the messages that get displayed for plugins, and any Bash Tag suggestions LOOT makes. +

    Clicking the Sort Plugins button will begin the plugin sorting process. This will sort your plugins, allow you to make any changes to the load order it produces, then display a report that details the results of LOOT's activity. +

    Clicking the View Last Report button will display the report generated the last time LOOT sorted your plugins for the current game. +

    The File menu provides menu items for sorting plugins, viewing the debug log and the last report LOOT generated, and quitting LOOT. The menu's Redate Plugins option is provided so that Skyrim modders may set the load order for the Creation Kit. It is only enabled for Skyrim, and changes the timestamps of the plugins in its Data folder to match their current load order. A side effect of changing the timestamps is that any Steam Workshop mods installed will be re-downloaded. +

    The Edit menu provides menu items for accessing LOOT's metadata editor and the settings window. +

    The Game menu allows you to change which game LOOT is running for. Games that LOOT cannot find are greyed out, and the the one LOOT is running for is marked with a bullet point. To change the active game, simply select another game in the list. +

    The Help menu provides a link to this readme and an about page that contains the version of LOOT being run, some legal information and a link to the project homepage.

    Sorting Plugins

    -
    - BOSS confirmation dialog - BOSS confirmation dialog with editing panel visible -
    Viewing & editing BOSS's calculated load order.
    +
    + LOOT confirmation dialog +
    Viewing & editing LOOT's calculated load order.

    Clicking the Sort Plugins button in the main window will begin the sorting process. -

    First, BOSS downloads and applies any masterlist updates available, if the relevant setting is enabled. If the latest update cannot be parsed (eg. due to typos), then BOSS will roll back until it finds a version that works. -

    BOSS then sorts your plugins according to a combination of data from the plugins themselves, and any masterlist and userlist entries they may have. If a cyclic interaction is detected (eg. A depends on B depends on A), then sorting will fail. -

    If sorting is successful, the calculated load order is then displayed in the dialog shown above. "Dummy" plugins (ie. only contain a header record) are displayed in grey text, and other plugins that load BSAs are displayed in blue text. -Clicking on a plugin in the list will display the editing panel, where its load order related metadata can be edited. The Show only conflicting plugins checkbox filters the plugin list so that only plugins which can be validly added to the Load After list and either contain conflicting records or (if the selected plugin loads a BSA) load BSAs that may contain conflicting resources. The checkbox must be ticked before plugins can be added to the Load After list, which is done by drag 'n' dropping them from the plugin list, and it must be unticked to select another plugin for editing. The priority value is explained below. -

    If the Apply button is clicked, BOSS does one of two things: if no edits were made, then it immediately applies the load order; but if edits were made, then it repeats the sorting process with the new edits applied. If the Cancel button is clicked, then the load order and any edits made are discarded. -

    BOSS then generates a report and displays it either in a new window or in your default browser, according to the value of the relevant setting. Any errors encountered during the sorting process will be displayed in this report. See the next section for more information on the report. -

    BOSS is able to sort plugins ghosted by Wrye Bash, and can extract Bash Tags and version numbers from plugin descriptions. Provided that they have the Filter Bash Tag present in their description, BOSS can recognise filter patches and so avoid displaying unnecessary error messages for any of their masters that may be missing. -

    While reading very large plugins, such as the game's main master file, BOSS may appear to stop responding: this is not an issue. The time it takes for BOSS to sort your load order depends primarily on the size of the masterlist being used, the total size of the files in your load order, and the number of plugins in your load order. The first run is likely to be longer than subsequent runs as BOSS needs to download the full masterlist, rather than just the changes made by updates. In testing, it was found that sorting ~90 plugins with a total size of ~350 MB and a 5 MB masterlist takes around 15 seconds, though performance will vary with computer hardware. +

    First, LOOT downloads and applies any masterlist updates available, if the relevant setting is enabled. If the latest update cannot be parsed (eg. due to typos), then LOOT will roll back until it finds a version that works. +

    LOOT then sorts your plugins according to a combination of data from the plugins themselves, and any masterlist and userlist entries they may have. If a cyclic interaction is detected (eg. A depends on B depends on A), then sorting will fail. +

    If sorting is successful, the calculated load order is then displayed in the dialog shown above. In this window, you can view the load order calculated by LOOT, and make any edits to the metadata used that you feel are necessary. The window is a simplified version of the metadata editor window, in which all metadata that does not affect sorting is hidden. Please see the section below for more information on how to edit metadata using it. +

    If the Apply button is clicked, LOOT does one of two things: if no edits were made, then it immediately applies the load order; but if edits were made, then it repeats the sorting process with the new edits applied. If the Cancel button is clicked, then the load order and any edits made are discarded. +

    LOOT then generates a report and displays it either in a new window or in your default browser, according to the value of the relevant setting. Any errors encountered during the sorting process will be displayed in this report. See the next section for more information on the report. +

    LOOT is able to sort plugins ghosted by Wrye Bash, and can extract Bash Tags and version numbers from plugin descriptions. Provided that they have the Filter Bash Tag present in their description, LOOT can recognise filter patches and so avoid displaying unnecessary error messages for any of their masters that may be missing. +

    While reading very large plugins, such as the game's main master file, LOOT may appear to stop responding: this is not an issue. The time it takes for LOOT to sort your load order depends primarily on the size of the masterlist being used, the total size of the files in your load order, and the number of plugins in your load order. The first run is likely to be longer than subsequent runs as LOOT needs to download the full masterlist, rather than just the changes made by updates. In testing, it was found that sorting ~90 plugins with a total size of ~350 MB and a 5 MB masterlist takes around 15 seconds, though performance will vary with computer hardware.

    The Results Report

    - BOSS report summary tab - BOSS report details tab -
    BOSS's report viewer.
    + LOOT report summary tab + LOOT report details tab +
    LOOT's report viewer.
    -

    BOSS's results report can be displayed either in BOSS's own report viewer, or in your default web browser, according to the value of the relevant setting. -

    The report is comprised of two sections: +

    LOOT's results report is comprised of two sections:

      -
    • The Summary tab gives information on the versions of BOSS and the masterlist used, whether masterlist updating is enabled, and breaks down the numbers of each message type in the Summary and Details tabs. It also notifies you if there have been no changes in the Details tab since you last ran BOSS for the same game. Finally, the Summary tab is also where any global messages supplied in the masterlist and any errors encountered during sorting are displayed. -
    • The Details tab lists the plugins BOSS sorted in their new load order, along with any messages BOSS has provided for them. BOSS will also display the plugin's CRC value and extract its version if found in the plugin's description field. If BOSS suggests any Bash Tags to be added, they will be displayed in green text, while any Bash Tags to be removed will be displayed in red text. +
    • The Summary tab gives information on the versions of LOOT and the masterlist used, whether masterlist updating is enabled, and breaks down some message and plugin numbers. It also notifies you if there have been no changes in the Details tab since you last ran LOOT for the same game. Finally, the Summary tab is also where any global messages supplied in the masterlist and any errors encountered during sorting are displayed. +
    • The Details tab lists the plugins LOOT sorted in their new load order, along with any messages LOOT has provided for them. LOOT will also display the plugin's CRC value and extract its version if found in the plugin's description field. If LOOT suggests any Bash Tags to be added, they will be displayed in green text, while any Bash Tags to be removed will be displayed in red text.

    In addition, there are a few filters that can be used to selectively hide items in the Details tab. These filters are:

    • Hide Version Numbers: Hides the version numbers printed in blue next to those plugins that provide them.
    • Hide CRCs: Hides the CRCs printed in orange next to those plugins that provide them. -
    • Hide Notes: Hides all messages attached to plugins that have the Note: prefix. +
    • Hide Notes: Hides all plugin messages that have the Note: prefix.
    • Hide Bash Tag Suggestions: Hides all Bash Tag suggestions.
    • Hide 'Do Not Clean' Messages: Hides any messages that contain the string Do not clean.. +
    • Hide Inactive Plugin Messages: Hides all messages attached to plugins that are inactive.
    • Hide All Plugin Messages: Hides all plugin messages.
    • Hide Messageless Plugins: Hides any plugins that have no visible messages.
    -

    BOSS will display the version numbers of any plugins that provide them in their description fields. If a plugin supplies no version number, it cannot be displayed. The version numbers may not reflect the actual version of the mod installed - this could either be due to the mod author forgetting to update the description, or due to a mistake in BOSS's detection. As version numbers are supplied by mod authors in a wide range of formats and BOSS has to detect as many as possible, it occasionally identifies parts of some descriptions as version numbers incorrectly. When in doubt, check the version number given in a mod's readme. -

    BOSS's plugin messages are a valuable resource, acting as a means of providing users with information that they might otherwise not obtain. It is important for a stable, healthy game that you act on any messages that require action. -

    If you think a message suggests an unnecessary action, report it to an official BOSS thread. If you encounter a message that is non-conditional, ie. it suggests an action but is still displayed on subsequent runs of BOSS after the action has been carried out, also report it to an official BOSS thread, so that it can be made conditional. +

    LOOT will display the version numbers of any plugins that provide them in their description fields. If a plugin supplies no version number, it cannot be displayed. The version numbers may not reflect the actual version of the mod installed - this could either be due to the mod author forgetting to update the description, or due to a mistake in LOOT's detection. As version numbers are supplied by mod authors in a wide range of formats and LOOT has to detect as many as possible, it occasionally identifies parts of some descriptions as version numbers incorrectly. When in doubt, check the version number given in a mod's readme. +

    LOOT's plugin messages are a valuable resource, acting as a means of providing users with information that they might otherwise not obtain. It is important for a stable, healthy game that you act on any messages that require action. +

    If you think a message suggests an unnecessary action, report it to an official LOOT thread. If you encounter a message that is non-conditional, ie. it suggests an action but is still displayed on subsequent runs of LOOT after the action has been carried out, also report it to an official LOOT thread, so that it can be made conditional. -

    Customising BOSS's Results

    +

    Customising LOOT's Results

    -
    BOSS's metadata editor.
    +
    LOOT's metadata editor.
    -

    BOSS's sorting algorithm uses the contents of plugins to work out where they should load relative to one another. However, this is sometimes not enough for it to produce a correct load order. In such cases, additional metadata can be supplied so that the plugins get sorted correctly. This metadata is supplied to BOSS by two sources: one is the masterlist, which is maintained by the BOSS team, and the other is the userlist, which you can edit as you desire. -

    The metadata editor allows you to manage the metadata stored in your userlist. When opened, it lists all the plugins you have installed, and any that are missing but have existing user-added metadata, in alphabetical order. Plugins that load BSAs are displayed in blue text, and plugins with user-added metadata are displayed in bold text. Selecting a plugin then opens its metadata for editing, and displays any existing metadata in the fields to the right of the plugin list. Right-clicking a plugin displays a context menu containing a few commands. The editor fields and context menu commands are explained in the tables below. -

    The Add …, Edit … and Remove … buttons are used to edit the contents of the list currently visible. The Edit … and Remove … buttons are greyed out if no row is selected or if the selected row is not user-added metadata, but comes from the masterlist or the plugin itself. Metadata that comes from the masterlist or the plugin itself cannot be edited or removed, only added to. This is to prevent users from accidently overriding important metadata. +

    LOOT's sorting algorithm uses the contents of plugins to work out where they should load relative to one another. However, this is sometimes not enough for it to produce a correct load order. In such cases, additional metadata can be supplied so that the plugins get sorted correctly. This metadata is supplied to LOOT by two sources: one is the masterlist, which is maintained by the LOOT team, and the other is the userlist, which you can edit as you desire. +

    The metadata editor allows you to manage the metadata stored in your userlist. It is a more fully-featured version of the dialog displayed during sorting. When opened, it lists all the plugins you have installed, and any that are missing but have existing user-added metadata, in alphabetical order. Plugins that load BSAs are displayed in blue text, and plugins with user-added metadata are displayed with a tick in the first column of the list. Selecting a plugin then opens its metadata for editing, and displays any existing metadata in the fields to the right of the plugin list. Right-clicking a plugin displays a context menu containing a few commands. The editor fields and context menu commands are explained in the tables below. +

    The Add …, Edit … and Remove … buttons are used to edit the contents of the list currently visible. The Edit … and Remove … buttons are greyed out if no row is selected or if the selected row is not user-added metadata, but comes from the masterlist or the plugin itself. Metadata that comes from the masterlist or the plugin itself cannot be edited or removed, only added to. This is to prevent users from accidentally overriding important metadata. + +

    The Show only conflicting plugins checkbox filters the plugin list so that only plugins which either contain conflicting records or (if the selected plugin loads a BSA) load BSAs that may contain conflicting resources are displayed. While the filter is active, it is also possible to add plugins to the Requirements, Incompatibilities and Load After lists by drag 'n' dropping them from the plugin list. The filter must be deactivated to select another plugin for editing. +

    The Save Changes button will save any user-added metadata to your userlist, including any changes made, then exit the metadata editor. The Cancel button will exit the editor without saving any changes. -
    FieldDescription
    Enable User ChangesIf this is checked, BOSS will use the metadata you supplied when sorting the current plugin. Otherwise, your metadata will be ignored. -
    PriorityThis is a rough control for how far up or down the load order a plugin should go. Plugins with equal priority will be compared as normal by the sorting algorithm, but plugins with a larger priority value will load later in the load order than plugins with a smaller priority value. Priority comparisons are only used for plugins that are not masters, requirements or otherwise told to load after one another, and only between plugins that conflict, except if a plugin is empty, in which case conflict status doesn't matter. Plugins have a default priority of 0. -
    RequirementsThis is a list of files that are required by the current plugin for it to function correctly. BOSS will display an error message if any of the listed files are missing. +
    Enable User ChangesIf this is checked, LOOT will use the metadata you supplied when sorting the current plugin. Otherwise, your metadata will be ignored. +
    PriorityModifies plugin position relative to others that change one or more of the same records, but which are otherwise unrelated (ie. neither plugin lists the other as a master, requirement, or in its "load after" list). Plugins that don't change any of the same records are not compared, unless: +
      +
    • One or both of the plugins is a "dummy" plugin, containing only a header record. +
    • One or both of the plugins has the Compare priority against all other plugins checkbox ticked. +
    +

    A plugin with a higher priority value will load after a plugin with a lower priority value. Plugins have a default priority of 0. +

    RequirementsThis is a list of files that are required by the current plugin for it to function correctly. LOOT will display an error message if any of the listed files are missing.

    Any file, not just plugins, can be listed here, and each file has three sub-fields:

    • The filename is the path, relative to the game's Data folder, of the file to be checked for. This sub-field is required.
    • The display name is optional, and if specified will be used instead of the filename in any error messages that are displayed if a problem is encountered relating to the file. -
    • The condition is the optional condition string that is used to determine if the file should be checked for. If left blank, the file will always be checked for. Condition strings are a relatively advanced part of BOSS's functionality, and their syntax is covered in the Metadata Syntax documentation. +
    • The condition is the optional condition string that is used to determine if the file should be checked for. If left blank, the file will always be checked for. Condition strings are a relatively advanced part of LOOT's functionality, and their syntax is covered in the Metadata Syntax documentation.
    -

    Note that listing a plugin's masters as requirements is pointless, as BOSS already checks them. -

    IncompatibilitiesThis is a list of files that are incompatible with the plugin. BOSS will display an error message if any of the listed files are found. +

    Note that listing a plugin's masters as requirements is pointless, as LOOT already checks them. +

    IncompatibilitiesThis is a list of files that are incompatible with the plugin. LOOT will display an error message if any of the listed files are found.

    Any file, not just plugins, can be listed here, and each file has the same three sub-fields as for the requirements field.

    Load AfterThis is a list of plugins which, if present, the current plugin must load after, but which are not required. This field can be used for resolving specific compatibility issues. -
    MessagesA list of messages that are to be displayed for the plugin in BOSS's report. These have no bearing on a plugin's position in the load order. +
    MessagesA list of messages that are to be displayed for the plugin in LOOT's report. These have no bearing on a plugin's position in the load order.

    Each message has four sub-fields:

      -
    • The type is fairly self-explanatory, and is used to provide messages of varying severity with appropriate emphasis in BOSS's report. +
    • The type is fairly self-explanatory, and is used to provide messages of varying severity with appropriate emphasis in LOOT's report.
    • The content is the actual message text.
    • The condition is, like for the corresponding file sub-field, used to determine if the message should be displayed. If left blank, the message is displayed. -
    • The language is the language BOSS runs in that the message will be displayed for. For example, if the message language is set to English and BOSS is running in German, then the message will not be displayed. If left unspecified, the message will be shown no matter what language BOSS is running in. +
    • The language is the language LOOT runs in that the message will be displayed for. For example, if the message language is set to English and LOOT is running in German, then the message will not be displayed. If left unspecified, the message will be shown no matter what language LOOT is running in.
    -

    If a message's condition determines that it should not be displayed, then it will not be displayed, no matter the language. However, if a message's condition determines that it should be displayed, but the language is specified and doesn't match the language BOSS is running in, the message will not be displayed. -

    Bash TagsA list of Bash Tags. These are used by Wrye Bash when generating a Bashed Patch. BOSS's metadata includes Bash Tag addition and removal suggestions, and any Bash Tags that came with the plugin are also displayed. -

    As BOSS can suggest Bash Tags be added or removed, it is possible for the same Tag to appear twice, being suggested for addition and removal. In such cases, removal overrides addition. +

    If a message's condition determines that it should not be displayed, then it will not be displayed, no matter the language. However, if a message's condition determines that it should be displayed, but the language is specified and doesn't match the language LOOT is running in, the message will not be displayed. +

    Bash TagsA list of Bash Tags. These are used by Wrye Bash when generating a Bashed Patch. LOOT's metadata includes Bash Tag addition and removal suggestions, and any Bash Tags that came with the plugin are also displayed. +

    As LOOT can suggest Bash Tags be added or removed, it is possible for the same Tag to appear twice, being suggested for addition and removal. In such cases, removal overrides addition.

    Each Bash Tag has three sub-fields:

    • The state determines whether the Tag is to be suggested for addition or removal. @@ -246,145 +250,136 @@ Clicking on a plugin in the list will display the editing panel, where its load
    Context Menu CommandDescription
    Copy NameCopies the selected plugin's filename to the clipboard. -
    Copy Metadata As TextCopies the selected plugin's current metadata, as it appears in the userlist, to the clipboard. This makes it easier to share your metadata changes with the BOSS team, as they can then paste this text directly into the masterlist, and also avoids any typos being introduced. If posting the text in an online forum that supports BBCode (as most forums do), be sure to wrap it in [code] tags, eg. [code]copied text[/code], so that the spaces are not removed by the forum software. -
    Remove All User-Added MetadataThis removes all saved user-added metadata from the selected plugin, and any unsaved data added to the plugin since the Metadata Editor window was opened. +
    Copy Metadata As TextCopies the selected plugin's current metadata, as it appears in the userlist, to the clipboard. This makes it easier to share your metadata changes with the LOOT team, as they can then paste this text directly into the masterlist, and also avoids any typos being introduced. If posting the text in an online forum that supports BBCode (as most forums do), be sure to wrap it in [code] tags, eg. [code]copied text[/code], so that the spaces are not removed by the forum software. +
    Remove Plugin User-Added MetadataThis removes all saved user-added metadata from the selected plugin, and any unsaved data added to the plugin since the Metadata Editor window was opened. +
    Remove All User-Added MetadataThis removes all user-added metadata from all plugins.
    - +

    Editing Settings

    -
    BOSS's settings window.
    +
    LOOT's settings window.
    -

    BOSS's settings window may be accessed by clicking Edit→Settings in the main window's menu bar. BOSS's settings are detailed in the table below. +

    LOOT's settings window may be accessed by clicking Edit→Settings in the main window's menu bar. LOOT's settings are detailed in the table below. -
    SettingDescription
    Default GameIf set to something other than Autodetect, this overrides game autodetection. If the game specified is not detected, BOSS falls back to autodetection. -
    LanguageControls the language BOSS uses in its interfaces. Debug messages are always displayed in English, and any plugin messages that do not have translations in the selected language will be displayed in English instead. -
    Debug VerbosityControls the verbosity of the debug output, which is written to %LOCALAPPDATA%\BOSS\BOSSDebugLog.txt. -
    Update masterlist before sortingIf checked, BOSS will update its masterlist, should an update be available, before sorting plugins. -
    View reports externally in default browser.If checked, BOSS will display its report using your default web browser instead of opening its own window. +
    Default GameIf set to something other than Autodetect, this overrides game autodetection. If the game specified is not detected, LOOT falls back to autodetection. +
    LanguageControls the language LOOT uses in its interfaces. Debug messages are always displayed in English, and any plugin messages that do not have translations in the selected language will be displayed in English instead. +
    Debug VerbosityControls the verbosity of the debug output, which is written to %LOCALAPPDATA%\LOOT\LOOTDebugLog.txt. +
    Update masterlist before sortingIf checked, LOOT will update its masterlist, should an update be available, before sorting plugins.
    -

    The games list allows the customisation of which games BOSS offers support for, trivialising support for multiple copies of a game and Total Conversions. The games listed here will be displayed in the main window's Game menu when BOSS is next run. The Add Game, Edit Game and Remove Game buttons are used to edit the list. Each game has several columns, which are explained below. +

    The games list allows the customisation of which games LOOT offers support for, trivialising support for multiple copies of a game and Total Conversions. The games listed here will be displayed in the main window's Game menu when LOOT is next run. The Add Game, Edit Game and Remove Game buttons are used to edit the list. Each game has several columns, which are explained below.
    ColumnDescription
    NameThe name of the game, or another identifying string, that is displayed in menus and the main window's title bar. -
    Base Game TypeEvery game BOSS runs for must use the plugin file format and load order system of one of the following games: +
    Base Game TypeEvery game LOOT runs for must use the plugin file format and load order system of one of the following games:
    • TES IV: Oblivion
    • TES V: Skyrim
    • Fallout 3
    • Fallout: New Vegas
    -
    BOSS Folder NameThe sub-folder which BOSS uses to store the game's files in. Each game must be given a unique sub-folder. +
    LOOT Folder NameThe sub-folder which LOOT uses to store the game's files in. Each game must be given a unique sub-folder.
    Master FileThe game's main master file. This is specified as it must load before all other plugins. Note that Skyrim-based games will always load Skyrim.esm first, so this column must always be set to Skyrim.esm for such games. -
    Masterlist Repository URLThe URL of the repository that BOSS uses to update its local copy of the masterlist. If set to an empty string, masterlist updating will be skipped. +
    Masterlist Repository URLThe URL of the repository that LOOT uses to update its local copy of the masterlist. If set to an empty string, masterlist updating will be skipped.

    - Masterlist repositories are Git repositories that are configured to allow unauthenticated read access and contain a masterlist file named masterlist.yaml in their root directory. The BOSS team maintains a set of official repositories for the games that BOSS supports by default. -
    Masterlist Repository BranchThe branch of the masterlist repository that BOSS should get masterlist updates from. + Masterlist repositories are Git repositories that are configured to allow unauthenticated read access and contain a masterlist file named masterlist.yaml in their root directory. The LOOT team maintains a set of official repositories for the games that LOOT supports by default. +
    Masterlist Repository BranchThe branch of the masterlist repository that LOOT should get masterlist updates from.
    Install PathThe path to the game's folder, in which the Data folder lies. Either this or a registry key must be supplied. -
    Install Path Registry KeyThe registry key, in HKEY_LOCAL_MACHINE, that contains the install path of the game. This is used to obtain the install path if BOSS has no previous record of the game's install path, or BOSS's stored install path is invalid. Either this or an install path must be supplied. +
    Install Path Registry KeyThe registry key, in HKEY_LOCAL_MACHINE, that contains the install path of the game. This is used to obtain the install path if LOOT has no previous record of the game's install path, or LOOT's stored install path is invalid. Either this or an install path must be supplied.

    Note that for Skyrim, multiple copies or Total Conversions will all edit the same plugins.txt file, and so they lack the level of independence that is achievable for other games.

    Troubleshooting

    -

    If BOSS encounters a problem at any point, it should provide an error message, either in a dialog (as is generally the case) or in its report (as for errors encountered during the sorting process). If BOSS unexpectedly crashes, or you experience a problem for which no error message is given, please report the crash or problem to an official BOSS thread (see Contributing To BOSS), so that it can be fixed. -

    If the information below does not help you to solve any problems you are experiencing, please seek further support in one of the official BOSS threads. -

    There are a few general reasons why BOSS may fail to function correctly. Check if any of the symptoms listed below fit your issue. +

    If LOOT encounters a problem at any point, it should provide an error message, either in a dialog (as is generally the case) or in its report (as for errors encountered during the sorting process). If LOOT unexpectedly crashes, or you experience a problem for which no error message is given, please report the crash or problem to an official LOOT thread (see Contributing To LOOT), so that it can be fixed. +

    If the information below does not help you to solve any problems you are experiencing, please seek further support in one of the official LOOT threads. +

    There are a few general reasons why LOOT may fail to function correctly. Check if any of the symptoms listed below fit your issue.

    -
    No change in load order. +
    LOOT ran without any errors, but the load order hasn't changed to match what LOOT has in its report.
    Make sure that you aren't using another utility to lock your load order. -
    Some plugins have the wrong or no version number given in the BOSS Log. +
    If you're sorting for Skyrim, make sure that you haven't replaced or renamed your TESV.exe, as this interferes with LOOT's ability to decide how to set the load order. +
    Some plugins have the wrong or no version number given in LOOT's report.
    No solution. -
    You get an error message of the form There is a problem sending the command to the program. -
    Windows sometimes does this when it tries to open files in their default application. If you're sure that you have a default program for HTML files set, restarting your computer generally fixes the issue. -
    A game is installed, but BOSS cannot detect it. +
    A game is installed, but LOOT cannot detect it.
    The game's Registry entry is missing. This happens to a lot of people, because Steam likes to remove it whenever the game is updated or its game cache is verified. Run the game's launcher to add the Registry entry back again. +
    There are no line breaks in plugins.txt or loadorder.txt when they are opened in Notepad. +
    There probably are LF line breaks, but Notepad only recognises CRLF line breaks. It doesn't make any difference to the game.
    -

    Contributing To BOSS

    -

    User contribution of additions and corrections to BOSS's masterlists are vital to the upkeep of BOSS. Please let us know what you know! +

    Contributing To LOOT

    +

    LOOT is very much a community project, and contributions from its users are vital to its upkeep. The best way to contribute is to make changes yourself at GitHub! It's the fastest way to get changes you want applied, and you'll get your name automatically immortalised in our credits. -

    General discussion and the submission of questions, suggestions and metadata takes place in BOSS's official threads for Oblivion, Skyrim, Fallout 3 and Fallout: New Vegas. These are linked to at the bottom of BOSS's homepage. +

    Otherwise, general discussion takes place in LOOT's official forum threads. These are linked to at the bottom of LOOT's homepage. + +

    If you want to submit metadata, the easiest way to do so is to add the metadata to your own LOOT install (either during sorting or in the Metadata Editor), and use the Copy Metadata As Text feature to easily get it in a form that you can then edit into a masterlist on GitHub or post in the official forum threads.

    Information on dirty plugins is very welcome, but for such information to be useful we require at least the filename and the CRC of the dirty plugin. The CRC may be calculated using Wrye Bash or 7-zip, with other sources being unverified as correct. In the case of 7-zip, the CRC checksum for data is the one required. In addition to the CRC, the number of records removed (the ITM count) and/or undeleted (the UDR count) are also welcome. -

    If you wish to submit metadata, the easiest way to do so is to add the metadata to your own BOSS install (either during sorting or in the Metadata Editor), and use the Copy Metadata As Text feature to easily get it in a form that you can then post in the official forum threads. +

    -

    Translating BOSS

    -

    BOSS supports translation into other languages, with the following limitations: +

    Translating LOOT

    +

    LOOT supports translation into other languages, with the following limitations:

      -
    • Debug log messages and error messages generated by the libraries BOSS uses cannot be translated. +
    • Debug log messages and error messages generated by the libraries LOOT uses cannot be translated.
    • Masterlist messages can be translated, but translations must be submitted to the masterlist maintainers for addition. -
    • The languages BOSS supports is hardcoded, so BOSS must be updated to include new translations. +
    • The languages LOOT supports is hardcoded, so LOOT must be updated to include new translations.
    -

    Translations can be submitted for inclusion into BOSS in the relevant issue tracker entry, by posting it in one of BOSS's official threads (see Contributing To BOSS), or by contacting one of the BOSS team directly (see Project Members). -

    To translate BOSS's installer: +

    Translations are best submitted through GitHub's forking system. You will need to fork the LOOT source code repository. All file paths given below are relative to the base folder of that repository. +

    To translate LOOT's installer:

      -
    1. Download the installer script. -
    2. Open the downloaded installer script in a text editor of your choice. +
    3. Open the installer script at src/installer.nsi in a text editor of your choice.
    4. The English strings are located in the section with the heading English Strings. Copy and paste this section into a new text file, and translate the quoted strings, replacing the English text. For the lines beginning VIAddVersionKey, only translate the second quoted string.
    5. Save the text file containing your translated strings.
    -To translate the BOSS application: +To translate the LOOT application:
    1. Download and install the latest version of Poedit. -
    2. Download BOSS's translation template file. -
    3. If you are updating an existing translation, download the relevant translation file for the language you're interested in: - -
    4. Open Poedit and select File->Preferences, then in the Editor tab ensure that the checkbox for the Automatically compile .mo file on save setting is checked. Click OK to close the preferences window. -
    5. If you are starting a new translation, select File->New catalogue from POT file... and choose the template file you downloaded. In the Catalog properties dialog, just click OK without changing anything. -
    6. If you are updating a previous translation, open the translation file you downloaded in Poedit, then select Catalogue->Update from POT file... and choose the template file you downloaded. Click OK in the Update summary dialog. +
    7. If you are starting a new translation, select File->New catalogue from POT file... and choose the template file at resources/l10n/template.pot. In the Catalog properties dialog, just click OK without changing anything. +
    8. If you are updating a previous translation, open in Poedit the loot.po translation file in the relevant subdirectory of resources/l10n, then select Catalogue->Update from POT file... and choose the template file you downloaded. Click OK in the Update summary dialog.
    9. Edit the translation file to add or update translations of the programs' text. Strings that were added since the last translation are displayed in bold and dark blue, and strings you have edited the translations of are marked with a star to the left of their source text in the main list.

      Some languages may use different words or phrases for different contexts where only one word or phrase may be used for all contexts in English. While no contextual information is supplied to translators by default, it can be added on request. To request the addition of contextual information to a text string, contact WrinklyNinja, quoting the structure that contains the string for which you are requesting contextual information.

      Some strings to be translated may contain special characters. Different types of special character that may be encountered are:

      • Backslashes \. Backslashes must be escaped using another backslash, so if you wanted to display a single backslash \, you would put \\ in your translated string. -
      • Double-quotation marks ". Double-quotation marks must be preceded by a backslash, ie. \", or BOSS will crash when it tries to display the string. +
      • Double-quotation marks ". Double-quotation marks must be preceded by a backslash, ie. \", or LOOT will crash when it tries to display the string.
      • New line characters \n. Do not change the position of these characters relative to the surrounding text, they are responsible for creating new lines.
      • Words containing an ampersand &. If a string contains a word that begins with or includes an ampersand, the string is for a menu item and the ampersand is a symbol placed before a specific letter and used to show which keyboard key can be used to select that menu item. The ampersand can be moved to be placed before a more appropriate letter in the translated text. -
      • Formatting placeholders. Placeholders are used so that BOSS can substitute text or numbers that are generated at runtime into pre-made strings. They appear as a number surrounded by percentage signs, eg. %1%. If formatting placeholders are used in the untranslated string, they must all be present in the translated string, or BOSS will crash when it tries to display the translated string. Placeholders can be moved around so that the sentence makes grammatical sense in the target language. +
      • Formatting placeholders. Placeholders are used so that LOOT can substitute text or numbers that are generated at runtime into pre-made strings. They appear as a number surrounded by percentage signs, eg. %1%. If formatting placeholders are used in the untranslated string, they must all be present in the translated string, or LOOT will crash when it tries to display the translated string. Placeholders can be moved around so that the sentence makes grammatical sense in the target language.
      -
    10. Save the translation file with the filename boss.po in a location of your choosing. This will also create a boss.mo file in the same location. +
    11. Save the translation file with the filename loot.po in a location of your choosing.

    Credits

    -

    Since June 2009, BOSS has been a collaborative project, first on Google Code and now on GitHub. An up-to-date list of team members past and present may be viewed on the project wiki. Unless otherwise noted, project members can be contacted on the Bethesda Softworks Forums or on The Nexus Forums via the private messaging system. -

    As BOSS is very much a community project, credit is due to a very large number of sources and people outside of the BOSS Team. Some people have gone out of their way and provided continuing, expert and detailed help - thank you very much! -

    In addition to the above data-related support, the following are credited with application-related support: +

    LOOT is developed by a team on GitHub, with contributions from users. A full list of GitHub contributors may be found here. An up-to-date list of team members may be viewed on the project wiki. Unless otherwise noted, team members can be contacted on the Bethesda Softworks Forums or on The Nexus Forums via the private messaging system. +

    LOOT's masterlists were largely converted from BOSS's masterlists, and so credit is due to the very large number of sources and people who have contributed to them. +

    In addition, the following are credited with application-related support:

      -
    • Dark Creations: For hosting BOSS's Bugzilla bug tracker that was used by v2 to collect anonymous unrecognised plugin reports. Particular thanks to its administrators Andalaybay and Xae for offering to host the tracker and helping to work around Firefox and Bugzilla bugs encountered. -
    • Surazal: For providing the inspiration for many features through his BOSS Masterlist Manager macro for Microsoft Word. -
    • myk002: For code contributions during development of v1.6–2.1. -
    • Hickory: For providing the icon BOSS uses. -
    • Ysne58: For keeping the thread links on BOSS's Nexus site pages up to date. -
    • Łukasz Niemczyk: For the Polish translation of v3. -
    • bluesky404: For the Chinese translation of v3. -
    • Kaos: For the French translation of v3. -
    • For beta testing: Surazal, myk002, Hickory, Ysne58, the Beta Testing & Analysis Guild at TES Alliance, AndalayBay, dAb, dj2005, Dubiousness, hyno111, Invader, matter2003, NightStar, olminator, saebel, Telyn, wiz0floyd, wormheart, Zanderat, zone22 and many more. +
    • Icon: jonwd7 +
    • Polish translation: Łukasz Niemczyk +
    • Chinese translation: bluesky404 +
    • French translation: Kaos +
    • Spanish translation: Sharlikran +
    • Russian translation: Tokc.D.K. +
    • Brazilian Portuguese translation: Kassane +
    • Finnish translation: 3ventic +
    • Beta testing: Too many to list, thank you all!
    -

    BOSS is written in C++ and makes use of the Alphanum, Boost, libespm, libgit2, libloadorder, PugiXML, wxWidgets and yaml-cpp libraries. BOSS's reports are written in HTML5/CSS3/Javascript and make use of Polyfill.js to provide Internet Explorer 8 compatibility. Copyright license information for all these may be found here. +

    LOOT is written in C++ and makes use of the Alphanum, Boost, libespm, libgit2, libloadorder, wxWidgets and yaml-cpp libraries. LOOT's reports are written in HTML5/CSS3/Javascript and make use of Polyfill.js and RequireJS. Copyright license information for all these may be found here.

    License

    -

    BOSS is distributed under the GNU General Public License v3.0, aside from the documentation, which is distributed under the GNU Free Documentation License v1.3. The full texts of the licenses are included with BOSS in the accompanying GNU GPL v3.txt and GNU FDL v1.3.txt files. +

    LOOT is distributed under the GNU General Public License v3.0, aside from the documentation, which is distributed under the GNU Free Documentation License v1.3. The full texts of the licenses are included with LOOT in the accompanying GNU GPL v3.txt and GNU FDL v1.3.txt files. -

    While the GPL license allows anyone to make derivative works of BOSS, the BOSS Team encourages those thinking of doing so to first discuss their reasoning for such an endeavour with the Team. It may be that what the derivative work would do differently is already planned for a future version of BOSS or would be happily integrated into BOSS, thus avoiding any extra effort by others. +

    While the GPL license allows anyone to make derivative works of LOOT, the LOOT Team encourages those thinking of doing so to first discuss their reasoning for such an endeavour with the Team. It may be that what the derivative work would do differently is already planned for a future version of LOOT or would be happily integrated into LOOT, thus avoiding any extra effort by others. -

    BOSS has been specifically designed to prevent it being locked into the BOSS Team's official masterlist repositories. Nevertheless, the BOSS Team appeals to the community to avoid the distribution of unofficial masterlists, as this would only hamper the effort to create one set of stores for load order information. Any issues with a masterlist are best brought to the attention of the BOSS Team so that they may be remedied. +

    LOOT has been specifically designed to prevent it being locked into the LOOT Team's official masterlist repositories. Nevertheless, the LOOT Team appeals to the community to avoid the distribution of unofficial masterlists, as this would only hamper the effort to create one set of stores for load order information. Any issues with a masterlist are best brought to the attention of the LOOT Team so that they may be remedied.

    GNU Free Documentation License Version 1.3 Notice:

    Copyright (C) 2012—2014 WrinklyNinja
    @@ -396,11 +391,11 @@ A copy of the license is included in the file named "GNU FDL v1.3.txt".Appendices

    Introduction To Load Orders

    -

    This appendix provides a general overview of load ordering in the games BOSS supports for those who are unfamiliar with the concept. For simplicity, the game will be used when the text refers to any of the games that BOSS supports. +

    This appendix provides a general overview of load ordering in the games LOOT supports for those who are unfamiliar with the concept. For simplicity, the game will be used when the text refers to any of the games that LOOT supports.

    Mod plugins for the game are files that end in .esp or .esm. These files are created by the game's official editing tools, or by third-party modders' tools. They contain various data records, which cover almost all aspects of what is in the game – NPCs, items, races, interiors, worlds, quests, etc. – and can either be new or changes to the records added by another plugin. -

    When the game is run, it loads each installed plugin one by one in a certain load order. The load order is important for two reasons: +

    When the game is run, it loads each installed plugin one by one in a certain load order. The load order is important for two reasons:

      -
    • If one plugin changes a record added by another plugin, the former must load after the latter. If it doesn't, the game will crash on launch. +
    • If one plugin changes a record added by another plugin, the former must load after the latter. If it doesn't, the game will crash on launch.
    • The game can only apply one version of a record, so if multiple plugins contain the same record, the last-loaded plugin's version overrides all others. This is known as the rule of one, and it holds true for almost all record types. Some overrides can cause problems in-game, and a good load order is one that arranges plugins to avoid such problems.

    There are a few hardcoded rules related to load order: @@ -411,29 +406,30 @@ A copy of the license is included in the file named "GNU FDL v1.3.txt".In Skyrim, if Update.esm is present, it is always loaded. It loads after all other master plugins, unless it has another position explicitly set.

    A plugin's position in the load order is often displayed by mod managers as a hexadecimal number, from 00 to FE (0 to 255 in decimal). The plugin with position 00 loads first, and the plugin with position FE is loaded last. Hexadecimal numbers are used to display the load order positions of plugins because these numbers form the first two digits of the code that the game uses to reference the records that the plugin adds, so knowing the numbers allows modders and mod users to determine from which plugin a record is from. +

    In Oblivion, Fallout 3 and Fallout: New Vegas, load order is determined by plugin timestamps, and the plugins you have accessed are listed in %LOCALAPPDATA%\<game>\plugins.txt. As such, it's best to use a mod manager to create a backup of your load order. In Skyrim, the load order of active plugins is stored in %LOCALAPPDATA%\<game>\plugins.txt, and modding utilities generally use %LOCALAPPDATA%\<game>\loadorder.txt to store the load order of all plugins. This makes backing up your load order as easy as making copies of those two files.

    Dirty Edits, Mod Cleaning & CRCs

    Dirty edits are often a side-effect of mod creation, and are often due to bugs in the utilities Bethesda has provided to create mods, rather than bad practice by mod authors. Dirty edits can cause a wide range of issues, including incorrect game settings, missing content, broken quests and crashing to desktop. The more dirty edits there are in a mod, and the more mods with dirty edits you use, the more likely you are to experience issues.

    Thankfully there is a way to remove dirty edits from mods relatively easily, a process known as mod cleaning, using TES4Edit, FO3Edit, FNVEdit or TES5Edit (for Oblivion, Fallout 3, Fallout: New Vegas and Skyrim respectively). Detailed instructions and information on mod cleaning are available for Oblivion and Skyrim, with the process being largely the same for the others. -

    The problem of dirty edits is largely a problem of ignorance on the part of mod authors and users alike of the problems dirty mods can cause. As such, there are community efforts to raise awareness of dirty edits and cleaning. BOSS plays a key role in these efforts, as it holds the complete list of all known dirty mods, and it uses this information to provide notification messages to users for any dirty mods they have installed. -

    BOSS identifies and describes unclean plugins using four key pieces of information. They are: +

    The problem of dirty edits is largely a problem of ignorance on the part of mod authors and users alike of the problems dirty mods can cause. As such, there are community efforts to raise awareness of dirty edits and cleaning. LOOT plays a key role in these efforts, as it holds the complete list of all known dirty mods (as does BOSS), and it uses this information to provide notification messages to users for any dirty mods they have installed. +

    LOOT identifies and describes unclean plugins using four key pieces of information. They are:

      -
    • CRC value: CRC values are a highly accurate way of identifying files based on their contents, as if the contents change, so does the CRC value. BOSS identifies an unclean plugin by comparing the installed plugin's CRC value against the CRC values for known unclean versions of that plugin. This identification method has the limitation that it can't detect unclean plugins that aren't already known as such, and won't detect unclean but edited plugins, but it's a lot faster than actually checking for dirty edits in the plugin. +
    • CRC value: CRC values are a highly accurate way of identifying files based on their contents, as if the contents change, so does the CRC value. LOOT identifies an unclean plugin by comparing the installed plugin's CRC value against the CRC values for known unclean versions of that plugin. This identification method has the limitation that it can't detect unclean plugins that aren't already known as such, and won't detect unclean but edited plugins, but it's a lot faster than actually checking for dirty edits in the plugin.
    • ITM Count: ITM records are a type of dirty edit where a mod has overwritten something in the game without actually changing anything. If another mod higher up in the load order makes an intentional change to that thing, it will have its effect cancelled out by the ITM record, which can cause problems. The ITM count is the number of ITM records found and corrected in the mod plugin.
    • UDR Count: Deleting records is a significant cause of crashes and game bugs. UDRs are records that the mod deleted from the game or from another mod that have been corrected safely by undeleting them and disabling them instead, which has the same intended effect without causing issues. The UDR count is the number of deleted reference records found and corrected in the mod plugin.
    • Deleted Navmesh Count: Like deleting records, deleting navmeshes can cause crashes. However, these cannot be automatically corrected, and require manual cleaning. Navmeshes don't exist in Oblivion, so this information doesn't apply.
    -

    In addition to the above, there is another type of dirty edit known as a wild edit. These are any edit that is unrelated to the purpose of the mod, and so provide unnecessary opportunity for conflicts with other mods that do need to change the same thing. It can be difficult to tell if an edit is a wild edit, and so they cannot be automatically cleaned. BOSS can still notify users of wild edits and link to information on fixing them if the CRCs of plugins with wild edits are reported, along with details on what needs cleaning. -

    BOSS and the modding communities rely on user contribution of this information to progress. For information on how to contribute, see Contributing To BOSS. If you find that a mod contains dirty edits, you should also report this to the mod's author so that they can fix it. -

    Note: TES4Edit et al. will include a variety of junk records in the ITM count for a plugin, such as new empty cells that are automatically generated and are almost impossible to remove. These junk records are non-harmful, and BOSS may inform users when a mod contains these and no true ITMs to avoid confusion. +

    In addition to the above, there is another type of dirty edit known as a wild edit. These are any edit that is unrelated to the purpose of the mod, and so provide unnecessary opportunity for conflicts with other mods that do need to change the same thing. It can be difficult to tell if an edit is a wild edit, and so they cannot be automatically cleaned. LOOT can still notify users of wild edits and link to information on fixing them if the CRCs of plugins with wild edits are reported, along with details on what needs cleaning. +

    LOOT and the modding communities rely on user contribution of this information to progress. For information on how to contribute, see Contributing To LOOT. If you find that a mod contains dirty edits, you should also report this to the mod's author so that they can fix it. +

    Note: TES4Edit et al. will include a variety of junk records in the ITM count for a plugin, such as new empty cells that are automatically generated and are almost impossible to remove. These junk records are non-harmful, and LOOT may inform users when a mod contains these and no true ITMs to avoid confusion.

    File Permissions

    -

    If you are running Windows Vista or a later version of Windows, BOSS (and other modding programs) may be prevented from working correctly by the UAC security feature. There are four common workarounds to this problem: +

    If you are running Windows Vista or a later version of Windows, LOOT (and other modding programs) may be prevented from working correctly by the UAC security feature. There are four common workarounds to this problem:

    1. Install the game outside the Program Files (or Program Files (x86) if on 64-bit Windows). UAC prevents unauthorised edits to these folders, so by installing the game outside of them, you remove it from UAC's reach, allowing you to use mods more easily.
    2. Deactivate UAC. This can be done from the Control Panel, and will turn UAC off across the whole of your computer. It is up to you whether you feel that you have adequate security measures in place to do this without risk.
    3. Give yourself Full Control permissions over your game install folder. This will allow you to make any edits you desire while keeping UAC active and on guard for any edits made by programs you do not run, and also means that you do not need to reinstall your game to a new location. -
    4. Run BOSS as an Administrator. Right-click the BOSS executable, or the shortcut if launching from a shortcut, and select Run as administrator. +
    5. Run LOOT as an Administrator. Right-click the LOOT executable, or the shortcut if launching from a shortcut, and select Run as administrator.

    For those that wish to take the third option and give themselves Full Control permissions, here is a guide:

      @@ -444,65 +440,53 @@ A copy of the license is included in the file named "GNU FDL v1.3.txt".In the Properties window, select OK to exit. You should now have Full Control permissions over your chosen folder.
    -

    Differences between BOSS v2 and v3

    -

    BOSS version 3 is an almost complete redesign and rewrite of v2. As part of its development, many features present in v2 have been changed or removed, and the table below provides an overview of these changes. - - - -
    Feature / ComponentBOSS v2BOSS v3 -
    Plugin sorting mechanismBOSS scans the game plugin folder for plugins, and arranges those found in the order that they appear in the masterlist. This order is then altered according to any user rules present in the userlist.BOSS scans the game plugin folder for plugins, reads their contents, and uses this data on their masters and the records they change in conjunction with any additional metadata supplied by the masterlist and userlist to calculate the optimal load order according to its sorting algorithm. The load order produced is generally different to that provided by v2. -
    Masterlist updatingBOSS downloads a masterlist and inserts into it version information that is scraped from Google Code.BOSS uses Git to update masterlists, benefiting from a more robust mechanism with support for differential updates (reducing the amount of data that needs to be downloaded) and rolling back revisions in case of parsing errors. -
    Masterlist structure & syntaxUses a custom file format.Uses YAML 1.2, with custom condition string syntax modelled after Python's condition expressions. -
    Userlist structure & syntaxUses a custom file format, different from the masterlist format.Uses the same format and syntax as the masterlist. -
    Morrowind supportTechnically supports Morrowind, though its masterlist is near-empty.Does not support Morrowind. Morrowind mod users are advised to use mlox. -
    BOSS file locationsAll BOSS's files are stored in the BOSS folder first installed.BOSS stores any files it creates (reports, masterlists, userlists, settings) in the %LOCALAPPDATA%\BOSS folder. -
    Game selection on first run.BOSS asks the user to select a game from a list.BOSS selects the first game detected. -
    File CRC calculationFile CRC calculation is optional.File CRC calculation is always-on, as it no longer presents any significant additional performance impact. -
    BOSS Log / Report formatThe BOSS Log can either be generated as plain text or as HTML.The BOSS Report can only be generated as HTML. -
    Perform trial runBOSS can perform a trial run, in which it displays the load order it would set, but does not set it.The option to perform a trial run has been removed, as equivalent functionality is provided by cancelling sorting at the confirmation dialog. -
    Update masterlist onlyBOSS can be run to update a game's masterlist without then sorting any plugins, even if that game is not installed.BOSS can only update a masterlist as part of the sorting process, and cannot run for games that are not installed. This is because BOSS's updating process no longer inserts version information into the masterlists, and so the exact same masterlists that BOSS uses can now be downloaded from BOSS's online repositories using a web browser, removing the need for BOSS to include this functionality. -
    Undo changesIt is possible to run BOSS to undo its changes back one run or two.It is no longer possible to undo load order changes through BOSS. Instead a confirmation dialog is provided to allow users to make sure that BOSS will set a load order they want, and to give them a last-minute opportunity to backup their existing load order, perhaps using a mod manager of their choice. -
    Optionally suppress BOSS Log / Report displayBOSS allows the user to stop the BOSS Log being automatically displayed after sorting.The BOSS Report is always displayed after sorting, as it is more important for the user to verify that the automated sorting process completed successfully and correctly. -
    Nehrim supportBOSS provides first-class support for Nehrim alongside Oblivion, Skyrim, Fallout 3 and Fallout: New Vegas.BOSS supports Nehrim as an Oblivion-derived game instance, and the Nehrim and Oblivion masterlists have been merged. This is due to v3's generalised support for Total Conversion mods across the games it supports. In practice Nehrim support appears the same. -
    User rulesBOSS allows the user to customise its output by providing user rules for specifying relative plugin positions and for adding to or replacing the messages attached to mods.BOSS allows the user to add to any metadata provided by the masterlist. -
      -
    • It is no longer possible to precisely set a plugin's load order position. BOSS can be told that a plugin A has to load after another plugin B, but where exactly after B that plugin A is positioned is decided by the sorting algorithm. -
    • It is no longer possible to specify a plugin A to load before another plugin B, though a similar effect may be produced by loading B after A. -
    • It is no longer possible to sort or insert into groups, as groups no longer exist. -
    • It is no longer possible to replace messages provided by the masterlist. -
    • Knowledge of message syntax is no longer required to add new messages. -
    • It is now possible to provide conditions for user-added messages. -
    -
    Updating BOSSBOSS includes an update checker and a semi-automated update process.BOSS no longer includes an update checker or a semi-automated update process. This is because new releases are announced in the masterlists anyway, and the semi-automated update process is not as efficient as using the installer. -
    Manual editing of user rules / metadataBOSS allows the user to open the userlist file for manual editing from the GUI.BOSS only provides the GUI metadata editor for editing the userlist. Users may still edit the userlist file manually, but it must also be located manually. -
    Proxy SupportBOSS includes support for proxies, allowing users to specify the proxy hostname and port number and provide authentication details.BOSS no longer includes any proxy support, as the proxy support in v2 was reported broken a few times and it was deemed not worth fixing due to very low usage. -
    BOSS Log / Report contentThe BOSS Log includes the following sections: -
      -
    • Summary -
    • User Rules -
    • Script Extender Plugins -
    • Recognised Plugins -
    • Unrecognised Plugins -
    -
    The user rules and script extender plugins sections have been removed as user metadata cannot fail to be applied, and the script extender plugins information was deemed irrelevant. The recognised and unrecognised plugins sections have been combined into one Details section, as there is no longer any such thing as an unrecognised plugin. -
    BOSS Log / Report FiltersThe HTML BOSS Log includes a large number of filters to selectively hide content.The number of filters has been reduced, as some are no longer applicable: -
      -
    • BOSS no longer labels active plugins as such, so the active label filter has been removed. -
    • Requirement and incompatibility messages no longer exist (instead warnings are displayed if the relevant files are missing / present), so their corresponding filters have been removed. -
    • The hide clean plugins filter has been removed as it was misleading, since the plugins hidden were not necessary clean. -
    -
    BOSS Log plugin submissionBOSS allows users to submit unrecognised plugins from the HTML BOSS Log.As there is no longer any such thing as an unrecognised plugin, the submission system has been removed. -
    BOSS Log display customisationBOSS allows users to customise the colour scheme used by the BOSS Log.BOSS does not allow customisation of the colour scheme used by the BOSS report. However, the styling is now provided by a static stylesheet instead of being dynamically generated within the report every time BOSS is run, so this static stylesheet can be edited to achieve the same effect. -
    Command line interfaceBOSS provides a command line interface.BOSS does not provide a command line interface, as the greater need for user interaction makes it unwieldy. -
    Windows XP supportSupports Windows XP.Does not support Windows XP. -
    -

    Version History

    -

    Only the history of version 3 is given, as changes prior to version 3 are irrelevant due to the complete redesign that occurred. The masterlists are updated far too frequently for their changes to be concisely recorded here, but a full history of changes to them may be viewed by browsing the GitHub repositories. +

    Only program history is recorded here. The masterlists are updated far too frequently for their changes to be concisely recorded here, but a full history of changes to them may be viewed by browsing the GitHub repositories. -

    3.0.0 - Day February 2014

    +

    0.6.0 - 05 July 2014

      -
    • BOSS completely redesigned from scratch and almost completely rewritten. See Differences between BOSS v2 and v3 for an overview of the changes. +
    • Fixed: The uninstaller not removing the Git repositories used to update the masterlists. +
    • Fixed: Miscellaneous crashes due to uncaught exceptions. +
    • Fixed: Plugin priorities are now temporarily "inherited" during sorting so that a plugin with a low priority that is made via metadata to load after a plugin with a high priority doesn't cause other plugins with lower priorities to be positioned incorrectly. +
    • Fixed: The default language is now correctly set to English. +
    • Fixed: Defaults for the online masterlist repository used for Nehrim. +
    • Fixed: Endless sorting loop that occurred if some user metadata was disabled. +
    • Added: Display of masterlist revision date in reports. +
    • Added: Report filter for inactive plugin messages. +
    • Added: The number of dirty plugins, active plugins and plugins in total to the report summary. +
    • Added: A find dialog to the report viewer, initiated using the Ctrl-F keyboard shortcut. +
    • Added: LOOT's windows now remember their last position and size. +
    • Added: Command line parameter for selecting the game LOOT should run for. +
    • Added: Finnish translation. +
    • Removed: Support for Windows XP. +
    • Removed: Support for loading BOSS masterlists using the API. This was a leftover from when LOOT was BOSSv3 and backwards compatibility was an issue. +
    • Removed: The ability to open reports in an external browser. This was necessitated by the changes to report generation. +
    • Removed: The MSVC 2013 redistributable requirement. +
    • Removed: The "None Specified" language option is no longer available: English is the new default. +
    • Changed: Unified and improved the metadata editors launched during and outside of sorting. +
        +
      • The metadata editor now resizes more appropriately. +
      • The mid-sorting instance hides the requirement, incompatibility, Bash Tags, dirty info and message lists. +
      • Both instances now have a conflict filter, priority display in their plugin list and drag 'n' drop from the plugin list into whatever metadata lists are visible. +
      • The mid-sorting instance also hides the load after entry edit button, and the button to add new entries (so drag 'n' drop is the only available method of adding entries). +
      • The metadata editor now displays plugins with user edits using a tick beside their name, rather than bolding their name text. +
      • Plugins that have been edited in the current instance have their list entry text bolded. +
      • Checkboxes have been added to set whether or not a priority value is "global". The UI also now displays the priority value used in comparisons (ie. with the millions and higher digits omitted). +
      • A right-click menu command for clearing all user-added metadata for all plugins has been added to the metadata editor. +
      +
    • Changed: Missing master/requirement and incompatibility errors are downgraded to warnings if the plugin in question is inactive. +
    • Changed: Masterlist update errors have been made more user-friendly. +
    • Changed: If an error is encountered during masterlist update, LOOT will now silently delete the repository folder and attempt the update again. If it fails again, it will then report an error. +
    • Changed: Masterlist update now handles repository interaction a lot more like Git itself does, so should be less error-prone. +
    • Changed: Cyclic dependency error messages now detail the full cycle. +
    • Changed: LOOT's report now uses a static HTML file and generates a javascript file that is dynamically loaded to contain the report data. This removes the PugiXML build dependency. +
    • Changed: Debug log message priorities adjusted so that medium verbosity includes more useful data. +
    • Changed: Updated dependencies: libgit2 (v0.21.0), wxWidgets (v3.0.1), libloadorder (latest), libespm (latest). +
    + +

    0.5.0 - 31 March 2014

    +
      +
    • Initial release.
    + + + + + + + + + + + + + + + + +
    +
    + +
      +
    1. File + +
    2. Game + +
    3. Settings +
    4. Help + +
    +
      +
    1. Update Masterlist +
    2. Sort +
    +
    +
    + +
    +
    +

    Summary

    + + +
    Masterlist RevisionN/A +
    Masterlist DateN/A +
    + + +
    Warnings0 +
    Errors0 +
    Total Messages0 +
    + + +
    Active Plugins0 +
    Dirty Plugins0 +
    Total Plugins0 +
    +
    +
    +

    General Messages

    +
      + +
    +
    + +
    +
    + + +

    LOOT

    +

    Copyright © 2012–2014 WrinklyNinja +

    Load order optimisation for Oblivion, Skyrim, Fallout 3 and Fallout: New Vegas. +

    http://loot.github.io +

    +LOOT 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 any later version. + +LOOT 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 LOOT. If not, see <http://www.gnu.org/licenses/>. +
    + +
    + + +

    Settings

    + +
    + +
    + + + + + + + +
    NameBase GameLOOT FolderMaster FileMasterlist Repository URLMasterlist Repository BranchInstall PathInstall Path Registry Key +
    Add new row...
    +

    +

    Language changes will be applied after LOOT is restarted. +


    +
    + + +
    +
    + + + + + \ No newline at end of file diff --git a/resources/script.js b/resources/script.js deleted file mode 100644 index f3c09c6d..00000000 --- a/resources/script.js +++ /dev/null @@ -1,222 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2013 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ -'use strict'; -function isStorageSupported() { - try { - return ('localStorage' in window && window['localStorage'] !== null && window['localStorage'] !== undefined); - } catch (e) { - return false; - } -} -function saveCheckboxState(evt) { - if (evt.currentTarget.checked) { - try { - localStorage.setItem(evt.currentTarget.id, true); - } catch (e) { - if (e == QUOTA_EXCEEDED_ERR) { - alert('Web storage quota for this document has been exceeded. Please empty your browser\'s cache. Note that this will delete all locally stored data.'); - } - } - } else { - localStorage.removeItem(evt.currentTarget.id); - } -} -function loadSettings() { - var i = localStorage.length - 1; - while (i > -1) { - var elem = document.getElementById(localStorage.key(i)); - if (elem != null && 'defaultChecked' in elem) { - elem.dispatchEvent(new MouseEvent('click')); - } - i--; - } -} -function showElement(element) { - if (element != null) { - if (element.className.indexOf('hidden') != -1) { - element.className = element.className.replace('hidden', ''); - } - } -} -function hideElement(element) { - if (element != null) { - if (element.className.indexOf('hidden') == -1) { - element.className += ' hidden'; - } - } -} -function stepUnhideElement(element) { - if (element != null && element.className.indexOf('hidden') != -1) { - element.className = element.className.replace('hidden', ''); - } -} -function stepHideElement(element) { - if (element != null) { - element.className += ' hidden'; - } -} -function toggleDisplayCSS(evt) { - var e = document.getElementsByClassName(evt.target.getAttribute('data-class')); - if (evt.target.checked) { - for (var i = 0, z = e.length; i < z; i++) { - e[i].className += ' hidden'; - } - } else { - for (var i = 0, z = e.length; i < z; i++) { - e[i].className = e[i].className.replace('hidden', ''); - } - } -} -function toggleFilters(evt) { - var filters = document.getElementById('filters'); - if (document.getElementById('filtersToggle').className.indexOf('current') == -1) { - showElement(filters); - evt.target.className += ' current'; - } else { - hideElement(filters); - evt.target.className = evt.target.className.replace('current', ''); - } -} -function showSection(evt) { - var elemArr = document.getElementById('nav').querySelectorAll('.button[data-section]'); - var i = elemArr.length - 1; - while (i > -1) { - hideElement(document.getElementById(elemArr[i].getAttribute('data-section'))); - i--; - } - showElement(document.getElementById(evt.target.getAttribute('data-section'))); - var elem = document.querySelector('#nav div.current[data-section]'); - if (elem != null) { - elem.className = elem.className.replace('current', ''); - } - if (evt.target.className.indexOf('current') == -1) { - evt.target.className += ' current'; - } /*Also enable/disable filters based on current page.*/ - if (evt.target.getAttribute('data-section') == 'plugins') { - showElement(document.getElementById('filtersToggle')); - if (document.getElementById('filtersToggle').className.indexOf('current') != -1) { - showElement(filters); - } - } else { - hideElement(document.getElementById('filtersToggle')); - hideElement(document.getElementById('filters')); - } -} -function toggleMessages(evt) { - var listItems = document.getElementById('plugins').getElementsByTagName('li'); - var i = listItems.length - 1; - var hiddenNo = parseInt(document.getElementById('hiddenMessageNo').innerHTML); - while (i > -1) { - var spans = listItems[i].getElementsByTagName('span'); - if (spans.length == 0 || spans[0].className.indexOf('mod') == -1) { - var filterMatch = false; - if (evt.target.id == 'hideAllPluginMessages') { - filterMatch = true; - } else if (evt.target.id == 'hideNotes' && listItems[i].className.indexOf('say') != -1) { - filterMatch = true; - } else if (evt.target.id == 'hideDoNotCleanMessages' && listItems[i].innerHTML.indexOf('Do not clean.') != -1) { - filterMatch = true; - } - if (filterMatch) { - if (evt.target.checked) { - if (listItems[i].className.indexOf('hidden') == -1) { - hiddenNo++; - } - stepHideElement(listItems[i]); - } else { - stepUnhideElement(listItems[i]); - if (listItems[i].className.indexOf('hidden') == -1) { - hiddenNo--; - } - } - } - } - i--; - } - document.getElementById('hiddenMessageNo').innerHTML = hiddenNo; - togglePlugins(evt); -} -function togglePlugins(evt) { - var plugins = document.getElementById('plugins').getElementsByTagName('ul')[0].childNodes; - var i = plugins.length - 1; - var hiddenNo = parseInt(document.getElementById('hiddenPluginNo').innerHTML); - while (i > -1) { - if (plugins[i].nodeType == Node.ELEMENT_NODE) { - var isMessageless = true; - var messages = plugins[i].getElementsByTagName('li'); - var j = messages.length - 1; - while (j > -1) { - if (messages[j].className.indexOf('hidden') == -1) { - isMessageless = false; - break; - } - j--; - } - if (document.getElementById('hideMessagelessPlugins').checked && isMessageless) { - if (plugins[i].className.indexOf('hidden') == -1) { - hiddenNo++; - hideElement(plugins[i]); - } - } else if (plugins[i].className.indexOf('hidden') != -1) { - hiddenNo--; - showElement(plugins[i]); - } - } - i--; - } - document.getElementById('hiddenPluginNo').innerHTML = hiddenNo; -} -function setupEventHandlers() { - var i, elemArr; - if (isStorageSupported()) { /*Set up filter value and CSS setting storage read/write handlers.*/ - elemArr = document.getElementById('filters').getElementsByTagName('input'); - i = elemArr.length - 1; - while (i > -1) { - elemArr[i].addEventListener('click', saveCheckboxState, false); - i--; - } - } - document.getElementById('filtersToggle').addEventListener('click', toggleFilters, false); - /*Set up handlers for section display.*/ - elemArr = document.getElementById('nav').querySelectorAll('.button[data-section]'); - var i = elemArr.length - 1; - while (i > -1) { - elemArr[i].addEventListener('click', showSection, false); - i--; - } - document.getElementById('hideVersionNumbers').addEventListener('click', toggleDisplayCSS, false); - document.getElementById('hideCRCs').addEventListener('click', toggleDisplayCSS, false); - document.getElementById('hideBashTags').addEventListener('click', toggleDisplayCSS, false); - document.getElementById('hideNotes').addEventListener('click', toggleMessages, false); - document.getElementById('hideDoNotCleanMessages').addEventListener('click', toggleMessages, false); - document.getElementById('hideAllPluginMessages').addEventListener('click', toggleMessages, false); - document.getElementById('hideMessagelessPlugins').addEventListener('click', togglePlugins, false); -} -function init() { - setupEventHandlers(); - if (isStorageSupported()) { - loadSettings(); - } - showElement(document.getElementsByTagName('section')[0]) -} -init(); diff --git a/resources/settings.yaml b/resources/settings.yaml index ae6e8c74..b383ac8a 100644 --- a/resources/settings.yaml +++ b/resources/settings.yaml @@ -1,22 +1,21 @@ -# Example Default BOSS Settings File +# Example Default LOOT Settings File # This file is written in YAML . -Language: eng # One of 'eng', 'spa', 'rus' or ''. +language: eng # One of 'eng', 'spa', 'rus' or ''. -Game: auto # auto, or one of the 'folder' values below. -Last Game: auto # auto, or one of the 'folder' values below. -Debug Verbosity: 0 # 0, 1, 2, 3. Logging takes place if > 0. -Update Masterlist: true -View Report Externally: false -Generate Graph Image: false +game: auto # auto, or one of the 'folder' values below. +lastGame: auto # auto, or one of the 'folder' values below. +debugVerbosity: 0 # 0, 1, 2, 3. Logging takes place if > 0. +updateMasterlist: true # Games. The four types are 'Oblivion', 'Skyrim', 'Fallout3' and 'FalloutNV'. They correspond to each base game's libespm and libloadorder settings. -Games: +games: - folder: Oblivion name: "TES IV: Oblivion" type: Oblivion master: Oblivion.esm - url: https://github.com/boss-developers/boss-oblivion.git + repo: https://github.com/loot/oblivion.git + branch: master path: ~ registry: Software\Bethesda Softworks\Oblivion\Installed Path @@ -24,7 +23,8 @@ Games: name: "TES V: Skyrim" type: Skyrim master: Skyrim.esm - url: https://github.com/boss-developers/boss-skyrim.git + repo: https://github.com/loot/skyrim.git + branch: master path: ~ registry: Software\Bethesda Softworks\Skyrim\Installed Path @@ -32,7 +32,8 @@ Games: name: Fallout 3 type: Fallout3 master: Fallout3.esm - url: https://github.com/boss-developers/boss-fallout3.git + repo: https://github.com/loot/fallout3.git + branch: master path: ~ registry: Software\Bethesda Softworks\Fallout3\Installed Path @@ -40,7 +41,8 @@ Games: name: "Fallout: New Vegas" type: FalloutNV master: FalloutNV.esm - url: https://github.com/boss-developers/boss-fallout-new-vegas.git + repo: https://github.com/loot/falloutnv.git + branch: master path: ~ registry: Software\Bethesda Softworks\FalloutNV\Installed Path @@ -48,6 +50,7 @@ Games: name: Nehrim - At Fate's Edge type: Oblivion master: Nehrim.esm - url: https://github.com/boss-developers/boss-oblivion.git + repo: https://github.com/loot/oblivion.git + branch: master path: ~ - registry: Software\Microsoft\Windows\CurrentVersion\Uninstall\Nehrim - At Fate's Edge_is1 + registry: Software\Microsoft\Windows\CurrentVersion\Uninstall\Nehrim - At Fate's Edge_is1\InstallLocation diff --git a/resources/style.css b/resources/style.css deleted file mode 100644 index fbec65ba..00000000 --- a/resources/style.css +++ /dev/null @@ -1,171 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2013 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ -body { - font:10pt/1.5 Helvetica,sans-serif; - margin:0; - background:#f8f8f8; -} -noscript div { - background:#c00; - display:block; - padding:10px 5px; - color:white; -} -#nav { - background:#e3e3e3; - position:fixed; - top:0; - left:0; - z-index:2; - box-shadow: 0 0 3px 1px rgba(0,0,0,0.5); - width:100%; -} -.button { - display:inline-table; - cursor:pointer; - padding:0.5em; - text-decoration:none; - transition:background 0.2s; -} -.button.current { - background: #ccc; -} -.button[id] { - position:absolute; - right:0; - top:0; -} -#main { - position:absolute; - top:32px; - width:100%; -} -#summary, #plugins { - padding:1em; -} -#summary > table { - border-collapse:separate; - border-spacing:0; -} -td { - padding:0.5em; - line-height:1.5; - text-align:right; - padding-left:3em; -} -table td:first-child { - text-align:left; - padding-left:0; -} -#noChanges { - font-weight:bold; - font-size:12pt; - text-align:center; - margin:1em; -} -#filters { - background:#e8e8e8; - z-index:1; - overflow:hidden; - position:fixed; - right:0; - top:32px; - display:block; - box-shadow:0 0 3px 1px rgba(0,0,0,0.5); -} -#filters.hidden { - display:none; -} -#filters label { - display:block; - padding:0.2em 0.5em; - white-space:nowrap; - cursor:pointer; -} -#filters div { - padding:0.4em; - font-style:italic; -} -input[type='checkbox'] { - position:relative; - top:0.15em; - margin-right:0.5em; -} -ul { - margin-top:0.5em; - list-style:none; - padding-left:0; -} - - -#plugins > ul > li, #summary > div { - background:white; - overflow:hidden; - margin:1em; - box-shadow:0 0 3px 0px rgba(0,0,0,0.5); - padding:1em; -} -.mod { - font-size:1.3em; - display:block; - font-weight:normal; - margin-bottom:0em; - margin-top:0; -} -.version{ - color:#6394F8; -} -.crc{ - color:#BC8923; -} -.tag.add { - color:green; -} -.tag.remove { - color:red; -} -.hidden { - display:none; -} -#summary > div { - float:left; -} -#summary li, li > ul > li { - padding:0.5em 1em; - list-style:disc inside; -} -.error, .warn { - padding:0.5em 1em; - list-style:disc inside; -} -.error{ - background:#ff9090; -} -.warn{ - background:#FFDD55; -} -h2 { - font-weight: normal; - margin:0; - display:block; -} diff --git a/src/api/api.cpp b/src/api/api.cpp index 415da290..f41767dd 100644 --- a/src/api/api.cpp +++ b/src/api/api.cpp @@ -1,35 +1,34 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2013-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ #include "api.h" -#include "../backend/globals.h" #include "../backend/game.h" #include "../backend/metadata.h" #include "../backend/parsers.h" #include "../backend/generators.h" #include "../backend/error.h" #include "../backend/streams.h" -#include "../backend/legacy-parser.h" #include @@ -37,104 +36,106 @@ #include #include #include +#include +#include +#include -#include #include #include #include -#include -#include -const unsigned int boss_ok = boss::error::ok; -const unsigned int boss_error_liblo_error = boss::error::liblo_error; -const unsigned int boss_error_file_write_fail = boss::error::path_write_fail; -const unsigned int boss_error_parse_fail = boss::error::path_read_fail; -const unsigned int boss_error_condition_eval_fail = boss::error::condition_eval_fail; -const unsigned int boss_error_regex_eval_fail = boss::error::regex_eval_fail; -const unsigned int boss_error_no_mem = boss::error::no_mem; -const unsigned int boss_error_invalid_args = boss::error::invalid_args; -const unsigned int boss_error_no_tag_map = boss::error::no_tag_map; -const unsigned int boss_error_path_not_found = boss::error::path_not_found; -const unsigned int boss_error_no_game_detected = boss::error::no_game_detected; -const unsigned int boss_error_windows_error = boss::error::windows_error; -const unsigned int boss_error_sorting_error = boss::error::sorting_error; -const unsigned int boss_return_max = boss_error_sorting_error; +const unsigned int loot_ok = loot::error::ok; +const unsigned int loot_error_liblo_error = loot::error::liblo_error; +const unsigned int loot_error_file_write_fail = loot::error::path_write_fail; +const unsigned int loot_error_parse_fail = loot::error::path_read_fail; +const unsigned int loot_error_condition_eval_fail = loot::error::condition_eval_fail; +const unsigned int loot_error_regex_eval_fail = loot::error::regex_eval_fail; +const unsigned int loot_error_no_mem = loot::error::no_mem; +const unsigned int loot_error_invalid_args = loot::error::invalid_args; +const unsigned int loot_error_no_tag_map = loot::error::no_tag_map; +const unsigned int loot_error_path_not_found = loot::error::path_not_found; +const unsigned int loot_error_no_game_detected = loot::error::no_game_detected; +const unsigned int loot_error_windows_error = loot::error::windows_error; +const unsigned int loot_error_sorting_error = loot::error::sorting_error; +const unsigned int loot_return_max = loot_error_sorting_error; // The following are the games identifiers used by the API. -const unsigned int boss_game_tes4 = boss::g_game_tes4; -const unsigned int boss_game_tes5 = boss::g_game_tes5; -const unsigned int boss_game_fo3 = boss::g_game_fo3; -const unsigned int boss_game_fonv = boss::g_game_fonv; +const unsigned int loot_game_tes4 = loot::Game::tes4; +const unsigned int loot_game_tes5 = loot::Game::tes5; +const unsigned int loot_game_fo3 = loot::Game::fo3; +const unsigned int loot_game_fonv = loot::Game::fonv; -// BOSS message types. -const unsigned int boss_message_say = boss::g_message_say; -const unsigned int boss_message_warn = boss::g_message_warn; -const unsigned int boss_message_error = boss::g_message_error; -const unsigned int boss_message_tag = boss::g_message_tag; +// LOOT message types. +const unsigned int loot_message_say = loot::Message::say; +const unsigned int loot_message_warn = loot::Message::warn; +const unsigned int loot_message_error = loot::Message::error; +const unsigned int loot_message_tag = loot::Message::tag; -// BOSS message languages. -const unsigned int boss_lang_any = boss::g_lang_any; -const unsigned int boss_lang_english = boss::g_lang_english; -const unsigned int boss_lang_spanish = boss::g_lang_spanish; -const unsigned int boss_lang_russian = boss::g_lang_russian; -const unsigned int boss_lang_french = boss::g_lang_french; -const unsigned int boss_lang_chinese = boss::g_lang_chinese; -const unsigned int boss_lang_polish = boss::g_lang_polish; -const unsigned int boss_lang_brazilian_portuguese = boss::g_lang_brazilian_portuguese; -const unsigned int boss_lang_danish = boss::g_lang_danish; +// LOOT message languages. +const unsigned int loot_lang_any = loot::Language::any; +const unsigned int loot_lang_english = loot::Language::english; +const unsigned int loot_lang_spanish = loot::Language::spanish; +const unsigned int loot_lang_russian = loot::Language::russian; +const unsigned int loot_lang_french = loot::Language::french; +const unsigned int loot_lang_chinese = loot::Language::chinese; +const unsigned int loot_lang_polish = loot::Language::polish; +const unsigned int loot_lang_brazilian_portuguese = loot::Language::brazilian_portuguese; +const unsigned int loot_lang_finnish = loot::Language::finnish; +const unsigned int loot_lang_german = loot::Language::german; +const unsigned int loot_lang_danish = loot::Language::danish; -// BOSS cleanliness codes. -const unsigned int boss_needs_cleaning_no = 0; -const unsigned int boss_needs_cleaning_yes = 1; -const unsigned int boss_needs_cleaning_unknown = 2; +// LOOT cleanliness codes. +const unsigned int loot_needs_cleaning_no = 0; +const unsigned int loot_needs_cleaning_yes = 1; +const unsigned int loot_needs_cleaning_unknown = 2; -struct _boss_db_int { - _boss_db_int() - : extTagMap(NULL), - extAddedTagIds(NULL), - extRemovedTagIds(NULL), - extMessageArray(NULL), +struct _loot_db_int { + _loot_db_int() + : extTagMap(nullptr), + extAddedTagIds(nullptr), + extRemovedTagIds(nullptr), + extMessageArray(nullptr), extMessageArraySize(0) { - extMessage.type = boss_message_say; - extMessage.message = NULL; + extMessage.type = loot_message_say; + extMessage.message = nullptr; } - ~_boss_db_int() { + ~_loot_db_int() { delete [] extAddedTagIds; delete [] extRemovedTagIds; delete [] extMessage.message; - if (extTagMap != NULL) { + if (extTagMap != nullptr) { for (size_t i=0; i < bashTagMap.size(); i++) delete [] extTagMap[i]; //Gotta clear those allocated strings. delete [] extTagMap; } - if (extMessageArray != NULL) { + if (extMessageArray != nullptr) { for (size_t i=0; i < extMessageArraySize; i++) delete [] extMessageArray[i].message; //Gotta clear those allocated strings. delete [] extMessageArray; } } - boss::Game game; - std::list metadata, rawMetadata, userMetadata, rawUserMetadata; + loot::Game game; + std::list metadata, rawMetadata, userMetadata, rawUserMetadata; - boost::unordered_map bashTagMap; + std::unordered_map bashTagMap; char ** extTagMap; unsigned int * extAddedTagIds; unsigned int * extRemovedTagIds; - boss_message extMessage; - boss_message * extMessageArray; + loot_message extMessage; + loot_message * extMessageArray; size_t extMessageArraySize; }; -char * extMessageStr = NULL; +char * extMessageStr = nullptr; // std::string to null-terminated char string converter. char * ToNewCString(std::string str) { @@ -142,20 +143,35 @@ char * ToNewCString(std::string str) { return strcpy(p, str.c_str()); } -unsigned int c_error(const boss::error& e) { +unsigned int c_error(const loot::error& e) { delete[] extMessageStr; try { extMessageStr = new char[strlen(e.what()) + 1]; strcpy(extMessageStr, e.what()); } - catch (std::bad_alloc& e) { - extMessageStr = NULL; + catch (std::bad_alloc& /*e*/) { + extMessageStr = nullptr; } return e.code(); } unsigned int c_error(const unsigned int code, const std::string& what) { - return c_error(boss::error(code, what.c_str())); + return c_error(loot::error(code, what.c_str())); +} + +//////////////////////////////////// +// Dummy Masterlist member functions +//////////////////////////////////// + +// The API doesn't depend on libgit2, by not compiling ".git.cpp", so the member functions are defined +// below as dummies. + +namespace loot { + void Masterlist::GetGitInfo(const boost::filesystem::path& path) {} + + void Masterlist::Update(Game& game, const unsigned int language) { + this->MetadataList::Load(game.MasterlistPath()); + } } @@ -166,19 +182,19 @@ unsigned int c_error(const unsigned int code, const std::string& what) { // Outputs a string giving the details of the last time an error or // warning return code was returned by a function. The string exists // until this function is called again or until CleanUpAPI is called. -BOSS_API unsigned int boss_get_error_message (const char ** const message) { - if (message == NULL) - return c_error(boss_error_invalid_args, "Null message pointer passed."); +LOOT_API unsigned int loot_get_error_message (const char ** const message) { + if (message == nullptr) + return c_error(loot_error_invalid_args, "Null message pointer passed."); *message = extMessageStr; - return boss_ok; + return loot_ok; } // Frees memory allocated to error string. -BOSS_API void boss_cleanup () { +LOOT_API void loot_cleanup () { delete [] extMessageStr; - extMessageStr = NULL; + extMessageStr = nullptr; } @@ -186,24 +202,24 @@ BOSS_API void boss_cleanup () { // Version Functions ////////////////////////////// -// Returns whether this version of BOSS supports the API from the given -// BOSS version. Abstracts BOSS API stability policy away from clients. -BOSS_API bool boss_is_compatible (const unsigned int versionMajor, const unsigned int versionMinor, const unsigned int versionPatch) { - return versionMajor == boss::g_version_major && versionMinor == boss::g_version_minor; +// Returns whether this version of LOOT supports the API from the given +// LOOT version. Abstracts LOOT API stability policy away from clients. +LOOT_API bool loot_is_compatible (const unsigned int versionMajor, const unsigned int versionMinor, const unsigned int versionPatch) { + return versionMajor == loot::g_version_major && versionMinor == loot::g_version_minor; } -// Returns the version string for this version of BOSS. +// Returns the version string for this version of LOOT. // The string exists until this function is called again or until // CleanUpAPI is called. -BOSS_API unsigned int boss_get_version (unsigned int * const versionMajor, unsigned int * const versionMinor, unsigned int * const versionPatch) { - if (versionMajor == NULL || versionMinor == NULL || versionPatch == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); +LOOT_API unsigned int loot_get_version (unsigned int * const versionMajor, unsigned int * const versionMinor, unsigned int * const versionPatch) { + if (versionMajor == nullptr || versionMinor == nullptr || versionPatch == nullptr) + return c_error(loot_error_invalid_args, "Null pointer passed."); - *versionMajor = boss::g_version_major; - *versionMinor = boss::g_version_minor; - *versionPatch = boss::g_version_patch; + *versionMajor = loot::g_version_major; + *versionMinor = loot::g_version_minor; + *versionPatch = loot::g_version_patch; - return boss_ok; + return loot_ok; } @@ -216,11 +232,11 @@ BOSS_API unsigned int boss_get_version (unsigned int * const versionMajor, unsig // is the path to that game's Data folder, and is case-sensitive if the // underlying filesystem is case-sensitive. This function also checks that // plugins.txt and loadorder.txt (if they both exist) are in sync. If -// dataPath == NULL then the API will attempt to detect the data path of +// dataPath == nullptr then the API will attempt to detect the data path of // the specified game. -BOSS_API unsigned int boss_create_db (boss_db * const db, const unsigned int clientGame, const char * const gamePath) { - if (db == NULL || (clientGame != boss_game_tes4 && clientGame != boss_game_tes5 && clientGame != boss_game_fo3 && clientGame != boss_game_fonv)) - return c_error(boss_error_invalid_args, "Null pointer passed."); +LOOT_API unsigned int loot_create_db (loot_db * const db, const unsigned int clientGame, const char * const gamePath) { + if (db == nullptr || (clientGame != loot_game_tes4 && clientGame != loot_game_tes5 && clientGame != loot_game_fo3 && clientGame != loot_game_fonv)) + return c_error(loot_error_invalid_args, "Null pointer passed."); //Set the locale to get encoding conversions working correctly. std::setlocale(LC_CTYPE, ""); @@ -232,30 +248,30 @@ BOSS_API unsigned int boss_create_db (boss_db * const db, const unsigned int cli boost::log::core::get()->set_logging_enabled(false); std::string game_path = ""; - if (gamePath != NULL) + if (gamePath != nullptr) game_path = gamePath; - boss::Game game; + loot::Game game; try { - game = boss::Game(clientGame).SetPath(game_path).Init(); //This also checks to see if the game is installed if game_path is empty and throws an exception if it is not detected. It also creates a folder in %LOCALAPPDATA% and reads the active plugins list, but that shouldn't be an issue. - } catch (boss::error& e) { + game = loot::Game(clientGame).SetPath(game_path).Init(); //This also checks to see if the game is installed if game_path is empty and throws an exception if it is not detected. It also creates a folder in %LOCALAPPDATA% and reads the active plugins list, but that shouldn't be an issue. + } catch (loot::error& e) { return c_error(e); } - boss_db retVal; + loot_db retVal; try { - retVal = new _boss_db_int; + retVal = new _loot_db_int; } catch (std::bad_alloc& e) { - return c_error(boss_error_no_mem, e.what()); + return c_error(loot_error_no_mem, e.what()); } retVal->game = game; *db = retVal; - return boss_ok; + return loot_ok; } // Destroys the given DB, freeing any memory allocated as part of its use. -BOSS_API void boss_destroy_db (boss_db db) { +LOOT_API void loot_destroy_db (loot_db db) { delete db; } @@ -268,45 +284,38 @@ BOSS_API void boss_destroy_db (boss_db db) { // Can be called multiple times. On error, the database is unchanged. // Paths are case-sensitive if the underlying filesystem is case-sensitive. // masterlistPath and userlistPath are files. -BOSS_API unsigned int boss_load_lists (boss_db db, const char * const masterlistPath, +LOOT_API unsigned int loot_load_lists (loot_db db, const char * const masterlistPath, const char * const userlistPath) { - if (db == NULL || masterlistPath == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); + if (db == nullptr || masterlistPath == nullptr) + return c_error(loot_error_invalid_args, "Null pointer passed."); - std::list temp; - std::list userTemp; + std::list temp; + std::list userTemp; try { if (boost::filesystem::exists(masterlistPath)) { - if (boost::algorithm::iends_with(masterlistPath, ".yaml")) { - boss::ifstream in(masterlistPath); - YAML::Node tempNode = YAML::Load(in); - in.close(); - temp = tempNode["plugins"].as< std::list >(); - } - else { - boost::filesystem::path p(masterlistPath); - std::list filler; - Loadv2Masterlist(p, temp, filler); - } + loot::ifstream in(masterlistPath); + YAML::Node tempNode = YAML::Load(in); + in.close(); + temp = tempNode["plugins"].as< std::list >(); } } catch (std::exception& e) { - return c_error(boss_error_parse_fail, e.what()); + return c_error(loot_error_parse_fail, e.what()); } try { - if (userlistPath != NULL) { + if (userlistPath != nullptr) { if (boost::filesystem::exists(userlistPath)) { if (boost::algorithm::iends_with(userlistPath, ".yaml")) { - boss::ifstream in(userlistPath); + loot::ifstream in(userlistPath); YAML::Node tempNode = YAML::Load(in); in.close(); - userTemp = tempNode["plugins"].as< std::list >(); + userTemp = tempNode["plugins"].as< std::list >(); } } } } catch (YAML::Exception& e) { - return c_error(boss_error_parse_fail, e.what()); + return c_error(loot_error_parse_fail, e.what()); } //Also free memory. @@ -314,29 +323,29 @@ BOSS_API unsigned int boss_load_lists (boss_db db, const char * const masterlist delete [] db->extAddedTagIds; delete [] db->extRemovedTagIds; - if (db->extTagMap != NULL) { + if (db->extTagMap != nullptr) { for (size_t i=0; i < db->bashTagMap.size(); i++) delete [] db->extTagMap[i]; //Gotta clear those allocated strings. delete [] db->extTagMap; } - if (db->extMessageArray != NULL) { + if (db->extMessageArray != nullptr) { for (size_t i=0; i < db->extMessageArraySize; i++) delete [] db->extMessageArray[i].message; //Gotta clear those allocated strings. delete [] db->extMessageArray; } - db->extAddedTagIds = NULL; - db->extRemovedTagIds = NULL; - db->extTagMap = NULL; - db->extMessageArray = NULL; + db->extAddedTagIds = nullptr; + db->extRemovedTagIds = nullptr; + db->extTagMap = nullptr; + db->extMessageArray = nullptr; db->rawMetadata = temp; db->metadata = temp; db->userMetadata = userTemp; db->rawUserMetadata = userTemp; - return boss_ok; + return loot_ok; } // Evaluates all conditional lines and regex mods the loaded masterlist. @@ -345,27 +354,27 @@ BOSS_API unsigned int boss_load_lists (boss_db db, const char * const masterlist // is called. Repeated calls re-evaluate the masterlist from scratch each time, // ignoring the results of any previous evaluations. Paths are case-sensitive // if the underlying filesystem is case-sensitive. -BOSS_API unsigned int boss_eval_lists (boss_db db, const unsigned int language) { - if (db == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); +LOOT_API unsigned int loot_eval_lists (loot_db db, const unsigned int language) { + if (db == nullptr) + return c_error(loot_error_invalid_args, "Null pointer passed."); - std::list temp = db->rawMetadata; + std::list temp = db->rawMetadata; try { db->game.RefreshActivePluginsList(); - for (std::list::iterator it=temp.begin(); it != temp.end();) { + for (auto it=temp.begin(); it != temp.end();) { it->EvalAllConditions(db->game, language); if (it->IsRegexPlugin()) { - boost::regex regex; + std::regex reg; try { - regex = boost::regex(it->Name(), boost::regex::perl|boost::regex::icase); - } catch (boost::regex_error& e) { - return c_error(boss_error_regex_eval_fail, e.what()); + reg = std::regex(it->Name(), std::regex::ECMAScript | std::regex::icase); + } catch (std::exception& e) { + return c_error(loot_error_regex_eval_fail, e.what()); } for (boost::filesystem::directory_iterator itr(db->game.DataPath()); itr != boost::filesystem::directory_iterator(); ++itr) { const std::string filename = itr->path().filename().string(); - if (boost::regex_match(filename, regex)) { - boss::Plugin p = *it; + if (std::regex_match(filename, reg)) { + loot::Plugin p = *it; p.Name(filename); temp.push_back(p); } @@ -375,27 +384,27 @@ BOSS_API unsigned int boss_eval_lists (boss_db db, const unsigned int language) ++it; } } - } catch (boss::error& e) { + } catch (loot::error& e) { return c_error(e); } db->metadata = temp; temp = db->rawUserMetadata; try { - for (std::list::iterator it=temp.begin(); it != temp.end();) { + for (auto it=temp.begin(); it != temp.end();) { it->EvalAllConditions(db->game, language); if (it->IsRegexPlugin()) { - boost::regex regex; + std::regex reg; try { - regex = boost::regex(it->Name(), boost::regex::perl|boost::regex::icase); - } catch (boost::regex_error& e) { - return c_error(boss_error_regex_eval_fail, e.what()); + reg = std::regex(it->Name(), std::regex::ECMAScript | std::regex::icase); + } catch (std::exception& e) { + return c_error(loot_error_regex_eval_fail, e.what()); } for (boost::filesystem::directory_iterator itr(db->game.DataPath()); itr != boost::filesystem::directory_iterator(); ++itr) { const std::string filename = itr->path().filename().string(); - if (boost::regex_match(filename, regex)) { - boss::Plugin p = *it; + if (std::regex_match(filename, reg)) { + loot::Plugin p = *it; p.Name(filename); temp.push_back(p); } @@ -405,12 +414,12 @@ BOSS_API unsigned int boss_eval_lists (boss_db db, const unsigned int language) ++it; } } - } catch (boss::error& e) { + } catch (loot::error& e) { return c_error(e); } db->userMetadata = temp; - return boss_ok; + return loot_ok; } @@ -421,134 +430,133 @@ BOSS_API unsigned int boss_eval_lists (boss_db db, const unsigned int language) // Returns an array of the Bash Tags encounterred when loading the masterlist // and userlist, and the number of tags in the returned array. The array and // its contents are static and should not be freed by the client. -BOSS_API unsigned int boss_get_tag_map (boss_db db, char *** const tagMap, size_t * const numTags) { - if (db == NULL || tagMap == NULL || numTags == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); +LOOT_API unsigned int loot_get_tag_map (loot_db db, char *** const tagMap, size_t * const numTags) { + if (db == nullptr || tagMap == nullptr || numTags == nullptr) + return c_error(loot_error_invalid_args, "Null pointer passed."); //Clear existing array allocation. - if (db->extTagMap != NULL) { + if (db->extTagMap != nullptr) { for (size_t i=0, max=db->bashTagMap.size(); i < max; ++i) { delete [] db->extTagMap[i]; } delete [] db->extTagMap; - db->extTagMap = NULL; + db->extTagMap = nullptr; } //Initialise output. - *tagMap = NULL; + *tagMap = nullptr; *numTags = 0; - boost::unordered_set allTags; + std::unordered_set allTags; - for (std::list::iterator it=db->metadata.begin(), endIt=db->metadata.end(); it != endIt; ++it) { - std::set tags = it->Tags(); - for (std::set::const_iterator jt=tags.begin(), endJt=tags.end(); jt != endJt; ++jt) { - allTags.insert(jt->Name()); + for (const auto &plugin: db->metadata) { + std::set tags(plugin.Tags()); + for (const auto &tag: tags) { + allTags.insert(tag.Name()); } } - for (std::list::iterator it=db->userMetadata.begin(), endIt=db->userMetadata.end(); it != endIt; ++it) { - std::set tags = it->Tags(); - for (std::set::const_iterator jt=tags.begin(), endJt=tags.end(); jt != endJt; ++jt) { - allTags.insert(jt->Name()); + for (const auto &plugin : db->userMetadata) { + std::set tags(plugin.Tags()); + for (const auto &tag : tags) { + allTags.insert(tag.Name()); } } if (allTags.empty()) - return boss_ok; + return loot_ok; try { db->extTagMap = new char*[allTags.size()]; } catch (std::bad_alloc& e) { - return c_error(boss_error_no_mem, e.what()); + return c_error(loot_error_no_mem, e.what()); } unsigned int UID = 0; try { - for (boost::unordered_set::const_iterator it=allTags.begin(), endIt=allTags.end(); it != endIt; ++it) { - db->bashTagMap.emplace(*it, UID); + for (const auto &tag: allTags) { + db->bashTagMap.emplace(tag, UID); //Also allocate memory. - db->extTagMap[UID] = ToNewCString(*it); + db->extTagMap[UID] = ToNewCString(tag); UID++; } } catch (std::bad_alloc& e) { - return c_error(boss_error_no_mem, e.what()); + return c_error(loot_error_no_mem, e.what()); } *tagMap = db->extTagMap; *numTags = allTags.size(); - return boss_ok; + return loot_ok; } // Returns arrays of Bash Tag UIDs for Bash Tags suggested for addition and removal -// by BOSS's masterlist and userlist, and the number of tags in each array. +// by LOOT's masterlist and userlist, and the number of tags in each array. // The returned arrays are valid until the db is destroyed or until the Load // function is called. The arrays should not be freed by the client. modName is // case-insensitive. If no Tags are found for an array, the array pointer (*tagIds) -// will be NULL. The userlistModified bool is true if the userlist contains Bash Tag +// will be nullptr. The userlistModified bool is true if the userlist contains Bash Tag // suggestion message additions. -BOSS_API unsigned int boss_get_plugin_tags (boss_db db, const char * const plugin, +LOOT_API unsigned int loot_get_plugin_tags (loot_db db, const char * const plugin, unsigned int ** const tagIds_added, size_t * const numTags_added, unsigned int ** const tagIds_removed, size_t * const numTags_removed, bool * const userlistModified) { - if (db == NULL || plugin == NULL || tagIds_added == NULL || numTags_added == NULL || tagIds_removed == NULL || numTags_removed == NULL || userlistModified == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); + if (db == nullptr || plugin == nullptr || tagIds_added == nullptr || numTags_added == nullptr || tagIds_removed == nullptr || numTags_removed == nullptr || userlistModified == nullptr) + return c_error(loot_error_invalid_args, "Null pointer passed."); //Clear existing array allocations. delete [] db->extAddedTagIds; delete [] db->extRemovedTagIds; - db->extAddedTagIds = NULL; - db->extRemovedTagIds = NULL; + db->extAddedTagIds = nullptr; + db->extRemovedTagIds = nullptr; //Initialise output. - *tagIds_added = NULL; - *tagIds_removed = NULL; + *tagIds_added = nullptr; + *tagIds_removed = nullptr; *userlistModified = false; *numTags_added = 0; *numTags_removed = 0; - boost::unordered_set tagsAdded, tagsRemoved; - std::list::iterator pluginIt = std::find(db->metadata.begin(), db->metadata.end(), boss::Plugin(plugin)); + std::unordered_set tagsAdded, tagsRemoved; + std::list::iterator pluginIt = std::find(db->metadata.begin(), db->metadata.end(), loot::Plugin(plugin)); if (pluginIt != db->metadata.end()) { - std::set tags = pluginIt->Tags(); - for (std::set::const_iterator it=tags.begin(), endIt=tags.end(); it != endIt; ++it) { - if (it->IsAddition()) - tagsAdded.insert(it->Name()); + std::set tags(pluginIt->Tags()); + for (const auto &tag: tags) { + if (tag.IsAddition()) + tagsAdded.insert(tag.Name()); else - tagsRemoved.insert(it->Name()); + tagsRemoved.insert(tag.Name()); } } - pluginIt = std::find(db->userMetadata.begin(), db->userMetadata.end(), boss::Plugin(plugin)); + pluginIt = std::find(db->userMetadata.begin(), db->userMetadata.end(), loot::Plugin(plugin)); if (pluginIt != db->userMetadata.end()) { *userlistModified = true; - std::set tags = pluginIt->Tags(); - for (std::set::const_iterator it = tags.begin(), endIt = tags.end(); it != endIt; ++it) { - if (it->IsAddition()) - tagsAdded.insert(it->Name()); + std::set tags(pluginIt->Tags()); + for (const auto &tag : tags) { + if (tag.IsAddition()) + tagsAdded.insert(tag.Name()); else - tagsRemoved.insert(it->Name()); - + tagsRemoved.insert(tag.Name()); } } if ((!tagsAdded.empty() || !tagsRemoved.empty()) && db->bashTagMap.empty()) { - return c_error(boss_error_no_tag_map, "No Bash Tag map has been previously generated."); + return c_error(loot_error_no_tag_map, "No Bash Tag map has been previously generated."); } std::vector tagsAddedIDs, tagsRemovedIDs; - for (boost::unordered_set::const_iterator it=tagsAdded.begin(), endIt=tagsAdded.end(); it != endIt; ++it) { - boost::unordered_map::const_iterator mapIter = db->bashTagMap.find(*it); + for (const auto &tagNames: tagsAdded) { + const auto mapIter(db->bashTagMap.find(tagNames)); if (mapIter != db->bashTagMap.end()) tagsAddedIDs.push_back(mapIter->second); } - for (boost::unordered_set::const_iterator it=tagsRemoved.begin(), endIt=tagsRemoved.end(); it != endIt; ++it) { - boost::unordered_map::const_iterator mapIter = db->bashTagMap.find(*it); + for (const auto &tagNames : tagsRemoved) { + const auto mapIter(db->bashTagMap.find(tagNames)); if (mapIter != db->bashTagMap.end()) - tagsRemovedIDs.push_back(mapIter->second); + tagsAddedIDs.push_back(mapIter->second); } //Allocate memory. @@ -566,7 +574,7 @@ BOSS_API unsigned int boss_get_plugin_tags (boss_db db, const char * const plugi db->extRemovedTagIds[i] = tagsRemovedIDs[i]; } } catch (std::bad_alloc& e) { - return c_error(boss_error_no_mem, e.what()); + return c_error(loot_error_no_mem, e.what()); } //Set outputs. @@ -575,84 +583,84 @@ BOSS_API unsigned int boss_get_plugin_tags (boss_db db, const char * const plugi *numTags_added = numAdded; *numTags_removed = numRemoved; - return boss_ok; + return loot_ok; } // Returns the messages attached to the given plugin. Messages are valid until Load, -// DestroyBossDb or GetPluginMessages are next called. plugin is case-insensitive. -// If no messages are attached, *messages will be NULL and numMessages will equal 0. -BOSS_API unsigned int boss_get_plugin_messages (boss_db db, const char * const plugin, - boss_message ** const messages, +// loot_destroy_db or loot_get_plugin_messages are next called. plugin is case-insensitive. +// If no messages are attached, *messages will be nullptr and numMessages will equal 0. +LOOT_API unsigned int loot_get_plugin_messages (loot_db db, const char * const plugin, + loot_message ** const messages, size_t * const numMessages) { - if (db == NULL || plugin == NULL || messages == NULL || numMessages == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); + if (db == nullptr || plugin == nullptr || messages == nullptr || numMessages == nullptr) + return c_error(loot_error_invalid_args, "Null pointer passed."); //Clear existing array allocation. - if (db->extMessageArray != NULL) { + if (db->extMessageArray != nullptr) { for (size_t i=0; i < db->extMessageArraySize; ++i) { delete [] db->extMessageArray[i].message; } delete [] db->extMessageArray; - db->extMessageArray = NULL; + db->extMessageArray = nullptr; } //Initialise output. - *messages = NULL; + *messages = nullptr; *numMessages = 0; - std::list pluginMessages; - std::list::iterator pluginIt = std::find(db->metadata.begin(), db->metadata.end(), boss::Plugin(plugin)); + std::list pluginMessages; + std::list::iterator pluginIt = std::find(db->metadata.begin(), db->metadata.end(), loot::Plugin(plugin)); if (pluginIt != db->metadata.end()) { pluginMessages = pluginIt->Messages(); } - pluginIt = std::find(db->userMetadata.begin(), db->userMetadata.end(), boss::Plugin(plugin)); + pluginIt = std::find(db->userMetadata.begin(), db->userMetadata.end(), loot::Plugin(plugin)); if (pluginIt != db->userMetadata.end()) { - std::list temp = pluginIt->Messages(); + std::list temp = pluginIt->Messages(); pluginMessages.insert(pluginMessages.end(), temp.begin(), temp.end()); } db->extMessageArraySize = pluginMessages.size(); try { - db->extMessageArray = new boss_message[db->extMessageArraySize]; + db->extMessageArray = new loot_message[db->extMessageArraySize]; int i = 0; - for (std::list::const_iterator it=pluginMessages.begin(), endIt=pluginMessages.end(); it != endIt; ++it) { - db->extMessageArray[i].type = it->Type(); - db->extMessageArray[i].message = ToNewCString(it->ChooseContent(boss::g_lang_any).Str()); + for (const auto &message: pluginMessages) { + db->extMessageArray[i].type = message.Type(); + db->extMessageArray[i].message = ToNewCString(message.ChooseContent(loot::Language::any).Str()); } } catch (std::bad_alloc& e) { - return c_error(boss_error_no_mem, e.what()); + return c_error(loot_error_no_mem, e.what()); } *messages = db->extMessageArray; *numMessages = db->extMessageArraySize; - return boss_ok; + return loot_ok; } -BOSS_API unsigned int boss_get_dirty_info(boss_db db, const char * const plugin, unsigned int * const needsCleaning) { - if (db == NULL || plugin == NULL || needsCleaning == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); +LOOT_API unsigned int loot_get_dirty_info(loot_db db, const char * const plugin, unsigned int * const needsCleaning) { + if (db == nullptr || plugin == nullptr || needsCleaning == nullptr) + return c_error(loot_error_invalid_args, "Null pointer passed."); - *needsCleaning = boss_needs_cleaning_unknown; + *needsCleaning = loot_needs_cleaning_unknown; //Get all dirty info. - std::set dirtyInfo; - std::list::iterator pluginIt = std::find(db->metadata.begin(), db->metadata.end(), boss::Plugin(plugin)); + std::set dirtyInfo; + std::list::iterator pluginIt = std::find(db->metadata.begin(), db->metadata.end(), loot::Plugin(plugin)); if (pluginIt != db->metadata.end()) { dirtyInfo = pluginIt->DirtyInfo(); } - pluginIt = std::find(db->userMetadata.begin(), db->userMetadata.end(), boss::Plugin(plugin)); + pluginIt = std::find(db->userMetadata.begin(), db->userMetadata.end(), loot::Plugin(plugin)); if (pluginIt != db->userMetadata.end()) { - std::set temp = pluginIt->DirtyInfo(); + std::set temp = pluginIt->DirtyInfo(); dirtyInfo.insert(temp.begin(), temp.end()); } if (!dirtyInfo.empty()) { - *needsCleaning = boss_needs_cleaning_yes; + *needsCleaning = loot_needs_cleaning_yes; } - return boss_ok; + return loot_ok; } @@ -660,20 +668,23 @@ BOSS_API unsigned int boss_get_dirty_info(boss_db db, const char * const plugin, // and/or dirty messages, plus the Tag suggestions and/or messages themselves and their // conditions, in order to create the Wrye Bash taglist. outputFile is the path to use // for output. If outputFile already exists, it will only be overwritten if overwrite is true. -BOSS_API unsigned int boss_write_minimal_list (boss_db db, const char * const outputFile, const bool overwrite) { - if (db == NULL || outputFile == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); +LOOT_API unsigned int loot_write_minimal_list (loot_db db, const char * const outputFile, const bool overwrite) { + if (db == nullptr || outputFile == nullptr) + return c_error(loot_error_invalid_args, "Null pointer passed."); + + if (!boost::filesystem::exists(boost::filesystem::path(outputFile).parent_path())) + return c_error(loot_error_invalid_args, "Output directory does not exist."); if (boost::filesystem::exists(outputFile) && !overwrite) - return c_error(boss_error_invalid_args, "Output file exists but overwrite is not set to true."); + return c_error(loot_error_invalid_args, "Output file exists but overwrite is not set to true."); - std::list temp = db->metadata; - for (std::list::iterator it=temp.begin(), endIt=temp.end(); it != endIt; ++it) { - boss::Plugin p(it->Name()); - p.Tags(it->Tags()); - p.DirtyInfo(it->DirtyInfo()); + std::list temp = db->metadata; + for (auto &plugin: temp) { + loot::Plugin p(plugin.Name()); + p.Tags(plugin.Tags()); + p.DirtyInfo(plugin.DirtyInfo()); - *it = p; + plugin = p; } YAML::Emitter yout; @@ -683,11 +694,11 @@ BOSS_API unsigned int boss_write_minimal_list (boss_db db, const char * const ou << YAML::EndMap; boost::filesystem::path p(outputFile); - boss::ofstream out(p); + loot::ofstream out(p); if (out.fail()) - return c_error(boss_error_invalid_args, "Couldn't open output file"); + return c_error(loot_error_invalid_args, "Couldn't open output file"); out << yout.c_str(); out.close(); - return boss_ok; + return loot_ok; } diff --git a/src/api/api.h b/src/api/api.h index a441224d..a3fd34cc 100644 --- a/src/api/api.h +++ b/src/api/api.h @@ -1,23 +1,24 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2013-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ @@ -25,11 +26,11 @@ @file api.h @brief This file contains the API frontend. - @note The BOSS API is *not* thread safe. Thread safety is a goal, but one that has not yet been achieved. Bear this in mind if using it in a multi-threaded client. + @note The LOOT API is *not* thread safe. Thread safety is a goal, but one that has not yet been achieved. Bear this in mind if using it in a multi-threaded client. @section var_sec Variable Types - The BOSS API uses character strings and integers for information input/output. + The LOOT API uses character strings and integers for information input/output. - All strings are null-terminated byte character strings encoded in UTF-8. - All codes are unsigned integers at least 16 bits in size. - All array sizes are unsigned integers at least 16 bits in size. @@ -37,15 +38,15 @@ @section memory_sec Memory Management - The BOSS API manages the memory of strings and arrays it returns internally, so such strings and arrays should not be deallocated by the client. + The LOOT API manages the memory of strings and arrays it returns internally, so such strings and arrays should not be deallocated by the client. Data returned by a function lasts until a function is called which returns data of the same type (eg. a string is stored until the client calls another function which returns a string, an integer array lasts until another integer array is returned, etc.). - All allocated memory is freed when boss_destroy_db() is called, except the string allocated by boss_get_error_message(), which must be freed by calling boss_cleanup(). + All allocated memory is freed when loot_destroy_db() is called, except the string allocated by loot_get_error_message(), which must be freed by calling loot_cleanup(). */ -#ifndef __BOSS_API_H__ -#define __BOSS_API_H__ +#ifndef __LOOT_API_H__ +#define __LOOT_API_H__ #include @@ -64,19 +65,19 @@ #endif // set up dll import/export decorators -// when compiling the dll on windows, ensure BOSS_EXPORT is defined. clients +// when compiling the dll on windows, ensure LOOT_EXPORT is defined. clients // that use this header do not need to define anything to import the symbols // properly. #if defined(_WIN32) || defined(_WIN64) -# ifdef BOSS_STATIC -# define BOSS_API -# elif defined BOSS_EXPORT -# define BOSS_API __declspec(dllexport) +# ifdef LOOT_STATIC +# define LOOT_API +# elif defined LOOT_EXPORT +# define LOOT_API __declspec(dllexport) # else -# define BOSS_API __declspec(dllimport) +# define LOOT_API __declspec(dllimport) # endif #else -# define BOSS_API +# define LOOT_API #endif #ifdef __cplusplus @@ -90,20 +91,20 @@ extern "C" //////////////////////// /** - @brief A structure that holds all game-specific data used by the BOSS API. + @brief A structure that holds all game-specific data used by the LOOT API. @details Used to keep each game's data independent. Abstracts the definition of the API's internal state while still providing type safety across the library. Multiple handles can also be made for each game, though it should be kept in mind that the API is not thread-safe. */ -typedef struct _boss_db_int * boss_db; +typedef struct _loot_db_int * loot_db; /** @brief A structure that holds the type of a message and the message string itself. - @var boss_message::type The type of the message, specified using one of the message type codes given below. - @var boss_message::message The message string itself. + @var loot_message::type The type of the message, specified using one of the message type codes given below. + @var loot_message::message The message string itself. */ typedef struct { unsigned int type; const char * message; -} boss_message; +} loot_message; /*********************//** @@ -112,82 +113,84 @@ typedef struct { *************************/ ///@{ -BOSS_API extern const unsigned int boss_ok; ///< The function completed successfully. -BOSS_API extern const unsigned int boss_error_liblo_error; ///< There was an error in performing a load order operation. -BOSS_API extern const unsigned int boss_error_file_write_fail; ///< A file could not be written to. -BOSS_API extern const unsigned int boss_error_parse_fail; ///< There was an error parsing the file. -BOSS_API extern const unsigned int boss_error_condition_eval_fail; ///< There was an error evaluating the conditionals in a metadata file. -BOSS_API extern const unsigned int boss_error_regex_eval_fail; ///< There was an error evaluating the regular expressions in a metadata file. -BOSS_API extern const unsigned int boss_error_no_mem; ///< The API was unable to allocate the required memory. -BOSS_API extern const unsigned int boss_error_invalid_args; ///< Invalid arguments were given for the function. -BOSS_API extern const unsigned int boss_error_no_tag_map; ///< No Bash Tag map has been generated yet. -BOSS_API extern const unsigned int boss_error_path_not_found; ///< A file or folder path could not be found. -BOSS_API extern const unsigned int boss_error_no_game_detected; ///< The given game could not be found. -BOSS_API extern const unsigned int boss_error_windows_error; ///< An error occurred during a call to the Windows API. -BOSS_API extern const unsigned int boss_error_sorting_error; ///< An error occurred while sorting plugins. +LOOT_API extern const unsigned int loot_ok; ///< The function completed successfully. +LOOT_API extern const unsigned int loot_error_liblo_error; ///< There was an error in performing a load order operation. +LOOT_API extern const unsigned int loot_error_file_write_fail; ///< A file could not be written to. +LOOT_API extern const unsigned int loot_error_parse_fail; ///< There was an error parsing the file. +LOOT_API extern const unsigned int loot_error_condition_eval_fail; ///< There was an error evaluating the conditionals in a metadata file. +LOOT_API extern const unsigned int loot_error_regex_eval_fail; ///< There was an error evaluating the regular expressions in a metadata file. +LOOT_API extern const unsigned int loot_error_no_mem; ///< The API was unable to allocate the required memory. +LOOT_API extern const unsigned int loot_error_invalid_args; ///< Invalid arguments were given for the function. +LOOT_API extern const unsigned int loot_error_no_tag_map; ///< No Bash Tag map has been generated yet. +LOOT_API extern const unsigned int loot_error_path_not_found; ///< A file or folder path could not be found. +LOOT_API extern const unsigned int loot_error_no_game_detected; ///< The given game could not be found. +LOOT_API extern const unsigned int loot_error_windows_error; ///< An error occurred during a call to the Windows API. +LOOT_API extern const unsigned int loot_error_sorting_error; ///< An error occurred while sorting plugins. /** @brief Matches the value of the highest-numbered return code. @details Provided in case clients wish to incorporate additional return codes in their implementation and desire some method of avoiding value conflicts. */ -BOSS_API extern const unsigned int boss_return_max; +LOOT_API extern const unsigned int loot_return_max; ///@} /*******************//** @name Game Codes - @brief Used with boss_create_db(). + @brief Used with loot_create_db(). ***********************/ ///@{ -BOSS_API extern const unsigned int boss_game_tes4; ///< Game code for The Elder Scrolls IV: Oblivion. -BOSS_API extern const unsigned int boss_game_tes5; ///< Game code for The Elder Scrolls V: Skyrim. -BOSS_API extern const unsigned int boss_game_fo3; ///< Game code for Fallout 3. -BOSS_API extern const unsigned int boss_game_fonv; ///< Game code for Fallout: New Vegas. +LOOT_API extern const unsigned int loot_game_tes4; ///< Game code for The Elder Scrolls IV: Oblivion. +LOOT_API extern const unsigned int loot_game_tes5; ///< Game code for The Elder Scrolls V: Skyrim. +LOOT_API extern const unsigned int loot_game_fo3; ///< Game code for Fallout 3. +LOOT_API extern const unsigned int loot_game_fonv; ///< Game code for Fallout: New Vegas. ///@} /***************************//** @name Message Type Codes - @brief Used with the boss_message structure. + @brief Used with the loot_message structure. *******************************/ ///@{ -BOSS_API extern const unsigned int boss_message_say; ///< Denotes a generic note-type message. -BOSS_API extern const unsigned int boss_message_warn; ///< Denotes a warning message. -BOSS_API extern const unsigned int boss_message_error; ///< Denotes an error message. +LOOT_API extern const unsigned int loot_message_say; ///< Denotes a generic note-type message. +LOOT_API extern const unsigned int loot_message_warn; ///< Denotes a warning message. +LOOT_API extern const unsigned int loot_message_error; ///< Denotes an error message. /** @brief Denites a Bash Tag suggestion message. @details This type should never be seen client-side as it is only used during conversion between internal Bash Tag and message structures, but it is provided just in case. */ -BOSS_API extern const unsigned int boss_message_tag; +LOOT_API extern const unsigned int loot_message_tag; ///@} /*******************************//** @name Message Language Codes - @brief Used with boss_eval_lists(). + @brief Used with loot_eval_lists(). ***********************************/ ///@{ -BOSS_API extern const unsigned int boss_lang_any; ///< Tells the API to select messages of any language. -BOSS_API extern const unsigned int boss_lang_english; ///< Tells the API to preferentially select English messages. -BOSS_API extern const unsigned int boss_lang_spanish; ///< Tells the API to preferentially select Spanish messages. -BOSS_API extern const unsigned int boss_lang_russian; ///< Tells the API to preferentially select Russian messages. -BOSS_API extern const unsigned int boss_lang_french; ///< Tells the API to preferentially select French messages. -BOSS_API extern const unsigned int boss_lang_chinese; ///< Tells the API to preferentially select Chinese messages. -BOSS_API extern const unsigned int boss_lang_polish; ///< Tells the API to preferentially select Polish messages. -BOSS_API extern const unsigned int boss_lang_brazilian_portuguese; ///< Tells the API to preferentially select Polish messages. -BOSS_API extern const unsigned int boss_lang_danish; ///< Tells the API to preferentially select Danish messages. +LOOT_API extern const unsigned int loot_lang_any; ///< Tells the API to select messages of any language. +LOOT_API extern const unsigned int loot_lang_english; ///< Tells the API to preferentially select English messages. +LOOT_API extern const unsigned int loot_lang_spanish; ///< Tells the API to preferentially select Spanish messages. +LOOT_API extern const unsigned int loot_lang_russian; ///< Tells the API to preferentially select Russian messages. +LOOT_API extern const unsigned int loot_lang_french; ///< Tells the API to preferentially select French messages. +LOOT_API extern const unsigned int loot_lang_chinese; ///< Tells the API to preferentially select Chinese messages. +LOOT_API extern const unsigned int loot_lang_polish; ///< Tells the API to preferentially select Polish messages. +LOOT_API extern const unsigned int loot_lang_brazilian_portuguese; ///< Tells the API to preferentially select Brazilian Portuguese messages. +LOOT_API extern const unsigned int loot_lang_finnish; ///< Tells the API to preferentially select Finnish messages. +LOOT_API extern const unsigned int loot_lang_german; ///< Tells the API to preferentially select German messages. +LOOT_API extern const unsigned int loot_lang_danish; ///< Tells the API to preferentially select Danish messages. ///@} /*********************************//** @name Plugin Cleanliness Codes - @brief Used with boss_get_dirty_message(). + @brief Used with loot_get_dirty_message(). *************************************/ ///@{ -BOSS_API extern const unsigned int boss_needs_cleaning_no; ///< Denotes that the plugin queried does not need cleaning. -BOSS_API extern const unsigned int boss_needs_cleaning_yes; ///< Denotes that the plugin queried needs cleaning. -BOSS_API extern const unsigned int boss_needs_cleaning_unknown; ///< Denotes that the API is unable to determine whether or not the plugin queried needs cleaning. +LOOT_API extern const unsigned int loot_needs_cleaning_no; ///< Denotes that the plugin queried does not need cleaning. +LOOT_API extern const unsigned int loot_needs_cleaning_yes; ///< Denotes that the plugin queried needs cleaning. +LOOT_API extern const unsigned int loot_needs_cleaning_unknown; ///< Denotes that the API is unable to determine whether or not the plugin queried needs cleaning. ///@} @@ -203,12 +206,12 @@ BOSS_API extern const unsigned int boss_needs_cleaning_unknown; ///< Denotes th @param details A pointer to the error details string outputted by the function. @returns A return code. */ -BOSS_API unsigned int boss_get_error_message (const char ** const message); +LOOT_API unsigned int loot_get_error_message (const char ** const message); /** @brief Frees the memory allocated to the last error details string. */ -BOSS_API void boss_cleanup (); +LOOT_API void loot_cleanup (); ///@} @@ -226,7 +229,7 @@ BOSS_API void boss_cleanup (); @param versionPatch The patch version number to check. @returns True if the API versions are compatible, false otherwise. */ -BOSS_API bool boss_is_compatible (const unsigned int versionMajor, const unsigned int versionMinor, const unsigned int versionPatch); +LOOT_API bool loot_is_compatible (const unsigned int versionMajor, const unsigned int versionMinor, const unsigned int versionPatch); /** @brief Gets the API version. @@ -235,9 +238,11 @@ BOSS_API bool boss_is_compatible (const unsigned int versionMajor, const unsigne @param versionMinor A pointer to the minor version number. @param versionPatch A pointer to the patch version number. */ -BOSS_API unsigned int boss_get_version (unsigned int * const versionMajor, unsigned int * const versionMinor, unsigned int * const versionPatch); +LOOT_API unsigned int loot_get_version (unsigned int * const versionMajor, unsigned int * const versionMinor, unsigned int * const versionPatch); +///@} + /***************************************//** @name Lifecycle Management Functions *******************************************/ @@ -251,14 +256,14 @@ BOSS_API unsigned int boss_get_version (unsigned int * const versionMajor, unsig @param gamePath The relative or absolute path to the game folder, ot `NULL`. If `NULL`, the API will attempt to detect the data path of the specified game. @returns A return code. */ -BOSS_API unsigned int boss_create_db (boss_db * const db, const unsigned int clientGame, const char * const gamePath); +LOOT_API unsigned int loot_create_db (loot_db * const db, const unsigned int clientGame, const char * const gamePath); /** @brief Destroy an existing database handle. @details Destroys the given database handle, freeing up memory allocated during its use, excluding any memory allocated to error messages. @param db The database handle to destroy. */ -BOSS_API void boss_destroy_db (boss_db db); +LOOT_API void loot_destroy_db (loot_db db); ///@} @@ -272,11 +277,11 @@ BOSS_API void boss_destroy_db (boss_db db); @brief Loads the masterlist and userlist from the paths specified. @details Can be called multiple times, each time replacing the previously-loaded data. @param db The database the function acts on. - @param masterlistPath A string containing the relative or absolute path to the masterlist file that should be loaded. The API supports loading both v3 and v2.3 masterlists. - @param userlistPath A string containing the relative or absolute path to the userlist file that should be loaded, or `NULL`. If `NULL`, no userlist will be loaded. The API only upports loading v3 userlists. + @param masterlistPath A string containing the relative or absolute path to the masterlist file that should be loaded. + @param userlistPath A string containing the relative or absolute path to the userlist file that should be loaded, or `NULL`. If `NULL`, no userlist will be loaded. @returns A return code. */ -BOSS_API unsigned int boss_load_lists (boss_db db, const char * const masterlistPath, +LOOT_API unsigned int loot_load_lists (loot_db db, const char * const masterlistPath, const char * const userlistPath); /** @@ -286,7 +291,7 @@ BOSS_API unsigned int boss_load_lists (boss_db db, const char * const masterlist @param language The language code that is used for message language comparisons. @returns A return code. */ -BOSS_API unsigned int boss_eval_lists (boss_db db, const unsigned int language); +LOOT_API unsigned int loot_eval_lists (loot_db db, const unsigned int language); ///@} @@ -298,17 +303,17 @@ BOSS_API unsigned int boss_eval_lists (boss_db db, const unsigned int language); /** @brief Outputs an array of the Bash Tags that are suggested in the database. - @details This function must be called prior to calling boss_get_plugin_tags() to ensure that the latter can return the Tags using the correct array indicies. + @details This function must be called prior to calling loot_get_plugin_tags() to ensure that the latter can return the Tags using the correct array indicies. @param db The database the function acts on. - @param tagMap A pointer to the outputted array of Bash Tags. The array functions as a map where the indicies are the keys, allowing the API to use them as UIDs for Bash Tags instead of passing their names as strings every time boss_get_plugin_tags() is called. If no Bash Tags are suggested, this will be `NULL`. + @param tagMap A pointer to the outputted array of Bash Tags. The array functions as a map where the indicies are the keys, allowing the API to use them as UIDs for Bash Tags instead of passing their names as strings every time loot_get_plugin_tags() is called. If no Bash Tags are suggested, this will be `NULL`. @param numTags A pointer to the size of the outputted array. If no Bash Tags are suggested, this will be `0`. @returns A return code. */ -BOSS_API unsigned int boss_get_tag_map (boss_db db, char *** const tagMap, size_t * const numTags); +LOOT_API unsigned int loot_get_tag_map (loot_db db, char *** const tagMap, size_t * const numTags); /** @brief Outputs the Bash Tags suggested for addition and removal by the database for the given plugin. - @details boss_get_tag_map() must be called before this to ensure that the Bash Tag UIDs outputted by this function can be matched up to name strings. + @details loot_get_tag_map() must be called before this to ensure that the Bash Tag UIDs outputted by this function can be matched up to name strings. @param db The database the function acts on. @param plugin The filename of the plugin to look up Bash Tag suggestions for. @param tags_added A pointer to the outputted array of UIDs of the Bash Tags suggested for addition to the specified plugin. `NULL` if no Bash Tag additions are suggested. @@ -318,7 +323,7 @@ BOSS_API unsigned int boss_get_tag_map (boss_db db, char *** const tagMap, size_ @param userlistModified `true` if the Bash Tag suggestions were modified by the data in the userlist, `false` otherwise. @returns A return code. */ -BOSS_API unsigned int boss_get_plugin_tags (boss_db db, const char * const plugin, +LOOT_API unsigned int loot_get_plugin_tags (loot_db db, const char * const plugin, unsigned int ** const tags_added, size_t * const numTags_added, unsigned int ** const tags_removed, @@ -329,12 +334,12 @@ BOSS_API unsigned int boss_get_plugin_tags (boss_db db, const char * const plugi @brief Outputs the messages associated with the given plugin in the database. @param db The database the function acts on. @param plugin The filename of the plugin to look up messages for. - @param messages A pointer to the outputted array of messages associated with the specified plugin, given as boss_message structures. `NULL` if the plugin has no messages associated with it. + @param messages A pointer to the outputted array of messages associated with the specified plugin, given as loot_message structures. `NULL` if the plugin has no messages associated with it. @param numMessages A pointer to the size of the outputted array. If no messages are outputted, this will be `0`. @returns A return code. */ -BOSS_API unsigned int boss_get_plugin_messages (boss_db db, const char * const plugin, - boss_message ** const messages, +LOOT_API unsigned int loot_get_plugin_messages (loot_db db, const char * const plugin, + loot_message ** const messages, size_t * const numMessages); /** @@ -344,10 +349,10 @@ BOSS_API unsigned int boss_get_plugin_messages (boss_db db, const char * const p @param db The database the function acts on. @param plugin The plugin to look up dirty status information for. @param needsCleaning A pointer to a plugin cleanliness code. - @returns A return code. + @returns A return code. */ -BOSS_API unsigned int boss_get_dirty_info (boss_db db, const char * const plugin, +LOOT_API unsigned int loot_get_dirty_info (loot_db db, const char * const plugin, unsigned int * const needsCleaning); /** @@ -357,7 +362,7 @@ BOSS_API unsigned int boss_get_dirty_info (boss_db db, const char * const plugin @param overwrite If `false` and `outputFile` already exists, no data will be written. Otherwise, data will be written. @returns A return code. */ -BOSS_API unsigned int boss_write_minimal_list (boss_db db, const char * const outputFile, const bool overwrite); +LOOT_API unsigned int loot_write_minimal_list (loot_db db, const char * const outputFile, const bool overwrite); ///@} diff --git a/src/archive.py b/src/archive.py index 7788c1c1..b77f2711 100644 --- a/src/archive.py +++ b/src/archive.py @@ -1,95 +1,135 @@ #! /usr/bin/env python # -*- coding: utf-8 -*- -# Creates an archive of a BOSS release, putting it in the 'build' folder. +# Creates an archive of a LOOT release, putting it in the 'build' folder. -# Files and folders that need to go in (relative to repository root): +# LOOT # -# build/BOSS.exe -# resources/l10n/es/LC_MESSAGES/boss.mo -# resources/l10n/es/LC_MESSAGES/wxstd.mo -# resources/l10n/ru/LC_MESSAGES/boss.mo -# resources/l10n/ru/LC_MESSAGES/wxstd.mo -# resources/l10n/fr/LC_MESSAGES/boss.mo -# resources/l10n/fr/LC_MESSAGES/wxstd.mo -# resources/l10n/zh/LC_MESSAGES/boss.mo -# resources/l10n/zh/LC_MESSAGES/wxstd.mo -# resources/l10n/pl/LC_MESSAGES/boss.mo -# resources/l10n/pl/LC_MESSAGES/wxstd.mo -# resources/polyfill.js -# resources/script.js -# resources/style.css -# docs/images -# docs/licenses -# docs/BOSS Metadata Syntax.html -# docs/BOSS Readme.html - -# BOSS -# -# A plugin load order optimiser for games that use the esp/esm plugin system. +# A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and +# Fallout: New Vegas. # # Copyright (C) 2013-2014 WrinklyNinja # -# This file is part of BOSS. +# This file is part of LOOT. # -# BOSS is free software: you can redistribute +# LOOT 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. # -# BOSS is distributed in the hope that it will +# LOOT 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 BOSS. If not, see +# along with LOOT. If not, see # . import sys import os import shutil import zipfile +import subprocess temp_path = os.path.join('..', 'build', 'archive.tmp') -archive_name = 'BOSS Archive.zip' +archive_name = 'LOOT Archive.zip' -# Set archive name if alternative is given. -if (len(sys.argv) > 1): - archive_name = sys.argv[1] +# Some initial setup. +# +# There are two compression methods available: +# +# * Zip (Deflate) +# * 7-zip (LZMA) +# +# Python 3.3+ can also do BZIP2 and LZMA zip archives, but they don't have good +# Windows OS support, so people think they should be able to open them without +# an archiving utility, find they can't, and think the archive is broken. So +# they won't be used. +# +# Look for 7-zip in its default install location, and use it if it is found. +# Fall back to zip if not. +# +# Archives are named using the output of `git describe --tags --long`, if Git +# is found in the current PATH. Otherwise, they will simply be named +# 'LOOT Archive'. -# First make sure that the temporary folder for the archive exists. -if not os.path.exists(temp_path): - os.makedirs(temp_path) +# Python 3.3+ has shutil.which, but 2.7 doesn't. +if 'which' in dir(shutil): + git = shutil.which('git.exe') +else: + git = None + path = os.getenv('PATH') + for p in path.split(os.path.pathsep): + p = os.path.join(p, 'git.exe') + if os.path.exists(p) and os.access(p, os.X_OK): + git = p + +if not git: + # Git wasn't found in PATH, do a search (in GitHub install location). + github = os.path.join( os.getenv('LOCALAPPDATA'), 'GitHub' ) + for folder, subdirs, files in os.walk(github): + for subdir in subdirs: + # Check for a \\cmd\git.exe + if os.path.exists( os.path.join( folder, subdir, 'cmd', 'git.exe') ): + git = os.path.join( folder, subdir, 'cmd', 'git.exe') + + +if git: + args = [git, 'describe', '--tags', '--long'] + output = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + if len(output[1]) == 0: + archive_name = 'LOOT ' + output[0].decode('ascii')[:-1] + else: + archive_name = 'LOOT Archive' +else: + archive_name = 'LOOT Archive' + +# Delete the temporary folder if it already exists, then create it. +if os.path.exists(temp_path): + shutil.rmtree(temp_path) +os.makedirs(temp_path) # Now copy everything into the temporary folder. -shutil.copy( os.path.join('..', 'build', 'BOSS.exe'), temp_path ) +shutil.copy( os.path.join('..', 'build', 'Release', 'LOOT.exe'), temp_path ) +shutil.copy( os.path.join('..', 'build', 'Release', 'd3dcompiler_43.dll'), temp_path ) +shutil.copy( os.path.join('..', 'build', 'Release', 'd3dcompiler_46.dll'), temp_path ) +shutil.copy( os.path.join('..', 'build', 'Release', 'libEGL.dll'), temp_path ) +shutil.copy( os.path.join('..', 'build', 'Release', 'libGLESv2.dll'), temp_path ) +shutil.copy( os.path.join('..', 'build', 'Release', 'libcef.dll'), temp_path ) +shutil.copy( os.path.join('..', 'build', 'Release', 'cef.pak'), temp_path ) +shutil.copy( os.path.join('..', 'build', 'Release', 'cef_100_percent.pak'), temp_path ) +shutil.copy( os.path.join('..', 'build', 'Release', 'cef_200_percent.pak'), temp_path ) +shutil.copy( os.path.join('..', 'build', 'Release', 'devtools_resources.pak'), temp_path ) +shutil.copy( os.path.join('..', 'build', 'Release', 'icudtl.dat'), temp_path ) -for lang in ['es', 'ru', 'fr', 'zh_CN', 'pl', 'pt_BR']: +for lang in ['es', 'ru', 'fr', 'zh_CN', 'pl', 'pt_BR', 'fi', 'de']: os.makedirs(os.path.join(temp_path, 'resources', 'l10n', lang, 'LC_MESSAGES')) - shutil.copy( os.path.join('..', 'resources', 'l10n', lang, 'LC_MESSAGES', 'boss.mo'), os.path.join(temp_path, 'resources', 'l10n', lang, 'LC_MESSAGES') ) - shutil.copy( os.path.join('..', 'resources', 'l10n', lang, 'LC_MESSAGES', 'wxstd.mo'), os.path.join(temp_path, 'resources', 'l10n', lang, 'LC_MESSAGES') ) + shutil.copy( os.path.join('..', 'resources', 'l10n', lang, 'LC_MESSAGES', 'loot.mo'), os.path.join(temp_path, 'resources', 'l10n', lang, 'LC_MESSAGES') ) - -shutil.copy( os.path.join('..', 'resources', 'polyfill.js'), os.path.join(temp_path, 'resources') ) -shutil.copy( os.path.join('..', 'resources', 'script.js'), os.path.join(temp_path, 'resources') ) -shutil.copy( os.path.join('..', 'resources', 'style.css'), os.path.join(temp_path, 'resources') ) +shutil.copytree( os.path.join('..', 'resources', 'report'), os.path.join(temp_path, 'resources', 'report') ) +shutil.copy( os.path.join('..', 'resources', 'icon.ico'), os.path.join(temp_path, 'resources') ) shutil.copytree( os.path.join('..', 'docs', 'images'), os.path.join(temp_path, 'docs', 'images') ) shutil.copytree( os.path.join('..', 'docs', 'licenses'), os.path.join(temp_path, 'docs', 'licenses') ) -shutil.copy( os.path.join('..', 'docs', 'BOSS Metadata Syntax.html'), os.path.join(temp_path, 'docs') ) -shutil.copy( os.path.join('..', 'docs', 'BOSS Readme.html'), os.path.join(temp_path, 'docs') ) - +shutil.copy( os.path.join('..', 'docs', 'LOOT Metadata Syntax.html'), os.path.join(temp_path, 'docs') ) +shutil.copy( os.path.join('..', 'docs', 'LOOT Readme.html'), os.path.join(temp_path, 'docs') ) # Now compress the temporary folder. (Creating a zip because I can't get pylzma to work...) os.chdir(temp_path) -zip = zipfile.ZipFile( os.path.join('..', archive_name), 'w', zipfile.ZIP_DEFLATED ) -for root, dirs, files in os.walk('.'): - for file in files: - zip.write(os.path.join(root, file)) -zip.close() -os.chdir('..') +sevenzip_path = os.path.join('C:\\', 'Program Files', '7-Zip', '7z.exe') +if os.path.exists(sevenzip_path): + out_path = os.path.join('..', archive_name + '.7z') + args = [sevenzip_path, 'a', '-r', out_path] + subprocess.call(args) +else: + zip = zipfile.ZipFile( os.path.join('..', archive_name + '.zip'), 'w', zipfile.ZIP_DEFLATED ) + for root, dirs, files in os.walk('.'): + for file in files: + zip.write(os.path.join(root, file)) + zip.close() +os.chdir('..') # And finally, delete the temporary folder. shutil.rmtree('archive.tmp') diff --git a/src/backend/error.h b/src/backend/error.h index b8630e6d..5aba022f 100644 --- a/src/backend/error.h +++ b/src/backend/error.h @@ -1,33 +1,34 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2012-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ -#ifndef __BOSS_ERROR__ -#define __BOSS_ERROR__ +#ifndef __LOOT_ERROR__ +#define __LOOT_ERROR__ #include #include -namespace boss { +namespace loot { class error : public std::exception { public: diff --git a/src/backend/game.cpp b/src/backend/game.cpp index b3666a70..097e8845 100644 --- a/src/backend/game.cpp +++ b/src/backend/game.cpp @@ -1,23 +1,24 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2012-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ @@ -27,85 +28,276 @@ #include "error.h" #include "metadata.h" #include "parsers.h" +#include "streams.h" +#include "generators.h" +#include "graph.h" #include +#include +#include +#include using namespace std; namespace fs = boost::filesystem; namespace lc = boost::locale; -namespace boss { +namespace loot { - std::vector GetGames(const YAML::Node& settings) { + std::vector GetGames(YAML::Node& settings) { vector games; - if (settings["Games"]) - games = settings["Games"].as< vector >(); + if (settings["games"]) + games = settings["games"].as< vector >(); - if (find(games.begin(), games.end(), Game(g_game_tes4)) == games.end()) - games.push_back(Game(g_game_tes4)); + if (find(games.begin(), games.end(), Game(Game::tes4)) == games.end()) + games.push_back(Game(Game::tes4)); - if (find(games.begin(), games.end(), Game(g_game_tes5)) == games.end()) - games.push_back(Game(g_game_tes5)); + if (find(games.begin(), games.end(), Game(Game::tes5)) == games.end()) + games.push_back(Game(Game::tes5)); - if (find(games.begin(), games.end(), Game(g_game_fo3)) == games.end()) - games.push_back(Game(g_game_fo3)); + if (find(games.begin(), games.end(), Game(Game::fo3)) == games.end()) + games.push_back(Game(Game::fo3)); - if (find(games.begin(), games.end(), Game(g_game_fonv)) == games.end()) - games.push_back(Game(g_game_fonv)); + if (find(games.begin(), games.end(), Game(Game::fonv)) == games.end()) + games.push_back(Game(Game::fonv)); + + // If there were any missing defaults, make sure they're in settings now. + settings["games"] = games; return games; } - Game::Game() : id(g_game_autodetect) {} + size_t SelectGame(const YAML::Node& settings, const std::vector& games, const std::string& cmdLineGame) { + string preferredGame(cmdLineGame); + if (preferredGame.empty()) { + // Get preferred game from settings. + if (settings["game"] && settings["game"].as() != "auto") + preferredGame = settings["game"].as(); + else if (settings["lastGame"] && settings["lastGame"].as() != "auto") + preferredGame = settings["lastGame"].as(); + } + + // Get index of preferred game if there is one. + for (size_t i = 0; i < games.size(); ++i) { + if (preferredGame.empty() && games[i].IsInstalled()) + return i; + else if (!preferredGame.empty() && preferredGame == games[i].FolderName() && games[i].IsInstalled()) + return i; + } + // Preferred game not found, just pick the first installed one. + for (size_t i = 0; i < games.size(); ++i) { + if (games[i].IsInstalled()) + return i; + } + + throw error(error::no_game_detected, "None of the supported games were detected."); + } + + // MetadataList member functions + //------------------------------ + + void MetadataList::Load(const boost::filesystem::path& filepath) { + plugins.clear(); + messages.clear(); + + BOOST_LOG_TRIVIAL(debug) << "Loading file: " << filepath; + + loot::ifstream in(filepath); + YAML::Node metadataList = YAML::Load(in); + in.close(); + + if (metadataList["plugins"]) { + for (const auto& node : metadataList["plugins"]) { + Plugin plugin(node.as()); + if (plugin.IsRegexPlugin()) + regexPlugins.push_back(plugin); + else + plugins.insert(plugin); + } + } + if (metadataList["globals"]) + messages = metadataList["globals"].as< list >(); + + BOOST_LOG_TRIVIAL(debug) << "File loaded successfully."; + } + + void MetadataList::Save(const boost::filesystem::path& filepath) { + BOOST_LOG_TRIVIAL(trace) << "Saving metadata list to: " << filepath; + YAML::Emitter yout; + yout.SetIndent(2); + yout << YAML::BeginMap + << YAML::Key << "plugins" << YAML::Value << plugins + << YAML::Key << "globals" << YAML::Value << messages + << YAML::EndMap; + + loot::ofstream uout(filepath); + uout << yout.c_str(); + uout.close(); + } + + void MetadataList::clear() { + plugins.clear(); + messages.clear(); + } + + bool MetadataList::operator == (const MetadataList& rhs) const { + if (this->plugins.size() != rhs.plugins.size() || this->messages.size() != rhs.messages.size()) { + BOOST_LOG_TRIVIAL(info) << "Metadata edited for some plugin, new and old userlists differ in size."; + return false; + } + else { + for (const auto& rhsPlugin : rhs.plugins) { + const auto it = this->plugins.find(rhsPlugin); + + if (it == this->plugins.end()) { + BOOST_LOG_TRIVIAL(info) << "Metadata added for plugin: " << it->Name(); + return false; + } + + if (!it->DiffMetadata(rhsPlugin).HasNameOnly()) { + BOOST_LOG_TRIVIAL(info) << "Metadata edited for plugin: " << it->Name(); + return false; + } + } + // Messages are compared exactly by the '==' operator, so there's no need to do a more + // fine-grained check. + for (const auto& rhsMessage : rhs.messages) { + const auto it = std::find(this->messages.begin(), this->messages.end(), rhsMessage); + + if (it == this->messages.end()) { + return false; + } + } + } + return true; + } + + std::list MetadataList::Plugins() const { + list pluginList(plugins.begin(), plugins.end()); + + pluginList.insert(pluginList.end(), regexPlugins.begin(), regexPlugins.end()); + + return pluginList; + } + + Plugin MetadataList::FindPlugin(const Plugin& plugin) const { + auto it = plugins.find(plugin); + + if (it != plugins.end()) + return *it; + + it = find(regexPlugins.begin(), regexPlugins.end(), plugin); + + if (it != regexPlugins.end()) + return *it; + else + return Plugin(plugin.Name()); + } + + void MetadataList::AddPlugin(const Plugin& plugin) { + if (plugin.IsRegexPlugin()) + regexPlugins.push_back(plugin); + else + plugins.insert(plugin); + } + + void MetadataList::ErasePlugin(const Plugin& plugin) { + auto it = plugins.find(plugin); + + if (it != plugins.end()) { + plugins.erase(it); + return; + } + + it = find(regexPlugins.begin(), regexPlugins.end(), plugin); + + if (it != regexPlugins.end()) { + regexPlugins.erase(it); + } + } + + // Masterlist member functions + //---------------------------- + + bool Masterlist::Load(Game& game, const unsigned int language) { + try { + return Update(game, language); + } + catch (error& e) { + if (e.code() != error::ok) { + // Error wasn't a parsing error. Need to try parsing masterlist if it exists. + try { + MetadataList::Load(game.MasterlistPath()); + } + catch (...) {} + } + throw e; + } + } + + std::string Masterlist::GetRevision(const boost::filesystem::path& path) { + if (revision.empty()) + GetGitInfo(path); + + return revision; + } + + std::string Masterlist::GetDate(const boost::filesystem::path& path) { + if (date.empty()) + GetGitInfo(path); + + return date; + } + + // Game member functions + //---------------------- + + Game::Game() : id(Game::autodetect) {} Game::Game(const unsigned int gameCode, const std::string& folder) : id(gameCode) { - if (Id() == g_game_tes4) { + if (Id() == Game::tes4) { _name = "TES IV: Oblivion"; registryKey = "Software\\Bethesda Softworks\\Oblivion\\Installed Path"; - bossFolderName = "Oblivion"; + lootFolderName = "Oblivion"; _masterFile = "Oblivion.esm"; espm_settings = espm::Settings("tes4"); - _repositoryURL = "https://github.com/boss-developers/boss-oblivion.git"; - _repositoryBranch = "gh-pages"; - } else if (Id() == g_game_tes5) { + _repositoryURL = "https://github.com/loot/oblivion.git"; + _repositoryBranch = "master"; + } else if (Id() == Game::tes5) { _name = "TES V: Skyrim"; registryKey = "Software\\Bethesda Softworks\\Skyrim\\Installed Path"; - bossFolderName = "Skyrim"; + lootFolderName = "Skyrim"; _masterFile = "Skyrim.esm"; espm_settings = espm::Settings("tes5"); - _repositoryURL = "https://github.com/boss-developers/boss-skyrim.git"; - _repositoryBranch = "gh-pages"; - } else if (Id() == g_game_fo3) { + _repositoryURL = "https://github.com/loot/skyrim.git"; + _repositoryBranch = "master"; + } else if (Id() == Game::fo3) { _name = "Fallout 3"; registryKey = "Software\\Bethesda Softworks\\Fallout3\\Installed Path"; - bossFolderName = "Fallout3"; + lootFolderName = "Fallout3"; _masterFile = "Fallout3.esm"; espm_settings = espm::Settings("fo3"); - _repositoryURL = "https://github.com/boss-developers/boss-fallout3.git"; - _repositoryBranch = "gh-pages"; - } else if (Id() == g_game_fonv) { + _repositoryURL = "https://github.com/loot/fallout3.git"; + _repositoryBranch = "master"; + } else if (Id() == Game::fonv) { _name = "Fallout: New Vegas"; registryKey = "Software\\Bethesda Softworks\\FalloutNV\\Installed Path"; - bossFolderName = "FalloutNV"; + lootFolderName = "FalloutNV"; _masterFile = "FalloutNV.esm"; espm_settings = espm::Settings("fonv"); - _repositoryURL = "https://github.com/boss-developers/boss-fallout-new-vegas.git"; - _repositoryBranch = "gh-pages"; - } else { - BOOST_LOG_TRIVIAL(error) << "Invalid game ID supplied."; - throw error(error::invalid_args, lc::translate("Invalid game ID supplied.").str()); + _repositoryURL = "https://github.com/loot/falloutnv.git"; + _repositoryBranch = "master"; } if (!folder.empty()) - bossFolderName = folder; + lootFolderName = folder; } Game& Game::SetDetails(const std::string& name, const std::string& masterFile, const std::string& repositoryURL, const std::string& repositoryBranch, const std::string& path, const std::string& registry) { - BOOST_LOG_TRIVIAL(trace) << "Setting new details for game: " << _name; + BOOST_LOG_TRIVIAL(info) << "Setting new details for game: " << _name; if (!name.empty()) _name = name; @@ -135,21 +327,26 @@ namespace boss { } Game& Game::Init() { - BOOST_LOG_TRIVIAL(trace) << "Initialising filesystem-related data for game: " << _name; + if (id != Game::tes4 && id != Game::tes5 && id != Game::fo3 && id != Game::fonv) { + throw error(error::invalid_args, lc::translate("Invalid game ID supplied.").str()); + } + + BOOST_LOG_TRIVIAL(info) << "Initialising filesystem-related data for game: " << _name; //First look for local install, then look for Registry. if (gamePath.empty() || !fs::exists(gamePath / "Data" / _masterFile)) { - if (fs::exists(fs::path("..") / "Data" / _masterFile)) + if (fs::exists(fs::path("..") / "Data" / _masterFile)) { gamePath = ".."; +#ifdef _WIN32 + } else { string path; string key_parent = fs::path(registryKey).parent_path().string(); string key_name = fs::path(registryKey).filename().string(); - if (RegKeyExists("HKEY_LOCAL_MACHINE", key_parent, key_name)) { - path = RegKeyStringValue("HKEY_LOCAL_MACHINE", key_parent, key_name); - if (fs::exists(fs::path(path) / "Data" / _masterFile)) - gamePath = fs::path(path); - } + path = RegKeyStringValue("HKEY_LOCAL_MACHINE", key_parent, key_name); + if (!path.empty() && fs::exists(fs::path(path) / "Data" / _masterFile)) + gamePath = fs::path(path); +#endif } } @@ -159,7 +356,7 @@ namespace boss { } RefreshActivePluginsList(); - CreateBOSSGameFolder(); + CreateLOOTGameFolder(); return *this; } @@ -172,20 +369,24 @@ namespace boss { if (fs::exists(fs::path("..") / "Data" / _masterFile)) return true; +#ifdef _WIN32 string path; string key_parent = fs::path(registryKey).parent_path().string(); string key_name = fs::path(registryKey).filename().string(); - if (RegKeyExists("HKEY_LOCAL_MACHINE", key_parent, key_name)) { - path = RegKeyStringValue("HKEY_LOCAL_MACHINE", key_parent, key_name); - if (fs::exists(fs::path(path) / "Data" / _masterFile)) - return true; - } + path = RegKeyStringValue("HKEY_LOCAL_MACHINE", key_parent, key_name); + if (!path.empty() && fs::exists(fs::path(path) / "Data" / _masterFile)) + return true; +#endif return false; } bool Game::operator == (const Game& rhs) const { - return (boost::iequals(_name, rhs.Name()) || boost::iequals(bossFolderName, rhs.FolderName())); + return (boost::iequals(_name, rhs.Name()) || boost::iequals(lootFolderName, rhs.FolderName())); + } + + bool Game::operator == (const std::string& nameOrFolderName) const { + return (boost::iequals(_name, nameOrFolderName) || boost::iequals(lootFolderName, nameOrFolderName)); } unsigned int Game::Id() const { @@ -197,7 +398,7 @@ namespace boss { } string Game::FolderName() const { - return bossFolderName; + return lootFolderName; } std::string Game::Master() const { @@ -225,38 +426,38 @@ namespace boss { } fs::path Game::MasterlistPath() const { - return g_path_local / bossFolderName / "masterlist.yaml"; + return g_path_local / lootFolderName / "masterlist.yaml"; } fs::path Game::UserlistPath() const { - return g_path_local / bossFolderName / "userlist.yaml"; + return g_path_local / lootFolderName / "userlist.yaml"; } - fs::path Game::ReportPath() const { - return g_path_local / bossFolderName / "report.html"; + fs::path Game::ReportDataPath() const { + return g_path_local / lootFolderName / "reportdata.js"; } void Game::RefreshActivePluginsList() { - BOOST_LOG_TRIVIAL(trace) << "Refreshing active plugins list for game: " << _name; + BOOST_LOG_TRIVIAL(debug) << "Refreshing active plugins list for game: " << _name; lo_game_handle gh; char ** pluginArr; size_t pluginArrSize; int ret; - if (Id() == g_game_tes4) + if (Id() == Game::tes4) ret = lo_create_handle(&gh, LIBLO_GAME_TES4, gamePath.string().c_str()); - else if (Id() == g_game_tes5) + else if (Id() == Game::tes5) ret = lo_create_handle(&gh, LIBLO_GAME_TES5, gamePath.string().c_str()); - else if (Id() == g_game_fo3) + else if (Id() == Game::fo3) ret = lo_create_handle(&gh, LIBLO_GAME_FO3, gamePath.string().c_str()); - else if (Id() == g_game_fonv) + else if (Id() == Game::fonv) ret = lo_create_handle(&gh, LIBLO_GAME_FNV, gamePath.string().c_str()); if (ret != LIBLO_OK && ret != LIBLO_WARN_LO_MISMATCH) { - const char * e = NULL; + const char * e = nullptr; string err; lo_get_error_message(&e); - if (e == NULL) { + if (e == nullptr) { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to create a game handle. Details could not be fetched."; err = lc::translate("libloadorder failed to create a game handle. Details could not be fetched.").str(); } @@ -271,11 +472,11 @@ namespace boss { ret = lo_set_game_master(gh, _masterFile.c_str()); if (ret != LIBLO_OK) { - const char * e = NULL; + const char * e = nullptr; string err; lo_get_error_message(&e); lo_destroy_handle(gh); - if (e == NULL) { + if (e == nullptr) { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to initialise game master file support. Details could not be fetched."; err = lc::translate("libloadorder failed to initialise game master file support. Details could not be fetched.").str(); } @@ -288,17 +489,17 @@ namespace boss { } if (lo_get_active_plugins(gh, &pluginArr, &pluginArrSize) != LIBLO_OK) { - const char * e = NULL; + const char * e = nullptr; string err; lo_get_error_message(&e); lo_destroy_handle(gh); - if (e == NULL) { + if (e == nullptr) { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to get the active plugins list. Details could not be fetched."; err = lc::translate("libloadorder failed to get the active plugins list. Details could not be fetched.").str(); } else { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to get the active plugins list. Details: " << e; - string err = lc::translate("libloadorder failed to get the active plugins list. Details:").str() + " " + e; + err = lc::translate("libloadorder failed to get the active plugins list. Details:").str() + " " + e; } lo_cleanup(); throw error(error::liblo_error, err); @@ -306,44 +507,44 @@ namespace boss { activePlugins.clear(); for (size_t i=0; i < pluginArrSize; ++i) { - activePlugins.insert(boost::to_lower_copy(string(pluginArr[i]))); + activePlugins.insert(boost::locale::to_lower(string(pluginArr[i]))); } lo_destroy_handle(gh); } bool Game::IsActive(const std::string& plugin) const { - return activePlugins.find(boost::to_lower_copy(plugin)) != activePlugins.end(); + return activePlugins.find(boost::locale::to_lower(plugin)) != activePlugins.end(); } - void Game::GetLoadOrder(std::list& loadOrder) const { - BOOST_LOG_TRIVIAL(trace) << "Setting load order for game: " << _name; + void Game::GetLoadOrder(std::list& loadOrder) const { + BOOST_LOG_TRIVIAL(debug) << "Getting load order for game: " << _name; lo_game_handle gh; char ** pluginArr; size_t pluginArrSize; int ret; - if (Id() == g_game_tes4) + if (Id() == Game::tes4) ret = lo_create_handle(&gh, LIBLO_GAME_TES4, gamePath.string().c_str()); - else if (Id() == g_game_tes5) + else if (Id() == Game::tes5) ret = lo_create_handle(&gh, LIBLO_GAME_TES5, gamePath.string().c_str()); - else if (Id() == g_game_fo3) + else if (Id() == Game::fo3) ret = lo_create_handle(&gh, LIBLO_GAME_FO3, gamePath.string().c_str()); - else if (Id() == g_game_fonv) + else if (Id() == Game::fonv) ret = lo_create_handle(&gh, LIBLO_GAME_FNV, gamePath.string().c_str()); if (ret != LIBLO_OK && ret != LIBLO_WARN_LO_MISMATCH) { - const char * e = NULL; + const char * e = nullptr; string err; lo_get_error_message(&e); - if (e == NULL) { + if (e == nullptr) { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to create a game handle. Details could not be fetched."; err = lc::translate("libloadorder failed to create a game handle. Details could not be fetched.").str(); } else { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to create a game handle. Details: " << e; - string err = lc::translate("libloadorder failed to create a game handle. Details:").str() + " " + e; + err = lc::translate("libloadorder failed to create a game handle. Details:").str() + " " + e; } lo_cleanup(); throw error(error::liblo_error, err); @@ -352,34 +553,34 @@ namespace boss { ret = lo_set_game_master(gh, _masterFile.c_str()); if (ret != LIBLO_OK) { - const char * e = NULL; + const char * e = nullptr; string err; lo_get_error_message(&e); lo_destroy_handle(gh); - if (e == NULL) { + if (e == nullptr) { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to initialise game master file support. Details could not be fetched."; err = lc::translate("libloadorder failed to initialise game master file support. Details could not be fetched.").str(); } else { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to initialise game master file support. Details: " << e; - string err = lc::translate("libloadorder failed to initialise game master file support. Details:").str() + " " + e; + err = lc::translate("libloadorder failed to initialise game master file support. Details:").str() + " " + e; } lo_cleanup(); throw error(error::liblo_error, err); } if (lo_get_load_order(gh, &pluginArr, &pluginArrSize) != LIBLO_OK) { - const char * e = NULL; + const char * e = nullptr; string err; lo_get_error_message(&e); lo_destroy_handle(gh); - if (e == NULL) { + if (e == nullptr) { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to set the load order. Details could not be fetched."; err = lc::translate("libloadorder failed to set the load order. Details could not be fetched.").str(); } else { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to get the load order. Details: " << e; - string err = lc::translate("libloadorder failed to get the load order. Details:").str() + " " + e; + err = lc::translate("libloadorder failed to get the load order. Details:").str() + " " + e; } lo_cleanup(); throw error(error::liblo_error, err); @@ -393,33 +594,33 @@ namespace boss { lo_destroy_handle(gh); } - void Game::SetLoadOrder(const std::list& loadOrder) const { - BOOST_LOG_TRIVIAL(trace) << "Setting load order for game: " << _name; + void Game::SetLoadOrder(const std::list& loadOrder) const { + BOOST_LOG_TRIVIAL(debug) << "Setting load order for game: " << _name; - lo_game_handle gh = NULL; - char ** pluginArr = NULL; + lo_game_handle gh = nullptr; + char ** pluginArr = nullptr; size_t pluginArrSize = 0; int ret; - if (Id() == g_game_tes4) + if (Id() == Game::tes4) ret = lo_create_handle(&gh, LIBLO_GAME_TES4, gamePath.string().c_str()); - else if (Id() == g_game_tes5) + else if (Id() == Game::tes5) ret = lo_create_handle(&gh, LIBLO_GAME_TES5, gamePath.string().c_str()); - else if (Id() == g_game_fo3) + else if (Id() == Game::fo3) ret = lo_create_handle(&gh, LIBLO_GAME_FO3, gamePath.string().c_str()); - else if (Id() == g_game_fonv) + else if (Id() == Game::fonv) ret = lo_create_handle(&gh, LIBLO_GAME_FNV, gamePath.string().c_str()); if (ret != LIBLO_OK && ret != LIBLO_WARN_LO_MISMATCH) { - const char * e = NULL; + const char * e = nullptr; string err; lo_get_error_message(&e); - if (e == NULL) { + if (e == nullptr) { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to create a game handle. Details could not be fetched."; err = lc::translate("libloadorder failed to create a game handle. Details could not be fetched.").str(); } else { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to create a game handle. Details: " << e; - string err = lc::translate("libloadorder failed to create a game handle. Details:").str() + " " + e; + err = lc::translate("libloadorder failed to create a game handle. Details:").str() + " " + e; } lo_cleanup(); throw error(error::liblo_error, err); @@ -427,17 +628,17 @@ namespace boss { ret = lo_set_game_master(gh, _masterFile.c_str()); if (ret != LIBLO_OK) { - const char * e = NULL; + const char * e = nullptr; string err; lo_get_error_message(&e); lo_destroy_handle(gh); - if (e == NULL) { + if (e == nullptr) { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to initialise game master file support. Details could not be fetched."; err = lc::translate("libloadorder failed to initialise game master file support. Details could not be fetched.").str(); } else { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to initialise game master file support. Details: " << e; - string err = lc::translate("libloadorder failed to initialise game master file support. Details:").str() + " " + e; + err = lc::translate("libloadorder failed to initialise game master file support. Details:").str() + " " + e; } lo_cleanup(); throw error(error::liblo_error, err); @@ -446,9 +647,9 @@ namespace boss { pluginArrSize = loadOrder.size(); pluginArr = new char*[pluginArrSize]; int i = 0; - for (list::const_iterator it=loadOrder.begin(),endIt=loadOrder.end(); it != endIt; ++it) { - pluginArr[i] = new char[it->Name().length() + 1]; - strcpy(pluginArr[i], it->Name().c_str()); + for (const auto &plugin: loadOrder) { + pluginArr[i] = new char[plugin.length() + 1]; + strcpy(pluginArr[i], plugin.c_str()); ++i; } @@ -456,17 +657,17 @@ namespace boss { for (size_t i=0; i < pluginArrSize; i++) delete [] pluginArr[i]; delete [] pluginArr; - const char * e = NULL; + const char * e = nullptr; string err; lo_get_error_message(&e); lo_destroy_handle(gh); - if (e == NULL) { + if (e == nullptr) { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to set the load order. Details could not be fetched."; err = lc::translate("libloadorder failed to set the load order. Details could not be fetched.").str(); } else { BOOST_LOG_TRIVIAL(error) << "libloadorder failed to set the load order. Details: " << e; - string err = lc::translate("libloadorder failed to set the load order. Details:").str() + " " + e; + err = lc::translate("libloadorder failed to set the load order. Details:").str() + " " + e; } lo_cleanup(); throw error(error::liblo_error, err); @@ -479,14 +680,153 @@ namespace boss { lo_destroy_handle(gh); } - void Game::CreateBOSSGameFolder() { - //Make sure that the BOSS game path exists. - try { - if (fs::exists(g_path_local) && !fs::exists(g_path_local / bossFolderName)) - fs::create_directory(g_path_local / bossFolderName); - } catch (fs::filesystem_error& e) { - BOOST_LOG_TRIVIAL(error) << "Could not create BOSS folder for game. Details: " << e.what(); - throw error(error::path_write_fail, lc::translate("Could not create BOSS folder for game. Details:").str() + " " + e.what()); + void Game::RedatePlugins() { + if (id != tes5) + return; + + list loadorder; + GetLoadOrder(loadorder); + + if (!loadorder.empty()) { + + time_t lastTime; + fs::path filepath = DataPath() / *loadorder.begin(); + if (!fs::exists(filepath) && fs::exists(filepath.string() + ".ghost")) + filepath += ".ghost"; + + lastTime = fs::last_write_time(filepath); + + for (const auto &pluginName: loadorder) { + + filepath = DataPath() / pluginName; + if (!fs::exists(filepath) && fs::exists(filepath.string() + ".ghost")) + filepath += ".ghost"; + + time_t thisTime = fs::last_write_time(filepath); + BOOST_LOG_TRIVIAL(info) << "Current timestamp for \"" << filepath.filename().string() << "\": " << thisTime; + if (thisTime >= lastTime) { + lastTime = thisTime; + BOOST_LOG_TRIVIAL(trace) << "No need to redate \"" << filepath.filename().string() << "\"."; + } + else { + lastTime += 60; + fs::last_write_time(filepath, lastTime); //Space timestamps by a minute. + BOOST_LOG_TRIVIAL(info) << "Redated \"" << filepath.filename().string() << "\" to: " << lastTime; + } + } } } + + void Game::LoadPlugins(bool headersOnly) { + boost::thread_group group; + uintmax_t meanFileSize = 0; + unordered_map tempMap; + std::vector groupPlugins; + //First calculate the mean plugin size. Store it temporarily in a map to reduce filesystem lookups and file size recalculation. + for (fs::directory_iterator it(this->DataPath()); it != fs::directory_iterator(); ++it) { + if (fs::is_regular_file(it->status()) && IsPlugin(it->path().string())) { + + uintmax_t fileSize = fs::file_size(it->path()); + meanFileSize += fileSize; + + tempMap.emplace(it->path().filename().string(), fileSize); + } + } + meanFileSize /= tempMap.size(); //Rounding error, but not important. + + //Now load plugins. + for (const auto &pluginPair : tempMap) { + + BOOST_LOG_TRIVIAL(info) << "Found plugin: " << pluginPair.first; + + //Insert the lowercased name as a key for case-insensitive matching. + auto plugin = plugins.emplace(boost::locale::to_lower(pluginPair.first), Plugin(pluginPair.first)); + + if (pluginPair.second > meanFileSize) { + BOOST_LOG_TRIVIAL(trace) << "Creating individual loading thread for: " << pluginPair.first; + group.create_thread([this, plugin, headersOnly]() { + BOOST_LOG_TRIVIAL(trace) << "Loading " << plugin.first->second.Name() << " individually."; + plugin.first->second = Plugin(*this, plugin.first->second.Name(), headersOnly); + }); + } + else { + groupPlugins.push_back(&plugin.first->second); + } + } + group.create_thread([this, &groupPlugins, headersOnly]() { + for (auto plugin : groupPlugins) { + const std::string name = plugin->Name(); + BOOST_LOG_TRIVIAL(trace) << "Loading " << plugin->Name() << " as part of a group."; + *plugin = Plugin(*this, name, headersOnly); + } + }); + + group.join_all(); + } + + bool Game::HasBeenLoaded() { + // Easy way to check is by checking the game's master file, + // which definitely shouldn't be empty. + auto pairIt = plugins.find(boost::locale::to_lower(_masterFile)); + + if (pairIt != plugins.end()) + return !pairIt->second.FormIDs().empty(); + + return false; + } + + void Game::CreateLOOTGameFolder() { + //Make sure that the LOOT game path exists. + try { + if (fs::exists(g_path_local) && !fs::exists(g_path_local / lootFolderName)) + fs::create_directory(g_path_local / lootFolderName); + } catch (fs::filesystem_error& e) { + BOOST_LOG_TRIVIAL(error) << "Could not create LOOT folder for game. Details: " << e.what(); + throw error(error::path_write_fail, lc::translate("Could not create LOOT folder for game. Details:").str() + " " + e.what()); + } + } + + std::list Game::Sort(const unsigned int language, std::function progressCallback) { + //Create a plugin graph containing the plugin and masterlist data. + loot::PluginGraph graph; + + progressCallback("Building plugin graph..."); + BOOST_LOG_TRIVIAL(info) << "Merging masterlist, userlist into plugin list, evaluating conditions and checking for install validity."; + for (const auto &plugin : this->plugins) { + vertex_t v = boost::add_vertex(plugin.second, graph); + BOOST_LOG_TRIVIAL(trace) << "Merging for plugin \"" << graph[v].Name() << "\""; + + //Check if there is a plugin entry in the masterlist. This will also find matching regex entries. + BOOST_LOG_TRIVIAL(trace) << "Merging masterlist data down to plugin list data."; + graph[v].MergeMetadata(this->masterlist.FindPlugin(graph[v])); + + //Check if there is a plugin entry in the userlist. This will also find matching regex entries. + Plugin ulistPlugin = this->userlist.FindPlugin(graph[v]); + + if (!ulistPlugin.HasNameOnly() && ulistPlugin.Enabled()) { + BOOST_LOG_TRIVIAL(trace) << "Merging userlist data down to plugin list data."; + graph[v].MergeMetadata(ulistPlugin); + } + + //Now that items are merged, evaluate any conditions they have. + BOOST_LOG_TRIVIAL(trace) << "Evaluate conditions for merged plugin data."; + try { + graph[v].EvalAllConditions(*this, language); + } + catch (std::exception& e) { + BOOST_LOG_TRIVIAL(error) << "\"" << graph[v].Name() << "\" contains a condition that could not be evaluated. Details: " << e.what(); + list messages(graph[v].Messages()); + messages.push_back(loot::Message(loot::Message::error, (boost::format(lc::translate("\"%1%\" contains a condition that could not be evaluated. Details: %2%")) % graph[v].Name() % e.what()).str())); + graph[v].Messages(messages); + } + + //Also check install validity. + BOOST_LOG_TRIVIAL(trace) << "Checking that the current install is valid according to this plugin's data."; + graph[v].CheckInstallValidity(*this); + } + + // Now add edges and sort. + progressCallback("Adding edges to plugin graph and performing topological sort..."); + return loot::Sort(graph); + } } diff --git a/src/backend/game.h b/src/backend/game.h index 5a02eaa8..e303002c 100644 --- a/src/backend/game.h +++ b/src/backend/game.h @@ -1,50 +1,99 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2012-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ -#ifndef __BOSS_GAME__ -#define __BOSS_GAME__ +#ifndef __LOOT_GAME__ +#define __LOOT_GAME__ +#include "metadata.h" #include #include -#include +#include +#include +#include #include -#include -#include +#include #include #include #include -namespace boss { +namespace loot { + + class Game; - class Plugin; + /* Each Game object should store the config details specific to that game. + It should also store the plugin and masterlist data for that game. + Plugin data should be stored as an unordered hashset, the elements of which are + referenced by ordered lists and other structures. + Masterlist / userlist data should be stored as structures which hold plugin and + global message lists. + Each game should have functions to load this plugin and masterlist / userlist + data. Plugin data should be loaded as header-only and as full data. + */ + + class MetadataList { + public: + void Load(const boost::filesystem::path& filepath); + void Save(const boost::filesystem::path& filepath); + void clear(); + + bool operator == (const MetadataList& rhs) const; //Compares content. + + std::list Plugins() const; + Plugin FindPlugin(const Plugin& plugin) const; + void AddPlugin(const Plugin& plugin); + void ErasePlugin(const Plugin& plugin); + + std::list messages; + protected: + std::unordered_set plugins; + std::list regexPlugins; + }; + + class Masterlist : public MetadataList { + public: + + bool Load(Game& game, const unsigned int language); //Handles update with load fallback. + bool Update(Game& game, const unsigned int language); + + std::string GetRevision(const boost::filesystem::path& path); + std::string GetDate(const boost::filesystem::path& path); + + private: + void GetGitInfo(const boost::filesystem::path& path); + + std::string revision; + std::string date; + }; class Game { public: - Game(); //Sets game to BOSS_g_game_autodetect, with all other vars being empty. - Game(const unsigned int baseGameCode, const std::string& bossFolder = ""); + //Game functions. + Game(); //Sets game to LOOT_Game::autodetect, with all other vars being empty. + Game(const unsigned int baseGameCode, const std::string& lootFolder = ""); Game& SetDetails(const std::string& name, const std::string& masterFile, const std::string& repositoryURL, const std::string& repositoryBranch, @@ -55,6 +104,7 @@ namespace boss { bool IsInstalled() const; bool operator == (const Game& rhs) const; //Compares names and folder names. + bool operator == (const std::string& nameOrFolderName) const; unsigned int Id() const; std::string Name() const; //Returns the game's name, eg. "TES IV: Oblivion". @@ -64,44 +114,63 @@ namespace boss { std::string RepoURL() const; std::string RepoBranch() const; - boost::filesystem::path GamePath() const; boost::filesystem::path DataPath() const; boost::filesystem::path MasterlistPath() const; boost::filesystem::path UserlistPath() const; - boost::filesystem::path ReportPath() const; + boost::filesystem::path ReportDataPath() const; + //Game plugin functions. bool IsActive(const std::string& plugin) const; - void GetLoadOrder(std::list& loadOrder) const; - void SetLoadOrder(const std::list& loadOrder) const; + void GetLoadOrder(std::list& loadOrder) const; + void SetLoadOrder(const std::list& loadOrder) const; //Modifies game load order, even though const. void RefreshActivePluginsList(); + void RedatePlugins(); //Change timestamps to match load order (Skyrim only). + void LoadPlugins(bool headersOnly); //Loads all installed plugins. + bool HasBeenLoaded(); // Checks if the game's plugins have already been loaded. + + std::list Sort(const unsigned int language, std::function progressCallback); //Caches for condition results, active plugins and CRCs. - boost::unordered_map conditionCache; //Holds lowercased strings. - boost::unordered_map crcCache; //Holds lowercased strings. + std::unordered_map conditionCache; //Holds lowercased strings. + std::unordered_map crcCache; //Holds lowercased strings. + + //Plugin data and metadata lists. + Masterlist masterlist; + MetadataList userlist; + std::unordered_map plugins; //Map so that plugin data can be edited. espm::Settings espm_settings; + + static const unsigned int autodetect = 0; + static const unsigned int tes4 = 1; + static const unsigned int tes5 = 2; + static const unsigned int fo3 = 3; + static const unsigned int fonv = 4; private: - unsigned id; + unsigned int id; std::string _name; std::string _masterFile; std::string registryKey; - std::string bossFolderName; + std::string lootFolderName; std::string _repositoryURL; std::string _repositoryBranch; boost::filesystem::path gamePath; //Path to the game's folder. - boost::unordered_set activePlugins; //Holds lowercased strings. - //Creates directory in BOSS folder for BOSS's game-specific files. - void CreateBOSSGameFolder(); + std::unordered_set activePlugins; //Holds lowercased strings. + + //Creates directory in LOOT folder for LOOT's game-specific files. + void CreateLOOTGameFolder(); }; - std::vector GetGames(const YAML::Node& settings); + std::vector GetGames(YAML::Node& settings); + + size_t SelectGame(const YAML::Node& settings, const std::vector& games, const std::string& cmdLineGame); } #endif diff --git a/src/backend/generators.cpp b/src/backend/generators.cpp new file mode 100644 index 00000000..2800a0f7 --- /dev/null +++ b/src/backend/generators.cpp @@ -0,0 +1,182 @@ +/* LOOT + +A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and +Fallout: New Vegas. + +Copyright (C) 2013-2014 WrinklyNinja + +This file is part of LOOT. + +LOOT 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. + +LOOT 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 LOOT. If not, see +. +*/ + +#include "generators.h" +#include "helpers.h" +#include "globals.h" +#include "parsers.h" +#include "streams.h" + +#include +#include + +#include + +using namespace std; + +namespace YAML { + + Emitter& operator << (Emitter& out, const loot::PluginDirtyInfo& rhs) { + out << BeginMap + << Key << "crc" << Value << Hex << rhs.CRC() << Dec + << Key << "util" << Value << rhs.CleaningUtility(); + + if (rhs.ITMs() > 0) + out << Key << "itm" << Value << rhs.ITMs(); + if (rhs.UDRs() > 0) + out << Key << "udr" << Value << rhs.UDRs(); + if (rhs.DeletedNavmeshes() > 0) + out << Key << "nav" << Value << rhs.DeletedNavmeshes(); + + out << EndMap; + + return out; + } + + Emitter& operator << (Emitter& out, const loot::Game& rhs) { + out << BeginMap + << Key << "type" << Value << loot::Game(rhs.Id()).FolderName() + << Key << "folder" << Value << rhs.FolderName() + << Key << "name" << Value << rhs.Name() + << Key << "master" << Value << rhs.Master() + << Key << "repo" << Value << rhs.RepoURL() + << Key << "branch" << Value << rhs.RepoBranch() + << Key << "path" << Value << rhs.GamePath().string() + << Key << "registry" << Value << rhs.RegistryKey() + << EndMap; + + return out; + } + + Emitter& operator << (Emitter& out, const loot::MessageContent& rhs) { + out << BeginMap; + + out << Key << "lang" << Value << loot::Language(rhs.Language()).Locale(); + + out << Key << "str" << Value << rhs.Str(); + + out << EndMap; + + return out; + } + + Emitter& operator << (Emitter& out, const loot::Message& rhs) { + out << BeginMap; + + if (rhs.Type() == loot::Message::say) + out << Key << "type" << Value << "say"; + else if (rhs.Type() == loot::Message::warn) + out << Key << "type" << Value << "warn"; + else + out << Key << "type" << Value << "error"; + + if (rhs.Content().size() == 1) + out << Key << "content" << Value << rhs.Content().front().Str(); + else + out << Key << "content" << Value << rhs.Content(); + + if (!rhs.Condition().empty()) + out << Key << "condition" << Value << rhs.Condition(); + + out << EndMap; + + return out; + } + + Emitter& operator << (Emitter& out, const loot::File& rhs) { + if (!rhs.IsConditional() && rhs.DisplayName().empty()) + out << rhs.Name(); + else { + out << BeginMap + << Key << "name" << Value << rhs.Name(); + + if (rhs.IsConditional()) + out << Key << "condition" << Value << rhs.Condition(); + + if (rhs.DisplayName() != rhs.Name()) + out << Key << "display" << Value << rhs.DisplayName(); + + out << EndMap; + } + + return out; + } + + Emitter& operator << (Emitter& out, const loot::Tag& rhs) { + if (!rhs.IsConditional()) { + if (rhs.IsAddition()) + out << rhs.Name(); + else + out << '-' << rhs.Name(); + } + else { + out << BeginMap; + if (rhs.IsAddition()) + out << Key << "name" << Value << rhs.Name(); + else + out << Key << "name" << Value << ('-' + rhs.Name()); + + out << Key << "condition" << Value << rhs.Condition() + << EndMap; + } + + return out; + } + + Emitter& operator << (Emitter& out, const loot::Plugin& rhs) { + if (!rhs.HasNameOnly()) { + + out << BeginMap + << Key << "name" << Value << rhs.Name(); + + if (rhs.IsPriorityExplicit()) + out << Key << "priority" << Value << rhs.Priority(); + + if (!rhs.Enabled()) + out << Key << "enabled" << Value << rhs.Enabled(); + + if (!rhs.LoadAfter().empty()) + out << Key << "after" << Value << rhs.LoadAfter(); + + if (!rhs.Reqs().empty()) + out << Key << "req" << Value << rhs.Reqs(); + + if (!rhs.Incs().empty()) + out << Key << "inc" << Value << rhs.Incs(); + + if (!rhs.Messages().empty()) + out << Key << "msg" << Value << rhs.Messages(); + + if (!rhs.Tags().empty()) + out << Key << "tag" << Value << rhs.Tags(); + + if (!rhs.DirtyInfo().empty()) + out << Key << "dirty" << Value << rhs.DirtyInfo(); + + out << EndMap; + } + + return out; + } +} \ No newline at end of file diff --git a/src/backend/generators.h b/src/backend/generators.h index 94029244..55b60af4 100644 --- a/src/backend/generators.h +++ b/src/backend/generators.h @@ -1,770 +1,74 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2013-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ -#ifndef __BOSS_GENERATORS__ -#define __BOSS_GENERATORS__ +#ifndef __LOOT_GENERATORS__ +#define __LOOT_GENERATORS__ -#include "helpers.h" #include "metadata.h" -#include "globals.h" -#include "parsers.h" -#include "streams.h" -#include #include #include #include -#include +#include #include -#include - -namespace boss { - - //BOSS Report generation stuff. - - struct xml_string_writer: pugi::xml_writer { - std::string result; - - virtual void write(const void* data, size_t size) { - result += std::string(static_cast(data), size); - } - }; - - inline void WriteMessage(pugi::xml_node& listItem, unsigned int type, std::string content) { - - if (type == g_message_say) - content = boost::locale::translate("Note:").str() + " " + content; - else if (type == g_message_tag) { - content = boost::locale::translate("Bash Tag Suggestion(s):").str() + " " + content; - } else if (type == g_message_warn) - content = boost::locale::translate("Warning:").str() + " " + content; - else - content = boost::locale::translate("Error:").str() + " " + content; - - //Now look for Markdown URL syntax and convert any found. - boost::regex regex("(\\[([^\\]]+)\\]\\s?\\(|<)((file|https?)://\\S+)(\\)|>)", boost::regex::perl | boost::regex::icase); // \2 is the label, \3 is the URL. - - boost::match_results results; - std::string::iterator start, end; - start = content.begin(); - end = content.end(); - - while (boost::regex_search(start, end, results, regex)) { - - BOOST_LOG_TRIVIAL(trace) << "Results size: " << results.size(); - - //Get data from match. - std::string url, label; - if (results[3].matched) - url = std::string(results[3].first, results[3].second); - if (results[2].matched) - label = std::string(results[2].first, results[2].second); - else - label = url; - - //Insert normal text preceding hyperlink. - listItem.append_child(pugi::node_pcdata).set_value(std::string(results.prefix().first, results.prefix().second).c_str()); - - //Insert hyperlink. - pugi::xml_node a = listItem.append_child(); - a.set_name("a"); - a.append_attribute("href").set_value(url.c_str()); - a.text().set(label.c_str()); - - //Set string to end of matched section. - start = results.suffix().first; - } - - //Insert any leftover text. - listItem.append_child(pugi::node_pcdata).set_value(std::string(start, end).c_str()); - - } - - inline void GenerateHead(pugi::xml_document& doc) { - BOOST_LOG_TRIVIAL(trace) << "Creating BOSS report head."; - - //Add DOCTYPE node. - doc.append_child(pugi::node_doctype).set_value("html"); - - //Create 'head' node. - pugi::xml_node head = doc.append_child(); - head.set_name("head"); - - //Now add head elements. - pugi::xml_node node; - - node = head.append_child(); - node.set_name("meta"); - node.append_attribute("http-equiv").set_value("X-UA-Compatible"); - node.append_attribute("content").set_value("IE=edge"); - - node = head.append_child(); - node.set_name("meta"); - node.append_attribute("charset").set_value("utf-8"); - - node = head.append_child(); - node.set_name("title"); - node.text().set(boost::locale::translate("BOSS Report").str().c_str()); - - node = head.append_child(); - node.set_name("link"); - node.append_attribute("rel").set_value("stylesheet"); - node.append_attribute("href").set_value(ToFileURL(g_path_css).c_str()); - - node = head.append_child(); - node.set_name("script"); - node.append_attribute("src").set_value(ToFileURL(g_path_polyfill).c_str()); - node.text().set(" "); - } - - inline void AppendNav(pugi::xml_node& body) { - BOOST_LOG_TRIVIAL(trace) << "Appending navigation bar to BOSS report."; - - pugi::xml_node nav, div; - - nav = body.append_child(); - nav.set_name("div"); - nav.append_attribute("id").set_value("nav"); - - div = nav.append_child(); - div.set_name("div"); - div.append_attribute("class").set_value("button current"); - div.append_attribute("data-section").set_value("summary"); - div.text().set(boost::locale::translate("Summary").str().c_str()); - - div = nav.append_child(); - div.set_name("div"); - div.append_attribute("class").set_value("button"); - div.append_attribute("data-section").set_value("plugins"); - div.text().set(boost::locale::translate("Details").str().c_str()); - - div = nav.append_child(); - div.set_name("div"); - div.append_attribute("class").set_value("button hidden"); - div.append_attribute("id").set_value("filtersToggle"); - div.text().set(boost::locale::translate("Filters").str().c_str()); - } - - inline void AppendMessages(pugi::xml_node& parent, const std::list& messages, int& warnNo, int& errorNo) { - if (!messages.empty()) { - pugi::xml_node list = parent.append_child(); - list.set_name("ul"); - - for (std::list::const_iterator it=messages.begin(), endit=messages.end(); it != endit; ++it) { - - pugi::xml_node li = list.append_child(); - li.set_name("li"); - - if (it->Type() == g_message_say) - li.append_attribute("class").set_value("say"); - else if (it->Type() == g_message_tag) - li.append_attribute("class").set_value("tag"); - else if (it->Type() == g_message_warn) { - li.append_attribute("class").set_value("warn"); - ++warnNo; - } else { - li.append_attribute("class").set_value("error"); - ++errorNo; - } - - //Turn any urls into hyperlinks. - WriteMessage(li, it->Type(), it->Content().front().Str()); - } - } - } - - inline void AppendSummary(pugi::xml_node& main, - bool hasChanged, - const std::string& masterlistVersion, - bool masterlistUpdateEnabled, - int messageNo, - int warnNo, - int errorNo, - std::list& messages) { - - BOOST_LOG_TRIVIAL(trace) << "Appending summary tab to BOSS report."; - - pugi::xml_node summary = main.append_child(); - summary.set_name("div"); - summary.append_attribute("id").set_value("summary"); - - pugi::xml_node div = summary.append_child(); - div.set_name("div"); - - pugi::xml_node heading = div.append_child(); - heading.set_name("h2"); - heading.text().set(boost::locale::translate("Summary").str().c_str()); - - pugi::xml_node table = div.append_child(); - table.set_name("table"); - table = table.append_child(); - table.set_name("tbody"); - - pugi::xml_node row, cell; - - row = table.append_child(); - row.set_name("tr"); - cell = row.append_child(); - cell.set_name("td"); - cell.text().set(boost::locale::translate("BOSS Version").str().c_str()); - cell = row.append_child(); - cell.set_name("td"); - cell.text().set((IntToString(g_version_major)+"."+IntToString(g_version_minor)+"."+IntToString(g_version_patch)).c_str()); - - row = table.append_child(); - row.set_name("tr"); - cell = row.append_child(); - cell.set_name("td"); - cell.text().set(boost::locale::translate("Masterlist Version").str().c_str()); - cell = row.append_child(); - cell.set_name("td"); - cell.text().set(masterlistVersion.c_str()); - - row = table.append_child(); - row.set_name("tr"); - cell = row.append_child(); - cell.set_name("td"); - cell.text().set(boost::locale::translate("Masterlist Updating").str().c_str()); - cell = row.append_child(); - cell.set_name("td"); - if (masterlistUpdateEnabled) - cell.text().set(boost::locale::translate("Enabled").str().c_str()); - else - cell.text().set(boost::locale::translate("Disabled").str().c_str()); - - if (!hasChanged) { - BOOST_LOG_TRIVIAL(info) << "No changes in the BOSS report details tab since the last run."; - /*pugi::xml_node note = summary.append_child(); - note.set_name("div"); - note.append_attribute("id").set_value("noChanges"); - note.text().set(boost::locale::translate("No change in details since last run.").str().c_str()); - */ - messages.push_front(boss::Message(boss::g_message_say, boost::locale::translate("There have been no changes in the Details tab since BOSS was last run for this game.").str())); - } - - if (!messages.empty()) { - - div = summary.append_child(); - div.set_name("div"); - - heading = div.append_child(); - heading.set_name("h2"); - heading.text().set(boost::locale::translate("General Messages").str().c_str()); - - AppendMessages(div, messages, warnNo, errorNo); - messageNo += messages.size(); - } - - row = table.append_child(); - row.set_name("tr"); - cell = row.append_child(); - cell.set_name("td"); - cell.text().set(boost::locale::translate("Total Number of Messages").str().c_str()); - cell = row.append_child(); - cell.set_name("td"); - cell.text().set(IntToString(messageNo).c_str()); - - row = table.append_child(); - row.set_name("tr"); - cell = row.append_child(); - cell.set_name("td"); - cell.text().set(boost::locale::translate("Number of Warnings").str().c_str()); - cell = row.append_child(); - cell.set_name("td"); - cell.text().set(IntToString(warnNo).c_str()); - - row = table.append_child(); - row.set_name("tr"); - cell = row.append_child(); - cell.set_name("td"); - cell.text().set(boost::locale::translate("Number of Errors").str().c_str()); - cell = row.append_child(); - cell.set_name("td"); - cell.text().set(IntToString(errorNo).c_str()); - } - - inline bool AppendDetails(pugi::xml_node& main, const std::list& plugins, int& messageNo, int& warnNo, int& errorNo, const std::string& oldDetails) { - - BOOST_LOG_TRIVIAL(trace) << "Appending details tab to BOSS report."; - - pugi::xml_node details = main.append_child(); - details.set_name("div"); - details.append_attribute("id").set_value("plugins"); - details.append_attribute("class").set_value("hidden"); - - if (!plugins.empty()) { - - details = details.append_child(); - details.set_name("ul"); - - for (std::list::const_iterator it=plugins.begin(), endit=plugins.end(); it != endit; ++it) { - BOOST_LOG_TRIVIAL(trace) << "Appending details for plugin: " << it->Name(); - pugi::xml_node plugin = details.append_child(); - plugin.set_name("li"); - - pugi::xml_node node = plugin.append_child(); - node.set_name("span"); - node.append_attribute("class").set_value("mod"); - node.text().set(it->Name().c_str()); - - if (it->Crc() != 0) { - node = plugin.append_child(); - node.set_name("div"); - node.append_attribute("class").set_value("crc"); - node.text().set(("CRC: " + IntToHexString(it->Crc())).c_str()); - } - - if (!it->Version().empty()) { - node = plugin.append_child(); - node.set_name("div"); - node.append_attribute("class").set_value("version"); - node.text().set((boost::locale::translate("Version:").str() + " " + it->Version()).c_str()); - } - - std::list messages = it->Messages(); - messageNo += messages.size(); - - std::set tags = it->Tags(); - - if (!tags.empty()) { - std::string add, remove, content; - for (std::set::const_iterator jt=tags.begin(), endjt=tags.end(); jt != endjt; ++jt) { - if (jt->IsAddition()) - add += ", " + jt->Name(); - else - remove += ", " + jt->Name(); - } - if (!add.empty()) { - node = plugin.append_child(); - node.set_name("div"); - node.append_attribute("class").set_value("tag add"); - node.text().set((boost::locale::translate("Add:").str() + " " + add.substr(2)).c_str()); - } - if (!remove.empty()) { - node = plugin.append_child(); - node.set_name("div"); - node.append_attribute("class").set_value("tag remove"); - node.text().set((boost::locale::translate("Remove:").str() + " " + remove.substr(2)).c_str()); - } - } - - std::set dirtyInfo = it->DirtyInfo(); - for (std::set::const_iterator jt=dirtyInfo.begin(), endjt=dirtyInfo.end(); jt != endjt; ++jt) { - boost::format f; - if (jt->ITMs() > 0 && jt->UDRs() > 0 && jt->DeletedNavmeshes() > 0) - f = boost::format(boost::locale::translate("Contains %1% ITM records, %2% UDR records and %3% deleted navmeshes. Clean with %4%.")) % jt->ITMs() % jt->UDRs() % jt->DeletedNavmeshes() % jt->CleaningUtility(); - else if (jt->ITMs() == 0 && jt->UDRs() == 0 && jt->DeletedNavmeshes() == 0) - f = boost::format(boost::locale::translate("Clean with %1%.")) % jt->CleaningUtility(); - - - else if (jt->ITMs() == 0 && jt->UDRs() > 0 && jt->DeletedNavmeshes() > 0) - f = boost::format(boost::locale::translate("Contains %1% UDR records and %2% deleted navmeshes. Clean with %3%.")) % jt->UDRs() % jt->DeletedNavmeshes() % jt->CleaningUtility(); - else if (jt->ITMs() == 0 && jt->UDRs() == 0 && jt->DeletedNavmeshes() > 0) - f = boost::format(boost::locale::translate("Contains %1% deleted navmeshes. Clean with %2%.")) % jt->DeletedNavmeshes() % jt->CleaningUtility(); - else if (jt->ITMs() == 0 && jt->UDRs() > 0 && jt->DeletedNavmeshes() == 0) - f = boost::format(boost::locale::translate("Contains %1% UDR records. Clean with %2%.")) % jt->UDRs() % jt->CleaningUtility(); - - else if (jt->ITMs() > 0 && jt->UDRs() == 0 && jt->DeletedNavmeshes() > 0) - f = boost::format(boost::locale::translate("Contains %1% ITM records and %2% deleted navmeshes. Clean with %3%.")) % jt->ITMs() % jt->DeletedNavmeshes() % jt->CleaningUtility(); - else if (jt->ITMs() > 0 && jt->UDRs() == 0 && jt->DeletedNavmeshes() == 0) - f = boost::format(boost::locale::translate("Contains %1% ITM records. Clean with %2%.")) % jt->ITMs() % jt->CleaningUtility(); - - else if (jt->ITMs() > 0 && jt->UDRs() > 0 && jt->DeletedNavmeshes() == 0) - f = boost::format(boost::locale::translate("Contains %1% ITM records and %2% UDR records. Clean with %3%.")) % jt->ITMs() % jt->UDRs() % jt->CleaningUtility(); - - messages.push_back(boss::Message(boss::g_message_warn, f.str())); - } - - AppendMessages(plugin, messages, warnNo, errorNo); - } - } - - xml_string_writer writer; - details.print(writer, "", pugi::format_default | pugi::format_no_declaration | pugi::format_raw); - - return writer.result != oldDetails; - } - - inline void AppendMain(pugi::xml_node& body, - const std::string& oldDetails, - const std::string& masterlistVersion, - bool masterlistUpdateEnabled, - std::list& messages, - const std::list& plugins, - int& pluginMessageNo - ) { - - BOOST_LOG_TRIVIAL(trace) << "Appending main content to BOSS report."; - - pugi::xml_node main = body.append_child(); - main.set_name("div"); - main.append_attribute("id").set_value("main"); - - pugi::xml_node noscript, div; - - noscript = main.append_child(); - noscript.set_name("noscript"); - div = noscript.append_child(); - div.set_name("div"); - div.text().set(boost::locale::translate("The BOSS Report requires Javascript to be enabled in order to function.").str().c_str()); - - int messageNo=0, warnNo=0, errorNo=0; - bool hasChanged = AppendDetails(main, plugins, messageNo, warnNo, errorNo, oldDetails); - pluginMessageNo = messageNo; - - AppendSummary(main, hasChanged, masterlistVersion, masterlistUpdateEnabled, messageNo, warnNo, errorNo, messages); - } - - inline void AppendFilters(pugi::xml_node& body, int messageNo, int pluginNo) { - - BOOST_LOG_TRIVIAL(trace) << "Appending filters to BOSS report."; - - pugi::xml_node filters = body.append_child(); - filters.set_name("div"); - filters.append_attribute("id").set_value("filters"); - filters.append_attribute("class").set_value("hidden"); - - pugi::xml_node label, input; - - label = filters.append_child(); - label.set_name("label"); - input = label.append_child(); - input.set_name("input"); - input.append_attribute("type").set_value("checkbox"); - input.append_attribute("id").set_value("hideVersionNumbers"); - input.append_attribute("data-class").set_value("version"); - label.text().set(boost::locale::translate("Hide Version Numbers").str().c_str()); - - label = filters.append_child(); - label.set_name("label"); - input = label.append_child(); - input.set_name("input"); - input.append_attribute("type").set_value("checkbox"); - input.append_attribute("id").set_value("hideCRCs"); - input.append_attribute("data-class").set_value("crc"); - label.text().set(boost::locale::translate("Hide CRCs").str().c_str()); - - label = filters.append_child(); - label.set_name("label"); - input = label.append_child(); - input.set_name("input"); - input.append_attribute("type").set_value("checkbox"); - input.append_attribute("id").set_value("hideBashTags"); - input.append_attribute("data-class").set_value("tag"); - label.text().set(boost::locale::translate("Hide Bash Tag Suggestions").str().c_str()); - - label = filters.append_child(); - label.set_name("label"); - input = label.append_child(); - input.set_name("input"); - input.append_attribute("type").set_value("checkbox"); - input.append_attribute("id").set_value("hideNotes"); - label.text().set(boost::locale::translate("Hide Notes").str().c_str()); - - label = filters.append_child(); - label.set_name("label"); - input = label.append_child(); - input.set_name("input"); - input.append_attribute("type").set_value("checkbox"); - input.append_attribute("id").set_value("hideDoNotCleanMessages"); - label.text().set(boost::locale::translate("Hide 'Do Not Clean' Messages").str().c_str()); - - label = filters.append_child(); - label.set_name("label"); - input = label.append_child(); - input.set_name("input"); - input.append_attribute("type").set_value("checkbox"); - input.append_attribute("id").set_value("hideAllPluginMessages"); - label.text().set(boost::locale::translate("Hide All Plugin Messages").str().c_str()); - - label = filters.append_child(); - label.set_name("label"); - input = label.append_child(); - input.set_name("input"); - input.append_attribute("type").set_value("checkbox"); - input.append_attribute("id").set_value("hideMessagelessPlugins"); - label.text().set(boost::locale::translate("Hide Messageless Plugins").str().c_str()); - - pugi::xml_node span; - - label = filters.append_child(); - label.set_name("div"); - span = label.append_child(); - span.set_name("span"); - span.append_attribute("id").set_value("hiddenPluginNo"); - span.text().set("0"); - label.append_child(pugi::node_pcdata).set_value((boost::format(boost::locale::translate("%1% of %2% plugins hidden.")) % "" % IntToString(pluginNo)).str().c_str()); //Blank string is so that translators get full string format. - - label = filters.append_child(); - label.set_name("div"); - span = label.append_child(); - span.set_name("span"); - span.append_attribute("id").set_value("hiddenMessageNo"); - span.text().set("0"); - label.append_child(pugi::node_pcdata).set_value((boost::format(boost::locale::translate("%1% of %2% messages hidden.")) % "" % IntToString(messageNo)).str().c_str()); //Blank string is so that translators get full string format. - } - - inline void AppendScripts(pugi::xml_node& body) { - - BOOST_LOG_TRIVIAL(trace) << "Appending scripts to BOSS report."; - - pugi::xml_node node; - - node = body.append_child(); - node.set_name("script"); - node.append_attribute("src").set_value(ToFileURL(g_path_js).c_str()); - node.text().set(" "); - - } - - inline void GenerateReport(const boost::filesystem::path& file, - std::list& messages, - const std::list& plugins, - const std::string& oldDetails, - const std::string& masterlistVersion, - const bool masterlistUpdateEnabled) { - - pugi::xml_document doc; - - GenerateHead(doc); - - pugi::xml_node body = doc.append_child(); - body.set_name("body"); - - AppendNav(body); - - int messageNo=0; - AppendMain(body, oldDetails, masterlistVersion, masterlistUpdateEnabled, messages, plugins, messageNo); - - AppendFilters(body, messageNo, plugins.size()); - - AppendScripts(body); - //PugiXML's save_file doesn't handle Unicode paths right (it can't open them right), so use a stream instead. - boost::filesystem::path outpath(file); - boss::ofstream out(outpath); - doc.save(out, "\t", pugi::format_default | pugi::format_no_declaration | pugi::format_raw); - out.close(); - - } - - //Default settings file generation. - - inline void GenerateDefaultSettingsFile(const std::string& file) { - - BOOST_LOG_TRIVIAL(info) << "Generating default settings file."; - - YAML::Node root; - std::vector games; - - root["Language"] = "eng"; - root["Game"] = "auto"; - root["Last Game"] = "auto"; - root["Debug Verbosity"] = 0; - root["Update Masterlist"] = true; - root["View Report Externally"] = false; - - games.push_back(Game(g_game_tes4)); - games.push_back(Game(g_game_tes5)); - games.push_back(Game(g_game_fo3)); - games.push_back(Game(g_game_fonv)); - games.push_back(Game(g_game_tes4, "Nehrim").SetDetails("Nehrim - At Fate's Edge", "Nehrim.esm", "https://github.com/boss-developers/boss-oblivion.git", "gh-pages", "", "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Nehrim - At Fate's Edge_is1")); - - root["Games"] = games; - - //Save settings. - YAML::Emitter yout; - yout.SetIndent(2); - yout << root; - - boost::filesystem::path p(file); - boss::ofstream out(p); - out << yout.c_str(); - out.close(); - } -} namespace YAML { template Emitter& operator << (Emitter& out, const std::set& rhs) { out << BeginSeq; - for (typename std::set::const_iterator it=rhs.begin(), endIt=rhs.end(); it != endIt; ++it) { - out << *it; + for (const auto &element: rhs) { + out << element; } out << EndSeq; return out; } - inline Emitter& operator << (Emitter& out, const boss::PluginDirtyInfo& rhs) { - out << BeginMap - << Key << "crc" << Value << Hex << rhs.CRC() << Dec - << Key << "util" << Value << rhs.CleaningUtility(); - - if (rhs.ITMs() > 0) - out << Key << "itm" << Value << rhs.ITMs(); - if (rhs.UDRs() > 0) - out << Key << "udr" << Value << rhs.UDRs(); - if (rhs.DeletedNavmeshes() > 0) - out << Key << "nav" << Value << rhs.DeletedNavmeshes(); - - out << EndMap; - - return out; - } - - inline Emitter& operator << (Emitter& out, const boss::Game& rhs) { - out << BeginMap - << Key << "folder" << Value << rhs.FolderName() - << Key << "name" << Value << rhs.Name() - << Key << "master" << Value << rhs.Master() - << Key << "repo" << Value << rhs.RepoURL() - << Key << "branch" << Value << rhs.RepoBranch() - << Key << "path" << Value << rhs.GamePath().string() - << Key << "registry" << Value << rhs.RegistryKey(); - - if (rhs.Id() == boss::g_game_tes4) - out << Key << Value << boss::Game(boss::g_game_tes4).FolderName(); - else if (rhs.Id() == boss::g_game_tes5) - out << Key << Value << boss::Game(boss::g_game_tes5).FolderName(); - else if (rhs.Id() == boss::g_game_fo3) - out << Key << Value << boss::Game(boss::g_game_fo3).FolderName(); - else if (rhs.Id() == boss::g_game_fonv) - out << Key << Value << boss::Game(boss::g_game_fonv).FolderName(); - - out << EndMap; - - return out; - } - - inline Emitter& operator << (Emitter& out, const boss::MessageContent& rhs) { - out << BeginMap; - - out << Key << "lang" << Value << boss::Language(rhs.Language()).Locale(); - - out << Key << "str" << Value << rhs.Str(); - - out << EndMap; - - return out; - } - - inline Emitter& operator << (Emitter& out, const boss::Message& rhs) { - out << BeginMap; - - if (rhs.Type() == boss::g_message_say) - out << Key << "type" << Value << "say"; - else if (rhs.Type() == boss::g_message_warn) - out << Key << "type" << Value << "warn"; - else - out << Key << "type" << Value << "error"; - - if (rhs.Content().size() == 1 && rhs.Content().front().Language() == boss::g_lang_any) - out << Key << "content" << Value << rhs.Content().front().Str(); - else - out << Key << "content" << Value << rhs.Content(); - - if (!rhs.Condition().empty()) - out << Key << "condition" << Value << rhs.Condition(); - - out << EndMap; - - return out; - } - - inline Emitter& operator << (Emitter& out, const boss::File& rhs) { - if (!rhs.IsConditional() && rhs.DisplayName().empty()) - out << rhs.Name(); - else { - out << BeginMap - << Key << "name" << Value << rhs.Name(); - - if (rhs.IsConditional()) - out << Key << "condition" << Value << rhs.Condition(); - - if (rhs.DisplayName() != rhs.Name()) - out << Key << "display" << Value << rhs.DisplayName(); - - out << EndMap; + template + Emitter& operator << (Emitter& out, const std::unordered_set& rhs) { + out << BeginSeq; + for (const auto &element : rhs) { + out << element; } + out << EndSeq; - return out; + return out; } - inline Emitter& operator << (Emitter& out, const boss::Tag& rhs) { - if (!rhs.IsConditional()) { - if (rhs.IsAddition()) - out << rhs.Name(); - else - out << '-' << rhs.Name(); - } else { - out << BeginMap; - if (rhs.IsAddition()) - out << Key << "name" << Value << rhs.Name(); - else - out << Key << "name" << Value << ('-' + rhs.Name()); + Emitter& operator << (Emitter& out, const loot::PluginDirtyInfo& rhs); - out << Key << "condition" << Value << rhs.Condition() - << EndMap; - } + Emitter& operator << (Emitter& out, const loot::Game& rhs); - return out; - } + Emitter& operator << (Emitter& out, const loot::MessageContent& rhs); - inline Emitter& operator << (Emitter& out, const boss::Plugin& rhs) { - if (!rhs.HasNameOnly()) { + Emitter& operator << (Emitter& out, const loot::Message& rhs); - out << BeginMap - << Key << "name" << Value << rhs.Name(); + Emitter& operator << (Emitter& out, const loot::File& rhs); - if (rhs.IsPriorityExplicit()) - out << Key << "priority" << Value << rhs.Priority(); + Emitter& operator << (Emitter& out, const loot::Tag& rhs); - if (!rhs.Enabled()) - out << Key << "enabled" << Value << rhs.Enabled(); - - if (!rhs.LoadAfter().empty()) - out << Key << "after" << Value << rhs.LoadAfter(); - - if (!rhs.Reqs().empty()) - out << Key << "req" << Value << rhs.Reqs(); - - if (!rhs.Incs().empty()) - out << Key << "inc" << Value << rhs.Incs(); - - if (!rhs.Messages().empty()) - out << Key << "msg" << Value << rhs.Messages(); - - if (!rhs.Tags().empty()) - out << Key << "tag" << Value << rhs.Tags(); - - if (!rhs.DirtyInfo().empty()) - out << Key << "dirty" << Value << rhs.DirtyInfo(); - - out << EndMap; - } - - return out; - } + Emitter& operator << (Emitter& out, const loot::Plugin& rhs); } #endif diff --git a/src/backend/git.cpp b/src/backend/git.cpp new file mode 100644 index 00000000..2c2b15d9 --- /dev/null +++ b/src/backend/git.cpp @@ -0,0 +1,478 @@ +/* LOOT + + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. + + Copyright (C) 2012-2014 WrinklyNinja + + This file is part of LOOT. + + LOOT 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. + + LOOT 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 LOOT. If not, see + . +*/ + +#include "error.h" +#include "parsers.h" +#include "streams.h" +#include "helpers.h" +#include "game.h" + +#include +#include +#include + +#include + +using namespace std; + +namespace fs = boost::filesystem; +namespace lc = boost::locale; + +namespace loot { + + struct git_handler { + public: + git_handler() : repo(nullptr), remote(nullptr), cfg(nullptr), obj(nullptr), commit(nullptr), ref(nullptr), ref2(nullptr), sig(nullptr), blob(nullptr), merge_head(nullptr), tree(nullptr), diff(nullptr) {} + + ~git_handler() { + git_commit_free(commit); + git_object_free(obj); + git_config_free(cfg); + git_remote_free(remote); + git_repository_free(repo); + git_reference_free(ref); + git_reference_free(ref2); + git_signature_free(sig); + git_blob_free(blob); + git_merge_head_free(merge_head); + git_tree_free(tree); + git_diff_free(diff); + } + + void call(int error_code) { + if (!error_code) + return; + + const git_error * last_error = giterr_last(); + std::string error_message; + if (last_error == nullptr) + error_message = to_string(error_code) + "."; + else + error_message = to_string(error_code) + "; " + last_error->message; + giterr_clear(); + + if (ui_message.empty()) + ui_message = (boost::format(lc::translate("Git operation failed. Error: %1%")) % error_message).str(); + + BOOST_LOG_TRIVIAL(error) << "Git operation failed. Error: " << error_message; + throw loot::error(loot::error::git_error, ui_message); + } + + git_repository * repo; + git_remote * remote; + git_config * cfg; + git_object * obj; + git_commit * commit; + git_reference * ref; + git_reference * ref2; + git_signature * sig; + git_blob * blob; + git_merge_head * merge_head; + git_tree * tree; + git_diff * diff; + + + std::string ui_message; + }; + + bool isRepository(const fs::path& path) { + return git_repository_open_ext(NULL, path.string().c_str(), GIT_REPOSITORY_OPEN_NO_SEARCH, NULL) == 0; + } + + // Removes the read-only flag from some files in git repositories created by libgit2. + void FixRepoPermissions(const fs::path& path) { + BOOST_LOG_TRIVIAL(trace) << "Recursively setting write permission on directory: " << path; + for (fs::recursive_directory_iterator it(path); it != fs::recursive_directory_iterator(); ++it) { + BOOST_LOG_TRIVIAL(trace) << "Setting write permission for: " << it->path(); + fs::permissions(it->path(), fs::add_perms | fs::owner_write); + } + } + + int diffFileCallback(const git_diff_delta *delta, float progress, void * payload) { + BOOST_LOG_TRIVIAL(trace) << "Checking diff for: " << delta->old_file.path; + if (strcmp(delta->old_file.path, "masterlist.yaml") == 0) { + BOOST_LOG_TRIVIAL(warning) << "Edited masterlist found."; + *(bool*)payload = true; + } + + return 0; + } + + void Masterlist::GetGitInfo(const boost::filesystem::path& path) { + if (!isRepository(path.parent_path())) { + revision = "Unknown: Git repository missing"; + date = "Unknown: Git repository missing"; + } + else if (!fs::exists(path)) { + revision = "N/A: No masterlist present"; + date = "N/A: No masterlist present"; + } + else { + // Perform a git diff, then iterate the deltas to see if one exists for masterlist.yaml. + git_handler git; + git.ui_message = "An error occurred while trying to read the local masterlist's version. If this error happens again, try deleting the \".git\" folder in " + path.parent_path().string() + "."; + BOOST_LOG_TRIVIAL(debug) << "Existing repository found, attempting to open it."; + git.call(git_repository_open(&git.repo, path.parent_path().string().c_str())); + + BOOST_LOG_TRIVIAL(trace) << "Getting the tree for the HEAD revision."; + git.call(git_revparse_single(&git.obj, git.repo, "HEAD^{tree}")); + git.call(git_tree_lookup(&git.tree, git.repo, git_object_id(git.obj))); + + BOOST_LOG_TRIVIAL(trace) << "Performing git diff."; + git.call(git_diff_tree_to_workdir_with_index(&git.diff, git.repo, git.tree, NULL)); + + BOOST_LOG_TRIVIAL(trace) << "Iterating over git diff deltas."; + bool isMasterlistDifferent = false; + git.call(git_diff_foreach(git.diff, &diffFileCallback, NULL, NULL, &isMasterlistDifferent)); + + //Need to get the HEAD object, because the individual file has a different SHA. + git_object_free(git.obj); + git.obj = nullptr; //Just to be safe. + BOOST_LOG_TRIVIAL(info) << "Getting the Git object for the tree at HEAD."; + git.call(git_revparse_single(&git.obj, git.repo, "HEAD")); + + BOOST_LOG_TRIVIAL(trace) << "Getting the Git object ID."; + const git_oid * oid = git_object_id(git.obj); + + BOOST_LOG_TRIVIAL(trace) << "Generating hex string for Git object ID."; + char sha1[10]; + git_oid_tostr(sha1, 10, oid); + revision = sha1; + + BOOST_LOG_TRIVIAL(trace) << "Getting date for Git object ID."; + git.call(git_commit_lookup(&git.commit, git.repo, oid)); + git_time_t time = git_commit_time(git.commit); + boost::locale::date_time dateTime(time); + stringstream out; + out << boost::locale::as::ftime("%Y-%m-%d") << dateTime; + date = out.str(); + + if (isMasterlistDifferent) { + revision += " (edited)"; + date += " (edited)"; + } + } + } + + bool Masterlist::Update(Game& game, const unsigned int language) { + git_handler git; + fs::path repo_path = game.MasterlistPath().parent_path(); + string repo_branch = game.RepoBranch(); + + // First initialise some stuff that isn't specific to a repository. + BOOST_LOG_TRIVIAL(debug) << "Creating a reflog signature to use."; + // Create a reflog signature for any changes. + git.call(git_signature_new(&git.sig, "LOOT", "loot@placeholder.net", 0, 0)); + + BOOST_LOG_TRIVIAL(debug) << "Setting up checkout options."; + char * paths[] = { "masterlist.yaml" }; + git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT; + checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE; + checkout_opts.paths.strings = paths; + checkout_opts.paths.count = 1; + + // Now try to access the repository if it exists, or clone one if it doesn't. + BOOST_LOG_TRIVIAL(trace) << "Attempting to open the Git repository at: " << repo_path; + if (!isRepository(repo_path)) { + git.ui_message = "An error occurred while trying to clone the remote masterlist repository."; + // Clone the remote repository. + BOOST_LOG_TRIVIAL(info) << "Repository doesn't exist, cloning the remote repository."; + + bool wasEmpty = true; + fs::path temp_path = repo_path.string() + ".temp"; + if (!fs::is_empty(repo_path)) { + // Clear any read-only flags first. + FixRepoPermissions(repo_path); + // Now, libgit2 doesn't support cloning into non-empty folders. Rename the folder + // temporarily, and move its contents back in afterwards, skipping any that then conflict. + BOOST_LOG_TRIVIAL(trace) << "Repo path not empty, renaming folder."; + // If the temp path already exists, it needs to be deleted. + if (fs::exists(temp_path)) { + FixRepoPermissions(temp_path); + fs::remove_all(temp_path); + } + // There's no point moving the .git folder, so delete that. + fs::remove_all(repo_path / ".git"); + // Now move to temp path. + fs::rename(repo_path, temp_path); + // Recreate the game folder so that we don't inadvertently cause any other errors (everything past LOOT init assumes it exists). + fs::create_directory(repo_path); + wasEmpty = false; + } + + //First set up clone options. + + git_clone_options clone_options = GIT_CLONE_OPTIONS_INIT; + clone_options.checkout_opts = checkout_opts; + clone_options.bare = 0; + clone_options.checkout_branch = repo_branch.c_str(); + clone_options.signature = git.sig; +#ifndef _WIN32 + //OpenSSL doesn't seem to like GitHub's certificate. + clone_options.ignore_cert_errors = 1; +#endif + + //Now perform the clone. + git.call(git_clone(&git.repo, game.RepoURL().c_str(), repo_path.string().c_str(), &clone_options)); + + if (fs::exists(temp_path)) { + //Move contents back in. + BOOST_LOG_TRIVIAL(trace) << "Repo path wasn't empty, moving previous files back in."; + for (fs::directory_iterator it(temp_path); it != fs::directory_iterator(); ++it) { + if (!fs::exists(repo_path / it->path().filename())) { + //No conflict, OK to move back in. + fs::rename(it->path(), repo_path / it->path().filename()); + } + } + //Delete temporary folder. + FixRepoPermissions(temp_path); + fs::remove_all(temp_path); + } + } + else { + // Repository exists: check settings are correct, then pull updates. + git.ui_message = "An error occurred while trying to access the local masterlist repository. If this error happens again, try deleting the \".git\" folder in \"%LOCALAPPDATA%\\LOOT\\" + game.FolderName() + "\"."; + + // Open the repository. + BOOST_LOG_TRIVIAL(info) << "Existing repository found, attempting to open it."; + git.call(git_repository_open(&git.repo, repo_path.string().c_str())); + + // Check that the repository's remote settings match LOOT's. + BOOST_LOG_TRIVIAL(info) << "Checking to see if remote URL matches URL in settings."; + git.call(git_remote_load(&git.remote, git.repo, "origin")); + const char * url = git_remote_url(git.remote); + + BOOST_LOG_TRIVIAL(info) << "Remote URL given: " << game.RepoURL(); + BOOST_LOG_TRIVIAL(info) << "Remote URL in repository settings: " << url; + if (url != game.RepoURL()) { + BOOST_LOG_TRIVIAL(info) << "URLs do not match, setting repository URL to URL in settings."; + // The URLs don't match. Change the remote URL to match the one LOOT has. + git.call(git_remote_set_url(git.remote, game.RepoURL().c_str())); + + // Now save change. + git.call(git_remote_save(git.remote)); + } + + // Now fetch updates from the remote. + BOOST_LOG_TRIVIAL(trace) << "Fetching updates from remote."; + git.ui_message = "An error occurred while trying to update the masterlist. This could be due to a server-side error. Try again in a few minutes."; + + git.call(git_remote_fetch(git.remote, git.sig, nullptr)); + + // Print some stats on what was fetched either during update or clone. + const git_transfer_progress * stats = git_remote_stats(git.remote); + BOOST_LOG_TRIVIAL(info) << "Received " << stats->indexed_objects << " of " << stats->total_objects << " objects in " << stats->received_bytes << " bytes."; + + // Check that a branch with the correct name exists. + git.ui_message = "An error occurred while trying to access the local masterlist repository. If this error happens again, try deleting the \".git\" folder in \"%LOCALAPPDATA%\\LOOT\\" + game.FolderName() + "\"."; + int ret = git_branch_lookup(&git.ref, git.repo, repo_branch.c_str(), GIT_BRANCH_LOCAL); + if (ret == GIT_ENOTFOUND) { + // Branch doesn't exist. Create a new branch using the remote branch's latest commit. + + BOOST_LOG_TRIVIAL(trace) << "Looking up commit referred to by the remote branch \"" << repo_branch << "\"."; + git.call(git_revparse_single(&git.obj, git.repo, (string("origin/") + repo_branch).c_str())); + const git_oid * commit_id = git_object_id(git.obj); + + BOOST_LOG_TRIVIAL(trace) << "Creating the new branch."; + + // Create a branch. + git.call(git_commit_lookup(&git.commit, git.repo, commit_id)); + git.call(git_branch_create(&git.ref, git.repo, repo_branch.c_str(), git.commit, 0, git.sig, NULL)); + + // Set upstream. Don't really know if this is necessary or not. + git.call(git_branch_set_upstream(git.ref, (string("origin/") + repo_branch).c_str())); + + BOOST_LOG_TRIVIAL(trace) << "Setting the upstream for the new branch."; + + // Free tree and commit pointers. Reference pointer is still used below. + git_object_free(git.obj); + git_commit_free(git.commit); + git.commit = nullptr; + git.obj = nullptr; + + BOOST_LOG_TRIVIAL(trace) << "Done creating the new branch."; + } + else if (ret != 0) + git.call(ret); // Handle other errors. + + // Check if HEAD points to the desired branch and set it to if not. + if (!git_branch_is_head(git.ref)) { + BOOST_LOG_TRIVIAL(trace) << "Setting HEAD to follow branch: " << repo_branch; + git.call(git_repository_set_head(git.repo, (string("refs/heads/") + repo_branch).c_str(), git.sig, (string("Updated HEAD to ") + repo_branch).c_str())); + } + + if (ret == 0) { + /* The branch did exist, and is now pointed at by HEAD. + Need to merge the remote branch into it. Just do a fast-forward merge because + that's all that should be necessary as the local repo shouldn't get changed by + the user. + */ + + BOOST_LOG_TRIVIAL(trace) << "Checking that local and remote branches can be merged by fast-forward."; + git_merge_analysis_t analysis; + git_merge_preference_t pref; + git.call(git_reference_lookup(&git.ref2, git.repo, (string("refs/remotes/origin/") + repo_branch).c_str())); + git.call(git_merge_head_from_ref(&git.merge_head, git.repo, git.ref2)); + git.call(git_merge_analysis(&analysis, &pref, git.repo, (const git_merge_head **)&git.merge_head, 1)); + + if ((analysis & GIT_MERGE_ANALYSIS_FASTFORWARD) != 0) { + BOOST_LOG_TRIVIAL(trace) << "Local branch can be fast-forwarded to remote branch."; + // The remote branch reference points to a particular commit. We just want to + // update the local branch reference to point to the same commit. + + // Get the commit object ID. + git.call(git_reference_peel(&git.obj, git.ref2, GIT_OBJ_COMMIT)); + const git_oid * commit_id = git_object_id(git.obj); + git_reference_free(git.ref2); + git.ref2 = nullptr; + git_object_free(git.obj); + git.obj = nullptr; + + // Set the reference target. + git.call(git_reference_set_target(&git.ref2, git.ref, commit_id, git.sig, "Setting branch reference.")); + + git_reference_free(git.ref2); + git.ref2 = nullptr; + } + else if ((analysis & GIT_MERGE_ANALYSIS_UP_TO_DATE) != 0) { + // No update necessary, so exit early to skip unnecessary masterlist parsing. + BOOST_LOG_TRIVIAL(trace) << "Local branch is up-to-date with remote branch."; + + BOOST_LOG_TRIVIAL(trace) << "Performing a Git checkout of HEAD."; + git.call(git_checkout_head(git.repo, &checkout_opts)); + + return false; + } + else { + // The local repository can't be easily merged. It's best just to delete and re-clone it. + FixRepoPermissions(repo_path / ".git"); + fs::remove_all(repo_path / ".git"); + return this->Update(game, language); + //throw error(error::git_error, "Local repository has been edited, an automatic fast-forward merge update is not possible."); + } + + } + + // Free branch pointer. + git_reference_free(git.ref); + git.ref = nullptr; + + BOOST_LOG_TRIVIAL(trace) << "Performing a Git checkout of HEAD."; + git.call(git_checkout_head(git.repo, &checkout_opts)); + + } + + // Now whether the repository was cloned or updated, the working directory contains + // the latest masterlist. Try parsing it: on failure, detach the HEAD back one commit + // and try again. + + bool parsingFailed = false; + std::string parsingError; + git.ui_message = "An error occurred while trying to read information on the updated masterlist. If this error happens again, try deleting the \".git\" folder in \"%LOCALAPPDATA%\\LOOT\\" + game.FolderName() + "\"."; + do { + // Get some descriptive info about what was checked out. + + BOOST_LOG_TRIVIAL(trace) << "Getting the Git object for HEAD."; + git.call(git_repository_head(&git.ref, git.repo)); + git.call(git_reference_peel(&git.obj, git.ref, GIT_OBJ_COMMIT)); + const git_oid * oid = git_object_id(git.obj); + + BOOST_LOG_TRIVIAL(trace) << "Generating hex string for the Git object."; + // git_object_short_id seems to be unstable, or I'm just not freeing memory right somewhere, I can't tell. + /*git_buf buffer; + git.call(git_object_short_id(&buffer, git.obj)); + revision = string(buffer.ptr, buffer.size); + git_buf_free(&buffer);*/ + char sha1[10]; + git_oid_tostr(sha1, 10, oid); + revision = sha1; + + BOOST_LOG_TRIVIAL(trace) << "Getting date for Git object ID."; + git.call(git_commit_lookup(&git.commit, git.repo, oid)); + git_time_t time = git_commit_time(git.commit); + // Now convert into a nice text format. + boost::locale::date_time dateTime(time); + stringstream out; + out << boost::locale::as::ftime("%Y-%m-%d") << dateTime; + date = out.str(); + + BOOST_LOG_TRIVIAL(debug) << "Set HEAD to commit (date): " << revision << " (" << date << ")."; + BOOST_LOG_TRIVIAL(trace) << "Freeing pointers."; + git_reference_free(git.ref); + git_object_free(git.obj); + git_commit_free(git.commit); + git.ref = nullptr; + git.obj = nullptr; + git.commit = nullptr; + + //Now try parsing the masterlist. + BOOST_LOG_TRIVIAL(debug) << "Testing masterlist parsing."; + try { + this->MetadataList::Load(game.MasterlistPath()); + + unordered_set tempSet; + for (auto &plugin : plugins) { + tempSet.insert(Plugin(plugin).EvalAllConditions(game, language)); + } + plugins = tempSet; + for (auto &plugin : regexPlugins) { + plugin.EvalAllConditions(game, language); + } + + for (auto &message: messages) { + message.EvalCondition(game, language); + } + + parsingFailed = false; + + } catch (std::exception& e) { + parsingFailed = true; + + //Roll back one revision if there's an error. + BOOST_LOG_TRIVIAL(error) << "Masterlist parsing failed. Masterlist revision " + string(revision) + ": " + e.what(); + + // Get an object ID for 'HEAD~1'. + git.call(git_revparse_single(&git.obj, git.repo, "HEAD~1")); + const git_oid * oid = git_object_id(git.obj); + git_object_free(git.obj); + git.obj = nullptr; + + // Detach HEAD to HEAD~1. This will roll back HEAD by one commit each time it is called. + git.call(git_repository_set_head_detached(git.repo, oid, git.sig, "Updated HEAD to HEAD~1")); + + // Checkout the new HEAD. + BOOST_LOG_TRIVIAL(trace) << "Performing a Git checkout of HEAD."; + git.call(git_checkout_head(git.repo, &checkout_opts)); + + if (parsingError.empty()) + parsingError = boost::locale::translate("Masterlist revision").str() + " " + string(revision) + ": " + e.what() + ". " + boost::locale::translate("Rolled back to the previous revision.").str(); + } + } while (parsingFailed); + + if (!parsingError.empty()) + throw error(error::ok, parsingError); //Throw an OK because the process still completed in a successful state. + + return true; + } +} diff --git a/src/backend/globals.cpp b/src/backend/globals.cpp index cad899fb..6c5b35f8 100644 --- a/src/backend/globals.cpp +++ b/src/backend/globals.cpp @@ -1,67 +1,42 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2012-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ #include "globals.h" #include "helpers.h" -namespace boss { - - //Game values. - const unsigned int g_game_autodetect = 0; - const unsigned int g_game_tes4 = 1; - const unsigned int g_game_tes5 = 2; - const unsigned int g_game_fo3 = 3; - const unsigned int g_game_fonv = 4; - - //Message types. - const unsigned int g_message_say = 0; - const unsigned int g_message_warn = 1; - const unsigned int g_message_error = 2; - const unsigned int g_message_tag = 3; - - //Languages. - const unsigned int g_lang_any = 0; - const unsigned int g_lang_english = 1; - const unsigned int g_lang_spanish = 2; - const unsigned int g_lang_russian = 3; - const unsigned int g_lang_french = 4; - const unsigned int g_lang_chinese = 5; - const unsigned int g_lang_polish = 6; - const unsigned int g_lang_brazilian_portuguese = 7; - const unsigned int g_lang_danish = 8; +namespace loot { //Version numbers. - const unsigned int g_version_major = 3; - const unsigned int g_version_minor = 0; + const unsigned int g_version_major = 0; + const unsigned int g_version_minor = 7; const unsigned int g_version_patch = 0; //Common paths. - const boost::filesystem::path g_path_readme = boost::filesystem::current_path() / "docs" / "BOSS Readme.html"; - const boost::filesystem::path g_path_css = boost::filesystem::current_path() / "resources" / "style.css"; - const boost::filesystem::path g_path_js = boost::filesystem::current_path() / "resources" / "script.js"; - const boost::filesystem::path g_path_polyfill = boost::filesystem::current_path() / "resources" / "polyfill.js"; - const boost::filesystem::path g_path_l10n = boost::filesystem::current_path() / "resources" / "l10n"; - const boost::filesystem::path g_path_local = GetLocalAppDataPath() / "BOSS"; - const boost::filesystem::path g_path_settings = g_path_local / "settings.yaml"; - const boost::filesystem::path g_path_log = g_path_local / "BOSSDebugLog.txt"; + const boost::filesystem::path g_path_readme = boost::filesystem::current_path() / "docs" / "LOOT Readme.html"; + const boost::filesystem::path g_path_report = boost::filesystem::current_path() / "resources" / "report" / "report.html"; + const boost::filesystem::path g_path_l10n = boost::filesystem::current_path() / "resources" / "l10n"; + const boost::filesystem::path g_path_local = GetLocalAppDataPath() / "LOOT"; + const boost::filesystem::path g_path_settings = g_path_local / "settings.yaml"; + const boost::filesystem::path g_path_log = g_path_local / "LOOTDebugLog.txt"; } diff --git a/src/backend/globals.h b/src/backend/globals.h index 7ce5ee7f..ac39d0a4 100644 --- a/src/backend/globals.h +++ b/src/backend/globals.h @@ -1,55 +1,32 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2012-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ -#ifndef __BOSS_GLOBALS__ -#define __BOSS_GLOBALS__ +#ifndef __LOOT_GLOBALS__ +#define __LOOT_GLOBALS__ #include -namespace boss { - - //Game values. - extern const unsigned int g_game_autodetect; - extern const unsigned int g_game_tes4; - extern const unsigned int g_game_tes5; - extern const unsigned int g_game_fo3; - extern const unsigned int g_game_fonv; - - //Message types. - extern const unsigned int g_message_say; - extern const unsigned int g_message_warn; - extern const unsigned int g_message_error; - extern const unsigned int g_message_tag; - - //Languages - extern const unsigned int g_lang_any; - extern const unsigned int g_lang_english; - extern const unsigned int g_lang_spanish; - extern const unsigned int g_lang_russian; - extern const unsigned int g_lang_french; - extern const unsigned int g_lang_chinese; - extern const unsigned int g_lang_polish; - extern const unsigned int g_lang_brazilian_portuguese; - extern const unsigned int g_lang_danish; +namespace loot { //Version numbers. extern const unsigned int g_version_major; @@ -57,14 +34,12 @@ namespace boss { extern const unsigned int g_version_patch; //Common paths. - extern const boost::filesystem::path g_path_local; extern const boost::filesystem::path g_path_readme; - extern const boost::filesystem::path g_path_settings; - extern const boost::filesystem::path g_path_css; - extern const boost::filesystem::path g_path_js; - extern const boost::filesystem::path g_path_polyfill; - extern const boost::filesystem::path g_path_log; + extern const boost::filesystem::path g_path_report; extern const boost::filesystem::path g_path_l10n; + extern const boost::filesystem::path g_path_local; + extern const boost::filesystem::path g_path_settings; + extern const boost::filesystem::path g_path_log; } #endif diff --git a/src/backend/graph.cpp b/src/backend/graph.cpp index 3a2ac0b3..c9ef9492 100644 --- a/src/backend/graph.cpp +++ b/src/backend/graph.cpp @@ -1,28 +1,33 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2012-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ +#include "error.h" #include "graph.h" #include "streams.h" +#include "helpers.h" + +#include #include #include @@ -32,19 +37,47 @@ using namespace std; -namespace lc = boost::locale; +namespace loot { -namespace boss { + struct cycle_detector : public boost::dfs_visitor<> { + cycle_detector() {} - cycle_detector::cycle_detector() {} + std::list trail; - void cycle_detector::back_edge(edge_t e, const PluginGraph& g) { - vertex_t vSource = boost::source(e, g); - vertex_t vTarget = boost::target(e, g); + inline void tree_edge(edge_t e, const PluginGraph& g) { + vertex_t source = boost::source(e, g); - BOOST_LOG_TRIVIAL(error) << "Cyclic interaction detected between plugins \"" << g[vSource].Name() << "\" and \"" << g[vTarget].Name() << "\"."; - throw boss::error(boss::error::sorting_error, (boost::format(lc::translate("Cyclic interaction detected between plugins \"%1%\" and \"%2%\".")) % g[vSource].Name() % g[vTarget].Name()).str()); - } + string name = g[source].Name(); + + // Check if the plugin already exists in the recorded trail. + auto it = find(trail.begin(), trail.end(), name); + + if (it != trail.end()) { + // Erase everything from this position onwards, as it doesn't + // contribute to a forward-cycle. + trail.erase(it, trail.end()); + } + + trail.push_back(name); + } + + inline void back_edge(edge_t e, const PluginGraph& g) { + vertex_t vSource = boost::source(e, g); + vertex_t vTarget = boost::target(e, g); + + trail.push_back(g[vSource].Name()); + list::iterator it = find(trail.begin(), trail.end(), g[vTarget].Name()); + string backCycle; + for (list::iterator endIt = trail.end(); it != endIt; ++it) { + backCycle += *it + ", "; + } + backCycle.erase(backCycle.length() - 2); + + BOOST_LOG_TRIVIAL(error) << "Cyclic interaction detected between plugins \"" << g[vSource].Name() << "\" and \"" << g[vTarget].Name() << "\". Back cycle: " << backCycle; + + throw loot::error(loot::error::sorting_error, (boost::format(boost::locale::translate("Cyclic interaction detected between plugins \"%1%\" and \"%2%\". Back cycle: %3%")) % g[vSource].Name() % g[vTarget].Name() % backCycle).str()); + } + }; bool GetVertexByName(const PluginGraph& graph, const std::string& name, vertex_t& vertex) { vertex_it vit, vit_end; @@ -60,32 +93,7 @@ namespace boss { return false; } - void Sort(const PluginGraph& graph, std::list& plugins) { - - //Topological sort requires an index map, which std::list-based VertexList graphs don't have, so one needs to be built separately. - - map index_map; - boost::associative_property_map< map > v_index_map(index_map); - size_t i=0; - BGL_FORALL_VERTICES(v, graph, PluginGraph) - put(v_index_map, v, i++); - - //Now we can sort. - - std::list sortedVertices; - boost::topological_sort(graph, std::front_inserter(sortedVertices), boost::vertex_index_map(v_index_map)); - - BOOST_LOG_TRIVIAL(info) << "Calculated order: "; - list tempPlugins; - for (std::list::iterator it = sortedVertices.begin(), endit = sortedVertices.end(); it != endit; ++it) { - BOOST_LOG_TRIVIAL(info) << '\t' << graph[*it].Name(); - tempPlugins.push_back(graph[*it]); - } - plugins.swap(tempPlugins); - } - void CheckForCycles(const PluginGraph& graph) { - //Depth-first search requires an index map, which std::list-based VertexList graphs don't have, so one needs to be built separately. map index_map; @@ -94,21 +102,41 @@ namespace boss { BGL_FORALL_VERTICES(v, graph, PluginGraph) put(v_index_map, v, i++); - boss::cycle_detector vis; + loot::cycle_detector vis; boost::depth_first_search(graph, visitor(vis).vertex_index_map(v_index_map)); } + bool EdgeCreatesCycle(PluginGraph& graph, vertex_t u, vertex_t v) { + //A cycle is created when adding the edge (u,v) if there already exists a path from v to u, so check for that using a breadth-first search. + + //Breadth-first search requires an index map, which std::list-based VertexList graphs don't have, so one needs to be built separately. + + map index_map; + boost::associative_property_map< map > v_index_map(index_map); + size_t i = 0; + BGL_FORALL_VERTICES(v, graph, PluginGraph) + put(v_index_map, v, i++); + + map predecessor_map; + boost::associative_property_map< map > v_predecessor_map(predecessor_map); + + boost::breadth_first_search(graph, v, visitor(boost::make_bfs_visitor(boost::record_predecessors(v_predecessor_map, boost::on_tree_edge()))).vertex_index_map(v_index_map)); + + return predecessor_map.find(u) != predecessor_map.end(); + } + void AddSpecificEdges(PluginGraph& graph) { //Add edges for all relationships that aren't overlaps or priority differences. - boss::vertex_it vit, vitend; + loot::vertex_it vit, vitend; for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) { vertex_t parentVertex; + int parentPriority = graph[*vit].Priority(); BOOST_LOG_TRIVIAL(trace) << "Adding specific edges to vertex for \"" << graph[*vit].Name() << "\"."; BOOST_LOG_TRIVIAL(trace) << "Adding edges for master flag differences."; - boss::vertex_it vit2 = vit; + loot::vertex_it vit2 = vit; ++vit2; while (vit2 != vitend) { @@ -137,64 +165,94 @@ namespace boss { BOOST_LOG_TRIVIAL(trace) << "Adding in-edges for masters."; vector strVec(graph[*vit].Masters()); - for (vector::const_iterator it=strVec.begin(), itend=strVec.end(); it != itend; ++it) { - if (boss::GetVertexByName(graph, *it, parentVertex) && + for (const auto &master: strVec) { + if (loot::GetVertexByName(graph, master, parentVertex) && !boost::edge(parentVertex, *vit, graph).second) { BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << graph[parentVertex].Name() << "\" to \"" << graph[*vit].Name() << "\"."; boost::add_edge(parentVertex, *vit, graph); + + int priority = graph[parentVertex].Priority(); + if (priority > parentPriority) { + parentPriority = priority; + } } } BOOST_LOG_TRIVIAL(trace) << "Adding in-edges for requirements."; set fileset(graph[*vit].Reqs()); - for (set::const_iterator it=fileset.begin(), itend=fileset.end(); it != itend; ++it) { - if (boss::IsPlugin(it->Name()) && - boss::GetVertexByName(graph, it->Name(), parentVertex) && + for (const auto &file: fileset) { + if (loot::IsPlugin(file.Name()) && + loot::GetVertexByName(graph, file.Name(), parentVertex) && !boost::edge(parentVertex, *vit, graph).second) { BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << graph[parentVertex].Name() << "\" to \"" << graph[*vit].Name() << "\"."; boost::add_edge(parentVertex, *vit, graph); + + int priority = graph[parentVertex].Priority(); + if (priority > parentPriority) { + parentPriority = priority; + } } } BOOST_LOG_TRIVIAL(trace) << "Adding in-edges for 'load after's."; fileset = graph[*vit].LoadAfter(); - for (set::const_iterator it=fileset.begin(), itend=fileset.end(); it != itend; ++it) { - if (boss::IsPlugin(it->Name()) && - boss::GetVertexByName(graph, it->Name(), parentVertex) && + for (const auto &file : fileset) { + if (loot::IsPlugin(file.Name()) && + loot::GetVertexByName(graph, file.Name(), parentVertex) && !boost::edge(parentVertex, *vit, graph).second) { BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << graph[parentVertex].Name() << "\" to \"" << graph[*vit].Name() << "\"."; boost::add_edge(parentVertex, *vit, graph); + + int priority = graph[parentVertex].Priority(); + if (priority > parentPriority) { + parentPriority = priority; + } } } + + //parentPriority is now the highest priority value of any plugin that the current plugin needs to load after. + //Set the current plugin's priority to parentPlugin. + if (parentPriority > 0 && graph[*vit].Priority() < parentPriority) { + BOOST_LOG_TRIVIAL(trace) << "Overriding priority for " << graph[*vit].Name() << " from " << graph[*vit].Priority() << " to " << parentPriority; + graph[*vit].Priority(parentPriority); + } + } } void AddPriorityEdges(PluginGraph& graph) { - boss::vertex_it vit, vitend; + loot::vertex_it vit, vitend; for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) { BOOST_LOG_TRIVIAL(trace) << "Adding priority difference edges to vertex for \"" << graph[*vit].Name() << "\"."; - //Priority differences should only be taken account between plugins that conflict. + //Priority differences should only be taken account between plugins that conflict. //However, an exception is made for plugins that contain only a header record, //as they are for loading BSAs, and in Skyrim that means the resources they load can //be affected by load order. - boss::vertex_it vit2, vitend2; + loot::vertex_it vit2, vitend2; for (boost::tie(vit2, vitend2) = boost::vertices(graph); vit2 != vitend2; ++vit2) { - if (graph[*vit].Priority() == graph[*vit2].Priority() || (!graph[*vit].FormIDs().empty() && !graph[*vit2].FormIDs().empty() && !graph[*vit].DoFormIDsOverlap(graph[*vit2]))) { + if (graph[*vit].Priority() == graph[*vit2].Priority() + || (abs(graph[*vit].Priority()) < max_priority && abs(graph[*vit2].Priority()) < max_priority + && !graph[*vit].FormIDs().empty() && !graph[*vit2].FormIDs().empty() && !graph[*vit].DoFormIDsOverlap(graph[*vit2]) + ) + ) { continue; } BOOST_LOG_TRIVIAL(trace) << "Checking priority difference between \"" << graph[*vit].Name() << "\" and \"" << graph[*vit2].Name() << "\"."; vertex_t vertex, parentVertex; - if (graph[*vit].Priority() < graph[*vit2].Priority()) { + //Modulo operator is not consistently defined for negative numbers except in C++11, so use function. + int p1 = modulo(graph[*vit].Priority(), max_priority); + int p2 = modulo(graph[*vit2].Priority(), max_priority); + if (p1 < p2) { parentVertex = *vit; vertex = *vit2; } else { @@ -214,7 +272,7 @@ namespace boss { } void AddOverlapEdges(PluginGraph& graph) { - boss::vertex_it vit, vitend; + loot::vertex_it vit, vitend; for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) { @@ -225,14 +283,12 @@ namespace boss { continue; } - boss::vertex_it vit2, vitend2; + loot::vertex_it vit2, vitend2; for (boost::tie(vit2, vitend2) = boost::vertices(graph); vit2 != vitend2; ++vit2) { if (vit == vit2 || boost::edge(*vit, *vit2, graph).second || boost::edge(*vit2, *vit, graph).second) //Vertices are the same or are already linked. continue; - BOOST_LOG_TRIVIAL(trace) << "Checking edge validity between \"" << graph[*vit].Name() << "\" and \"" << graph[*vit2].Name() << "\"."; - if (graph[*vit].DoFormIDsOverlap(graph[*vit2])) { vertex_t vertex, parentVertex; if (graph[*vit].NumOverrideFormIDs() > graph[*vit2].NumOverrideFormIDs()) { @@ -252,6 +308,7 @@ namespace boss { vertex = *vit; } + BOOST_LOG_TRIVIAL(trace) << "Checking edge validity between \"" << graph[*vit].Name() << "\" and \"" << graph[*vit2].Name() << "\"."; if (!EdgeCreatesCycle(graph, parentVertex, vertex)) { //No edge going the other way, OK to add this edge. BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << graph[parentVertex].Name() << "\" to \"" << graph[vertex].Name() << "\"."; @@ -263,22 +320,41 @@ namespace boss { } } - bool EdgeCreatesCycle(PluginGraph& graph, vertex_t u, vertex_t v) { - //A cycle is created when adding the edge (u,v) if there already exists a path from v to u, so check for that using a breadth-first search. + std::list Sort(PluginGraph& graph) { - //Breadth-first search requires an index map, which std::list-based VertexList graphs don't have, so one needs to be built separately. + //Now add the interactions between plugins to the graph as edges. + BOOST_LOG_TRIVIAL(info) << "Adding edges to plugin graph."; + BOOST_LOG_TRIVIAL(debug) << "Adding non-overlap edges."; + AddSpecificEdges(graph); + BOOST_LOG_TRIVIAL(debug) << "Adding priority edges."; + AddPriorityEdges(graph); + + BOOST_LOG_TRIVIAL(debug) << "Adding overlap edges."; + AddOverlapEdges(graph); + + BOOST_LOG_TRIVIAL(info) << "Checking to see if the graph is cyclic."; + CheckForCycles(graph); + + //Topological sort requires an index map, which std::list-based VertexList graphs don't have, so one needs to be built separately. map index_map; boost::associative_property_map< map > v_index_map(index_map); size_t i=0; BGL_FORALL_VERTICES(v, graph, PluginGraph) put(v_index_map, v, i++); - map predecessor_map; - boost::associative_property_map< map > v_predecessor_map(predecessor_map); + //Now we can sort. + BOOST_LOG_TRIVIAL(info) << "Performing a topological sort."; + list sortedVertices; + boost::topological_sort(graph, std::front_inserter(sortedVertices), boost::vertex_index_map(v_index_map)); - boost::breadth_first_search(graph, v, visitor(boost::make_bfs_visitor(boost::record_predecessors(v_predecessor_map, boost::on_tree_edge()))).vertex_index_map(v_index_map)); - - return predecessor_map.find(u) != predecessor_map.end(); + // Output a plugin list using the sorted vertices. + BOOST_LOG_TRIVIAL(info) << "Calculated order: "; + list plugins; + for (const auto &vertex: sortedVertices) { + BOOST_LOG_TRIVIAL(info) << '\t' << graph[vertex].Name(); + plugins.push_back(graph[vertex]); + } + return plugins; } } diff --git a/src/backend/graph.h b/src/backend/graph.h index 00d47a75..cbd0d340 100644 --- a/src/backend/graph.h +++ b/src/backend/graph.h @@ -1,65 +1,46 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2012-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ -#ifndef __BOSS_GRAPH__ -#define __BOSS_GRAPH__ +#ifndef __LOOT_GRAPH__ +#define __LOOT_GRAPH__ #include "metadata.h" -#include "error.h" -#include #include #include #include #include -namespace boss { +namespace loot { - typedef boost::adjacency_list PluginGraph; + typedef boost::adjacency_list PluginGraph; typedef boost::graph_traits::vertex_descriptor vertex_t; typedef boost::graph_traits::vertex_iterator vertex_it; typedef boost::graph_traits::edge_descriptor edge_t; typedef boost::graph_traits::edge_iterator edge_it; - struct cycle_detector : public boost::dfs_visitor<> { - cycle_detector(); - - void back_edge(edge_t e, const PluginGraph& g); - }; - - bool GetVertexByName(const PluginGraph& graph, const std::string& name, vertex_t& vertex); - - void Sort(const PluginGraph& graph, std::list& plugins); - - void CheckForCycles(const PluginGraph& graph); - - void AddSpecificEdges(PluginGraph& graph); - - void AddPriorityEdges(PluginGraph& graph); - - void AddOverlapEdges(PluginGraph& graph); - - bool EdgeCreatesCycle(PluginGraph& graph, vertex_t u, vertex_t v); + std::list Sort(PluginGraph& graph); } #endif diff --git a/src/backend/helpers.cpp b/src/backend/helpers.cpp index 77a685ca..c5bbbd59 100644 --- a/src/backend/helpers.cpp +++ b/src/backend/helpers.cpp @@ -1,23 +1,24 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2012-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ @@ -28,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -37,13 +37,13 @@ #include #include -#include -#include -#include -#include +#include +#include +#include #include +#include -#if _WIN32 || _WIN64 +#ifdef _WIN32 # ifndef UNICODE # define UNICODE # endif @@ -52,10 +52,10 @@ # endif # include "windows.h" # include "shlobj.h" +# include "shlwapi.h" #endif -#define BUFSIZE 4096 -namespace boss { +namespace loot { using namespace std; using boost::algorithm::replace_all; using boost::algorithm::replace_first; @@ -107,26 +107,36 @@ namespace boss { /// Array used to try each of the expressions defined above using /// an iteration for each of them. - boost::regex version_checks[7] = { - boost::regex(regex1, boost::regex::icase), - boost::regex(regex2, boost::regex::icase), - boost::regex(regex3, boost::regex::icase), - boost::regex(regex4, boost::regex::icase), - boost::regex(regex5, boost::regex::icase), //This incorrectly identifies "OBSE v19" where 19 is any integer. - boost::regex(regex6, boost::regex::icase), //This is responsible for metallicow's false positive. - boost::regex(regex7, boost::regex::icase) + regex version_checks[7] = { + regex(regex1, regex::ECMAScript | regex::icase), + regex(regex2, regex::ECMAScript | regex::icase), + regex(regex3, regex::ECMAScript | regex::icase), + regex(regex4, regex::ECMAScript | regex::icase), + regex(regex5, regex::ECMAScript | regex::icase), //This incorrectly identifies "OBSE v19" where 19 is any integer. + regex(regex6, regex::ECMAScript | regex::icase), //This is responsible for metallicow's false positive. + regex(regex7, regex::ECMAScript | regex::icase) }; ////////////////////////////////////////////////////////////////////////// // Helper functions ////////////////////////////////////////////////////////////////////////// + //Calculate modulo with dividend sign preserved, matching behaviour of C++11. + int modulo(int dividend, int divisor) { + divisor = abs(divisor); + if (dividend < 0) { + return -1 * (abs(dividend) % divisor); + } + else + return dividend % divisor; + } + //Calculate the CRC of the given file for comparison purposes. uint32_t GetCrc32(const fs::path& filename) { uint32_t chksum = 0; static const size_t buffer_size = 8192; char buffer[buffer_size]; - boss::ifstream ifile(filename, ios::binary); + loot::ifstream ifile(filename, ios::binary); BOOST_LOG_TRIVIAL(trace) << "Calculating CRC for: " << filename.string(); boost::crc_32_type result; if (ifile) { @@ -139,18 +149,10 @@ namespace boss { BOOST_LOG_TRIVIAL(error) << "Unable to open \"" << filename.string() << "\" for CRC calculation."; throw error(error::path_read_fail, (boost::format(lc::translate("Unable to open \"%1%\" for CRC calculation.")) % filename.string()).str()); } - BOOST_LOG_TRIVIAL(debug) << "CRC32(\"" << filename.string() << "\"):" << chksum; + BOOST_LOG_TRIVIAL(debug) << "CRC32(\"" << filename.string() << "\"): " << std::hex << chksum << std::dec; return chksum; } - //Converts an integer to a string using BOOST's Spirit.Karma, which is apparently a lot faster than a stringstream conversion... - std::string IntToString(const int n) { - string out; - back_insert_iterator sink(out); - karma::generate(sink,karma::upper[karma::int_],n); - return out; - } - //Converts an integer to a hex string using BOOST's Spirit.Karma, which is apparently a lot faster than a stringstream conversion... std::string IntToHexString(const int n) { string out; @@ -159,22 +161,9 @@ namespace boss { return out; } - //Converts a boolean to a string representation (true/false) - std::string BoolToString(const bool b) { - if (b) - return "true"; - else - return "false"; - } - - //Check if registry subkey exists. - bool RegKeyExists(const std::string& keyStr, const std::string& subkey, const std::string& value) { - return !RegKeyStringValue(keyStr, subkey, value).empty(); - } - +#ifdef _WIN32 //Get registry subkey value string. string RegKeyStringValue(const std::string& keyStr, const std::string& subkey, const std::string& value) { -#if _WIN32 || _WIN64 HKEY hKey, key; DWORD BufferSize = 4096; wchar_t val[4096]; @@ -191,11 +180,11 @@ namespace boss { key = HKEY_USERS; BOOST_LOG_TRIVIAL(trace) << "Getting registry object for key and subkey: " << keyStr << " + " << subkey; - LONG ret = RegOpenKeyEx(key, fs::path(subkey).wstring().c_str(), 0, KEY_READ|KEY_WOW64_32KEY, &hKey); + LONG ret = RegOpenKeyEx(key, ToWinWide(subkey).c_str(), 0, KEY_READ|KEY_WOW64_32KEY, &hKey); if (ret == ERROR_SUCCESS) { BOOST_LOG_TRIVIAL(trace) << "Getting value for entry: " << value; - ret = RegQueryValueEx(hKey, fs::path(value).wstring().c_str(), NULL, NULL, (LPBYTE)&val, &BufferSize); + ret = RegQueryValueEx(hKey, ToWinWide(value).c_str(), NULL, NULL, (LPBYTE)&val, &BufferSize); RegCloseKey(hKey); if (ret == ERROR_SUCCESS) @@ -204,13 +193,11 @@ namespace boss { return ""; } else return ""; -#else - return ""; -#endif } +#endif boost::filesystem::path GetLocalAppDataPath() { -#if _WIN32 || _WIN64 +#ifdef _WIN32 HWND owner = 0; TCHAR path[MAX_PATH]; @@ -221,79 +208,111 @@ namespace boss { return fs::path(path); else return fs::path(""); -#else - return fs::path(""); #endif } //Turns an absolute filesystem path into a valid file:// URL. std::string ToFileURL(const fs::path& file) { BOOST_LOG_TRIVIAL(trace) << "Converting file path " << file << " to a URL."; - return "file:///" + file.string(); //Seems that we don't need to worry about encoding, tested with Unicode paths. + +#ifdef _WIN32 + wstring wstr(MAX_PATH, 0); + DWORD len = MAX_PATH; + UrlCreateFromPath(ToWinWide(file.string()).c_str(), &wstr[0], &len, NULL); + string str = FromWinWide(wstr.c_str()); // Passing c_str() cuts off any unused buffer. + BOOST_LOG_TRIVIAL(trace) << "Converted to: " << str; + + return str; +#endif } +#ifdef _WIN32 + //Helper to turn UTF8 strings into strings that can be used by WinAPI. + std::wstring ToWinWide(const std::string& str) { + + int len = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), 0, 0); + std::wstring wstr(len, 0); + MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), &(wstr[0]), len); + return wstr; + } + + std::string FromWinWide(const std::wstring& wstr) { + int len = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], wstr.length(), NULL, 0, NULL, NULL); + std::string str(len, 0); + WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), wstr.length(), &str[0], len, NULL, NULL); + return str; + } +#endif + Language::Language(const unsigned int code) { Construct(code); } - Language::Language(const std::string& nameOrISOCode) { - if (nameOrISOCode == Language(g_lang_english).Name() || nameOrISOCode == Language(g_lang_english).Locale()) - Construct(g_lang_english); - else if (nameOrISOCode == Language(g_lang_spanish).Name() || nameOrISOCode == Language(g_lang_spanish).Locale()) - Construct(g_lang_spanish); - else if (nameOrISOCode == Language(g_lang_russian).Name() || nameOrISOCode == Language(g_lang_russian).Locale()) - Construct(g_lang_russian); - else if (nameOrISOCode == Language(g_lang_french).Name() || nameOrISOCode == Language(g_lang_french).Locale()) - Construct(g_lang_french); - else if (nameOrISOCode == Language(g_lang_chinese).Name() || nameOrISOCode == Language(g_lang_chinese).Locale()) - Construct(g_lang_chinese); - else if (nameOrISOCode == Language(g_lang_polish).Name() || nameOrISOCode == Language(g_lang_polish).Locale()) - Construct(g_lang_polish); - else if (nameOrISOCode == Language(g_lang_brazilian_portuguese).Name() || nameOrISOCode == Language(g_lang_brazilian_portuguese).Locale()) - Construct(g_lang_brazilian_portuguese); - else if (nameOrISOCode == Language(g_lang_danish).Name() || nameOrISOCode == Language(g_lang_danish).Locale()) - Construct(g_lang_danish); + Language::Language(const std::string& nameOrCode) { + if (nameOrCode == Language(Language::english).Name() || nameOrCode == Language(Language::english).Locale()) + Construct(Language::english); + else if (nameOrCode == Language(Language::spanish).Name() || nameOrCode == Language(Language::spanish).Locale()) + Construct(Language::spanish); + else if (nameOrCode == Language(Language::russian).Name() || nameOrCode == Language(Language::russian).Locale()) + Construct(Language::russian); + else if (nameOrCode == Language(Language::french).Name() || nameOrCode == Language(Language::french).Locale()) + Construct(Language::french); + else if (nameOrCode == Language(Language::chinese).Name() || nameOrCode == Language(Language::chinese).Locale()) + Construct(Language::chinese); + else if (nameOrCode == Language(Language::polish).Name() || nameOrCode == Language(Language::polish).Locale()) + Construct(Language::polish); + else if (nameOrCode == Language(Language::brazilian_portuguese).Name() || nameOrCode == Language(Language::brazilian_portuguese).Locale()) + Construct(Language::brazilian_portuguese); + else if (nameOrCode == Language(Language::finnish).Name() || nameOrCode == Language(Language::finnish).Locale()) + Construct(Language::finnish); + else if (nameOrCode == Language(Language::german).Name() || nameOrCode == Language(Language::german).Locale()) + Construct(Language::german); + else if (nameOrCode == Language(Language::danish).Name() || nameOrCode == Language(Language::danish).Locale()) + Construct(Language::danish); else - Construct(g_lang_any); + Construct(Language::english); } void Language::Construct(const unsigned int code) { _code = code; - if (_code == g_lang_any) { - _name = boost::locale::translate("None Specified"); - _locale = "en"; - } - else if (_code == g_lang_english) { - _name = "English"; - _locale = "en"; - } - else if (_code == g_lang_spanish) { + if (_code == Language::spanish) { _name = "Español"; _locale = "es"; } - else if (_code == g_lang_russian) { + else if (_code == Language::russian) { _name = "Русский"; _locale = "ru"; } - else if (_code == g_lang_french) { + else if (_code == Language::french) { _name = "Français"; _locale = "fr"; } - else if (_code == g_lang_chinese) { + else if (_code == Language::chinese) { _name = "简体中文"; _locale = "zh_CN"; } - else if (_code == g_lang_polish) { + else if (_code == Language::polish) { _name = "Polski"; _locale = "pl"; } - else if (_code == g_lang_brazilian_portuguese) { + else if (_code == Language::brazilian_portuguese) { _name = "Português do Brasil"; _locale = "pt_BR"; } - else if (_code == g_lang_danish) { + else if (_code == Language::finnish) { + _name = "suomi"; + _locale = "fi"; + } + else if (_code == Language::german) { + _name = "Deutsch"; + _locale = "de"; + } + else if (_code == Language::danish) { _name = "Dansk"; _locale = "da"; + else { + _name = "English"; + _locale = "en"; } } @@ -319,9 +338,9 @@ namespace boss { : verString(ver) {} Version::Version(const fs::path& file) { -#if _WIN32 || _WIN64 +#ifdef _WIN32 DWORD dummy = 0; - DWORD size = GetFileVersionInfoSize(file.wstring().c_str(), &dummy); + DWORD size = GetFileVersionInfoSize(ToWinWide(file.string()).c_str(), &dummy); if (size > 0) { LPBYTE point = new BYTE[size]; @@ -329,7 +348,7 @@ namespace boss { VS_FIXEDFILEINFO *info; string ver; - GetFileVersionInfo(file.wstring().c_str(),0,size,point); + GetFileVersionInfo(ToWinWide(file.string()).c_str(),0,size,point); VerQueryValue(point,L"\\",(LPVOID *)&info,&uLen); @@ -340,7 +359,7 @@ namespace boss { delete [] point; - verString = IntToString(dwLeftMost) + '.' + IntToString(dwSecondLeft) + '.' + IntToString(dwSecondRight) + '.' + IntToString(dwRightMost); + verString = to_string(dwLeftMost) + '.' + to_string(dwSecondLeft) + '.' + to_string(dwSecondRight) + '.' + to_string(dwRightMost); } #else // ensure filename has no quote characters in it to avoid command injection attacks @@ -354,7 +373,7 @@ namespace boss { // read out the version string static const uint32_t BUFSIZE = 32; char buf[BUFSIZE]; - if (NULL != fgets(buf, BUFSIZE, fp)) { + if (nullptr != fgets(buf, BUFSIZE, fp)) { verString = string(buf); } pclose(fp); @@ -373,11 +392,11 @@ namespace boss { bool Version::operator < (Version ver) { //Version string could have a wide variety of formats. Use regex to choose specific comparison types. - boost::regex reg1("(\\d+\\.?)+"); //a.b.c.d.e.f.... where the letters are all integers, and 'a' is the shortest possible match. + regex reg1("(\\d+\\.?)+"); //a.b.c.d.e.f.... where the letters are all integers, and 'a' is the shortest possible match. - //boost::regex reg2("(\\d+\\.?)+([a-zA-Z\\-]+(\\d+\\.?)*)+"); //Matches a mix of letters and numbers - from "0.99.xx", "1.35Alpha2", "0.9.9MB8b1", "10.52EV-D", "1.62EV" to "10.0EV-D1.62EV". + //regex reg2("(\\d+\\.?)+([a-zA-Z\\-]+(\\d+\\.?)*)+"); //Matches a mix of letters and numbers - from "0.99.xx", "1.35Alpha2", "0.9.9MB8b1", "10.52EV-D", "1.62EV" to "10.0EV-D1.62EV". - if (boost::regex_match(verString, reg1) && boost::regex_match(ver.AsString(), reg1)) { + if (regex_match(verString, reg1) && regex_match(ver.AsString(), reg1)) { //First type: numbers separated by periods. If two versions have a different number of numbers, then the shorter should be padded //with zeros. An arbitrary number of numbers should be supported. istringstream parser1(verString); diff --git a/src/backend/helpers.h b/src/backend/helpers.h index cafbac92..eac0d798 100644 --- a/src/backend/helpers.h +++ b/src/backend/helpers.h @@ -1,91 +1,108 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2012-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ -#ifndef __BOSS_HELPERS__ -#define __BOSS_HELPERS__ +#ifndef __LOOT_HELPERS__ +#define __LOOT_HELPERS__ #include "metadata.h" -#include +#include #include +#include #include -#include -namespace boss { +namespace loot { /// Array used to try each of the expressions defined using /// an iteration for each of them. - extern boost::regex version_checks[7]; + extern std::regex version_checks[7]; ////////////////////////////////////////////////////////////////////////// // Helper functions ////////////////////////////////////////////////////////////////////////// + //Calculate modulo with dividend sign preserved, matching behaviour of C++11. + int modulo(int dividend, int divisor); + //Calculate the CRC of the given file for comparison purposes. uint32_t GetCrc32(const boost::filesystem::path& filename); - //Converts an integer to a string using BOOST's Spirit.Karma. Faster than a stringstream conversion. - std::string IntToString(const int n); - //Converts an integer to a hex string using BOOST's Spirit.Karma. Faster than a stringstream conversion. std::string IntToHexString(const int n); - //Converts a boolean to a string representation (true/false) - std::string BoolToString(const bool b); - - //Check if registry subkey exists. - bool RegKeyExists(const std::string& keyStr, const std::string& subkey, const std::string& value); - +#ifdef _WIN32 //Get registry subkey value string. std::string RegKeyStringValue(const std::string& keyStr, const std::string& subkey, const std::string& value); +#endif - //Get the local application data path. + //Get the local application data path, within which LOOT's data folder should be stored. boost::filesystem::path GetLocalAppDataPath(); //Turns an absolute filesystem path into a valid file:// URL. std::string ToFileURL(const boost::filesystem::path& file); +#ifdef _WIN32 + //Helper to turn UTF8 strings into strings that can be used by WinAPI. + std::wstring ToWinWide(const std::string& str); + + std::string FromWinWide(const std::wstring& wstr); +#endif + //Language class for simpler language support. class Language { public: Language(const unsigned int code); - Language(const std::string& nameOrISOCode); + Language(const std::string& nameOrCode); unsigned int Code() const; std::string Name() const; std::string Locale() const; + static const unsigned int any = 0; // This shouldn't be used as a selectable language, just for when picking any string in a message. + static const unsigned int english = 1; + static const unsigned int spanish = 2; + static const unsigned int russian = 3; + static const unsigned int french = 4; + static const unsigned int chinese = 5; + static const unsigned int polish = 6; + static const unsigned int brazilian_portuguese = 7; + static const unsigned int finnish = 8; + static const unsigned int german = 9; + static const unsigned int danish = 10; + static std::vector Names() { std::vector vec; - vec.push_back(Language(g_lang_any).Name()); - vec.push_back(Language(g_lang_english).Name()); - vec.push_back(Language(g_lang_spanish).Name()); - vec.push_back(Language(g_lang_russian).Name()); - vec.push_back(Language(g_lang_french).Name()); - vec.push_back(Language(g_lang_chinese).Name()); - vec.push_back(Language(g_lang_polish).Name()); - vec.push_back(Language(g_lang_brazilian_portuguese).Name()); - vec.push_back(Language(g_lang_danish).Name()); + vec.push_back(Language(Language::english).Name()); + vec.push_back(Language(Language::spanish).Name()); + vec.push_back(Language(Language::russian).Name()); + vec.push_back(Language(Language::french).Name()); + vec.push_back(Language(Language::chinese).Name()); + vec.push_back(Language(Language::polish).Name()); + vec.push_back(Language(Language::brazilian_portuguese).Name()); + vec.push_back(Language(Language::finnish).Name()); + vec.push_back(Language(Language::german).Name()); + vec.push_back(Language(Language::danish).Name()); return vec; } private: diff --git a/src/backend/json.h b/src/backend/json.h new file mode 100644 index 00000000..ab9fec68 --- /dev/null +++ b/src/backend/json.h @@ -0,0 +1,78 @@ +/* LOOT + +A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and +Fallout: New Vegas. + +Copyright (C) 2014 WrinklyNinja + +This file is part of LOOT. + +LOOT 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. + +LOOT 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 LOOT. If not, see +. +*/ + +#ifndef __LOOT_JSON__ +#define __LOOT_JSON__ + + +#include + +#include + +namespace loot { + + // Handy class for turning YAML objects into JSON and vice-versa. + class JSON { + public: + + inline static YAML::Node parse(std::string& json) { + return YAML::Load(json); + } + + inline static std::string stringify(const YAML::Node& yaml) { + + YAML::Emitter out; + out.SetOutputCharset(YAML::EscapeNonAscii); + out.SetStringFormat(YAML::DoubleQuoted); + out.SetBoolFormat(YAML::TrueFalseBool); + out.SetSeqFormat(YAML::Flow); + out.SetMapFormat(YAML::Flow); + + out << yaml; + + // yaml-cpp produces `!` artifacts in its output, so remove them. + std::string json = out.c_str(); + boost::replace_all(json, "! ", ""); + // There's also a bit of weirdness where there are some \x escapes and some \u escapes. + // They should all be \u, so transform them. + boost::replace_all(json, "\\x", "\\u00"); + // yaml-cpp also emits booleans as "true" and "false" strings, whereas JSON expects the same unquoted basic values. The same happens for null and numbers. + boost::replace_all(json, "\": \"true\"", "\": true"); + boost::replace_all(json, "\": \"false\"", "\": false"); + boost::replace_all(json, "\": \"null\"", "\": null"); + boost::replace_all(json, "\": ~", "\": null"); + + // Using the definition at . + // Version numbers should be kept as strings though. + std::regex numbers("\"(?!version)([^\"]+)\": \"(-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)\"", std::regex::ECMAScript); + + json = std::regex_replace(json, numbers, "\"$1\": $2"); + + return json; + } + }; +} + + +#endif \ No newline at end of file diff --git a/src/backend/legacy-parser.h b/src/backend/legacy-parser.h deleted file mode 100644 index 42ab688e..00000000 --- a/src/backend/legacy-parser.h +++ /dev/null @@ -1,826 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2012-2014 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ - -#ifndef __BOSS_LEGACY_PARSER__ -#define __BOSS_LEGACY_PARSER__ - -// This file holds the code necessary for inputting a v2 masterlist and getting a list of plugins and a list of global messages from it. - -#ifndef BOOST_SPIRIT_UNICODE -#define BOOST_SPIRIT_UNICODE -#endif - -#include "metadata.h" -#include "error.h" -#include "game.h" -#include "streams.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boss { - namespace qi = boost::spirit::qi; - namespace unicode = boost::spirit::unicode; - namespace phoenix = boost::phoenix; - - //Message types for those that will be converted, but need identifying in the interim. Must not conflict with the values for the global types. - unsigned int message_inc = 1000; - unsigned int message_req = 1001; - unsigned int message_dirty = 1002; - - - /////////////////////////////// - // Keyword structures - /////////////////////////////// - - struct masterlistMsgKey_ : qi::symbols { - masterlistMsgKey_() { - add //New Message keywords. - ("say",g_message_say) - ("tag",g_message_tag) - ("req",message_req) - ("inc", message_inc) - ("dirty",message_dirty) - ("warn",g_message_warn) - ("error",g_message_error) - ; - } - }; - - - /////////////////////////////// - //Skipper Grammar - /////////////////////////////// - - //Skipper for userlist, modlist and ini parsers. - template - class Skipper : public qi::grammar { - public: - Skipper() : Skipper::base_type(start, "skipper grammar") { - - start = - spc - | UTF8 - | CComment - | CPlusPlusComment - | iniComment - | eof; - - spc = unicode::space - qi::eol; - - UTF8 = unicode::char_("\xef") >> unicode::char_("\xbb") >> unicode::char_("\xbf"); //UTF8 BOM - - CComment = "/*" >> *(unicode::char_ - "*/") >> "*/"; - - iniComment = qi::lit("#") >> *(unicode::char_ - qi::eol); - - CPlusPlusComment = !(qi::lit("http:") | qi::lit("https:") | qi::lit("file:")) >> "//" >> *(unicode::char_ - qi::eol); - - eof = *(spc | CComment | CPlusPlusComment | qi::eol) >> qi::eoi; - } - - void SkipIniComments(const bool b) { - if (b) - iniComment = (qi::lit("#") | qi::lit(";")) >> *(unicode::char_ - qi::eol); - else - iniComment = CComment; - } - private: - qi::rule start, spc, eof, CComment, CPlusPlusComment, lineComment, iniComment, UTF8; - }; - - /////////////////////////////// - //Modlist/Masterlist Grammar - /////////////////////////////// - - //Modlist/Masterlist grammar. - template - class LegacyMasterlistGrammar : public qi::grammar(), Skipper > { - public: - LegacyMasterlistGrammar() - : LegacyMasterlistGrammar::base_type(modList, "modlist grammar") { - masterlistMsgKey_ masterlistMsgKey; - const std::list noMessages; //An empty set of messages. - globalMessageBuffer = NULL; - - modList = - *qi::eol - > - ( - listVar - | globalMessage [phoenix::bind(&LegacyMasterlistGrammar::StoreGlobalMessage, this, qi::_1)] - | groupLine - | listPlugin [phoenix::push_back(qi::_val, qi::_1)] - | qi::eps - ) % +qi::eol; - - listVar = - (conditionals [phoenix::ref(lastConditional) = qi::_1] - >> unicode::no_case[qi::lit("set")] - >> ( - ':' - > charString - )) [phoenix::bind(&LegacyMasterlistGrammar::RecordVarCondition, this, qi::_1, qi::_2)] - ; - - globalMessage = - (conditionals [phoenix::ref(lastConditional) = qi::_1] - >> unicode::no_case[qi::lit("global")] - >> ( - messageKeyword - >> ':' - >> charString - ) - )[phoenix::bind(&LegacyMasterlistGrammar::MakeMessage, this, qi::_val, qi::_1, qi::_2, qi::_3)] - ; - - groupLine = - conditionals [phoenix::ref(lastConditional) = qi::_1] - >> unicode::no_case[qi::lit("begingroup:") - | qi::lit("endgroup")] - > charString; - - listPlugin = - conditionals [phoenix::ref(lastConditional) = qi::_1] - > -unicode::no_case[qi::lit("mod:") | qi::lit("regex:")] - > (charString - > pluginMessages) [phoenix::bind(&LegacyMasterlistGrammar::MakePlugin, this, qi::_val, qi::_1, qi::_2)] - ; - - pluginMessages %= - ( - +qi::eol - >> pluginMessage % +qi::eol - ) | qi::eps [qi::_1 = noMessages]; - - pluginMessage = - (conditionals [phoenix::ref(lastConditional) = qi::_1] - >> messageKeyword - >> ':' - >> charString) [phoenix::bind(&LegacyMasterlistGrammar::MakeMessage, this, qi::_val, qi::_1, qi::_2, qi::_3)] //The double >> matters. A single > doesn't work. - ; - - charString %= qi::lexeme[+(unicode::char_ - qi::eol)]; //String, with no skipper. - - messageKeyword %= unicode::no_case[masterlistMsgKey]; - - conditionals = - ( - conditional [qi::_val = qi::_1] - > *((andOr > conditional) [qi::_val += qi::_1 + qi::_2]) - ) - | unicode::no_case[unicode::string("else")][phoenix::bind(&LegacyMasterlistGrammar::InvertCondition, this, qi::_val, phoenix::ref(lastConditional))] - | qi::eps [qi::_val = ""]; - - andOr = - qi::lit("&&") [qi::_val = " and "] - | qi::lit("||") [qi::_val = " or "]; - - conditional = - (ifIfnot - > functCondition) [phoenix::bind(&LegacyMasterlistGrammar::ConvertVarCondition, this, qi::_val, qi::_1, qi::_2)]; - - ifIfnot %= - unicode::no_case[ - unicode::string("ifnot")[qi::_val = "ifnot "] - | unicode::string("if") [qi::_val = "if "] - ]; - - functCondition %= - ( - unicode::no_case[unicode::string("var")][qi::_1 = "var"] > unicode::char_('(') > variable > unicode::char_(')') //Variable condition. - ) | ( - unicode::no_case[unicode::string("file")][qi::_1 = "file"] > unicode::char_('(') > file > unicode::char_(')') //File condition. - ) | ( - unicode::no_case[unicode::string("checksum")][qi::_1 = "checksum"] > unicode::char_('(') > file > unicode::char_(',') > checksum > unicode::char_(')') //Checksum condition. - ) | ( - unicode::no_case[unicode::string("version")][qi::_1 = "version"] > unicode::char_('(') > file > unicode::char_(',') > version > unicode::char_(',') > comparator > unicode::char_(')') //Version condition. - ) | ( - unicode::no_case[unicode::string("regex")][qi::_1 = "regex"] > unicode::char_('(') > regex > unicode::char_(')') //Regex condition. - ) | ( - unicode::no_case[unicode::string("active")][qi::_1 = "active"] > unicode::char_('(') > file > unicode::char_(')') //Active condition. - ) | ( - unicode::no_case[unicode::string("lang")][qi::_1 = "lang"] > unicode::char_('(') > language > unicode::char_(')') //Language condition. - ) - ; - - variable %= +(unicode::char_ - (')' | qi::eol)); - - file %= qi::lexeme[unicode::char_('"') > - +(unicode::char_ - ('"' | qi::eol)) - > unicode::char_('"')]; - - checksum %= +unicode::xdigit; - - version %= file; - - comparator %= - unicode::string("=") // [qi::_val = "=="] - | unicode::string(">") - | unicode::string("<") - ; - - regex %= file; - - language %= file; - - - modList.name("modList"); - listVar.name("listVar"); - listPlugin.name("listPlugin"); - pluginMessages.name("pluginMessages"); - pluginMessage.name("pluginMessage"); - charString.name("charString"); - messageKeyword.name("messageKeyword"); - conditionals.name("conditional"); - andOr.name("andOr"); - conditional.name("conditional"); - ifIfnot.name("ifIfnot"); - functCondition.name("condition"); - variable.name("variable"); - file.name("file"); - checksum.name("checksum"); - version.name("version"); - comparator.name("comparator"); - regex.name("regex file"); - file.name("language"); - - qi::on_error(modList, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(listVar, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(listPlugin, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(pluginMessages, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(pluginMessage, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(charString, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(messageKeyword, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(conditionals, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(andOr, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(conditional, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(ifIfnot, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(functCondition, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(variable, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(file, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(checksum, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(version, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(comparator, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(regex, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - qi::on_error(language, phoenix::bind(&LegacyMasterlistGrammar::SyntaxError, this, qi::_1, qi::_2, qi::_3, qi::_4)); - } - - void SetGlobalMessageBuffer(std::list * buffer) { - globalMessageBuffer = buffer; - } - private: - qi::rule(), Skipper > modList; - qi::rule > listVar, groupLine; - qi::rule > listPlugin; - qi::rule(), Skipper > pluginMessages; - qi::rule > globalMessage, pluginMessage; - qi::rule messageKeyword; - qi::rule > charString, andOr, conditional, conditionals, ifIfnot, functCondition, variable, file, checksum, version, comparator, regex, language; - - std::map varConditionMap; - std::string lastConditional; - std::list * globalMessageBuffer; - - void StoreGlobalMessage(Message& message) { - if (globalMessageBuffer != NULL) - globalMessageBuffer->push_back(message); - } - - void RecordVarCondition(std::string& condition, std::string& var) { - varConditionMap.insert(std::pair(boost::to_lower_copy(var), condition)); - } - - bool IsPosInQuotedText(const std::string& text, size_t pos) { - std::string::const_iterator last = text.begin(); - std::advance(last, pos); - - return (std::count(text.begin(), last, '"') % 2); - } - - void InvertCondition(std::string& output, const std::string& input) { - //Want to swap all the "if" and "ifnot" instances that occur outside of quoted strings (in case a filename contains them). - - output = input; - - size_t pos = 0; - while (pos < output.length()) { - pos = output.find("if", pos); - - if (pos == std::string::npos) - break; - - if (!IsPosInQuotedText(output, pos)) { - if (output.substr(pos, 5) == "ifnot") - output.erase(pos + 2, 3); - else - output.insert(pos + 2, "not"); - } - - pos += 2; - } - - //Also want to swap all instances of "or" and "and" outside of quoted strings. - pos = 0; - while (pos < output.length()) { - size_t pos1 = output.find("and", pos); - size_t pos2 = output.find("or", pos); - - if (pos1 == std::string::npos && pos2 == std::string::npos) - break; - - if (pos2 == std::string::npos || pos1 < pos2) - pos = pos1; - else if (pos1 == std::string::npos || pos2 < pos1) - pos = pos2; - - if (!IsPosInQuotedText(output, pos)) { - if (pos == pos1) { - output.erase(pos, 3); - output.insert(pos, "or"); - } else { - output.erase(pos, 2); - output.insert(pos, "and"); - } - } - - pos += 3; - } - - } - - void ConvertVarCondition(std::string& output, std::string& ifIfnotStr, std::string& function) { - - if (function.find("var(") == std::string::npos) { - output = ifIfnotStr + function; - return; - } - - size_t pos1 = function.find("var(") + 4; - size_t pos2 = function.find(')', pos1); - - std::string var = function.substr(pos1, pos2 - pos1); - - std::map::const_iterator it = varConditionMap.find(boost::to_lower_copy(var)); - - if (it == varConditionMap.end()) { - BOOST_LOG_TRIVIAL(error) << "The variable \"" << var << "\" was not previously defined."; - throw boss::error(boss::error::condition_eval_fail, "The variable \"" + var + "\" was not previously defined."); //Isn't used by BOSS application, so don't need to translate. - } - - if (ifIfnotStr == "if ") - output = it->second; - else { - if (!it->second.empty()) - InvertCondition(output, it->second); - } - } - - void ConvertCondition(std::string& condition) { - /*Convert the v2 order of evaluation to the standard order. - The only consistent way to do this is to bracket everything, - which is supported by the v3 syntax. */ - - int bracketNo = 0; - size_t pos = 0; - - while ((pos = condition.find(" and ", pos)) != std::string::npos) { - - if (IsPosInQuotedText(condition, pos)) { - pos += 7; - continue; - } - - condition.insert(pos, " )"); - bracketNo++; - pos += 7; - - } - - pos = 0; - while ((pos = condition.find(" or ", pos)) != std::string::npos) { - - if (IsPosInQuotedText(condition, pos)) { - pos += 6; - continue; - } - - condition.insert(pos, " )"); - bracketNo++; - pos += 6; - } - - for (int i=0; i < bracketNo; ++i) { - condition.insert(0, "( "); - } - - //Convert "if" and "ifnot" to "" and "not". - - while ((pos = condition.find("if ")) != std::string::npos) { - - if (IsPosInQuotedText(condition, pos)) - continue; - - condition.erase(pos, 3); - - } - - while ((pos = condition.find("ifnot ")) != std::string::npos) { - - if (IsPosInQuotedText(condition, pos)) - continue; - - condition.erase(pos, 2); - } - - //Also convert the "=" comparator in version conditions to "==". For some reason doing this in-parser causes most of the version condition to disappear... - - pos = condition.find("version("); - if (pos != std::string::npos) { - pos = condition.find(",=)", pos); - - if (pos != std::string::npos) - condition.insert(pos + 1, "="); - } - - //Also convert file placeholders. - boost::replace_all(condition, "\"OBSE\"", "\"..\\obse_1_2_416.dll\""); - boost::replace_all(condition, "\"FOSE\"", "\"..\\fose_loader.exe\""); - boost::replace_all(condition, "\"NVSE\"", "\"..\\nvse_loader.exe\""); - boost::replace_all(condition, "\"SKSE\"", "\"..\\skse_loader.exe\""); - boost::replace_all(condition, "\"MWSE\"", "\"..\\MWSE.dll\""); - boost::replace_all(condition, "\"TES3\"", "\"..\\Morrowind.exe\""); - boost::replace_all(condition, "\"TES4\"", "\"..\\Oblivion.exe\""); - boost::replace_all(condition, "\"TES5\"", "\"..\\TESV.exe\""); - boost::replace_all(condition, "\"FO3\"", "\"..\\Fallout3.exe\""); - boost::replace_all(condition, "\"FONV\"", "\"..\\FalloutNV.exe\""); - - } - - void MakePlugin(Plugin& plugin, std::string& name, std::list& messages) { - plugin.Name(boost::algorithm::trim_copy(name)); - - //Need to remove any Bash Tag suggestion messages and apply them properly. - std::set tags; - std::set dirtyInfo; - std::list::iterator it = messages.begin(); - while (it != messages.end()) { - - if (it->Type() == g_message_tag) { - std::string message = it->ChooseContent(g_lang_any).Str(); - - std::string addedList, removedList; - size_t pos1, pos2 = std::string::npos; - - pos1 = message.find("{{BASH:"); - if (pos1 != std::string::npos) - pos2 = message.find("}}", pos1); - if (pos2 != std::string::npos) - addedList = message.substr(pos1 + 7, pos2 - pos1 - 7); - - pos1 = message.find("["); - pos2 = std::string::npos; - if (pos1 != std::string::npos) - pos2 = message.find("]", pos1); - if (pos2 != std::string::npos) - removedList = message.substr(pos1+1,pos2-pos1-1); - - if (!addedList.empty()) { - //Now we move through the list of added Tags. - //Search the set of already added Tags for each one and only add if it's not found. - std::string name; - pos1 = 0; - pos2 = addedList.find(",", pos1); - while (pos2 != std::string::npos) { - name = boost::algorithm::trim_copy(addedList.substr(pos1,pos2-pos1)); - if (tags.find(Tag(name)) == tags.end()) - tags.insert(Tag(name, true, it->Condition())); - pos1 = pos2+1; - pos2 = addedList.find(",", pos1); - } - name = boost::algorithm::trim_copy(addedList.substr(pos1)); - if (tags.find(Tag(name)) == tags.end()) - tags.insert(Tag(name, true, it->Condition())); - } - - if (!removedList.empty()) { - std::string name; - pos1 = 0; - pos2 = removedList.find(",", pos1); - while (pos2 != std::string::npos) { - name = boost::algorithm::trim_copy(removedList.substr(pos1,pos2-pos1)); - if (tags.find(Tag(name, false)) == tags.end()) - tags.insert(Tag(name, false, it->Condition())); - pos1 = pos2+1; - pos2 = removedList.find(",", pos1); - } - name = boost::algorithm::trim_copy(removedList.substr(pos1)); - if (tags.find(Tag(name, false)) == tags.end()) - tags.insert(Tag(name, false, it->Condition())); - } - - it = messages.erase(it); - } else if (it->Type() == g_message_say) { - std::string content = it->ChooseContent(g_lang_any).Str(); - unsigned int langInt = it->ChooseContent(g_lang_any).Language(); - std::string opener; - if (langInt == g_lang_english || langInt == g_lang_any) - opener = "Requires: "; - else if (langInt == g_lang_spanish) - opener = "Requiere: "; - else if (langInt == g_lang_russian) - opener = "Требуется: "; - - if (boost::starts_with(content, opener) && (boost::icontains(content, ".esp") || boost::icontains(content, ".esm"))) { - //Remove any requirement messages that contain a plugin filename, since it's probably a master, according to SilentSpike's experience. - it = messages.erase(it); - } else - ++it; - } else if (it->Type() == g_message_warn) { - std::string content = it->ChooseContent(g_lang_any).Str(); - unsigned int langInt = it->ChooseContent(g_lang_any).Language(); - std::string opener; - if (langInt == g_lang_english || langInt == g_lang_any) { - opener = "Contains dirty edits: "; - } else if (langInt == g_lang_spanish) { - opener = "Contiene ediciones sucia: "; - } else if (langInt == g_lang_russian) { - opener = "\"Грязные\" правки: "; - } - - if (boost::starts_with(content, opener)) { - //Convert to new data structure. - //Extract ITM, UDR counts from message, CRC from condition, and utility + link from message. - unsigned int itm = 0; - unsigned int udr = 0; - uint32_t crc; - std::string utility; - size_t pos1, pos2; - std::string content = it->ChooseContent(g_lang_any).Str(); - std::string condition = it->Condition(); - - //Extract CRC. - pos1 = condition.find("checksum("); - if (pos1 == std::string::npos) { - ++it; - continue; - } - pos1 = condition.find(',', pos1); - if (pos1 == std::string::npos) { - ++it; - continue; - } - pos2 = condition.find(')', pos1); - if (pos2 == std::string::npos) { - ++it; - continue; - } - crc = strtoul(condition.substr(pos1+1, pos2-pos1-1).c_str(), NULL, 16); - - //Extract ITM count. - pos1 = content.find("ITM"); - if (pos1 != std::string::npos) { - pos2 = content.rfind(':', pos1); - if (pos2 != std::string::npos) { - itm = atoi(content.substr(pos2+1, pos1-pos2-1).c_str()); - } - } - - //Extract UDR count. - pos2 = content.find("UDR"); - if (pos2 != std::string::npos) { - pos1 = content.rfind(',', pos2); - if (pos1 != std::string::npos) { - udr = atoi(content.substr(pos1+1, pos2-pos1-1).c_str()); - } - } - - //Extract utility and link. - pos1 = content.find('"'); - if (pos1 != std::string::npos) { - pos2 = content.find(' ', pos1); - if (pos2 == std::string::npos) - pos2 = content.find('"', pos1+1); - if (pos2 != std::string::npos) { - utility = content.substr(pos1, pos2-pos1); - } - } - pos2 = content.find("Edit"); - if (pos2 != std::string::npos) { - pos1 = content.rfind(' ', pos2); - if (pos1 != std::string::npos) { - if (utility.empty()) - utility = content.substr(pos1 + 1, pos2 + 3 - pos1); - else - utility += " " + content.substr(pos1 + 1, pos2 + 3 - pos1) + '"'; - } - } - dirtyInfo.insert(PluginDirtyInfo(crc, itm, udr, 0, utility)); - it = messages.erase(it); - - } else - ++it; - } else - ++it; - } - - plugin.DirtyInfo(dirtyInfo); - plugin.Messages(messages); - plugin.Tags(tags); - } - - void MakeMessage(Message& message, std::string& condition, unsigned int type, std::string& content) { - - //First check if the message has a language condition. If it does, remove it and use it to set the language of the message content. - - //Just in case there are multiple language conditions, erase them all and use the last. - std::string lang; - size_t pos1; - while ((pos1 = condition.find("lang(")) != std::string::npos) { - - if (IsPosInQuotedText(condition, pos1)) { - pos1 += 5; - continue; - } - - size_t pos2 = condition.find(')', pos1); - - lang = condition.substr(pos1 + 6, pos2 - 1 - (pos1 + 6)); - condition.erase(pos1, pos2 + 1 - pos1); - - //Also need to trim any leftover "and", "or", "if" and "ifnot". - - //First erase "if" and "ifnot". - if (pos1 >= 6) { - if (condition.substr(pos1 - 6, 5) == "ifnot") { - condition.erase(pos1 - 6, 6); - pos1 -= 6; - } else if (condition.substr(pos1 - 3, 2) == "if") { - condition.erase(pos1 - 3, 3); - pos1 -= 3; - } - } else if (pos1 == 3) { //First "if" condition. - condition.erase(0, 3); - pos1 = 0; - } - - //Now look immediately before the erased conditional for "and" and "or" and erase any found. If the conditional is the first, then do the same for any "and" and "or" immediately after it. - - if (pos1 == 0) { - if (condition.substr(pos1, 5) == " and ") - condition.erase(pos1, 5); - else if (condition.substr(pos1, 4) == " or ") - condition.erase(pos1, 4); - } else { - - assert(pos1 > 5); //Shouldn't be anything <= 5 here, but just to be safe. - if (condition.substr(pos1 - 5, 5) == " and ") - condition.erase(pos1 - 5, 5); - else if (condition.substr(pos1 - 4, 4) == " or ") - condition.erase(pos1 - 4, 4); - } - } - - //BOSSv2 supports Chinese and German in addition to English, Russian and Spanish, but they aren't used in any of the masterlists so don't bother mapping them. - unsigned int langInt; - if (lang == "english" || lang == "chinese" || lang == "german") - langInt = g_lang_english; - else if (lang == "russian") - langInt = g_lang_russian; - else if (lang == "spanish") - langInt = g_lang_spanish; - else - langInt = g_lang_any; - - - /* Now convert the temporary message types into say or warning messages as appropriate. Translations were obtained from the BOSSv2 translation files. Thanks to the translators for them. */ - - if (type == message_dirty) { - - std::string search; - std::string opener; - if (langInt == g_lang_english || langInt == g_lang_any) { - search = "do not clean"; - opener = "Contains dirty edits: "; - } else if (langInt == g_lang_spanish) { - search = "no se limpia"; - opener = "Contiene ediciones sucia: "; - } else if (langInt == g_lang_russian) { - search = "Не очищать"; - opener = "\"Грязные\" правки: "; - } - - if (boost::icontains(content, search)) - type = g_message_say; - else - type = g_message_warn; - - content = opener + content; - } else if (type == message_req) { - type = g_message_say; - - std::string opener; - if (langInt == g_lang_english || langInt == g_lang_any) - opener = "Requires: "; - else if (langInt == g_lang_spanish) - opener = "Requiere: "; - else if (langInt == g_lang_russian) - opener = "Требуется: "; - - content = opener + content; - } else if (type == message_inc) { - type = g_message_say; - - std::string opener; - if (langInt == g_lang_english || langInt == g_lang_any) - opener = "Incompatible with: "; - else if (langInt == g_lang_spanish) - opener = "Incompatible con: "; - else if (langInt == g_lang_russian) - opener = "Несовместим с: "; - - content = opener + content; - } - - std::vector mc_vec; - mc_vec.push_back(MessageContent(content, langInt)); - - if (!condition.empty()) - ConvertCondition(condition); - - message = Message(type, mc_vec, condition); - } - - //Parser error reporter. - void SyntaxError(Iter const& /*first*/, Iter const& last, Iter const& errorpos, boost::spirit::info const& what) { - std::string context(errorpos, min(errorpos +50, last)); - boost::trim(context); - - BOOST_LOG_TRIVIAL(error) << "Error parsing at \"" << context << "\", expected \"" << what.tag << "\"."; - throw boss::error(boss::error::condition_eval_fail, "Expected \"" + what.tag + "\" at \"" + context + "\"."); //Isn't used by BOSS application, so don't need to translate. - } - }; - - void Loadv2Masterlist(boost::filesystem::path& file, std::list& plugins, std::list& globalMessages) { - Skipper skipper; - LegacyMasterlistGrammar grammar; - std::string::const_iterator begin, end; - std::string contents; - - grammar.SetGlobalMessageBuffer(&globalMessages); - - boss::ifstream ifile(file); - ifile.unsetf(std::ios::skipws); // No white space skipping! - - std::copy( - std::istream_iterator(ifile), - std::istream_iterator(), - std::back_inserter(contents) - ); - - begin = contents.begin(); - end = contents.end(); - - bool r = phrase_parse(begin, end, grammar, skipper, plugins); - - if (!r || begin != end) { - BOOST_LOG_TRIVIAL(error) << "Failed to read file: " << file.string(); - throw boss::error(boss::error::path_read_fail, file.string()); - } - } -} -#endif diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index e268694b..c61dd678 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -1,41 +1,44 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2012-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ #include "helpers.h" #include "metadata.h" #include "parsers.h" +#include "streams.h" + +#include #include #include #include -#include #include #include using namespace std; -namespace boss { +namespace loot { namespace lc = boost::locale; @@ -44,7 +47,7 @@ namespace boss { FormID::FormID(const std::string& sourcePlugin, const uint32_t objectID) : plugin(sourcePlugin), id(objectID) {} FormID::FormID(const std::vector& sourcePlugins, const uint32_t formID) { - int index = formID >> 24; + unsigned int index = formID >> 24; id = formID & ~((uint32_t)index << 24); if (index >= sourcePlugins.size()) { @@ -115,13 +118,13 @@ namespace boss { return _condition; } - bool ConditionStruct::EvalCondition(boss::Game& game) const { + bool ConditionStruct::EvalCondition(loot::Game& game) const { if (_condition.empty()) return true; BOOST_LOG_TRIVIAL(trace) << "Evaluating condition: " << _condition; - boost::unordered_map::const_iterator it = game.conditionCache.find(boost::to_lower_copy(_condition)); + unordered_map::const_iterator it = game.conditionCache.find(boost::locale::to_lower(_condition)); if (it != game.conditionCache.end()) return it->second; @@ -137,22 +140,22 @@ namespace boss { bool r; try { r = boost::spirit::qi::phrase_parse(begin, end, grammar, skipper, eval); - } catch (boss::error& e) { + } catch (std::exception& e) { BOOST_LOG_TRIVIAL(error) << "Failed to parse condition \"" << _condition << "\": " << e.what(); - throw boss::error(boss::error::path_read_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\": %2%")) % _condition % e.what()).str()); + throw loot::error(loot::error::condition_eval_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\": %2%")) % _condition % e.what()).str()); } if (!r || begin != end) { BOOST_LOG_TRIVIAL(error) << "Failed to parse condition \"" << _condition << "\"."; - throw boss::error(boss::error::path_read_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\".")) % _condition).str()); + throw loot::error(loot::error::condition_eval_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\".")) % _condition).str()); } - game.conditionCache.emplace(boost::to_lower_copy(_condition), eval); + game.conditionCache.emplace(boost::locale::to_lower(_condition), eval); return eval; } - MessageContent::MessageContent() : _language(g_lang_any) {} + MessageContent::MessageContent() : _language(Language::english) {} MessageContent::MessageContent(const std::string& str, const unsigned int language) : _str(str), _language(language) {} @@ -176,7 +179,7 @@ namespace boss { Message::Message(const unsigned int type, const std::string& content, const std::string& condition) : _type(type), ConditionStruct(condition) { - _content.push_back(MessageContent(content)); + _content.push_back(MessageContent(content, Language::english)); } Message::Message(const unsigned int type, const std::vector& content, @@ -195,21 +198,22 @@ namespace boss { return (_type == rhs.Type() && _content == rhs.Content()); } - bool Message::EvalCondition(boss::Game& game, const unsigned int language) { + bool Message::EvalCondition(loot::Game& game, const unsigned int language) { - BOOST_LOG_TRIVIAL(trace) << "Choosing message language."; + BOOST_LOG_TRIVIAL(trace) << "Choosing message content for language: " << Language(language).Name(); if (_content.size() > 1) { - if (language == g_lang_any) //Can use a message of any language, so use the first string. + if (language == Language::any) //Can use a message of any language, so use the first string. _content.resize(1); else { MessageContent english, match; - for (vector::const_iterator it=_content.begin(), endit=_content.end(); it != endit; ++it) { - if (it->Language() == language) { - match = *it; + for (const auto &mc: _content) { + if (mc.Language() == language) { + match = mc; break; - } else if (it->Language() == g_lang_english) - english = *it; + } + else if (mc.Language() == Language::english) + english = mc; } _content.resize(1); if (!match.Str().empty()) @@ -223,16 +227,17 @@ namespace boss { MessageContent Message::ChooseContent(const unsigned int language) const { BOOST_LOG_TRIVIAL(trace) << "Choosing message content."; - if (_content.size() == 1 || language == g_lang_any) + if (_content.size() == 1 || language == Language::any) return _content[0]; else { MessageContent english, match; - for (vector::const_iterator it=_content.begin(), endit=_content.end(); it != endit; ++it) { - if (it->Language() == language) { - match = *it; + for (const auto &mc : _content) { + if (mc.Language() == language) { + match = mc; break; - } else if (it->Language() == g_lang_english) - english = *it; + } + else if (mc.Language() == Language::english) + english = mc; } if (!match.Str().empty()) return match; @@ -302,7 +307,7 @@ namespace boss { name = name.substr(0, name.length() - 6); } - Plugin::Plugin(boss::Game& game, const std::string& n, const bool headerOnly) + Plugin::Plugin(loot::Game& game, const std::string& n, const bool headerOnly) : name(n), enabled(true), priority(0), isMaster(false), crc(0), numOverrideRecords(0), _isPriorityExplicit(false) { // Get data from file contents using libespm. Assumes libespm has already been initialised. @@ -313,15 +318,21 @@ namespace boss { if (!boost::filesystem::exists(filepath) && boost::filesystem::exists(filepath.string() + ".ghost")) filepath += ".ghost"; - espm::File * file; - if (game.Id() == g_game_tes4) - file = new espm::tes4::File(filepath, game.espm_settings, false, headerOnly); - else if (game.Id() == g_game_tes5) - file = new espm::tes5::File(filepath, game.espm_settings, false, headerOnly); - else if (game.Id() == g_game_fo3) - file = new espm::fo3::File(filepath, game.espm_settings, false, headerOnly); - else - file = new espm::fonv::File(filepath, game.espm_settings, false, headerOnly); + espm::File * file = nullptr; + try { + if (game.Id() == Game::tes4) + file = new espm::tes4::File(filepath, game.espm_settings, false, headerOnly); + else if (game.Id() == Game::tes5) + file = new espm::tes5::File(filepath, game.espm_settings, false, headerOnly); + else if (game.Id() == Game::fo3) + file = new espm::fo3::File(filepath, game.espm_settings, false, headerOnly); + else + file = new espm::fonv::File(filepath, game.espm_settings, false, headerOnly); + } + catch (std::exception& e) { + BOOST_LOG_TRIVIAL(error) << "Cannot read plugin file \"" << name << "\". Details: " << e.what(); + messages.push_back(loot::Message(loot::Message::error, (boost::format(boost::locale::translate("Cannot read \"%1%\". Details: %2%")) % name % e.what()).str())); + } //If the name passed ends in '.ghost', that should be trimmed. if (boost::iends_with(name, ".ghost")) { @@ -344,8 +355,8 @@ namespace boss { vector records = file->getFormIDs(); vector plugins = masters; plugins.push_back(name); - for (vector::const_iterator it = records.begin(),endIt = records.end(); it != endIt; ++it) { - FormID fid = FormID(plugins, *it); + for (const auto &record: records) { + FormID fid = FormID(plugins, record); formIDs.insert(fid); if (!boost::iequals(fid.Plugin(), name)) ++numOverrideRecords; @@ -362,13 +373,13 @@ namespace boss { end = text.end(); BOOST_LOG_TRIVIAL(trace) << name << ": " << "Attempting to read the version from the description."; - for(int j = 0; j < 7 && version.empty(); j++) { - boost::smatch what; - while (boost::regex_search(begin, end, what, version_checks[j])) { + for (int j = 0; j < 7 && version.empty(); j++) { + smatch what; + while (regex_search(begin, end, what, version_checks[j])) { if (what.empty()) continue; - boost::ssub_match match = what[1]; + ssub_match match = what[1]; if (!match.matched) continue; @@ -393,15 +404,17 @@ namespace boss { vector bashTags; boost::split(bashTags, text, boost::is_any_of(",")); - for (int i=0,max=bashTags.size(); i::iterator it = loadAfter.begin(); it != loadAfter.end();) { + Plugin& Plugin::EvalAllConditions(loot::Game& game, const unsigned int language) { + for (auto it = loadAfter.begin(); it != loadAfter.end();) { if (!it->EvalCondition(game)) loadAfter.erase(it++); else ++it; } - for (set::iterator it = requirements.begin(); it != requirements.end();) { + for (auto it = requirements.begin(); it != requirements.end();) { if (!it->EvalCondition(game)) requirements.erase(it++); else ++it; } - for (set::iterator it = incompatibilities.begin(); it != incompatibilities.end();) { + for (auto it = incompatibilities.begin(); it != incompatibilities.end();) { if (!it->EvalCondition(game)) incompatibilities.erase(it++); else ++it; } - for (list::iterator it = messages.begin(); it != messages.end();) { + for (auto it = messages.begin(); it != messages.end();) { if (!it->EvalCondition(game, language)) it = messages.erase(it); else ++it; } - for (set::iterator it = tags.begin(); it != tags.end();) { + for (auto it = tags.begin(); it != tags.end();) { if (!it->EvalCondition(game)) tags.erase(it++); else @@ -600,28 +613,30 @@ namespace boss { //First need to get plugin's CRC. uint32_t crc = 0; - boost::unordered_map::iterator it = game.crcCache.find(boost::to_lower_copy(name)); + unordered_map::iterator it = game.crcCache.find(boost::locale::to_lower(name)); if (it != game.crcCache.end()) crc = it->second; else if (boost::filesystem::exists(game.DataPath() / name)) { crc = GetCrc32(game.DataPath() / name); - game.crcCache.emplace(boost::to_lower_copy(name), crc); + game.crcCache.emplace(boost::locale::to_lower(name), crc); } else if (boost::filesystem::exists(game.DataPath() / (name + ".ghost"))) { crc = GetCrc32(game.DataPath() / (name + ".ghost")); - game.crcCache.emplace(boost::to_lower_copy(name), crc); + game.crcCache.emplace(boost::locale::to_lower(name), crc); } else _dirtyInfo.clear(); - for (set::iterator it = _dirtyInfo.begin(); it != _dirtyInfo.end();) { + for (auto it = _dirtyInfo.begin(); it != _dirtyInfo.end();) { if (it->CRC() != crc) _dirtyInfo.erase(it++); else ++it; } + + return *this; } bool Plugin::HasNameOnly() const { - return !IsPriorityExplicit() && enabled == true && loadAfter.empty() && requirements.empty() && incompatibilities.empty() && messages.empty() && tags.empty() && _dirtyInfo.empty(); + return !IsPriorityExplicit() && loadAfter.empty() && requirements.empty() && incompatibilities.empty() && messages.empty() && tags.empty() && _dirtyInfo.empty(); } bool Plugin::IsRegexPlugin() const { @@ -634,8 +649,8 @@ namespace boss { bool Plugin::operator == (const Plugin& rhs) const { return (boost::iequals(name, rhs.Name()) - || (IsRegexPlugin() && boost::regex_match(rhs.Name(), boost::regex(name, boost::regex::perl|boost::regex::icase))) - || (rhs.IsRegexPlugin() && boost::regex_match(name, boost::regex(rhs.Name(), boost::regex::perl|boost::regex::icase)))); + || (IsRegexPlugin() && regex_match(rhs.Name(), regex(name, regex::ECMAScript | regex::icase))) + || (rhs.IsRegexPlugin() && regex_match(name, regex(rhs.Name(), regex::ECMAScript | regex::icase)))); } bool Plugin::operator != (const Plugin& rhs) const { @@ -682,9 +697,9 @@ namespace boss { std::set Plugin::OverrideFormIDs() const { set fidSubset; - for (set::const_iterator it = formIDs.begin(), endIt=formIDs.end(); it != endIt; ++it) { - if (!boost::iequals(it->Plugin(), name)) - fidSubset.insert(*it); + for (const auto &formID : formIDs) { + if (!boost::iequals(formID.Plugin(), name)) + fidSubset.insert(formID); } return fidSubset; } @@ -714,37 +729,73 @@ namespace boss { return false; } - std::vector Plugin::CheckInstallValidity(const Game& game) const { - std::vector errorMessages; + bool Plugin::CheckInstallValidity(const Game& game) { + unsigned int messageType; + if (game.IsActive(name)) + messageType = loot::Message::error; + else + messageType = loot::Message::warn; if (tags.find(Tag("Filter")) == tags.end()) { - for (vector::const_iterator it=masters.begin(), endIt=masters.end(); it != endIt; ++it) { - if (!boost::filesystem::exists(game.DataPath() / *it) && !boost::filesystem::exists(game.DataPath() / (*it + ".ghost"))) { - BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << *it << "\", but it is missing."; - errorMessages.push_back((boost::format(boost::locale::translate("This plugin requires \"%1%\" to be installed, but it is missing.")) % *it).str()); + for (const auto &master: masters) { + if (!boost::filesystem::exists(game.DataPath() / master) && !boost::filesystem::exists(game.DataPath() / (master + ".ghost"))) { + BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << master << "\", but it is missing."; + messages.push_back(loot::Message(messageType, (boost::format(boost::locale::translate("This plugin requires \"%1%\" to be installed, but it is missing.")) % master).str())); } - else if (!game.IsActive(*it)) { - BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << *it << "\", but it is inactive."; - errorMessages.push_back((boost::format(boost::locale::translate("This plugin requires \"%1%\" to be active, but it is inactive.")) % *it).str()); + else if (!game.IsActive(master)) { + BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << master << "\", but it is inactive."; + messages.push_back(loot::Message(messageType, (boost::format(boost::locale::translate("This plugin requires \"%1%\" to be active, but it is inactive.")) % master).str())); } } } - for (set::const_iterator it=requirements.begin(), endIt=requirements.end(); it != endIt; ++it) { - if (!boost::filesystem::exists(game.DataPath() / it->Name()) && !(IsPlugin(it->Name()) && boost::filesystem::exists(game.DataPath() / (it->Name() + ".ghost")))) { - BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << it->Name() << "\", but it is missing."; - errorMessages.push_back((boost::format(boost::locale::translate("This plugin requires \"%1%\" to be installed, but it is missing.")) % it->Name()).str()); + for (const auto &req: requirements) { + if (!boost::filesystem::exists(game.DataPath() / req.Name()) && !(IsPlugin(req.Name()) && boost::filesystem::exists(game.DataPath() / (req.Name() + ".ghost")))) { + BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << req.Name() << "\", but it is missing."; + messages.push_back(loot::Message(messageType, (boost::format(boost::locale::translate("This plugin requires \"%1%\" to be installed, but it is missing.")) % req.Name()).str())); } } - for (set::const_iterator it=incompatibilities.begin(), endIt=incompatibilities.end(); it != endIt; ++it) { - if (boost::filesystem::exists(game.DataPath() / it->Name()) || (IsPlugin(it->Name()) && boost::filesystem::exists(game.DataPath() / (it->Name() + ".ghost")))) { - BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" is incompatible with \"" << it->Name() << "\", but both are present."; - errorMessages.push_back((boost::format(boost::locale::translate("This plugin is incompatible with \"%1%\", but both are present.")) % it->Name()).str()); + for (const auto &inc: incompatibilities) { + if (boost::filesystem::exists(game.DataPath() / inc.Name()) || (IsPlugin(inc.Name()) && boost::filesystem::exists(game.DataPath() / (inc.Name() + ".ghost")))) { + if (!game.IsActive(inc.Name())) + messageType = loot::Message::warn; + BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" is incompatible with \"" << inc.Name() << "\", but both are present."; + messages.push_back(loot::Message(messageType, (boost::format(boost::locale::translate("This plugin is incompatible with \"%1%\", but both are present.")) % inc.Name()).str())); } } - return errorMessages; + + // Also evaluate dirty info. + bool isDirty = false; + for (const auto &element : _dirtyInfo) { + boost::format f; + if (element.ITMs() > 0 && element.UDRs() > 0 && element.DeletedNavmeshes() > 0) + f = boost::format(boost::locale::translate("Contains %1% ITM records, %2% UDR records and %3% deleted navmeshes. Clean with %4%.")) % element.ITMs() % element.UDRs() % element.DeletedNavmeshes() % element.CleaningUtility(); + else if (element.ITMs() == 0 && element.UDRs() == 0 && element.DeletedNavmeshes() == 0) + f = boost::format(boost::locale::translate("Clean with %1%.")) % element.CleaningUtility(); + + + else if (element.ITMs() == 0 && element.UDRs() > 0 && element.DeletedNavmeshes() > 0) + f = boost::format(boost::locale::translate("Contains %1% UDR records and %2% deleted navmeshes. Clean with %3%.")) % element.UDRs() % element.DeletedNavmeshes() % element.CleaningUtility(); + else if (element.ITMs() == 0 && element.UDRs() == 0 && element.DeletedNavmeshes() > 0) + f = boost::format(boost::locale::translate("Contains %1% deleted navmeshes. Clean with %2%.")) % element.DeletedNavmeshes() % element.CleaningUtility(); + else if (element.ITMs() == 0 && element.UDRs() > 0 && element.DeletedNavmeshes() == 0) + f = boost::format(boost::locale::translate("Contains %1% UDR records. Clean with %2%.")) % element.UDRs() % element.CleaningUtility(); + + else if (element.ITMs() > 0 && element.UDRs() == 0 && element.DeletedNavmeshes() > 0) + f = boost::format(boost::locale::translate("Contains %1% ITM records and %2% deleted navmeshes. Clean with %3%.")) % element.ITMs() % element.DeletedNavmeshes() % element.CleaningUtility(); + else if (element.ITMs() > 0 && element.UDRs() == 0 && element.DeletedNavmeshes() == 0) + f = boost::format(boost::locale::translate("Contains %1% ITM records. Clean with %2%.")) % element.ITMs() % element.CleaningUtility(); + + else if (element.ITMs() > 0 && element.UDRs() > 0 && element.DeletedNavmeshes() == 0) + f = boost::format(boost::locale::translate("Contains %1% ITM records and %2% UDR records. Clean with %3%.")) % element.ITMs() % element.UDRs() % element.CleaningUtility(); + + messages.push_back(loot::Message(loot::Message::warn, f.str())); + isDirty = true; + } + + return isDirty; } bool Plugin::LoadsBSA(const Game& game) const { - if (game.Id() != g_game_tes5 || IsRegexPlugin()) + if (game.Id() != Game::tes5 || IsRegexPlugin()) return false; return boost::filesystem::exists(game.DataPath() / (name.substr(0, name.length() - 3) + "bsa")); } @@ -765,17 +816,6 @@ namespace boss { return rhs == lhs; } - bool alpha_sort(const Plugin& lhs, const Plugin& rhs) { - return boost::ilexicographical_compare(rhs.Name(), lhs.Name()); - } - - bool master_sort(const Plugin& lhs, const Plugin& rhs) { - if (lhs.IsMaster() && !rhs.IsMaster()) - return true; - else - return false; - } - bool IsPlugin(const std::string& file) { if (boost::iends_with(file, ".esp") || boost::iends_with(file, ".esm") || boost::iends_with(file, ".esp.ghost") || boost::iends_with(file, ".esm.ghost")) diff --git a/src/backend/metadata.h b/src/backend/metadata.h index 2c4548d7..c85acbe1 100644 --- a/src/backend/metadata.h +++ b/src/backend/metadata.h @@ -1,39 +1,44 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2012-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ -#ifndef __BOSS_METADATA__ -#define __BOSS_METADATA__ +#ifndef __LOOT_METADATA__ +#define __LOOT_METADATA__ -#include "game.h" #include "globals.h" -#include +#include #include #include #include #include -namespace boss { +#include +namespace loot { + + const unsigned int max_priority = 1000000; + + class Game; //A FormID is a 32 bit unsigned integer of the form xxYYYYYY in hex. The xx is the position in the masters list of the plugin that the FormID is from, and the YYYYYY is the rest of the FormID. Here the xx bit is stored as the corresponding filename to allow comparison between FormIDs from different plugins. class FormID { @@ -78,7 +83,7 @@ namespace boss { ConditionStruct(const std::string& condition); bool IsConditional() const; - bool EvalCondition(boss::Game& game) const; + bool EvalCondition(loot::Game& game) const; std::string Condition() const; private: @@ -88,7 +93,7 @@ namespace boss { class MessageContent { public: MessageContent(); - MessageContent(const std::string& str, const unsigned int language = g_lang_any); + MessageContent(const std::string& str, const unsigned int language); std::string Str() const; unsigned int Language() const; @@ -111,11 +116,16 @@ namespace boss { bool operator < (const Message& rhs) const; bool operator == (const Message& rhs) const; - bool EvalCondition(boss::Game& game, const unsigned int language); + bool EvalCondition(loot::Game& game, const unsigned int language); unsigned int Type() const; std::vector Content() const; MessageContent ChooseContent(const unsigned int language) const; + + static const unsigned int say = 0; + static const unsigned int warn = 1; + static const unsigned int error = 2; + static const unsigned int tag = 3; private: unsigned int _type; std::vector _content; @@ -156,7 +166,7 @@ namespace boss { public: Plugin(); Plugin(const std::string& name); - Plugin(boss::Game& game, const std::string& name, const bool headerOnly); + Plugin(loot::Game& game, const std::string& name, const bool headerOnly); //Merges from the given plugin into this one, unless there is already equal metadata present. //For 'enabled' and 'priority' metadata, use the given plugin's values, but if the 'priority' user value is zero, ignore it. @@ -194,7 +204,7 @@ namespace boss { void Tags(const std::set& tags); void DirtyInfo(const std::set& info); - void EvalAllConditions(boss::Game& game, const unsigned int language); + Plugin& EvalAllConditions(loot::Game& game, const unsigned int language); bool HasNameOnly() const; bool IsRegexPlugin() const; bool LoadsBSA(const Game& game) const; @@ -212,7 +222,7 @@ namespace boss { bool MustLoadAfter(const Plugin& plugin) const; //Checks masters, reqs and loadAfter. //Validity checks. - std::vector CheckInstallValidity(const Game& game) const; //Checks that reqs and masters are all present, and that no incs are present. Returns a map of filenames and whether they are missing (if bool is true, then filename is a req or master, otherwise it's an inc). + bool CheckInstallValidity(const Game& game); //Checks that reqs and masters are all present, and that no incs are present. Returns true if the plugin is dirty. private: std::string name; bool enabled; //Default to true. @@ -235,25 +245,22 @@ namespace boss { size_t numOverrideRecords; }; - struct plugin_hash : std::unary_function { - inline size_t operator () (const Plugin& p) const { - size_t seed = 0; - boost::hash_combine(seed, p.Name()); - return seed; - } - }; - bool operator == (const File& lhs, const Plugin& rhs); bool operator == (const Plugin& lhs, const File& rhs); bool operator == (const std::string& lhs, const Plugin& rhs); - bool alpha_sort(const Plugin& lhs, const Plugin& rhs); - - bool master_sort(const Plugin& lhs, const Plugin& rhs); - bool IsPlugin(const std::string& file); } +namespace std { + template<> + struct hash < loot::Plugin > { + size_t operator() (const loot::Plugin& plugin) { + return hash()(boost::locale::to_lower(plugin.Name())); + } + }; +} + #endif diff --git a/src/backend/network.cpp b/src/backend/network.cpp deleted file mode 100644 index 0015dbfb..00000000 --- a/src/backend/network.cpp +++ /dev/null @@ -1,322 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2012-2014 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ - -#include "network.h" -#include "error.h" -#include "parsers.h" -#include "streams.h" -#include "helpers.h" - -#include -#include -#include - -#include - -using namespace std; - -namespace fs = boost::filesystem; -namespace lc = boost::locale; - -namespace boss { - - struct pointers_struct { - pointers_struct() : repo(NULL), remote(NULL), cfg(NULL), obj(NULL), commit(NULL) {} - - void free() { - git_commit_free(commit); - git_object_free(obj); - git_config_free(cfg); - git_remote_free(remote); - git_repository_free(repo); - } - - git_repository * repo; - git_remote * remote; - git_config * cfg; - git_object * obj; - git_commit * commit; - }; - - void handle_error(int error_code, pointers_struct& pointers) { - if (!error_code) - return; - - const git_error * error = giterr_last(); - std::string error_message; - if (error == NULL) - error_message = IntToString(error_code) + "."; - else - error_message = IntToString(error_code) + "; " + error->message; - pointers.free(); - giterr_clear(); - - BOOST_LOG_TRIVIAL(error) << "Git operation failed. Error: " << error_message; - throw boss::error(boss::error::git_error, (boost::format(lc::translate("Git operation failed. Error: %1%")) % error_message).str()); - } - - int progress_cb(const char *str, int len, void *data) { - BOOST_LOG_TRIVIAL(info) << string(str, len); - return 0; - } - - int update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data) { - char a_str[GIT_OID_HEXSZ + 1], b_str[GIT_OID_HEXSZ + 1]; - (void)data; - - git_oid_fmt(b_str, b); - b_str[GIT_OID_HEXSZ] = '\0'; - - if (git_oid_iszero(a)) { - BOOST_LOG_TRIVIAL(info) << "[new] " << b_str << " " << refname; - } else { - git_oid_fmt(a_str, a); - a_str[GIT_OID_HEXSZ] = '\0'; - BOOST_LOG_TRIVIAL(info) << "[updated] " << a_str << ".." << b_str << " " << refname; - } - - return 0; - } - - std::string UpdateMasterlist(Game& game, std::list& parsingErrors, std::list& plugins, std::list& messages) { - - /* List of Git operations (porcelain commands shown, will need to implement using plumbing in the API though): - - 1. Check if there is already a Git repository in the game's BOSS subfolder. - - Since the masterlists will each be in the root of a separate repository, just check if there is a `.git` folder present. - - 2a. If there is, compare its remote URL with the URL that BOSS is currently set to use. - - The current remote can be gotten using `git config --get remote.origin.url`. - - - 3a. If the URLs are different, then update the remote URL to the one given by BOSS. - - The remote URL can be changed using `git remote set-url origin ` - - 2b. If there isn't already a Git repo present, initialise one using the URL given (remembering to split the URL so that it ends in `.git`). - - `git init` - `git remote add origin ` - - - 3b. Now set up sparse checkout support, so that even if the repository has other files, the user's BOSS install only gets the masterlist added to it. - - `git config core.sparseCheckout true` - `echo masterlist.yaml >> .git/info/sparse-checkout` - - 4. Now update the repository. - - `git reset --hard HEAD` is required to undo any roll-backs that were done in the local repository. - `git pull origin master` - - 5. Get the masterlist's commit hash. - - 6. Test the masterlist to see if it parses OK (and evals conditions OK). - - 7a. If it has errors, checkout one revision earlier. - - `git checkout HEAD~1 masterlist.yaml` - - 8a. Go back to step (5). - - 7b. If it doesn't have errors, finish. - - */ - pointers_struct ptrs; - const git_transfer_progress * stats = NULL; - - BOOST_LOG_TRIVIAL(trace) << "Checking for a Git repository."; - - //Checking for a ".git" folder. - if (fs::exists(game.MasterlistPath().parent_path() / ".git")) { - //Repository exists. Open it. - BOOST_LOG_TRIVIAL(info) << "Existing repository found, attempting to open it."; - handle_error(git_repository_open(&ptrs.repo, game.MasterlistPath().parent_path().string().c_str()), ptrs); - - BOOST_LOG_TRIVIAL(trace) << "Attempting to get info on the repository remote."; - - //Now get remote info. - handle_error(git_remote_load(&ptrs.remote, ptrs.repo, "origin"), ptrs); - - BOOST_LOG_TRIVIAL(trace) << "Getting the remote URL."; - - //Get the remote URL. - const char * url = git_remote_url(ptrs.remote); - - BOOST_LOG_TRIVIAL(trace) << "Checking to see if remote URL matches URL in settings."; - - //Check if the repo URLs match. - BOOST_LOG_TRIVIAL(info) << "Remote URL given: " << game.RepoURL(); - BOOST_LOG_TRIVIAL(info) << "Remote URL in repository settings: " << url; - if (url != game.RepoURL()) { - BOOST_LOG_TRIVIAL(trace) << "URLs do not match, setting repository URL to URL in settings."; - //The URLs don't match. Change the remote URL to match the one BOSS has. - handle_error(git_remote_set_url(ptrs.remote, game.RepoURL().c_str()), ptrs); - - //Now save change. - handle_error(git_remote_save(ptrs.remote), ptrs); - } - } else { - BOOST_LOG_TRIVIAL(info) << "Repository doesn't exist, initialising a new repository."; - //Repository doesn't exist. Set up a repository. - handle_error(git_repository_init(&ptrs.repo, game.MasterlistPath().parent_path().string().c_str(), false), ptrs); - - BOOST_LOG_TRIVIAL(info) << "Setting the new repository's remote to: " << game.RepoURL(); - - //Now set the repository's remote. - handle_error(git_remote_create(&ptrs.remote, ptrs.repo, "origin", game.RepoURL().c_str()), ptrs); - - BOOST_LOG_TRIVIAL(trace) << "Getting the repository config."; - - handle_error(git_repository_config(&ptrs.cfg, ptrs.repo), ptrs); - - BOOST_LOG_TRIVIAL(trace) << "Setting the repository up for sparse checkouts."; - - handle_error(git_config_set_bool(ptrs.cfg, "core.sparseCheckout", true), ptrs); - - //Now add the masterlist file to the list of files to be checked out. We can actually just overwrite anything that was there previously, since it's only one file. - - BOOST_LOG_TRIVIAL(trace) << "Adding the masterlist to the list of files to be checked out."; - - boss::ofstream out(game.MasterlistPath().parent_path() / ".git/info/sparse-checkout"); - - out << "masterlist.yaml"; - - out.close(); - - } - - //WARNING: This is generally a very bad idea, since it makes HTTPS a little bit pointless, but in this case because we're only reading data and not really concerned about its integrity, it's acceptable. A better solution would be to figure out why GitHub's certificate appears to be invalid to OpenSSL. -#ifndef _WIN32 - git_remote_check_cert(ptrs.remote, 0); -#endif - - BOOST_LOG_TRIVIAL(trace) << "Fetching updates from remote."; - - //Now pull from the remote repository. This involves a fetch followed by a merge. First perform the fetch. - - //Set up callbacks. - git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT; - callbacks.update_tips = &update_cb; - callbacks.progress = &progress_cb; - git_remote_set_callbacks(ptrs.remote, &callbacks); - - stats = git_remote_stats(ptrs.remote); - - //Fetch from remote. - BOOST_LOG_TRIVIAL(trace) << "Fetching from remote."; - handle_error(git_remote_fetch(ptrs.remote), ptrs); - - BOOST_LOG_TRIVIAL(info) << "Received " << stats->indexed_objects << " of " << stats->total_objects << " objects in " << stats->received_bytes << " bytes."; - - // Now start the merging. Not entirely sure what's going on here, but it looks like libgit2's merge API is incomplete, you can create some git_merge_head objects, but can't do anything with them... - // Thankfully, we don't really need a merge, we just need to replace whatever's in the working directory with the relevant file from FETCH_HEAD, which was updated in the fetching step before. - // The porcelain equivalent is `git checkout refs/remotes/origin/gh-pages masterlist.yaml` - - BOOST_LOG_TRIVIAL(trace) << "Setting up checkout parameters."; - - char * paths[] = { "masterlist.yaml" }; - - git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT; - opts.checkout_strategy = GIT_CHECKOUT_FORCE; //Make sure the existing file gets overwritten. - opts.paths.strings = paths; - opts.paths.count = 1; - - //Next, we need to do a looping checkout / parsing check / roll-back. - - git_object_free(ptrs.obj); //Free object since it will be reallocated in loop. - - bool parsingFailed = false; - unsigned int rollbacks = 0; - char revision[10]; - do { - BOOST_LOG_TRIVIAL(trace) << "Getting the Git object for the tree at refs/remotes/origin/" << game.RepoBranch() << "~" << rollbacks << "."; - - //Get the commit hash so that we can report the revision if there is an error. - string filespec = "refs/remotes/origin/" + game.RepoBranch() + "~" + IntToString(rollbacks); - git_object * mlistObj; - - handle_error(git_revparse_single(&ptrs.obj, ptrs.repo, filespec.c_str()), ptrs); - - BOOST_LOG_TRIVIAL(trace) << "Checking out the tree at refs/remotes/origin/" << game.RepoBranch() << "~" << rollbacks << "."; - - //Now we can do the checkout. - handle_error(git_checkout_tree(ptrs.repo, ptrs.obj, &opts), ptrs); - - BOOST_LOG_TRIVIAL(trace) << "Getting the hash for the tree."; - - const git_oid * mlistOid = git_object_id(ptrs.obj); - - BOOST_LOG_TRIVIAL(trace) << "Converting and recording the first 10 hex characters of the hash."; - - git_oid_tostr(revision, 10, mlistOid); - - BOOST_LOG_TRIVIAL(info) << "Tree hash is: " << revision; - BOOST_LOG_TRIVIAL(trace) << "Freeing the masterlist object."; - - git_object_free(ptrs.obj); - - BOOST_LOG_TRIVIAL(trace) << "Testing masterlist parsing."; - - //Now try parsing the masterlist. - list messages; - list plugins; - try { - boss::ifstream in(game.MasterlistPath()); - YAML::Node mlist = YAML::Load(in); - in.close(); - - if (mlist["globals"]) - messages = mlist["globals"].as< list >(); - if (mlist["plugins"]) - plugins = mlist["plugins"].as< list >(); - - for (list::iterator it=plugins.begin(), endIt=plugins.end(); it != endIt; ++it) { - it->EvalAllConditions(game, g_lang_any); - } - - for (list::iterator it=messages.begin(), endIt=messages.end(); it != endIt; ++it) { - it->EvalCondition(game, g_lang_any); - } - - parsingFailed = false; - - } catch (std::exception& e) { - parsingFailed = true; - rollbacks++; - - //Roll back one revision if there's an error. - BOOST_LOG_TRIVIAL(error) << "Masterlist parsing failed. Masterlist revision " + string(revision) + ": " + e.what(); - - parsingErrors.push_back(boss::Message(boss::g_message_error, boost::locale::translate("Masterlist revision").str() + " " + string(revision) + ": " + e.what() + " " + boost::locale::translate("Rolled back to the previous revision.").str())); - } - } while (parsingFailed); - - //Finally, free memory. - ptrs.free(); - - return string(revision); - } -} diff --git a/src/backend/network.h b/src/backend/network.h deleted file mode 100644 index 85e5380e..00000000 --- a/src/backend/network.h +++ /dev/null @@ -1,37 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2012-2014 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ - -#ifndef __BOSS_NETWORK__ -#define __BOSS_NETWORK__ - -#include -#include - -#include "game.h" -#include "metadata.h" - -namespace boss { - - std::string UpdateMasterlist(Game& game, std::list& parsingErrors, std::list& plugins, std::list& messages); -} -#endif diff --git a/src/backend/parsers.h b/src/backend/parsers.h index fd473316..bd93daed 100644 --- a/src/backend/parsers.h +++ b/src/backend/parsers.h @@ -1,28 +1,29 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2012-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ -#ifndef __BOSS_PARSERS__ -#define __BOSS_PARSERS__ +#ifndef __LOOT_PARSERS__ +#define __LOOT_PARSERS__ #ifndef BOOST_SPIRIT_UNICODE #define BOOST_SPIRIT_UNICODE @@ -32,15 +33,16 @@ #define BOOST_SPIRIT_USE_PHOENIX_V3 1 #endif +#include "game.h" #include "metadata.h" #include "helpers.h" #include "error.h" -#include +#include +#include #include -#include #include #include #include @@ -59,11 +61,11 @@ namespace YAML { /////////////////////// template<> - struct convert { - static Node encode(const boss::Game& rhs) { + struct convert { + static Node encode(const loot::Game& rhs) { Node node; - node["type"] = boss::Game(rhs.Id()).FolderName(); + node["type"] = loot::Game(rhs.Id()).FolderName(); node["name"] = rhs.Name(); node["folder"] = rhs.FolderName(); node["master"] = rhs.Master(); @@ -75,18 +77,18 @@ namespace YAML { return node; } - static bool decode(const Node& node, boss::Game& rhs) { + static bool decode(const Node& node, loot::Game& rhs) { if (!node.IsMap() || !node["folder"] || !node["type"]) return false; - if (node["type"].as() == boss::Game(boss::g_game_tes4).FolderName()) - rhs = boss::Game(boss::g_game_tes4, node["folder"].as()); - else if (node["type"].as() == boss::Game(boss::g_game_tes5).FolderName()) - rhs = boss::Game(boss::g_game_tes5, node["folder"].as()); - else if (node["type"].as() == boss::Game(boss::g_game_fo3).FolderName()) - rhs = boss::Game(boss::g_game_fo3, node["folder"].as()); - else if (node["type"].as() == boss::Game(boss::g_game_fonv).FolderName()) - rhs = boss::Game(boss::g_game_fonv, node["folder"].as()); + if (node["type"].as() == loot::Game(loot::Game::tes4).FolderName()) + rhs = loot::Game(loot::Game::tes4, node["folder"].as()); + else if (node["type"].as() == loot::Game(loot::Game::tes5).FolderName()) + rhs = loot::Game(loot::Game::tes5, node["folder"].as()); + else if (node["type"].as() == loot::Game(loot::Game::fo3).FolderName()) + rhs = loot::Game(loot::Game::fo3, node["folder"].as()); + else if (node["type"].as() == loot::Game(loot::Game::fonv).FolderName()) + rhs = loot::Game(loot::Game::fonv, node["folder"].as()); else return false; @@ -111,8 +113,8 @@ namespace YAML { }; template<> - struct convert { - static Node encode(const boss::PluginDirtyInfo& rhs) { + struct convert { + static Node encode(const loot::PluginDirtyInfo& rhs) { Node node; node["crc"] = rhs.CRC(); node["util"] = rhs.CleaningUtility(); @@ -127,7 +129,7 @@ namespace YAML { return node; } - static bool decode(const Node& node, boss::PluginDirtyInfo& rhs) { + static bool decode(const Node& node, loot::PluginDirtyInfo& rhs) { if (!node.IsMap() || !node["crc"] || !node["util"]) return false; @@ -143,45 +145,45 @@ namespace YAML { std::string utility = node["util"].as(); - rhs = boss::PluginDirtyInfo(crc, itm, udr, nav, utility); + rhs = loot::PluginDirtyInfo(crc, itm, udr, nav, utility); return true; } }; template<> - struct convert { - static Node encode(const boss::MessageContent& rhs) { + struct convert { + static Node encode(const loot::MessageContent& rhs) { Node node; node["str"] = rhs.Str(); - node["lang"] = boss::Language(rhs.Language()).Locale(); + node["lang"] = loot::Language(rhs.Language()).Locale(); return node; } - static bool decode(const Node& node, boss::MessageContent& rhs) { + static bool decode(const Node& node, loot::MessageContent& rhs) { if (!node.IsMap() || !node["str"] || !node["lang"]) return false; std::string str = node["str"].as(); - unsigned int lang = boss::Language(node["lang"].as()).Code(); + unsigned int lang = loot::Language(node["lang"].as()).Code(); - rhs = boss::MessageContent(str, lang); + rhs = loot::MessageContent(str, lang); return true; } }; template<> - struct convert { - static Node encode(const boss::Message& rhs) { + struct convert { + static Node encode(const loot::Message& rhs) { Node node; node["condition"] = rhs.Condition(); node["content"] = rhs.Content(); - if (rhs.Type() == boss::g_message_say) + if (rhs.Type() == loot::Message::say) node["type"] = "say"; - else if (rhs.Type() == boss::g_message_warn) + else if (rhs.Type() == loot::Message::warn) node["type"] = "warn"; else node["type"] = "error"; @@ -189,7 +191,7 @@ namespace YAML { return node; } - static bool decode(const Node& node, boss::Message& rhs) { + static bool decode(const Node& node, loot::Message& rhs) { if(!node.IsMap() || !node["type"] || !node["content"]) return false; @@ -199,25 +201,25 @@ namespace YAML { type = node["type"].as(); if (boost::iequals(type, "say")) - typeNo = boss::g_message_say; + typeNo = loot::Message::say; else if (boost::iequals(type, "warn")) - typeNo = boss::g_message_warn; + typeNo = loot::Message::warn; else - typeNo = boss::g_message_error; + typeNo = loot::Message::error; } - std::vector content; + std::vector content; if (node["content"].IsSequence()) - content = node["content"].as< std::vector >(); + content = node["content"].as< std::vector >(); else { - content.push_back(boss::MessageContent(node["content"].as())); + content.push_back(loot::MessageContent(node["content"].as(), loot::Language::english)); } //Check now that at least one item in content is English if there are multiple items. if (content.size() > 1) { bool found = false; - for (std::vector::const_iterator it=content.begin(), endit=content.end(); it != endit; ++it) { - if (it->Language() == boss::g_lang_english) + for (const auto &mc: content) { + if (mc.Language() == loot::Language::english) found = true; } if (!found) @@ -228,14 +230,14 @@ namespace YAML { if (node["condition"]) condition = node["condition"].as(); - rhs = boss::Message(typeNo, content, condition); + rhs = loot::Message(typeNo, content, condition); return true; } }; template<> - struct convert { - static Node encode(const boss::File& rhs) { + struct convert { + static Node encode(const loot::File& rhs) { Node node; node["condition"] = rhs.Condition(); node["name"] = rhs.Name(); @@ -243,7 +245,7 @@ namespace YAML { return node; } - static bool decode(const Node& node, boss::File& rhs) { + static bool decode(const Node& node, loot::File& rhs) { if(node.IsMap()) { std::string condition, name, display; if (node["condition"]) @@ -252,16 +254,16 @@ namespace YAML { name = node["name"].as(); if (node["display"]) display = node["display"].as(); - rhs = boss::File(name, display, condition); + rhs = loot::File(name, display, condition); } else - rhs = boss::File(node.as()); + rhs = loot::File(node.as()); return true; } }; template<> - struct convert { - static Node encode(const boss::Tag& rhs) { + struct convert { + static Node encode(const loot::Tag& rhs) { Node node; node["condition"] = rhs.Condition(); if (rhs.IsAddition()) @@ -271,7 +273,7 @@ namespace YAML { return node; } - static bool decode(const Node& node, boss::Tag& rhs) { + static bool decode(const Node& node, loot::Tag& rhs) { std::string condition, tag; if(node.IsMap()) { if (node["condition"]) @@ -282,9 +284,9 @@ namespace YAML { tag = node.as(); if (tag[0] == '-') - rhs = boss::Tag(tag.substr(1), false, condition); + rhs = loot::Tag(tag.substr(1), false, condition); else - rhs = boss::Tag(tag, true, condition); + rhs = loot::Tag(tag, true, condition); return true; } @@ -294,8 +296,8 @@ namespace YAML { struct convert< std::set > { static Node encode(const std::set& rhs) { Node node; - for (typename std::set::const_iterator it=rhs.begin(), endIt=rhs.end(); it != endIt; ++it) { - node.push_back(*it); + for (const auto &element: rhs) { + node.push_back(element); } return node; } @@ -305,17 +307,40 @@ namespace YAML { return false; rhs.clear(); - for(YAML::const_iterator it=node.begin();it!=node.end();++it) { - rhs.insert(it->as()); + for (const auto &element : node) { + rhs.insert(element.as()); } return true; } }; + template + struct convert< std::unordered_set > { + static Node encode(const std::unordered_set& rhs) { + Node node; + for (const auto &element : rhs) { + node.push_back(element); + } + return node; + } + + static bool decode(const Node& node, std::unordered_set& rhs) { + if (!node.IsSequence()) + return false; + + rhs.clear(); + for (const auto &element : node) { + rhs.insert(element.as()); + } + return true; + + } + }; + template<> - struct convert { - static Node encode(const boss::Plugin& rhs) { + struct convert { + static Node encode(const loot::Plugin& rhs) { Node node; node["name"] = rhs.Name(); node["enabled"] = rhs.Enabled(); @@ -330,12 +355,12 @@ namespace YAML { return node; } - static bool decode(const Node& node, boss::Plugin& rhs) { + static bool decode(const Node& node, loot::Plugin& rhs) { if(!node.IsMap()) return false; if (node["name"]) - rhs = boss::Plugin(node["name"].as()); + rhs = loot::Plugin(node["name"].as()); if (node["enabled"]) rhs.Enabled(node["enabled"].as()); @@ -345,24 +370,24 @@ namespace YAML { } if (node["after"]) - rhs.LoadAfter(node["after"].as< std::set >()); + rhs.LoadAfter(node["after"].as< std::set >()); if (node["req"]) - rhs.Reqs(node["req"].as< std::set >()); + rhs.Reqs(node["req"].as< std::set >()); if (node["inc"]) - rhs.Incs(node["inc"].as< std::set >()); + rhs.Incs(node["inc"].as< std::set >()); if (node["msg"]) - rhs.Messages(node["msg"].as< std::list >()); + rhs.Messages(node["msg"].as< std::list >()); if (node["tag"]) - rhs.Tags(node["tag"].as< std::set >()); + rhs.Tags(node["tag"].as< std::set >()); if (node["dirty"]) - rhs.DirtyInfo(node["dirty"].as< std::set >()); + rhs.DirtyInfo(node["dirty"].as< std::set >()); return true; } }; } -namespace boss { +namespace loot { /////////////////////////////// // Condition parser/evaluator @@ -443,7 +468,7 @@ namespace boss { qi::on_error(invalidPathChars, phoenix::bind(&condition_grammar::SyntaxError, this, qi::labels::_1, qi::labels::_2, qi::labels::_3, qi::labels::_4)); } - void SetGame(boss::Game& g) { + void SetGame(loot::Game& g) { game = &g; } @@ -452,21 +477,21 @@ namespace boss { qi::rule quotedStr, filePath, comparator; qi::rule invalidPathChars; - boss::Game * game; + loot::Game * game; //Eval's exact paths. Check for files and ghosted plugins. void CheckFile(bool& result, const std::string& file) { BOOST_LOG_TRIVIAL(trace) << "Checking to see if the file \"" << file << "\" exists."; - if (file == "BOSS") { + if (file == "LOOT") { result = true; return; } if (!IsSafePath(file)) { BOOST_LOG_TRIVIAL(error) << "Invalid file path: " << file; - throw boss::error(boss::error::invalid_args, boost::locale::translate("Invalid file path:").str() + " " + file); + throw loot::error(loot::error::invalid_args, boost::locale::translate("Invalid file path:").str() + " " + file); } if (IsPlugin(file)) @@ -496,10 +521,14 @@ namespace boss { BOOST_LOG_TRIVIAL(trace) << "Checking to see if any files matching the regex \"" << regexStr << "\" exist."; - boost::regex sepReg("/|(\\\\\\\\)", boost::regex::perl); + regex sepReg("/|(\\\\\\\\)", regex::ECMAScript | regex::icase); std::vector components; - boost::algorithm::split_regex(components, regexStr, sepReg); + std::sregex_token_iterator it(regexStr.begin(), regexStr.end(), sepReg, -1); + std::sregex_token_iterator itend; + for (; it != itend; ++it) { + components.push_back(*it); + } std::string filename = components.back(); components.pop_back(); @@ -514,7 +543,7 @@ namespace boss { if (boost::contains(parent, "../../")){ BOOST_LOG_TRIVIAL(error) << "Invalid folder path: " << parent; - throw boss::error(boss::error::invalid_args, boost::locale::translate("Invalid folder path:").str() + " " + parent); + throw loot::error(loot::error::invalid_args, boost::locale::translate("Invalid folder path:").str() + " " + parent); } //Now we have a valid parent path and a regex filename. Check that @@ -526,16 +555,16 @@ namespace boss { return; } - boost::regex regex; + regex reg; try { - regex = boost::regex(filename, boost::regex::perl|boost::regex::icase); - } catch (boost::regex_error& e) { + reg = regex(filename, regex::ECMAScript | regex::icase); + } catch (exception& /*e*/) { BOOST_LOG_TRIVIAL(error) << "Invalid regex string:" << filename; - throw boss::error(boss::error::invalid_args, boost::locale::translate("Invalid regex string:").str() + " " + filename); + throw loot::error(loot::error::invalid_args, boost::locale::translate("Invalid regex string:").str() + " " + filename); } for (boost::filesystem::directory_iterator itr(parent_path); itr != boost::filesystem::directory_iterator(); ++itr) { - if (boost::regex_match(itr->path().filename().string(), regex)) { + if (regex_match(itr->path().filename().string(), reg)) { result = true; BOOST_LOG_TRIVIAL(trace) << "Matching file found: " << itr->path(); return; @@ -549,17 +578,17 @@ namespace boss { if (!IsSafePath(file)) { BOOST_LOG_TRIVIAL(error) << "Invalid file path: " << file; - throw boss::error(boss::error::invalid_args, boost::locale::translate("Invalid file path:").str() + " " + file); + throw loot::error(loot::error::invalid_args, boost::locale::translate("Invalid file path:").str() + " " + file); } uint32_t crc; - boost::unordered_map::iterator it = game->crcCache.find(boost::to_lower_copy(file)); + unordered_map::iterator it = game->crcCache.find(boost::to_lower_copy(file)); if (it != game->crcCache.end()) crc = it->second; else { - if (file == "BOSS") - crc = GetCrc32(boost::filesystem::absolute("BOSS.exe")); + if (file == "LOOT") + crc = GetCrc32(boost::filesystem::absolute("LOOT.exe")); if (boost::filesystem::exists(game->DataPath() / file)) crc = GetCrc32(game->DataPath() / file); else if (IsPlugin(file) && boost::filesystem::exists(game->DataPath() / (file + ".ghost"))) @@ -589,8 +618,8 @@ namespace boss { Version givenVersion = Version(version); Version trueVersion; - if (file == "BOSS") - trueVersion = Version(boost::filesystem::absolute("BOSS.exe")); + if (file == "LOOT") + trueVersion = Version(boost::filesystem::absolute("LOOT.exe")); else if (IsPlugin(file)) { Plugin plugin(*game, file, true); trueVersion = Version(plugin.Version()); @@ -611,7 +640,7 @@ namespace boss { } void CheckActive(bool& result, const std::string& file) { - if (file == "BOSS") + if (file == "LOOT") result = false; else result = game->IsActive(file); @@ -626,7 +655,7 @@ namespace boss { BOOST_LOG_TRIVIAL(error) << "Expected \"" << what.tag << "\" at \"" << context << "\"."; - throw boss::error(boss::error::condition_eval_fail, (boost::format(boost::locale::translate("Expected \"%1%\" at \"%2%\".")) % what.tag % context).str()); + throw loot::error(loot::error::condition_eval_fail, (boost::format(boost::locale::translate("Expected \"%1%\" at \"%2%\".")) % what.tag % context).str()); } //Checks that the path (not regex) doesn't go outside any game folders. @@ -638,7 +667,7 @@ namespace boss { boost::split(components, path, boost::is_any_of("/\\")); components.pop_back(); std::string parent_path; - for (std::vector::const_iterator it=components.begin(), endIt=components.end()--; it != endIt; ++it) { + for (auto it=components.cbegin(), endIt=components.cend()--; it != endIt; ++it) { if (*it == ".") continue; parent_path += *it + '/'; diff --git a/src/backend/streams.h b/src/backend/streams.h index 85c37999..22d23253 100644 --- a/src/backend/streams.h +++ b/src/backend/streams.h @@ -1,32 +1,33 @@ -/* BOSS +/* LOOT - A plugin load order optimiser for games that use the esp/esm plugin system. + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. Copyright (C) 2013-2014 WrinklyNinja - This file is part of BOSS. + This file is part of LOOT. - BOSS is free software: you can redistribute + LOOT 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. - BOSS is distributed in the hope that it will + LOOT 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 BOSS. If not, see + along with LOOT. If not, see . */ -#ifndef __BOSS_STREAMS__ -#define __BOSS_STREAMS__ +#ifndef __LOOT_STREAMS__ +#define __LOOT_STREAMS__ #include #include -namespace boss { +namespace loot { typedef boost::iostreams::stream< boost::iostreams::file_descriptor_sink > ofstream; typedef boost::iostreams::stream< boost::iostreams::file_descriptor_source > ifstream; typedef boost::iostreams::stream< boost::iostreams::file_descriptor > fstream; diff --git a/src/converter.cpp b/src/converter.cpp deleted file mode 100644 index d76b2657..00000000 --- a/src/converter.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2013-2014 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ - -#include "backend/legacy-parser.h" -#include "backend/generators.h" -#include "backend/streams.h" -#include "backend/metadata.h" - -using namespace std; - -int main(int argc, char * argv[]) { - string in_str, out_str; - if (argc < 3) { - in_str = "masterlist.txt"; - out_str = "masterlist.yaml"; - } else { - in_str = argv[1]; - out_str = argv[2]; - } - - boost::log::core::get()->set_logging_enabled(false); - - // Set up emitter. - YAML::Emitter yout; - yout.SetIndent(2); - - list test_plugins; - list globalMessages; - - //Parse the v2 masterlist and output it as a YAML masterlist. - try { - Loadv2Masterlist(boost::filesystem::path(in_str), test_plugins, globalMessages); - } catch (exception& e) { - cout << "An error was encountered during masterlist parsing. Message: " << e.what() << endl; - return 1; - } - - yout << YAML::BeginMap - << YAML::Key << "globals" << YAML::Value << globalMessages - << YAML::Key << "plugins" << YAML::Value << test_plugins - << YAML::EndMap; - - // Save output. - boost::filesystem::path out_path(out_str); - boss::ofstream out(out_path); - out << yout.c_str(); - out.close(); - - return 0; -} diff --git a/src/gui/app.cpp b/src/gui/app.cpp new file mode 100644 index 00000000..3dc8abae --- /dev/null +++ b/src/gui/app.cpp @@ -0,0 +1,414 @@ +/* LOOT + + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. + + Copyright (C) 2014 WrinklyNinja + + This file is part of LOOT. + + LOOT 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. + + LOOT 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 LOOT. If not, see + . +*/ + +#include "app.h" +#include "handler.h" + +#include "../backend/error.h" +#include "../backend/globals.h" +#include "../backend/helpers.h" +#include "../backend/parsers.h" +#include "../backend/generators.h" +#include "../backend/streams.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using boost::locale::translate; +using boost::format; + +namespace fs = boost::filesystem; + +namespace loot { + + LootState g_app_state = LootState(); + + LootApp::LootApp() {} + + CefRefPtr LootApp::GetBrowserProcessHandler() { + return this; + } + + CefRefPtr LootApp::GetRenderProcessHandler() { + return this; + } + + void LootApp::OnContextInitialized() { + //Make sure this is running in the UI thread. + assert(CefCurrentlyOn(TID_UI)); + + // Information used when creating the native window. + CefWindowInfo window_info; + +#ifdef _WIN32 + // On Windows we need to specify certain flags that will be passed to CreateWindowEx(). + window_info.SetAsPopup(NULL, "LOOT"); +#endif + + // Set the handler for browser-level callbacks. + CefRefPtr handler(new LootHandler()); + + // Specify CEF browser settings here. + CefBrowserSettings browser_settings; + + // Set URL to load. Ignore any command line values. + std::string url = ToFileURL(g_path_report); + + // Create the first browser window. + CefBrowserHost::CreateBrowser(window_info, handler.get(), url, browser_settings, NULL); + } + + void LootApp::OnWebKitInitialized() { + // Create the renderer-side router for query handling. + CefMessageRouterConfig config; + message_router_ = CefMessageRouterRendererSide::Create(config); + } + + bool LootApp::OnProcessMessageReceived( + CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) { + // Handle IPC messages from the browser process... + return message_router_->OnProcessMessageReceived(browser, source_process, message); + } + + + void LootApp::OnContextCreated(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) { + + // Register javascript functions. + message_router_->OnContextCreated(browser, frame, context); + } + + // LootState member functions + //--------------------------- + + LootState::LootState() : _currentGame(0) {} + + void LootState::Init(const std::string& cmdLineGame) { + // Do some preliminary locale / UTF-8 support setup here, in case the settings file reading requires it. + //Boost.Locale initialisation: Specify location of language dictionaries. + boost::locale::generator gen; + gen.add_messages_path(g_path_l10n.string()); + gen.add_messages_domain("loot"); + + //Boost.Locale initialisation: Generate and imbue locales. + locale::global(gen(Language(Language::english).Locale() + ".UTF-8")); + cout.imbue(locale()); + boost::filesystem::path::imbue(locale()); + + // Check if the LOOT local app data folder exists, and create it if not. + if (!fs::exists(g_path_local)) { + BOOST_LOG_TRIVIAL(info) << "Local app data LOOT folder doesn't exist, creating it."; + try { + fs::create_directory(g_path_local); + } + catch (exception& e) { + _initErrors.push_back((format(translate("Error: Could not create LOOT settings file. %1%")) % e.what()).str()); + } + } + if (fs::exists(g_path_settings)) { + try { + loot::ifstream in(g_path_settings); + _settings = YAML::Load(in); + in.close(); + } + catch (exception& e) { + _initErrors.push_back((format(translate("Error: Settings parsing failed. %1%")) % e.what()).str()); + } + } + // Check if the settings are valid (or if they don't exist). + if (!AreSettingsValid()) { + _settings = GetDefaultSettings(); + } + + //Set up logging. + boost::log::add_file_log( + boost::log::keywords::file_name = g_path_log.string().c_str(), + boost::log::keywords::auto_flush = true, + boost::log::keywords::format = ( + boost::log::expressions::stream + << "[" << boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%H:%M:%S") << "]" + << " [" << boost::log::trivial::severity << "]: " + << boost::log::expressions::smessage + ) + ); + boost::log::add_common_attributes(); + unsigned int verbosity; + if (_settings["debugVerbosity"]) { + verbosity = _settings["debugVerbosity"].as(); + } + if (verbosity == 0) + boost::log::core::get()->set_logging_enabled(false); + else { + boost::log::core::get()->set_logging_enabled(true); + + if (verbosity == 1) + boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::warning); //Log all warnings, errors and fatals. + else if (verbosity == 2) + boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::debug); //Log debugs, infos, warnings, errors and fatals. + else + boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::trace); //Log everything. + } + BOOST_LOG_TRIVIAL(info) << "LOOT Version: " << g_version_major << "." << g_version_minor << "." << g_version_patch; + + // The CEF debug log is appended to, not overwritten, so it gets really long. + // Delete the current CEF debug log. + fs::remove(g_path_local / "CEFDebugLog.txt"); + + // Now that settings have been loaded, set the locale again to handle translations. + if (_settings["language"] && _settings["language"].as() != Language(Language::english).Locale()) { + BOOST_LOG_TRIVIAL(debug) << "Initialising language settings."; + loot::Language lang(_settings["language"].as()); + BOOST_LOG_TRIVIAL(debug) << "Selected language: " << lang.Name(); + + //Boost.Locale initialisation: Generate and imbue locales. + locale::global(gen(lang.Locale() + ".UTF-8")); + cout.imbue(locale()); + boost::filesystem::path::imbue(locale()); + } + + // Detect games & select startup game + //----------------------------------- + + //Detect installed games. + BOOST_LOG_TRIVIAL(debug) << "Detecting installed games."; + try { + _games = GetGames(_settings); + } + catch (YAML::Exception& e) { + BOOST_LOG_TRIVIAL(error) << "Games' settings parsing failed. " << e.what(); + _initErrors.push_back((format(translate("Error: Games' settings parsing failed. %1%")) % e.what()).str()); + // Now redo, but with no games settings, so only the hardcoded defaults get loaded. It means the user can + // at least still then edit them. + _games = GetGames(YAML::Node()); + } + + try { + BOOST_LOG_TRIVIAL(debug) << "Selecting game."; + _currentGame = SelectGame(_settings, _games, cmdLineGame); + BOOST_LOG_TRIVIAL(debug) << "Initialising game-specific settings."; + _games[_currentGame].Init(); + } + catch (loot::error &e) { + if (e.code() == loot::error::no_game_detected) { + BOOST_LOG_TRIVIAL(error) << e.what(); + _initErrors.push_back(e.what()); + } + else { + BOOST_LOG_TRIVIAL(error) << "Game-specific settings could not be initialised. " << e.what(); + _initErrors.push_back((format(translate("Error: Game-specific settings could not be initialised. %1%")) % e.what()).str()); + } + } + BOOST_LOG_TRIVIAL(debug) << "Game selected is " << _games[_currentGame].Name(); + } + + const std::vector& LootState::InitErrors() const { + return _initErrors; + } + + + void LootState::UpdateGames(std::vector& games) { + unordered_set newGameFolders; + + // Update existing games, add new games. + for (auto &game : games) { + auto pos = find(_games.begin(), _games.end(), game); + + if (pos != _games.end()) { + pos->SetDetails(game.Name(), game.Master(), game.RepoURL(), game.RepoBranch(), game.GamePath().string(), game.RegistryKey()); + } + else { + _games.push_back(game); + } + + newGameFolders.insert(game.FolderName()); + } + // Remove deleted games. As the current game is stored using its index, + // removing an earlier game may invalidate it. + for (auto it = _games.begin(); it != _games.end();) { + if (newGameFolders.find(it->FolderName()) == newGameFolders.end()) { + if (distance(_games.begin(), it) < _currentGame) { + // Deleting a game before the current game, so the current game's + // index decreases by one. + --_currentGame; + } + it = _games.erase(it); + } + else + ++it; + } + } + + void LootState::ChangeGame(const std::string& newGameFolder) { + BOOST_LOG_TRIVIAL(debug) << "Changing current game to that with folder: " << newGameFolder; + auto it = find(_games.begin(), _games.end(), newGameFolder); + + _currentGame = std::distance(_games.begin(), it); + _games[_currentGame].Init(); + BOOST_LOG_TRIVIAL(debug) << "New game is " << _games[_currentGame].Name(); + } + + Game& LootState::CurrentGame() { + return _games[_currentGame]; + } + + std::vector LootState::InstalledGames() const { + vector installedGames; + for (const auto &game : _games) { + if (game.IsInstalled()) + installedGames.push_back(game.FolderName()); + } + return installedGames; + } + + const YAML::Node& LootState::GetSettings() const { + return _settings; + } + + void LootState::UpdateSettings(const YAML::Node& settings) { + _settings = settings; + } + + void LootState::SaveSettings() { + _settings["lastGame"] = _games[_currentGame].FolderName(); + + //Save settings. + try { + BOOST_LOG_TRIVIAL(debug) << "Saving LOOT settings."; + YAML::Emitter yout; + yout.SetIndent(2); + yout << _settings; + + loot::ofstream out(loot::g_path_settings); + out << yout.c_str(); + out.close(); + } + catch (std::exception &e) { + BOOST_LOG_TRIVIAL(error) << "Failed to save LOOT's settings. Error: " << e.what(); + } + } + + bool LootState::AreSettingsValid() { + if (!_settings["language"]) { + if (_settings["Language"]) { + // Conversion from 0.6 key. + _settings["language"] = _settings["Language"]; + _settings.remove("Language"); + } else + return false; + } + if (!_settings["game"]) { + if (_settings["Game"]) { + // Conversion from 0.6 key. + _settings["game"] = _settings["Game"]; + _settings.remove("Game"); + } + else + return false; + } + if (!_settings["lastGame"]) { + if (_settings["Last Game"]) { + // Conversion from 0.6 key. + _settings["lastGame"] = _settings["Last Game"]; + _settings.remove("Last Game"); + } + else + return false; + } + if (!_settings["debugVerbosity"]) { + if (_settings["Debug Verbosity"]) { + // Conversion from 0.6 key. + _settings["debugVerbosity"] = _settings["Debug Verbosity"]; + _settings.remove("Debug Verbosity"); + } + else + return false; + } + if (!_settings["updateMasterlist"]) + if (_settings["Update Masterlist"]) { + // Conversion from 0.6 key. + _settings["updateMasterlist"] = _settings["Update Masterlist"]; + _settings.remove("Update Masterlist"); + } + else + return false; + if (!_settings["games"]) { + if (_settings["Games"]) { + // Conversion from 0.6 key. + _settings["games"] = _settings["Games"]; + + for (auto &node : _settings["games"]) { + if (node["url"]) { + node["repo"] = node["url"]; + node["branch"] = "master"; + node.remove("url"); + } + } + + _settings.remove("Games"); + } + else + return false; + } + + if (_settings["windows"]) + _settings.remove("windows"); + + return true; + } + + YAML::Node LootState::GetDefaultSettings() { + YAML::Node root; + + root["language"] = "en"; + root["game"] = "auto"; + root["lastGame"] = "auto"; + root["debugVerbosity"] = 0; + root["updateMasterlist"] = true; + + std::vector games; + games.push_back(Game(Game::tes4)); + games.push_back(Game(Game::tes5)); + games.push_back(Game(Game::fo3)); + games.push_back(Game(Game::fonv)); + games.push_back(Game(Game::tes4, "Nehrim").SetDetails("Nehrim - At Fate's Edge", "Nehrim.esm", "https://github.com/loot/oblivion.git", "master", "", "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Nehrim - At Fate's Edge_is1\\InstallLocation")); + + root["games"] = games; + + return root; + } +} \ No newline at end of file diff --git a/src/gui/app.h b/src/gui/app.h new file mode 100644 index 00000000..33cae986 --- /dev/null +++ b/src/gui/app.h @@ -0,0 +1,96 @@ +/* LOOT + + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. + + Copyright (C) 2014 WrinklyNinja + + This file is part of LOOT. + + LOOT 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. + + LOOT 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 LOOT. If not, see + . +*/ + +#ifndef __LOOT_GUI_APP__ +#define __LOOT_GUI_APP__ + +#include "../backend/game.h" + +#include +#include + +#include + +namespace loot { + + class LootApp : public CefApp, + public CefBrowserProcessHandler, + public CefRenderProcessHandler { + public: + LootApp(); + + // Override CefApp methods. + virtual CefRefPtr GetBrowserProcessHandler() OVERRIDE; + virtual CefRefPtr GetRenderProcessHandler() OVERRIDE; + + // Override CefBrowserProcessHandler methods. + virtual void OnContextInitialized() OVERRIDE; + virtual void OnWebKitInitialized() OVERRIDE; + + // Override CefRenderProcessHandler methods. + virtual bool OnProcessMessageReceived(CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) OVERRIDE; + private: + CefRefPtr message_router_; + + virtual void OnContextCreated(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) OVERRIDE; + + IMPLEMENT_REFCOUNTING(LootApp); + }; + + class LootState { + public: + LootState(); + + // Init may fail with no + void Init(const std::string& cmdLineGame); + const std::vector& InitErrors() const; + + Game& CurrentGame(); + void ChangeGame(const std::string& newGameFolder); + void UpdateGames(std::vector& games); + // Get the folder names of the installed games. + std::vector InstalledGames() const; + + const YAML::Node& GetSettings() const; + void UpdateSettings(const YAML::Node& settings); + void SaveSettings(); + private: + YAML::Node _settings; + std::vector _games; + size_t _currentGame; + std::vector _initErrors; + + // Check if the settings file has the right root keys (doesn't check their values). + bool AreSettingsValid(); + YAML::Node GetDefaultSettings(); + }; + + extern LootState g_app_state; +} + +#endif \ No newline at end of file diff --git a/src/gui/editor.cpp b/src/gui/editor.cpp deleted file mode 100644 index 49370cee..00000000 --- a/src/gui/editor.cpp +++ /dev/null @@ -1,1280 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2013-2014 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ - -#include "editor.h" -#include "../backend/generators.h" -#include "../backend/streams.h" - -#include -#include -#include - -#include -#include - -using namespace std; - -////////////////////////////// -// TextDropTarget class -////////////////////////////// - -TextDropTarget::TextDropTarget(wxListView * owner, wxStaticText * name) : targetOwner(owner), targetName(name) {} - -bool TextDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString &data) { - if (data == targetName->GetLabelText() || targetOwner->FindItem(-1, data) != wxNOT_FOUND) - return false; - targetOwner->InsertItem(targetOwner->GetItemCount(), data); - targetOwner->SetColumnWidth(0, wxLIST_AUTOSIZE); - return true; -} - -/////////////////////////////////// -// Common Editor Class -/////////////////////////////////// - -CommonEditor::CommonEditor(const std::list& plugins, const boss::Game& game) : _basePlugins(plugins), _game(game) {} - -CommonEditor::CommonEditor(const std::list& plugins, const boss::Game& game, std::list& editedPlugins) : _basePlugins(plugins), _game(game), _editedPlugins(editedPlugins) {} - -boss::Plugin CommonEditor::GetMasterData(const wxString& plugin) const { - BOOST_LOG_TRIVIAL(debug) << "Getting hardcoded and masterlist metadata for plugin: " << plugin.ToUTF8(); - boss::Plugin p; - boss::Plugin p_in(string(plugin.ToUTF8())); - - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), p_in); - - if (it != _basePlugins.end()) - p = *it; - - return p; -} - -boss::Plugin CommonEditor::GetUserData(const wxString& plugin) const { - BOOST_LOG_TRIVIAL(debug) << "Getting userlist metadata for plugin: " << plugin.ToUTF8(); - boss::Plugin p(string(plugin.ToUTF8())); - - list::const_iterator it = std::find(_editedPlugins.begin(), _editedPlugins.end(), p); - - if (it != _editedPlugins.end()) - p = *it; - - return p; -} - -void CommonEditor::ApplyEdits(const wxString& plugin, wxListView * wxList) { - BOOST_LOG_TRIVIAL(debug) << "Applying edits to plugin: " << plugin.ToUTF8(); - - //Get recorded data. - boss::Plugin master(GetMasterData(plugin)); - boss::Plugin edited(GetNewData(plugin)); - - boss::Plugin diff = master.DiffMetadata(edited); - - list::iterator pos = std::find(_editedPlugins.begin(), _editedPlugins.end(), diff); - long i = wxList->FindItem(-1, plugin); - - if (!diff.HasNameOnly()) { - wxList->SetItemFont(i, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold()); - if (pos != _editedPlugins.end()) - *pos = diff; - else - _editedPlugins.push_back(diff); - } - else { - wxList->SetItemFont(i, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); - if (pos != _editedPlugins.end()) - _editedPlugins.erase(pos); //Prevents unnecessary writes. - } -} - -boss::File CommonEditor::RowToFile(wxListView * list, long row) const { - return boss::File( - string(list->GetItemText(row, 0).ToUTF8()), - string(list->GetItemText(row, 1).ToUTF8()), - string(list->GetItemText(row, 2).ToUTF8()) - ); -} - -boss::Tag CommonEditor::RowToTag(wxListView * list, long row) const { - string name = string(list->GetItemText(row, 1).ToUTF8()); - - if (list->GetItemText(row, 0) == State[1]) - return boss::Tag( - name, - false, - string(list->GetItemText(row, 2).ToUTF8()) - ); - else - return boss::Tag( - name, - true, - string(list->GetItemText(row, 2).ToUTF8()) - ); -} - -boss::PluginDirtyInfo CommonEditor::RowToPluginDirtyInfo(wxListView * list, long row) const { - string text(list->GetItemText(row, 0).ToUTF8()); - uint32_t crc = strtoul(text.c_str(), NULL, 16); - return boss::PluginDirtyInfo( - crc, - atoi(string(list->GetItemText(row, 1).ToUTF8()).c_str()), - atoi(string(list->GetItemText(row, 2).ToUTF8()).c_str()), - atoi(string(list->GetItemText(row, 3).ToUTF8()).c_str()), - string(list->GetItemText(row, 4).ToUTF8())); -} - - -/////////////////////////////////// -// Mini Editor Class -/////////////////////////////////// - - -MiniEditor::MiniEditor(wxWindow *parent, const wxString& title, const std::list& plugins, const boss::Game& game) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), CommonEditor(plugins, game) { - //Initialise editing panel. - editingPanel = new wxPanel(this, wxID_ANY); - - //Initialise controls. - pluginText = new wxStaticText(editingPanel, wxID_ANY, ""); - descText = new wxStaticText(this, wxID_ANY, translate("Please submit any edits made for reasons other than personal preference to the BOSS team so that they may be included in the masterlist.")); - prioritySpin = new wxSpinCtrl(editingPanel, wxID_ANY, "0"); - prioritySpin->SetRange(std::numeric_limits::min(), std::numeric_limits::max()); - filterCheckbox = new wxCheckBox(editingPanel, wxID_ANY, translate("Show only conflicting plugins")); - - pluginList = new wxListView(this, LIST_Plugins, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL); - loadAfterList = new wxListView(editingPanel, LIST_LoadAfter, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL); - loadAfterList->SetDropTarget(new TextDropTarget(loadAfterList, pluginText)); - - removeBtn = new wxButton(editingPanel, BUTTON_RemoveRow, translate("Remove Plugin")); - - //Set up list columns. - pluginList->AppendColumn(translate("Plugin")); - pluginList->AppendColumn(translate("Priority")); - - loadAfterList->AppendColumn(translate("Filename")); - loadAfterList->AppendColumn(translate("Display Name")); - loadAfterList->AppendColumn(translate("Condition")); - loadAfterList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); - loadAfterList->SetColumnWidth(1, 0); //Hide this from the user. - loadAfterList->SetColumnWidth(2, 0); //Hide this from the user. - - //Initialise control states. - removeBtn->Enable(false); - prioritySpin->Enable(false); - filterCheckbox->Enable(false); - - //Make plugin name bold text. - pluginText->SetFont(pluginText->GetFont().Bold()); - - //Set up event handling. - Bind(wxEVT_LIST_ITEM_SELECTED, &MiniEditor::OnPluginSelect, this, LIST_Plugins); - Bind(wxEVT_LIST_BEGIN_DRAG, &MiniEditor::OnDragStart, this, LIST_Plugins); - Bind(wxEVT_LIST_ITEM_SELECTED, &MiniEditor::OnRowSelect, this, LIST_LoadAfter); - Bind(wxEVT_BUTTON, &MiniEditor::OnRemoveRow, this, BUTTON_RemoveRow); - Bind(wxEVT_CHECKBOX, &MiniEditor::OnFilterToggle, this); - Bind(wxEVT_BUTTON, &MiniEditor::OnApply, this, wxID_APPLY); - Bind(wxEVT_SIZE, &MiniEditor::OnResize, this); - - //Set up tooltips. - pluginList->SetToolTip(translate("Select a plugin to edit its load order metadata.")); - loadAfterList->SetToolTip(translate("Drag and drop a plugin here to make the selected plugin load after it. The \"Show only conflicting plugins\" checkbox must be checked.")); - prioritySpin->SetToolTip(translate("Plugins with higher priorities will load after plugins with smaller priorities that they conflict with, unless one must explicitly load after the other.")); - filterCheckbox->SetToolTip(translate("Filters the plugin list to only display plugins which can be loaded after the currently selected plugin, and which either conflict with it, or, if it loads a BSA, also load BSAs. Also enables drag and drop of plugins into the Load After box.")); - removeBtn->SetToolTip(translate("Only newly-added plugins may be removed here. Use the metadata editor to remove other user-added plugins.")); - - //Set up editing panel layout. - wxBoxSizer * mainBox = new wxBoxSizer(wxVERTICAL); - mainBox->Add(pluginText, 0, wxTOP | wxBOTTOM, 10); - mainBox->Add(filterCheckbox, 0, wxTOP | wxBOTTOM, 10); - - wxBoxSizer * hbox2 = new wxBoxSizer(wxHORIZONTAL); - hbox2->Add(new wxStaticText(editingPanel, wxID_ANY, translate("Priority: ")), 0, wxRIGHT, 5); - hbox2->Add(prioritySpin); - mainBox->Add(hbox2, 0, wxEXPAND | wxBOTTOM, 10); - - wxStaticBoxSizer * staticBox = new wxStaticBoxSizer(wxVERTICAL, editingPanel, translate("Load After")); - staticBox->Add(loadAfterList, 1, wxEXPAND); - staticBox->Add(removeBtn, 0, wxEXPAND | wxALIGN_RIGHT | wxTOP, 5); - mainBox->Add(staticBox, 1, wxEXPAND); - - editingPanel->SetSizerAndFit(mainBox); - editingPanel->Layout(); - - //Set up rest of layout. - wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL); - - wxBoxSizer * hBox = new wxBoxSizer(wxHORIZONTAL); - hBox->Add(pluginList, 1, wxEXPAND | wxALL, 10); - hBox->Add(editingPanel, 0, wxEXPAND | wxTOP | wxBOTTOM | wxRIGHT, 10); - bigBox->Add(hBox, 1, wxEXPAND | wxALL, 5); - - bigBox->Add(descText, 0, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 15); - - //Need to add 'Yes' and 'No' buttons. - wxSizer * sizer = CreateSeparatedButtonSizer(wxAPPLY | wxCANCEL); - - //Now add buttons to window sizer. - if (sizer != NULL) - bigBox->Add(sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 15); - - //Fill pluginList with the contents of basePlugins. - int i = 0; - for (list::const_iterator it = _basePlugins.begin(); it != _basePlugins.end(); ++it) { - pluginList->InsertItem(i, FromUTF8(it->Name())); - pluginList->SetItem(i, 1, FromUTF8(boss::IntToString(it->Priority()))); - if (it->FormIDs().empty()) { - pluginList->SetItemTextColour(i, wxColour(122, 122, 122)); - } - else if (it->LoadsBSA(_game)) { - pluginList->SetItemTextColour(i, wxColour(0, 142, 219)); - } - ++i; - } - pluginList->SetColumnWidth(0, wxLIST_AUTOSIZE); - pluginList->SetColumnWidth(1, 0); - descText->Wrap(pluginList->GetClientSize().GetWidth()); - - SetBackgroundColour(wxColour(255, 255, 255)); - SetIcon(wxIconLocation("BOSS.exe")); - - editingPanel->Hide(); - SetSizerAndFit(bigBox); -} - -void MiniEditor::OnPluginSelect(wxListEvent& event) { - //Create Plugin object for selected plugin. - wxString selectedPlugin = pluginList->GetItemText(event.GetIndex()); - wxString currentPlugin = pluginText->GetLabelText(); - - //Check if the selected plugin is the same as the current plugin. - if (selectedPlugin != currentPlugin) { - BOOST_LOG_TRIVIAL(debug) << "User selected plugin: " << selectedPlugin.ToUTF8(); - - //Apply any current edits. - if (!currentPlugin.empty()) { - ApplyEdits(currentPlugin, pluginList); - //Also update the item's priority value in the plugins list in case it has changed. - pluginList->SetItem(pluginList->FindItem(-1, currentPlugin), 1, FromUTF8(boss::IntToString(prioritySpin->GetValue()))); - } - - //Merge metadata. - boss::Plugin plugin = GetMasterData(selectedPlugin); - plugin.MergeMetadata(GetUserData(selectedPlugin)); - - //Now fill editor fields with new plugin's info and update control states. - BOOST_LOG_TRIVIAL(debug) << "Filling editor fields with plugin info."; - pluginText->SetLabelText(FromUTF8(plugin.Name())); - - prioritySpin->SetValue(plugin.Priority()); - - loadAfterList->DeleteAllItems(); - set files = plugin.LoadAfter(); - int i = 0; - for (set::const_iterator it = files.begin(), endit = files.end(); it != endit; ++it) { - loadAfterList->InsertItem(i, FromUTF8(it->Name())); - ++i; - } - if (loadAfterList->GetItemCount() == 0) - loadAfterList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); - else - loadAfterList->SetColumnWidth(0, wxLIST_AUTOSIZE); - - //Set control states. - prioritySpin->Enable(true); - filterCheckbox->Enable(true); - removeBtn->Enable(false); - } - - //Change layout. - if (pluginList->GetColumnWidth(1) == 0) - pluginList->SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER); - if (!editingPanel->IsShown()) - editingPanel->Show(); - - //Window may need to be resized. - //Layout() doesn't do anything extra, it automatically gets called by the windows. - //InvalidateBestSize() doesn't do anything useful for the panel or the window. - pluginList->InvalidateBestSize(); //Makes the priority column visible without scrolling. - loadAfterList->InvalidateBestSize(); //Fixes long plugin filenames being cut off. - editingPanel->Fit(); //Fits the editing panel to the pluginText length. - editingPanel->SetMinSize(editingPanel->GetSize()); //Makes sure that the editing panel is not cut off when Fit() is called below. - descText->SetLabel(""); //If this isn't cleared, it'll stop the window resizing properly sometimes. - if (GetBestSize().GetHeight() > GetSize().GetHeight() || GetBestSize().GetWidth() > GetSize().GetWidth()) { - Fit(); - } - else { - descText->SetLabel(translate("Please submit any edits made for reasons other than personal preference to the BOSS team so that they may be included in the masterlist.")); - descText->Wrap(GetClientSize().GetWidth() - 30); - } -} - -void MiniEditor::OnFilterToggle(wxCommandEvent& event) { - //First need to merge the base and edited plugin lists so that the right priority values get displayed. - - list plugins(_basePlugins); - for (list::const_iterator it = _editedPlugins.begin(); it != _editedPlugins.end(); ++it) { - list::iterator pos = std::find(plugins.begin(), plugins.end(), *it); - pos->MergeMetadata(*it); - } - - //Disable list selection. - if (event.IsChecked()) - Unbind(wxEVT_LIST_ITEM_SELECTED, &MiniEditor::OnPluginSelect, this, LIST_Plugins); - else - Bind(wxEVT_LIST_ITEM_SELECTED, &MiniEditor::OnPluginSelect, this, LIST_Plugins); - - pluginList->Freeze(); - if (event.IsChecked()) { - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - list::const_iterator pos = std::find(plugins.begin(), plugins.end(), plugin); - - if (pos != plugins.end()) { - pluginList->DeleteAllItems(); - - bool loadsBSA = pos->LoadsBSA(_game); - - int i = 0; - for (list::const_iterator it = plugins.begin(); it != plugins.end(); ++it) { - //Want to filter to show only those the selected plugin can load after validly, and which also either conflict with it, - //or which load a BSA (if the selected plugin loads a BSA). - if (*it == *pos || !it->MustLoadAfter(*pos) && (pos->DoFormIDsOverlap(*it) || (loadsBSA && it->LoadsBSA(_game)))) { - pluginList->InsertItem(i, FromUTF8(it->Name())); - pluginList->SetItem(i, 1, FromUTF8(boss::IntToString(it->Priority()))); - if (it->FormIDs().empty()) { - pluginList->SetItemTextColour(i, wxColour(122, 122, 122)); - } - else if (it->LoadsBSA(_game)) { - pluginList->SetItemTextColour(i, wxColour(0, 142, 219)); - } - if (std::find(_editedPlugins.begin(), _editedPlugins.end(), *it) != _editedPlugins.end()) { - pluginList->SetItemFont(i, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold()); - } - ++i; - } - } - } - } - else { - pluginList->DeleteAllItems(); - int i = 0; - for (list::const_iterator it = plugins.begin(); it != plugins.end(); ++it) { - pluginList->InsertItem(i, FromUTF8(it->Name())); - pluginList->SetItem(i, 1, FromUTF8(boss::IntToString(it->Priority()))); - if (it->FormIDs().empty()) { - pluginList->SetItemTextColour(i, wxColour(122, 122, 122)); - } - else if (it->LoadsBSA(_game)) { - pluginList->SetItemTextColour(i, wxColour(0, 142, 219)); - } - if (std::find(_editedPlugins.begin(), _editedPlugins.end(), *it) != _editedPlugins.end()) { - pluginList->SetItemFont(i, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold()); - } - ++i; - } - } - - //Now re-select the current plugin in the list. - pluginList->Select(pluginList->FindItem(-1, pluginText->GetLabelText())); - pluginList->Thaw(); - Refresh(); -} - -void MiniEditor::OnRowSelect(wxListEvent& event) { - boss::File file(string(loadAfterList->GetItemText(event.GetIndex(), 0).ToUTF8())); - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); - - if (it != _basePlugins.end()) - plugin = *it; - else - BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name(); - - set loadAfter = plugin.LoadAfter(); - - if (loadAfter.find(file) == loadAfter.end()) { - BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was not found in base plugin metadata. Removal enabled."; - removeBtn->Enable(true); - } - else { - BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was found in base plugin metadata. Removal disabled."; - removeBtn->Enable(false); - } -} - -void MiniEditor::OnRemoveRow(wxCommandEvent& event) { - loadAfterList->DeleteItem(loadAfterList->GetFirstSelected()); - removeBtn->Enable(false); -} - -void MiniEditor::OnDragStart(wxListEvent& event) { - wxTextDataObject data(pluginList->GetItemText(event.GetItem())); - wxDropSource dropSource(pluginList); - dropSource.SetData(data); - wxDragResult result = dropSource.DoDragDrop(); -} - -void MiniEditor::OnApply(wxCommandEvent& event) { - //Apply any current edits. - wxString currentPlugin = pluginText->GetLabelText(); - if (!currentPlugin.empty()) - ApplyEdits(currentPlugin, pluginList); - - EndModal(event.GetId()); -} - -const std::list& MiniEditor::GetEditedPlugins() const { - return _editedPlugins; -} - -boss::Plugin MiniEditor::GetNewData(const wxString& plugin) const { - //Get new data. Because most of it is missing in the MiniEditor, start with the existing data. - boss::Plugin edited(GetMasterData(plugin)); - edited.Priority(prioritySpin->GetValue()); - set files; - for (int i = 0, max = loadAfterList->GetItemCount(); i < max; ++i) { - files.insert(RowToFile(loadAfterList, i)); - } - edited.LoadAfter(files); - - return edited; -} - -void MiniEditor::OnResize(wxSizeEvent& event) { - descText->SetLabel(translate("Please submit any edits made for reasons other than personal preference to the BOSS team so that they may be included in the masterlist.")); - descText->Wrap(GetClientSize().GetWidth()-30); - event.Skip(); -} - -/////////////////////////////////// -// Editor Class -/////////////////////////////////// - -Editor::Editor(wxWindow *parent, const wxString& title, const std::string userlistPath, const std::list& basePlugins, std::list& editedPlugins, const unsigned int language, const boss::Game& game) : wxFrame(parent, wxID_ANY, title), _userlistPath(userlistPath), CommonEditor(basePlugins, game, editedPlugins) { - - //Initialise child windows. - listBook = new wxNotebook(this, BOOK_Lists); - - wxPanel * reqsTab = new wxPanel(listBook); - wxPanel * incsTab = new wxPanel(listBook); - wxPanel * loadAfterTab = new wxPanel(listBook); - wxPanel * messagesTab = new wxPanel(listBook); - wxPanel * tagsTab = new wxPanel(listBook); - wxPanel * dirtyTab = new wxPanel(listBook); - - //Initialise controls. - pluginText = new wxStaticText(this, wxID_ANY, ""); - prioritySpin = new wxSpinCtrl(this, wxID_ANY, "0"); - prioritySpin->SetRange(std::numeric_limits::min(), std::numeric_limits::max()); - enableUserEditsBox = new wxCheckBox(this, wxID_ANY, translate("Enable User Changes")); - - addBtn = new wxButton(this, BUTTON_AddRow, translate("Add File")); - editBtn = new wxButton(this, BUTTON_EditRow, translate("Edit File")); - removeBtn = new wxButton(this, BUTTON_RemoveRow, translate("Remove File")); - applyBtn = new wxButton(this, BUTTON_Apply, translate("Save Changes")); - cancelBtn = new wxButton(this, BUTTON_Cancel, translate("Cancel")); - - pluginList = new wxListView(this, LIST_Plugins, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL); - reqsList = new wxListView(reqsTab, LIST_Reqs, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL); - incsList = new wxListView(incsTab, LIST_Incs, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL); - loadAfterList = new wxListView(loadAfterTab, LIST_LoadAfter, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL); - tagsList = new wxListView(tagsTab, LIST_BashTags, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL); - dirtyList = new wxListView(dirtyTab, LIST_DirtyInfo, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL); - messageList = new MessageList(messagesTab, LIST_Messages, language); - - pluginMenu = new wxMenu(); - - //Tie together notebooks and panels. - listBook->AddPage(reqsTab, translate("Requirements"), true); - listBook->AddPage(incsTab, translate("Incompatibilities")); - listBook->AddPage(loadAfterTab, translate("Load After")); - listBook->AddPage(messagesTab, translate("Messages")); - listBook->AddPage(tagsTab, translate("Bash Tags")); - listBook->AddPage(dirtyTab, translate("Dirty Info")); - - //Set up list columns. - pluginList->AppendColumn(translate("Plugins")); - - reqsList->AppendColumn(translate("Filename")); - reqsList->AppendColumn(translate("Display Name")); - reqsList->AppendColumn(translate("Condition")); - - incsList->AppendColumn(translate("Filename")); - incsList->AppendColumn(translate("Display Name")); - incsList->AppendColumn(translate("Condition")); - - loadAfterList->AppendColumn(translate("Filename")); - loadAfterList->AppendColumn(translate("Display Name")); - loadAfterList->AppendColumn(translate("Condition")); - - tagsList->AppendColumn(translate("Add/Remove")); - tagsList->AppendColumn(translate("Bash Tag")); - tagsList->AppendColumn(translate("Condition")); - - dirtyList->AppendColumn(translate("CRC")); - dirtyList->AppendColumn(translate("ITM Count")); - dirtyList->AppendColumn(translate("UDR Count")); - dirtyList->AppendColumn(translate("Deleted Navmesh Count")); - dirtyList->AppendColumn(translate("Cleaning Utility")); - - //Set up plugin right-click menu. - pluginMenu->Append(MENU_CopyName, translate("Copy Name")); - pluginMenu->Append(MENU_CopyMetadata, translate("Copy Metadata As Text")); - pluginMenu->Append(MENU_ClearMetadata, translate("Remove All User-Added Metadata")); - - //Initialise control states. - addBtn->Enable(false); - editBtn->Enable(false); - removeBtn->Enable(false); - prioritySpin->Enable(false); - enableUserEditsBox->Enable(false); - - //Make plugin name bold text. - wxFont font = pluginText->GetFont(); - font.SetWeight(wxFONTWEIGHT_BOLD); - pluginText->SetFont(font); - - //Set up event handling. - Bind(wxEVT_LIST_ITEM_SELECTED, &Editor::OnPluginSelect, this, LIST_Plugins); - Bind(wxEVT_LIST_ITEM_SELECTED, &Editor::OnRowSelect, this, LIST_Reqs); - Bind(wxEVT_LIST_ITEM_SELECTED, &Editor::OnRowSelect, this, LIST_Incs); - Bind(wxEVT_LIST_ITEM_SELECTED, &Editor::OnRowSelect, this, LIST_LoadAfter); - Bind(wxEVT_LIST_ITEM_SELECTED, &Editor::OnRowSelect, this, LIST_Messages); - Bind(wxEVT_LIST_ITEM_SELECTED, &Editor::OnRowSelect, this, LIST_BashTags); - Bind(wxEVT_LIST_ITEM_SELECTED, &Editor::OnRowSelect, this, LIST_DirtyInfo); - Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, &Editor::OnListBookChange, this, BOOK_Lists); - Bind(wxEVT_BUTTON, &Editor::OnQuit, this, BUTTON_Apply); - Bind(wxEVT_BUTTON, &Editor::OnQuit, this, BUTTON_Cancel); - Bind(wxEVT_BUTTON, &Editor::OnAddRow, this, BUTTON_AddRow); - Bind(wxEVT_BUTTON, &Editor::OnEditRow, this, BUTTON_EditRow); - Bind(wxEVT_BUTTON, &Editor::OnRemoveRow, this, BUTTON_RemoveRow); - Bind(wxEVT_LIST_ITEM_RIGHT_CLICK, &Editor::OnPluginListRightClick, this); - Bind(wxEVT_MENU, &Editor::OnPluginCopyName, this, MENU_CopyName); - Bind(wxEVT_MENU, &Editor::OnPluginCopyMetadata, this, MENU_CopyMetadata); - Bind(wxEVT_MENU, &Editor::OnPluginClearMetadata, this, MENU_ClearMetadata); - - //Set up tooltips. - pluginList->SetToolTip(translate("Select a plugin to edit its load order metadata.")); - prioritySpin->SetToolTip(translate("Plugins with higher priorities will load after plugins with smaller priorities that they conflict with, unless one must explicitly load after the other.")); - enableUserEditsBox->SetToolTip(translate("If unchecked, any user-added metadata will be ignored during sorting.")); - editBtn->SetToolTip(translate("Only user-added data may be removed.")); - removeBtn->SetToolTip(translate("Only user-added data may be removed.")); - - //Set up layout. - wxBoxSizer * bigBox = new wxBoxSizer(wxHORIZONTAL); - - bigBox->Add(pluginList, 1, wxEXPAND|wxALL, 10); - - wxBoxSizer * mainBox = new wxBoxSizer(wxVERTICAL); - - mainBox->Add(pluginText, 0, wxTOP|wxBOTTOM, 10); - - - wxBoxSizer * hbox1 = new wxBoxSizer(wxHORIZONTAL); - hbox1->Add(enableUserEditsBox, 0, wxALIGN_LEFT|wxRIGHT, 10); - hbox1->AddStretchSpacer(1); - hbox1->Add(new wxStaticText(this, wxID_ANY, translate("Priority: ")), 0, wxALIGN_RIGHT|wxLEFT|wxRIGHT, 5); - hbox1->Add(prioritySpin, 0, wxALIGN_RIGHT); - - mainBox->Add(hbox1, 0, wxEXPAND|wxALIGN_RIGHT|wxTOP|wxBOTTOM, 5); - - wxBoxSizer * tabBox1 = new wxBoxSizer(wxVERTICAL); - tabBox1->Add(reqsList, 1, wxEXPAND); - reqsTab->SetSizer(tabBox1); - - wxBoxSizer * tabBox2 = new wxBoxSizer(wxVERTICAL); - tabBox2->Add(incsList, 1, wxEXPAND); - incsTab->SetSizer(tabBox2); - - wxBoxSizer * tabBox3 = new wxBoxSizer(wxVERTICAL); - tabBox3->Add(loadAfterList, 1, wxEXPAND); - loadAfterTab->SetSizer(tabBox3); - - wxBoxSizer * tabBox4 = new wxBoxSizer(wxVERTICAL); - tabBox4->Add(messageList, 1, wxEXPAND); - messagesTab->SetSizer(tabBox4); - - wxBoxSizer * tabBox5 = new wxBoxSizer(wxVERTICAL); - tabBox5->Add(tagsList, 1, wxEXPAND); - tagsTab->SetSizer(tabBox5); - - wxBoxSizer * tabBox6 = new wxBoxSizer(wxVERTICAL); - tabBox6->Add(dirtyList, 1, wxEXPAND); - dirtyTab->SetSizer(tabBox6); - - mainBox->Add(listBook, 1, wxEXPAND|wxTOP|wxBOTTOM, 10); - - wxBoxSizer * hbox2 = new wxBoxSizer(wxHORIZONTAL); - hbox2->Add(addBtn, 0, wxRIGHT, 5); - hbox2->Add(editBtn, 0, wxLEFT|wxRIGHT, 5); - hbox2->Add(removeBtn, 0, wxLEFT, 5); - mainBox->Add(hbox2, 0, wxALIGN_RIGHT); - - mainBox->AddSpacer(30); - - wxBoxSizer * hbox6 = new wxBoxSizer(wxHORIZONTAL); - hbox6->Add(applyBtn, 0, wxRIGHT, 5); - hbox6->Add(cancelBtn, 0, wxLEFT, 5); - mainBox->Add(hbox6, 0, wxALIGN_RIGHT); - - bigBox->Add(mainBox, 2, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 10); - - //Fill pluginList with the contents of basePlugins. - int i = 0; - for (list::const_iterator it = _basePlugins.begin(); it != _basePlugins.end(); ++it) { - pluginList->InsertItem(i, FromUTF8(it->Name())); - if (it->LoadsBSA(_game)) { - pluginList->SetItemTextColour(i, wxColour(0, 142, 219)); - } - if (std::find(_editedPlugins.begin(), _editedPlugins.end(), *it) != _editedPlugins.end()) { - pluginList->SetItemFont(i, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold()); - } - } - pluginList->SetColumnWidth(0, wxLIST_AUTOSIZE); - - SetBackgroundColour(wxColour(255,255,255)); - SetIcon(wxIconLocation("BOSS.exe")); - - SetSizerAndFit(bigBox); - Layout(); -} - -void Editor::OnPluginSelect(wxListEvent& event) { - //Create Plugin object for selected plugin. - wxString selectedPlugin = pluginList->GetItemText(event.GetIndex()); - wxString currentPlugin = pluginText->GetLabelText(); - - //Check if the selected plugin is the same as the current plugin. - if (selectedPlugin != currentPlugin) { - BOOST_LOG_TRIVIAL(debug) << "User selected plugin: " << selectedPlugin.ToUTF8(); - - //Apply any current edits. - if (!currentPlugin.empty()) - ApplyEdits(currentPlugin, pluginList); - - //Merge metadata. - boss::Plugin plugin = GetMasterData(selectedPlugin); - plugin.MergeMetadata(GetUserData(selectedPlugin)); - - //Now fill editor fields with new plugin's info and update control states. - BOOST_LOG_TRIVIAL(debug) << "Filling editor fields with plugin info."; - pluginText->SetLabelText(FromUTF8(plugin.Name())); - - prioritySpin->SetValue(plugin.Priority()); - - enableUserEditsBox->SetValue(plugin.Enabled()); - - loadAfterList->DeleteAllItems(); - reqsList->DeleteAllItems(); - incsList->DeleteAllItems(); - messageList->DeleteAllItems(); - tagsList->DeleteAllItems(); - dirtyList->DeleteAllItems(); - - set files = plugin.LoadAfter(); - int i=0; - for (set::const_iterator it=files.begin(), endit=files.end(); it != endit; ++it) { - loadAfterList->InsertItem(i, FromUTF8(it->Name())); - loadAfterList->SetItem(i, 1, FromUTF8(it->DisplayName())); - loadAfterList->SetItem(i, 2, FromUTF8(it->Condition())); - ++i; - } - if (loadAfterList->GetItemCount() == 0) - loadAfterList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); - else - loadAfterList->SetColumnWidth(0, wxLIST_AUTOSIZE); - - files = plugin.Reqs(); - i=0; - for (set::const_iterator it=files.begin(), endit=files.end(); it != endit; ++it) { - reqsList->InsertItem(i, FromUTF8(it->Name())); - reqsList->SetItem(i, 1, FromUTF8(it->DisplayName())); - reqsList->SetItem(i, 2, FromUTF8(it->Condition())); - ++i; - } - if (reqsList->GetItemCount() == 0) - reqsList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); - else - reqsList->SetColumnWidth(0, wxLIST_AUTOSIZE); - - files = plugin.Incs(); - i=0; - for (set::const_iterator it=files.begin(), endit=files.end(); it != endit; ++it) { - incsList->InsertItem(i, FromUTF8(it->Name())); - incsList->SetItem(i, 1, FromUTF8(it->DisplayName())); - incsList->SetItem(i, 2, FromUTF8(it->Condition())); - ++i; - } - if (incsList->GetItemCount() == 0) - incsList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); - else - incsList->SetColumnWidth(0, wxLIST_AUTOSIZE); - - list messages = plugin.Messages(); - vector vec(messages.begin(), messages.end()); - messageList->SetItems(vec); - - set tags = plugin.Tags(); - i=0; - for (set::const_iterator it=tags.begin(), endit=tags.end(); it != endit; ++it) { - if (it->IsAddition()) - tagsList->InsertItem(i, State[0]); - else - tagsList->InsertItem(i, State[1]); - tagsList->SetItem(i, 1, FromUTF8(it->Name())); - tagsList->SetItem(i, 2, FromUTF8(it->Condition())); - ++i; - } - if (tagsList->GetItemCount() == 0) - tagsList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); - else - tagsList->SetColumnWidth(0, wxLIST_AUTOSIZE); - - set dirtyInfo = plugin.DirtyInfo(); - i=0; - for (set::const_iterator it=dirtyInfo.begin(), endit=dirtyInfo.end(); it != endit; ++it) { - dirtyList->InsertItem(i, FromUTF8(boss::IntToHexString(it->CRC()))); - dirtyList->SetItem(i, 1, FromUTF8(boss::IntToString(it->ITMs()))); - dirtyList->SetItem(i, 2, FromUTF8(boss::IntToString(it->UDRs()))); - dirtyList->SetItem(i, 3, FromUTF8(boss::IntToString(it->DeletedNavmeshes()))); - dirtyList->SetItem(i, 4, FromUTF8(it->CleaningUtility())); - ++i; - } - if (dirtyList->GetItemCount() == 0) - dirtyList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); - else - dirtyList->SetColumnWidth(0, wxLIST_AUTOSIZE); - - //Set control states. - prioritySpin->Enable(true); - enableUserEditsBox->Enable(true); - addBtn->Enable(true); - editBtn->Enable(false); - removeBtn->Enable(false); - } - Fit(); -} - -void Editor::OnPluginListRightClick(wxListEvent& event) { - PopupMenu(pluginMenu); -} - -void Editor::OnPluginCopyName(wxCommandEvent& event) { - if (wxTheClipboard->Open()) { - wxTheClipboard->SetData(new wxTextDataObject(pluginList->GetItemText(pluginList->GetFirstSelected()))); - wxTheClipboard->Close(); - } -} - -void Editor::OnPluginCopyMetadata(wxCommandEvent& event) { - wxString selectedPlugin = pluginList->GetItemText(pluginList->GetFirstSelected()); - boss::Plugin plugin = GetUserData(selectedPlugin); - - string text; - if (plugin.HasNameOnly()) - text = "name: " + plugin.Name(); - else { - YAML::Emitter yout; - yout.SetIndent(2); - yout << plugin; - text = yout.c_str(); - } - - BOOST_LOG_TRIVIAL(info) << "Exported userlist metadata text for \"" << selectedPlugin.ToUTF8() << "\": " << text; - - if (!text.empty() && wxTheClipboard->Open()) { - wxTheClipboard->SetData(new wxTextDataObject(FromUTF8(text))); - wxTheClipboard->Close(); - } -} - -void Editor::OnPluginClearMetadata(wxCommandEvent& event) { - wxMessageDialog dialog(this, - translate("Are you sure you want to clear all existing user-added metadata from this plugin?"), - translate("BOSS: Warning"), - wxYES_NO | wxCANCEL | wxICON_EXCLAMATION); - - if (dialog.ShowModal() == wxID_YES) { - long i = pluginList->GetFirstSelected(); - wxString selectedPlugin = pluginList->GetItemText(i); - boss::Plugin p(string(selectedPlugin.ToUTF8())); - - //Need to clear what's currently in the editor and what's from the userlist. - - list::const_iterator it = std::find(_editedPlugins.begin(), _editedPlugins.end(), p); - - //Delete existing userlist entry. - if (it != _editedPlugins.end()) - _editedPlugins.erase(it); - - //Also clear any unapplied data. Easiest way to do this is to simulate loading the plugin's data again. - pluginText->SetLabelText(""); - pluginList->Select(i, false); - pluginList->Select(i, true); - pluginList->SetItemFont(i, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); - } -} - -void Editor::OnListBookChange(wxBookCtrlEvent& event) { - BOOST_LOG_TRIVIAL(trace) << "Changed list tab."; - if (event.GetSelection() == 0 || event.GetSelection() == 1) { - addBtn->SetLabel(translate("Add File")); - editBtn->SetLabel(translate("Edit File")); - removeBtn->SetLabel(translate("Remove File")); - } else if (event.GetSelection() == 2) { - addBtn->SetLabel(translate("Add Plugin")); - editBtn->SetLabel(translate("Edit Plugin")); - removeBtn->SetLabel(translate("Remove Plugin")); - } else if (event.GetSelection() == 3) { - addBtn->SetLabel(translate("Add Message")); - editBtn->SetLabel(translate("Edit Message")); - removeBtn->SetLabel(translate("Remove Message")); - } else if (event.GetSelection() == 4) { - addBtn->SetLabel(translate("Add Bash Tag")); - editBtn->SetLabel(translate("Edit Bash Tag")); - removeBtn->SetLabel(translate("Remove Bash Tag")); - } else if (event.GetSelection() == 5) { - addBtn->SetLabel(translate("Add Dirty Info")); - editBtn->SetLabel(translate("Edit Dirty Info")); - removeBtn->SetLabel(translate("Remove Dirty Info")); - } - editBtn->Enable(false); - removeBtn->Enable(false); - - reqsList->Select(reqsList->GetFirstSelected(), false); - incsList->Select(incsList->GetFirstSelected(), false); - loadAfterList->Select(loadAfterList->GetFirstSelected(), false); - messageList->Select(messageList->GetFirstSelected(), false); - tagsList->Select(tagsList->GetFirstSelected(), false); - - Layout(); -} - -void Editor::OnAddRow(wxCommandEvent& event) { - if (listBook->GetSelection() < 3) { - BOOST_LOG_TRIVIAL(debug) << "Adding new file row."; - - FileEditDialog * rowDialog = new FileEditDialog(this, translate("BOSS: Add File/Plugin")); - - if (rowDialog->ShowModal() != wxID_OK) { - BOOST_LOG_TRIVIAL(debug) << "Cancelled adding new file row."; - return; - } - - wxListView * list; - if (listBook->GetSelection() == 0) - list = reqsList; - else if (listBook->GetSelection() == 1) - list = incsList; - else - list = loadAfterList; - - long i = list->GetItemCount(); - list->InsertItem(i, rowDialog->GetName()); - list->SetItem(i, 1, rowDialog->GetDisplayName()); - list->SetItem(i, 2, rowDialog->GetCondition()); - } else if (listBook->GetSelection() == 3) { - BOOST_LOG_TRIVIAL(debug) << "Adding new message row."; - - MessageEditDialog * rowDialog = new MessageEditDialog(this, translate("BOSS: Add Message")); - - if (rowDialog->ShowModal() != wxID_OK) { - BOOST_LOG_TRIVIAL(debug) << "Cancelled adding new message row."; - return; - } - - if (rowDialog->GetMessage().Content().empty()) { - BOOST_LOG_TRIVIAL(error) << "No content specified. Row will not be added."; - wxMessageBox( - translate("Error: No content specified. Row will not be added."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - return; - } - - messageList->AppendItem(rowDialog->GetMessage()); - } else if (listBook->GetSelection() == 4) { - BOOST_LOG_TRIVIAL(debug) << "Adding new tag row."; - - TagEditDialog * rowDialog = new TagEditDialog(this, translate("BOSS: Add Tag")); - - if (rowDialog->ShowModal() != wxID_OK) { - BOOST_LOG_TRIVIAL(debug) << "Cancelled adding new tag row."; - return; - } - - long i = tagsList->GetItemCount(); - tagsList->InsertItem(i, rowDialog->GetState()); - tagsList->SetItem(i, 1, rowDialog->GetName()); - tagsList->SetItem(i, 2, rowDialog->GetCondition()); - } else if (listBook->GetSelection() == 5) { - BOOST_LOG_TRIVIAL(debug) << "Adding new dirty info row."; - - DirtInfoEditDialog * rowDialog = new DirtInfoEditDialog(this, translate("BOSS: Add Dirty Info")); - - if (rowDialog->ShowModal() != wxID_OK) { - BOOST_LOG_TRIVIAL(debug) << "Cancelled adding dirty info row."; - return; - } - - long i = tagsList->GetItemCount(); - dirtyList->InsertItem(i, rowDialog->GetCRC()); - dirtyList->SetItem(i, 1, FromUTF8(boss::IntToString(rowDialog->GetITMs()))); - dirtyList->SetItem(i, 2, FromUTF8(boss::IntToString(rowDialog->GetUDRs()))); - dirtyList->SetItem(i, 3, FromUTF8(boss::IntToString(rowDialog->GetDeletedNavmeshes()))); - dirtyList->SetItem(i, 4, rowDialog->GetUtility()); - } -} - -void Editor::OnEditRow(wxCommandEvent& event) { - if (listBook->GetSelection() < 3) { - BOOST_LOG_TRIVIAL(debug) << "Editing file row."; - FileEditDialog * rowDialog = new FileEditDialog(this, translate("BOSS: Edit File/Plugin")); - - wxListView * list; - if (listBook->GetSelection() == 0) - list = reqsList; - else if (listBook->GetSelection() == 1) - list = incsList; - else - list = loadAfterList; - - long i = list->GetFirstSelected(); - - rowDialog->SetValues(list->GetItemText(i, 0), list->GetItemText(i, 1), list->GetItemText(i, 2)); - - if (rowDialog->ShowModal() != wxID_OK) { - BOOST_LOG_TRIVIAL(debug) << "Cancelled editing file row."; - return; - } - - list->SetItem(i, 0, rowDialog->GetName()); - list->SetItem(i, 1, rowDialog->GetDisplayName()); - list->SetItem(i, 2, rowDialog->GetCondition()); - } else if (listBook->GetSelection() == 3) { - BOOST_LOG_TRIVIAL(debug) << "Editing message row."; - MessageEditDialog * rowDialog = new MessageEditDialog(this, translate("BOSS: Edit Message")); - - long i = messageList->GetFirstSelected(); - - rowDialog->SetMessage(messageList->GetItem(i)); - - if (rowDialog->ShowModal() != wxID_OK) { - BOOST_LOG_TRIVIAL(debug) << "Cancelled editing message row."; - return; - } - - if (rowDialog->GetMessage().Content().empty()) { - BOOST_LOG_TRIVIAL(error) << "No content specified. Row will not be edited."; - wxMessageBox( - translate("Error: No content specified. Row will not be edited."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - return; - } - - messageList->SetItem(i, rowDialog->GetMessage()); - } else if (listBook->GetSelection() == 4) { - BOOST_LOG_TRIVIAL(debug) << "Editing tag row."; - TagEditDialog * rowDialog = new TagEditDialog(this, translate("BOSS: Edit Tag")); - - long i = tagsList->GetFirstSelected(); - - int stateNo; - if (tagsList->GetItemText(i, 0) == State[0]) - stateNo = 0; - else - stateNo = 1; - - rowDialog->SetValues(stateNo, tagsList->GetItemText(i, 1), tagsList->GetItemText(i, 2)); - - if (rowDialog->ShowModal() != wxID_OK) { - BOOST_LOG_TRIVIAL(debug) << "Cancelled editing tag row."; - return; - } - - tagsList->SetItem(i, 0, rowDialog->GetState()); - tagsList->SetItem(i, 1, rowDialog->GetName()); - tagsList->SetItem(i, 2, rowDialog->GetCondition()); - } else if (listBook->GetSelection() == 5) { - BOOST_LOG_TRIVIAL(debug) << "Editing dirty info row."; - DirtInfoEditDialog * rowDialog = new DirtInfoEditDialog(this, translate("BOSS: Edit Dirty Info")); - - long i = tagsList->GetFirstSelected(); - - rowDialog->SetValues(tagsList->GetItemText(i, 0), - atoi(string(tagsList->GetItemText(i, 1)).c_str()), - atoi(string(tagsList->GetItemText(i, 2)).c_str()), - atoi(string(tagsList->GetItemText(i, 3)).c_str()), - tagsList->GetItemText(i, 4)); - - if (rowDialog->ShowModal() != wxID_OK) { - BOOST_LOG_TRIVIAL(debug) << "Cancelled editing tag row."; - return; - } - - dirtyList->SetItem(i, 0, rowDialog->GetCRC()); - dirtyList->SetItem(i, 1, FromUTF8(boss::IntToString(rowDialog->GetITMs()))); - dirtyList->SetItem(i, 2, FromUTF8(boss::IntToString(rowDialog->GetUDRs()))); - dirtyList->SetItem(i, 3, FromUTF8(boss::IntToString(rowDialog->GetDeletedNavmeshes()))); - dirtyList->SetItem(i, 4, rowDialog->GetUtility()); - } -} - -void Editor::OnRemoveRow(wxCommandEvent& event) { - BOOST_LOG_TRIVIAL(debug) << "Removing row."; - wxListView * list; - if (listBook->GetSelection() == 0) - list = reqsList; - else if (listBook->GetSelection() == 1) - list = incsList; - else if (listBook->GetSelection() == 2) - list = loadAfterList; - else if (listBook->GetSelection() == 3) - list = messageList; - else - list = tagsList; - - list->DeleteItem(list->GetFirstSelected()); - - editBtn->Enable(false); - removeBtn->Enable(false); -} - -void Editor::OnRowSelect(wxListEvent& event) { - if (event.GetId() == LIST_Reqs) { - - //Create File object, search the masterlist vector for the plugin and search its reqs for this object. - boss::File file = RowToFile(reqsList, event.GetIndex()); - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); - - if (it != _basePlugins.end()) - plugin = *it; - else - BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name(); - - set reqs = plugin.Reqs(); - - if (reqs.find(file) == reqs.end()) { - BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was not found in base plugin metadata. Editing enabled."; - editBtn->Enable(true); - removeBtn->Enable(true); - } else { - BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was found in base plugin metadata. Editing disabled."; - editBtn->Enable(false); - removeBtn->Enable(false); - } - - } else if (event.GetId() == LIST_Incs) { - - boss::File file = RowToFile(incsList, event.GetIndex()); - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); - - if (it != _basePlugins.end()) - plugin = *it; - else - BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name(); - - set incs = plugin.Incs(); - - if (incs.find(file) == incs.end()) { - BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was not found in base plugin metadata. Editing enabled."; - editBtn->Enable(true); - removeBtn->Enable(true); - } else { - BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was found in base plugin metadata. Editing disabled."; - editBtn->Enable(false); - removeBtn->Enable(false); - } - - } else if (event.GetId() == LIST_LoadAfter) { - - boss::File file = RowToFile(loadAfterList, event.GetIndex()); - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); - - if (it != _basePlugins.end()) - plugin = *it; - else - BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name(); - - set loadAfter = plugin.LoadAfter(); - - if (loadAfter.find(file) == loadAfter.end()) { - BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was not found in base plugin metadata. Editing enabled."; - editBtn->Enable(true); - removeBtn->Enable(true); - } else { - BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was found in base plugin metadata. Editing disabled."; - editBtn->Enable(false); - removeBtn->Enable(false); - } - - } else if (event.GetId() == LIST_Messages) { - - boss::Message message = messageList->GetItem(event.GetIndex()); - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); - - if (it != _basePlugins.end()) - plugin = *it; - else - BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name(); - - list messages = plugin.Messages(); - - if (find(messages.begin(), messages.end(), message) == messages.end()) { - BOOST_LOG_TRIVIAL(trace) << "Message \"" << message.ChooseContent(boss::g_lang_any).Str() << "\" was not found in base plugin metadata. Editing enabled."; - editBtn->Enable(true); - removeBtn->Enable(true); - } else { - BOOST_LOG_TRIVIAL(trace) << "Message \"" << message.ChooseContent(boss::g_lang_any).Str() << "\" was found in base plugin metadata. Editing disabled."; - editBtn->Enable(false); - removeBtn->Enable(false); - } - - } else if (event.GetId() == LIST_BashTags) { - - boss::Tag tag = RowToTag(tagsList, event.GetIndex()); - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); - - if (it != _basePlugins.end()) - plugin = *it; - else - BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name(); - - set tags = plugin.Tags(); - - if (tags.find(tag) == tags.end()) { - BOOST_LOG_TRIVIAL(trace) << "Bash Tag \"" << tag.Name() << "\" was not found in base plugin metadata. Editing enabled."; - editBtn->Enable(true); - removeBtn->Enable(true); - } else { - BOOST_LOG_TRIVIAL(trace) << "Bash Tag \"" << tag.Name() << "\" was found in base plugin metadata. Editing disabled."; - editBtn->Enable(false); - removeBtn->Enable(false); - } - - } else { - boss::PluginDirtyInfo dirtyData = RowToPluginDirtyInfo(dirtyList, event.GetIndex()); - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); - - if (it != _basePlugins.end()) - plugin = *it; - else - BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name(); - - set dirtyInfo = plugin.DirtyInfo(); - - if (dirtyInfo.find(dirtyData) == dirtyInfo.end()) { - BOOST_LOG_TRIVIAL(trace) << "Dirty info for CRC \"" << dirtyData.CRC() << "\" was not found in base plugin metadata. Editing enabled."; - editBtn->Enable(true); - removeBtn->Enable(true); - } else { - BOOST_LOG_TRIVIAL(trace) << "Dirty info for CRC \"" << dirtyData.CRC() << "\" was found in base plugin metadata. Editing disabled."; - editBtn->Enable(false); - removeBtn->Enable(false); - } - } -} - -void Editor::OnQuit(wxCommandEvent& event) { - BOOST_LOG_TRIVIAL(debug) << "Exiting metadata editor."; - if (event.GetId() == BUTTON_Apply) { - - //Apply any current edits. - wxString currentPlugin = pluginText->GetLabelText(); - if (!currentPlugin.empty()) - ApplyEdits(currentPlugin, pluginList); - - BOOST_LOG_TRIVIAL(debug) << "Saving metadata edits to userlist."; - - //Save edits to userlist. - YAML::Emitter yout; - yout.SetIndent(2); - yout << YAML::BeginMap - << YAML::Key << "plugins" << YAML::Value << _editedPlugins - << YAML::EndMap; - - boost::filesystem::path p(_userlistPath); - boss::ofstream out(p); - out << yout.c_str(); - out.close(); - } - Close(); -} - -boss::Plugin Editor::GetNewData(const wxString& plugin) const { - BOOST_LOG_TRIVIAL(debug) << "Getting metadata from editor fields for plugin: " << plugin.ToUTF8(); - boss::Plugin p(string(plugin.ToUTF8())); - - p.Priority(prioritySpin->GetValue()); - p.Enabled(enableUserEditsBox->IsChecked()); - - set files; - for (int i=0,max=reqsList->GetItemCount(); i < max; ++i) { - files.insert(RowToFile(reqsList, i)); - } - p.Reqs(files); - files.clear(); - - for (int i=0,max=incsList->GetItemCount(); i < max; ++i) { - files.insert(RowToFile(incsList, i)); - } - p.Incs(files); - files.clear(); - - for (int i=0,max=loadAfterList->GetItemCount(); i < max; ++i) { - files.insert(RowToFile(loadAfterList, i)); - } - p.LoadAfter(files); - - set tags; - for (int i=0,max=tagsList->GetItemCount(); i < max; ++i) { - tags.insert(RowToTag(tagsList, i)); - } - p.Tags(tags); - - set dirtyInfo; - for (int i=0,max=dirtyList->GetItemCount(); i < max; ++i) { - dirtyInfo.insert(RowToPluginDirtyInfo(dirtyList, i)); - } - p.DirtyInfo(dirtyInfo); - - vector vec = messageList->GetItems(); - list messages(vec.begin(), vec.end()); - p.Messages(messages); - - return p; -} diff --git a/src/gui/editor.h b/src/gui/editor.h deleted file mode 100644 index 869095a6..00000000 --- a/src/gui/editor.h +++ /dev/null @@ -1,147 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2013-2014 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ -#ifndef __BOSS_GUI_EDITOR__ -#define __BOSS_GUI_EDITOR__ - -#include "ids.h" -#include "misc.h" -#include "../backend/metadata.h" - -#include -#include -#include -#include -#include -#include -#include - -/* Have two versions of the editor: one mini editor that only contains - controls for editing the load order related metadata, and a full editor - that contains controls for editing all the metadata. - - Both editors need to convert between metadata and control data, and to - keep track of what edits have been made. - - Have a immutable plugin list to keep track of non-user-edit metadata, - and a mutable plugin list to keep track of user-edit metadata. When - recording edits, diff the metadata obtained from the control values with - the metadata in the immutable plugin entry to get the new user-edit metadata. - - If a metadata type's corresponding control is not present (ie. in the mini - editor), then use the immutable plugin entry's metadata for that type. -*/ - -class TextDropTarget : public wxTextDropTarget { //Class to override virtual functions. -public: - TextDropTarget(wxListView * owner, wxStaticText * name); - virtual bool OnDropText(wxCoord x, wxCoord y, const wxString &data); -private: - wxListView * targetOwner; - wxStaticText * targetName; -}; - -class CommonEditor { -public: - CommonEditor(const std::list& plugins, const boss::Game& game); - CommonEditor(const std::list& plugins, const boss::Game& game, std::list& editedPlugins); -protected: - const boss::Game& _game; - const std::list _basePlugins; - std::list _editedPlugins; - - boss::Plugin GetMasterData(const wxString& plugin) const; - boss::Plugin GetUserData(const wxString& plugin) const; - virtual boss::Plugin GetNewData(const wxString& plugin) const = 0; - - void ApplyEdits(const wxString& plugin, wxListView * list); - - boss::File RowToFile(wxListView * list, long row) const; - boss::Tag RowToTag(wxListView * list, long row) const; - boss::PluginDirtyInfo RowToPluginDirtyInfo(wxListView * list, long row) const; -}; - -class MiniEditor : public wxDialog, public CommonEditor { -public: - MiniEditor(wxWindow *parent, const wxString& title, const std::list& plugins, const boss::Game& game); - - void OnPluginSelect(wxListEvent& event); - void OnRowSelect(wxListEvent& event); - void OnRemoveRow(wxCommandEvent& event); - void OnFilterToggle(wxCommandEvent& event); - void OnDragStart(wxListEvent& event); - void OnApply(wxCommandEvent& event); - void OnResize(wxSizeEvent& event); - - const std::list& GetEditedPlugins() const; -private: - wxListView * pluginList; - wxPanel * editingPanel; - wxButton * removeBtn; - wxListView * loadAfterList; - wxCheckBox * filterCheckbox; - wxSpinCtrl * prioritySpin; - wxStaticText * pluginText; - wxStaticText * descText; - - boss::Plugin GetNewData(const wxString& plugin) const; -}; - -class Editor : public wxFrame, public CommonEditor { -public: - Editor(wxWindow *parent, const wxString& title, const std::string userlistPath, const std::list& basePlugins, std::list& editedPlugins, const unsigned int language, const boss::Game& game); - - void OnPluginSelect(wxListEvent& event); - void OnPluginListRightClick(wxListEvent& event); - void OnPluginCopyName(wxCommandEvent& event); - void OnPluginCopyMetadata(wxCommandEvent& event); - void OnPluginClearMetadata(wxCommandEvent& event); - void OnListBookChange(wxBookCtrlEvent& event); - void OnAddRow(wxCommandEvent& event); - void OnEditRow(wxCommandEvent& event); - void OnRemoveRow(wxCommandEvent& event); - void OnRowSelect(wxListEvent& event); - void OnQuit(wxCommandEvent& event); -private: - wxMenu * pluginMenu; - wxButton * addBtn; - wxButton * editBtn; - wxButton * removeBtn; - wxButton * applyBtn; - wxButton * cancelBtn; - wxListView * pluginList; - wxListView * reqsList; - wxListView * incsList; - wxListView * loadAfterList; - MessageList * messageList; - wxListView * tagsList; - wxListView * dirtyList; - wxNotebook * listBook; - wxCheckBox * enableUserEditsBox; - wxSpinCtrl * prioritySpin; - wxStaticText * pluginText; - - const std::string _userlistPath; - - boss::Plugin GetNewData(const wxString& plugin) const; -}; -#endif diff --git a/src/gui/handler.cpp b/src/gui/handler.cpp new file mode 100644 index 00000000..f5273529 --- /dev/null +++ b/src/gui/handler.cpp @@ -0,0 +1,1178 @@ +/* LOOT + + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. + + Copyright (C) 2014 WrinklyNinja + + This file is part of LOOT. + + LOOT 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. + + LOOT 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 LOOT. If not, see + . +*/ + +#include "handler.h" +#include "resource.h" +#include "app.h" + +#include "../backend/json.h" +#include "../backend/parsers.h" +#include "../backend/generators.h" + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +using namespace std; + +using boost::format; + +namespace fs = boost::filesystem; +namespace loc = boost::locale; + +namespace loot { + + namespace { + LootHandler * g_instance = NULL; + } + + // WinHandler methods + //------------------- + + Handler::Handler() {} + + // Called due to cefQuery execution in binding.html. + bool Handler::OnQuery(CefRefPtr browser, + CefRefPtr frame, + int64 query_id, + const CefString& request, + bool persistent, + CefRefPtr callback) { + + if (request == "openReadme") { + try { + OpenReadme(); + callback->Success(""); + } + catch (error &e) { + BOOST_LOG_TRIVIAL(error) << e.what(); + callback->Failure(e.code(), e.what()); + } + catch (exception &e) { + BOOST_LOG_TRIVIAL(error) << e.what(); + callback->Failure(-1, e.what()); + } + return true; + } + else if (request == "openLogLocation") { + try { + OpenLogLocation(); + callback->Success(""); + } + catch (error &e) { + BOOST_LOG_TRIVIAL(error) << e.what(); + callback->Failure(e.code(), e.what()); + } + catch (exception &e) { + BOOST_LOG_TRIVIAL(error) << e.what(); + callback->Failure(-1, e.what()); + } + return true; + } + else if (request == "getVersion") { + callback->Success(GetVersion()); + return true; + } + else if (request == "getSettings") { + callback->Success(GetSettings()); + return true; + } + else if (request == "getLanguages") { + callback->Success(GetLanguages()); + return true; + } + else if (request == "getGameTypes") { + callback->Success(GetGameTypes()); + return true; + } + else if (request == "getInstalledGames") { + callback->Success(GetInstalledGames()); + return true; + } + else if (request == "getGameData") { + BOOST_LOG_TRIVIAL(info) << "Setting LOOT window title bar text to include game name: " << g_app_state.CurrentGame().Name(); + HWND handle = browser->GetHost()->GetWindowHandle(); +#ifdef _WIN32 + SetWindowText(handle, ToWinWide("LOOT: " + g_app_state.CurrentGame().Name()).c_str()); +#endif + try { + callback->Success(GetGameData()); + } + catch (error &e) { + BOOST_LOG_TRIVIAL(error) << "Failed to get game data. " << e.what(); + callback->Failure(e.code(), e.what()); + } + catch (exception &e) { + BOOST_LOG_TRIVIAL(error) << "Failed to get game data. " << e.what(); + callback->Failure(-1, e.what()); + } + return true; + } + else if (request == "cancelFind") { + browser->GetHost()->StopFinding(true); + callback->Success(""); + return true; + } + else if (request == "clearAllMetadata") { + callback->Success(ClearAllMetadata()); + return true; + } + else if (request == "redatePlugins") { + BOOST_LOG_TRIVIAL(debug) << "Redating plugins."; + try { + g_app_state.CurrentGame().RedatePlugins(); + callback->Success(""); + } + catch (error &e) { + BOOST_LOG_TRIVIAL(error) << "Failed to redate plugins. " << e.what(); + callback->Failure(e.code(), e.what()); + } + catch (exception &e) { + BOOST_LOG_TRIVIAL(error) << "Failed to redate plugins. " << e.what(); + callback->Failure(-1, e.what()); + } + + return true; + } + else if (request == "updateMasterlist") { + try { + callback->Success(UpdateMasterlist()); + } + catch (error &e) { + BOOST_LOG_TRIVIAL(error) << "Failed to update the masterlist. " << e.what(); + callback->Failure(e.code(), e.what()); + } + catch (exception &e) { + BOOST_LOG_TRIVIAL(error) << "Failed to update the masterlist. " << e.what(); + callback->Failure(-1, e.what()); + } + return true; + } + else if (request == "sortPlugins") { + callback->Success(SortPlugins()); + return true; + } + else if (request == "getInitErrors") { + YAML::Node node(g_app_state.InitErrors()); + if (node.size() > 0) + callback->Success(JSON::stringify(node)); + else + callback->Success("null"); + return true; + } + else { + // May be a request with arguments. + YAML::Node req; + try { + req = JSON::parse(request.ToString()); + } + catch (exception &e) { + BOOST_LOG_TRIVIAL(error) << "Failed to parse CEF query request \"" << request << "\": " << e.what(); + callback->Failure(-1, e.what()); + return true; + } + + return HandleComplexQuery(browser, req, callback); + } + + return false; + } + + // Handle queries with input arguments. + bool Handler::HandleComplexQuery(CefRefPtr browser, YAML::Node& request, + CefRefPtr callback) { + + + const string requestName = request["name"].as(); + + if (requestName == "find") { + // Has one arg, which is the search string. + Find(browser, request["args"][0].as()); + callback->Success(""); + return true; + } + else if (requestName == "changeGame") { + try { + // Has one arg, which is the folder name of the new game. + g_app_state.ChangeGame(request["args"][0].as()); + + BOOST_LOG_TRIVIAL(info) << "Setting LOOT window title bar text to include game name: " << g_app_state.CurrentGame().Name(); + HWND handle = browser->GetHost()->GetWindowHandle(); +#ifdef _WIN32 + SetWindowText(handle, ToWinWide("LOOT: " + g_app_state.CurrentGame().Name()).c_str()); +#endif + + callback->Success(GetGameData()); + } + catch (loot::error &e) { + BOOST_LOG_TRIVIAL(error) << "Failed to change game. Details: " << e.what(); + callback->Failure(e.code(), string("Failed to change game. Details: ") + e.what()); + } + catch (std::exception& e) { + BOOST_LOG_TRIVIAL(error) << "Failed to change game. Details: " << e.what(); + callback->Failure(-1, string("Failed to change game. Details: ") + e.what()); + } + return true; + } + else if (requestName == "getConflictingPlugins") { + // Has one arg, which is the name of the plugin to get conflicts for. + callback->Success(GetConflictingPlugins(request["args"][0].as())); + return true; + } + else if (requestName == "copyMetadata") { + // Has one arg, which is the name of the plugin to copy metadata for. + try { + CopyMetadata(request["args"][0].as()); + callback->Success(""); + } + catch (loot::error &e) { + BOOST_LOG_TRIVIAL(error) << "Failed to copy plugin metadata. Details: " << e.what(); + callback->Failure(e.code(), string("Failed to copy plugin metadata. Details: ") + e.what()); + } + catch (std::exception& e) { + BOOST_LOG_TRIVIAL(error) << "Failed to copy plugin metadata. Details: " << e.what(); + callback->Failure(-1, string("Failed to copy plugin metadata. Details: ") + e.what()); + } + return true; + } + else if (requestName == "clearPluginMetadata") { + // Has one arg, which is the name of the plugin to copy metadata for. + callback->Success(ClearPluginMetadata(request["args"][0].as())); + return true; + } + else if (requestName == "editorClosed") { + BOOST_LOG_TRIVIAL(debug) << "Editor for plugin closed."; + // One argument, which is the plugin metadata that has changed (+ its name). + callback->Success(ApplyUserEdits(request["args"][0])); + return true; + } + else if (requestName == "closeSettings") { + BOOST_LOG_TRIVIAL(trace) << "Settings dialog closed and changes accepted, updating settings object."; + + // Update the game details and settings. + g_app_state.UpdateSettings(request["args"][0]); + // If the user has deleted a default game, we don't want to restore it now. + // It will be restored when LOOT is next loaded. + vector games(request["args"][0]["games"].as< vector >()); + + g_app_state.UpdateGames(games); + + // Now send back the new list of installed games to the UI. + callback->Success(GetInstalledGames()); + return true; + } + else if (requestName == "applySort") { + BOOST_LOG_TRIVIAL(trace) << "User has accepted sorted load order, applying it."; + try { + g_app_state.CurrentGame().SetLoadOrder(request["args"][0].as>()); + callback->Success(""); + } + catch (error &e) { + BOOST_LOG_TRIVIAL(error) << e.what(); + callback->Failure(e.code(), e.what()); + } + catch (exception &e) { + BOOST_LOG_TRIVIAL(error) << e.what(); + callback->Failure(-1, e.what()); + } + + return true; + } + else if (requestName == "saveFilterState") { + const string id = request["args"][0].as(); + const string value = request["args"][1].as(); + SaveFilterState(id, value); + callback->Success(""); + return true; + } + else if (requestName == "copyContent") { + // Has one arg, just convert it to a YAML output string. + try { + YAML::Emitter yout; + yout.SetIndent(2); + yout << request["args"][0]; + string text = yout.c_str(); + // Get rid of yaml-cpp weirdness. + boost::replace_all(text, "! ", ""); + CopyToClipboard(text); + callback->Success(""); + } + catch (loot::error &e) { + BOOST_LOG_TRIVIAL(error) << "Failed to copy plugin metadata. Details: " << e.what(); + callback->Failure(e.code(), string("Failed to copy plugin metadata. Details: ") + e.what()); + } + catch (std::exception& e) { + BOOST_LOG_TRIVIAL(error) << "Failed to copy plugin metadata. Details: " << e.what(); + callback->Failure(-1, string("Failed to copy plugin metadata. Details: ") + e.what()); + } + return true; + } + return false; + } + + void Handler::Find(CefRefPtr browser, const std::string& search) { + // In case there is a search already running, cancel it. + browser->GetHost()->StopFinding(true); + + // Only one search at a time is allowed, so give a constant identifier, + // and we want case-insensitive forward searching, with no repeated + // searches. + browser->GetHost()->Find(0, search, true, false, false); + } + + std::string Handler::GetConflictingPlugins(const std::string& pluginName) { + BOOST_LOG_TRIVIAL(debug) << "Searching for plugins that conflict with " << pluginName; + + auto pluginIt = g_app_state.CurrentGame().plugins.find(boost::locale::to_lower(pluginName)); + + // Checking for FormID overlap will only work if the plugins have been loaded, so check if + // the plugins have been fully loaded, and if not load all plugins. + if (!g_app_state.CurrentGame().HasBeenLoaded()) + g_app_state.CurrentGame().LoadPlugins(false); + + YAML::Node node; + for (const auto& pluginPair : g_app_state.CurrentGame().plugins) { + if (pluginIt != g_app_state.CurrentGame().plugins.end()) { + if (pluginIt->second.DoFormIDsOverlap(pluginPair.second)) { + BOOST_LOG_TRIVIAL(debug) << "Found conflicting plugin: " << pluginPair.second.Name(); + node["conflicts"].push_back(pluginPair.second.Name()); + } + } + node["crcs"][pluginPair.second.Name()] = pluginPair.second.Crc(); + } + + if (node.size() > 0) + return JSON::stringify(node); + else + return "null"; + } + + void Handler::CopyMetadata(const std::string& pluginName) { + BOOST_LOG_TRIVIAL(debug) << "Copying metadata for plugin " << pluginName; + + // Get metadata from masterlist and userlist. + Plugin plugin = g_app_state.CurrentGame().masterlist.FindPlugin(pluginName); + plugin.MergeMetadata(g_app_state.CurrentGame().userlist.FindPlugin(pluginName)); + + // Generate text representation. + string text; + if (plugin.HasNameOnly()) + text = "name: " + plugin.Name(); + else { + YAML::Emitter yout; + yout.SetIndent(2); + yout << plugin; + text = yout.c_str(); + // Get rid of yaml-cpp weirdness. + boost::replace_all(text, "! ", ""); + } + + CopyToClipboard(text); + + BOOST_LOG_TRIVIAL(info) << "Exported userlist metadata text for \"" << pluginName << "\": " << text; + } + + std::string Handler::ClearPluginMetadata(const std::string& pluginName) { + BOOST_LOG_TRIVIAL(debug) << "Clearing user metadata for plugin " << pluginName; + + g_app_state.CurrentGame().userlist.ErasePlugin(Plugin(pluginName)); + + // Now rederive the displayed metadata from the masterlist. + YAML::Node derivedMetadata = GenerateDerivedMetadata(pluginName); + if (derivedMetadata.size() > 0) + return JSON::stringify(derivedMetadata); + else + return "null"; + } + + void Handler::SaveFilterState(const std::string& id, const std::string& value) { + BOOST_LOG_TRIVIAL(trace) << "Saving state of filter " << id << " as " << value; + YAML::Node settings = g_app_state.GetSettings(); + + if (value == "true") + settings["filters"][id] = true; + else if (value == "false" || value.empty()) + settings["filters"].remove(id); + else + settings["filters"][id] = value; + + g_app_state.UpdateSettings(settings); + } + + std::string Handler::ApplyUserEdits(const YAML::Node& pluginMetadata) { + BOOST_LOG_TRIVIAL(trace) << "Applying user edits for: " << pluginMetadata["name"].as(); + // Create new object for userlist entry. + Plugin newUserlistEntry(pluginMetadata["name"].as()); + + // Find existing userlist entry. + Plugin ulistPlugin = g_app_state.CurrentGame().userlist.FindPlugin(newUserlistEntry); + + // First sort out the priority value. This is only given if it was changed. + BOOST_LOG_TRIVIAL(trace) << "Calculating userlist metadata priority value from Javascript variables."; + if (pluginMetadata["modPriority"] && pluginMetadata["isGlobalPriority"]) { + BOOST_LOG_TRIVIAL(trace) << "Priority value was changed, recalculating..."; + // Priority value was changed, so add it to the userlist data. + int priority = pluginMetadata["modPriority"].as(); + + if (priority >= 0) { + priority += max_priority; + } + else { + priority -= max_priority; + } + newUserlistEntry.Priority(priority); + newUserlistEntry.SetPriorityExplicit(true); + } + else { + // Priority value wasn't changed, use the existing userlist value. + BOOST_LOG_TRIVIAL(trace) << "Priority value is unchanged, using existing userlist value (if it exists)."; + if (!ulistPlugin.HasNameOnly()) { + newUserlistEntry.Priority(ulistPlugin.Priority()); + newUserlistEntry.SetPriorityExplicit(ulistPlugin.IsPriorityExplicit()); + } + } + + // Now the enabled flag. + newUserlistEntry.Enabled(pluginMetadata["userlist"]["enabled"].as()); + + // Now metadata lists. These are given in their entirety, so replace anything that + // currently exists. + BOOST_LOG_TRIVIAL(trace) << "Recording metadata lists from Javascript variables."; + if (pluginMetadata["userlist"]["after"]) + newUserlistEntry.LoadAfter(pluginMetadata["userlist"]["after"].as>()); + if (pluginMetadata["userlist"]["req"]) + newUserlistEntry.Reqs(pluginMetadata["userlist"]["req"].as>()); + if (pluginMetadata["userlist"]["inc"]) + newUserlistEntry.Incs(pluginMetadata["userlist"]["inc"].as>()); + + if (pluginMetadata["userlist"]["msg"]) + newUserlistEntry.Messages(pluginMetadata["userlist"]["msg"].as>()); + if (pluginMetadata["userlist"]["tag"]) + newUserlistEntry.Tags(pluginMetadata["userlist"]["tag"].as>()); + if (pluginMetadata["userlist"]["dirty"]) + newUserlistEntry.DirtyInfo(pluginMetadata["userlist"]["dirty"].as>()); + + // Now replace existing userlist entry with the new one. + if (!ulistPlugin.HasNameOnly()) { + BOOST_LOG_TRIVIAL(trace) << "Replacing existing userlist entry with new metadata."; + if (newUserlistEntry.HasNameOnly()) + g_app_state.CurrentGame().userlist.ErasePlugin(ulistPlugin); + else { + // Set members are static, so just erase and add the new data. + g_app_state.CurrentGame().userlist.ErasePlugin(ulistPlugin); + g_app_state.CurrentGame().userlist.AddPlugin(newUserlistEntry); + } + } + else { + BOOST_LOG_TRIVIAL(trace) << "Adding new metadata to new userlist entry."; + g_app_state.CurrentGame().userlist.AddPlugin(newUserlistEntry); + } + + // Now rederive the derived metadata. + BOOST_LOG_TRIVIAL(trace) << "Returning newly derived display metadata."; + YAML::Node derivedMetadata = GenerateDerivedMetadata(newUserlistEntry.Name()); + if (derivedMetadata.size() > 0) + return JSON::stringify(derivedMetadata); + else + return "null"; + } + + void Handler::OpenReadme() { + BOOST_LOG_TRIVIAL(info) << "Opening LOOT readme."; + // Open readme in default application. + HINSTANCE ret = ShellExecute(0, NULL, ToWinWide(ToFileURL(g_path_readme)).c_str(), NULL, NULL, SW_SHOWNORMAL); + if ((int)ret <= 32) + throw error(error::windows_error, "Shell execute failed."); + } + + void Handler::OpenLogLocation() { + BOOST_LOG_TRIVIAL(info) << "Opening LOOT local appdata folder."; + //Open debug log folder. + HINSTANCE ret = ShellExecute(NULL, L"open", ToWinWide(g_path_log.parent_path().string()).c_str(), NULL, NULL, SW_SHOWNORMAL); + if ((int)ret <= 32) + throw error(error::windows_error, "Shell execute failed."); + } + + std::string Handler::GetVersion() { + BOOST_LOG_TRIVIAL(info) << "Getting LOOT version."; + YAML::Node version(to_string(g_version_major) + "." + to_string(g_version_minor) + "." + to_string(g_version_patch)); + return JSON::stringify(version); + } + + std::string Handler::GetSettings() { + BOOST_LOG_TRIVIAL(info) << "Getting LOOT settings."; + return JSON::stringify(g_app_state.GetSettings()); + } + + std::string Handler::GetLanguages() { + BOOST_LOG_TRIVIAL(info) << "Getting LOOT's supported languages."; + // Need to get an array of language names and their corresponding codes. + YAML::Node temp; + vector names = Language::Names(); + for (const auto& name : names) { + YAML::Node lang; + lang["name"] = name; + lang["locale"] = Language(name).Locale(); + temp.push_back(lang); + } + return JSON::stringify(temp); + } + + std::string Handler::GetGameTypes() { + BOOST_LOG_TRIVIAL(info) << "Getting LOOT's supported game types."; + YAML::Node temp; + temp.push_back(Game(Game::tes4).FolderName()); + temp.push_back(Game(Game::tes5).FolderName()); + temp.push_back(Game(Game::fo3).FolderName()); + temp.push_back(Game(Game::fonv).FolderName()); + return JSON::stringify(temp); + } + + std::string Handler::GetInstalledGames() { + BOOST_LOG_TRIVIAL(info) << "Getting LOOT's detected games."; + YAML::Node temp = YAML::Node(g_app_state.InstalledGames()); + if (temp.size() > 0) + return JSON::stringify(temp); + else + return "[]"; + } + + std::string Handler::GetGameData() { + /* GetGameData() can be called for initialising the UI for a game for the first time + in a session, or it can be called when changing to a game that has previously been + active. In the first case, all data should be loaded, but in the second, only load + order and plugin header info should be re-loaded. + Determine which case it is by checking to see if the game's plugins object is empty. + */ + BOOST_LOG_TRIVIAL(info) << "Getting data specific to LOOT's active game."; + // Get masterlist revision info and parse if it exists. Also get plugin headers info and parse userlist if it exists. + + bool isFirstLoad = g_app_state.CurrentGame().plugins.empty(); + g_app_state.CurrentGame().LoadPlugins(true); + + //Sort plugins into their load order. + list installed; + list loadOrder; + g_app_state.CurrentGame().GetLoadOrder(loadOrder); + for (const auto &pluginName : loadOrder) { + const auto pos = g_app_state.CurrentGame().plugins.find(boost::locale::to_lower(pluginName)); + + if (pos != g_app_state.CurrentGame().plugins.end()) + installed.push_back(pos->second); + } + + if (isFirstLoad) { + //Parse masterlist, don't update it. + if (fs::exists(g_app_state.CurrentGame().MasterlistPath())) { + BOOST_LOG_TRIVIAL(debug) << "Parsing masterlist."; + try { + g_app_state.CurrentGame().masterlist.MetadataList::Load(g_app_state.CurrentGame().MasterlistPath()); + } + catch (exception &e) { + g_app_state.CurrentGame().masterlist.messages.push_back(Message(Message::error, string("An error occurred while parsing the masterlist: ") + e.what())); + } + } + + //Parse userlist. + if (fs::exists(g_app_state.CurrentGame().UserlistPath())) { + BOOST_LOG_TRIVIAL(debug) << "Parsing userlist."; + try { + g_app_state.CurrentGame().userlist.Load(g_app_state.CurrentGame().UserlistPath()); + } + catch (exception &e) { + g_app_state.CurrentGame().userlist.messages.push_back(Message(Message::error, string("An error occurred while parsing the userlist: ") + e.what())); + } + } + } + + // Now convert to a single object that can be turned into a JSON string + //--------------------------------------------------------------------- + + // The data structure is to be set as 'loot.game'. + YAML::Node gameNode; + + // ID the game using its folder value. + gameNode["folder"] = g_app_state.CurrentGame().FolderName(); + + if (isFirstLoad) { + // Store the masterlist revision and date. + gameNode["masterlist"]["revision"] = g_app_state.CurrentGame().masterlist.GetRevision(g_app_state.CurrentGame().MasterlistPath()); + gameNode["masterlist"]["date"] = g_app_state.CurrentGame().masterlist.GetDate(g_app_state.CurrentGame().MasterlistPath()); + } + + // Now store plugin data. + for (const auto& plugin : installed) { + /* Each plugin has members while hold its raw masterlist and userlist data for + the editor, and also processed data for the main display. + */ + YAML::Node pluginNode; + // Find the masterlist metadata for this plugin. Treat Bash Tags from the plugin + // description as part of it. + BOOST_LOG_TRIVIAL(trace) << "Getting masterlist metadata for: " << plugin.Name(); + Plugin mlistPlugin(plugin); + mlistPlugin.MergeMetadata(g_app_state.CurrentGame().masterlist.FindPlugin(plugin)); + + // Now do the same again for any userlist data. + BOOST_LOG_TRIVIAL(trace) << "Getting userlist metadata for: " << plugin.Name(); + Plugin ulistPlugin(g_app_state.CurrentGame().userlist.FindPlugin(plugin)); + + pluginNode["__type"] = "Plugin"; // For conversion back into a JS typed object. + pluginNode["name"] = plugin.Name(); + pluginNode["isActive"] = g_app_state.CurrentGame().IsActive(plugin.Name()); + pluginNode["isDummy"] = false; // Set to false for now because null is a bit iffy and we just don't know yet. Although, we could read the record count from the TES4 header... Usual check is (plugin.second.FormIDs().size() == 0); + pluginNode["loadsBSA"] = plugin.LoadsBSA(g_app_state.CurrentGame()); + pluginNode["crc"] = IntToHexString(plugin.Crc()); + pluginNode["version"] = plugin.Version(); + + if (isFirstLoad) { + if (!mlistPlugin.HasNameOnly()) { + // Now add the masterlist metadata to the pluginNode. + pluginNode["masterlist"]["after"] = mlistPlugin.LoadAfter(); + pluginNode["masterlist"]["req"] = mlistPlugin.Reqs(); + pluginNode["masterlist"]["inc"] = mlistPlugin.Incs(); + pluginNode["masterlist"]["msg"] = mlistPlugin.Messages(); + pluginNode["masterlist"]["tag"] = mlistPlugin.Tags(); + pluginNode["masterlist"]["dirty"] = mlistPlugin.DirtyInfo(); + } + + if (!ulistPlugin.HasNameOnly()) { + // Now add the userlist metadata to the pluginNode. + pluginNode["userlist"]["enabled"] = ulistPlugin.Enabled(); + pluginNode["userlist"]["after"] = ulistPlugin.LoadAfter(); + pluginNode["userlist"]["req"] = ulistPlugin.Reqs(); + pluginNode["userlist"]["inc"] = ulistPlugin.Incs(); + pluginNode["userlist"]["msg"] = ulistPlugin.Messages(); + pluginNode["userlist"]["tag"] = ulistPlugin.Tags(); + pluginNode["userlist"]["dirty"] = ulistPlugin.DirtyInfo(); + } + } + + // Now merge masterlist and userlist metadata and evaluate, + // putting any resulting metadata into the base of the pluginNode. + YAML::Node derivedNode = GenerateDerivedMetadata(plugin, mlistPlugin, ulistPlugin); + + for (auto it = derivedNode.begin(); it != derivedNode.end(); ++it) { + const string key = it->first.as(); + pluginNode[key] = it->second; + } + + gameNode["plugins"].push_back(pluginNode); + } + + if (isFirstLoad) { + //Set language. + unsigned int language; + if (g_app_state.GetSettings()["language"]) + language = Language(g_app_state.GetSettings()["language"].as()).Code(); + else + language = Language::any; + BOOST_LOG_TRIVIAL(info) << "Using message language: " << Language(language).Name(); + + //Evaluate any conditions in the global messages. + BOOST_LOG_TRIVIAL(debug) << "Evaluating global message conditions."; + list messages = g_app_state.CurrentGame().masterlist.messages; + messages.insert(messages.end(), g_app_state.CurrentGame().userlist.messages.begin(), g_app_state.CurrentGame().userlist.messages.end()); + try { + list::iterator it = messages.begin(); + while (it != messages.end()) { + if (!it->EvalCondition(g_app_state.CurrentGame(), language)) + it = messages.erase(it); + else + ++it; + } + } + catch (std::exception& e) { + BOOST_LOG_TRIVIAL(error) << "A global message contains a condition that could not be evaluated. Details: " << e.what(); + messages.push_back(Message(Message::error, (format(loc::translate("A global message contains a condition that could not be evaluated. Details: %1%")) % e.what()).str())); + } + + // Now store global messages from masterlist. + gameNode["globalMessages"] = messages; + } + + return JSON::stringify(gameNode); + } + + std::string Handler::UpdateMasterlist() { + BOOST_LOG_TRIVIAL(debug) << "Updating and parsing masterlist."; + + //Set language. + unsigned int language; + if (g_app_state.GetSettings()["language"]) + language = Language(g_app_state.GetSettings()["language"].as()).Code(); + else + language = Language::any; + BOOST_LOG_TRIVIAL(info) << "Using message language: " << Language(language).Name(); + + // Update / parse masterlist. + bool wasChanged = true; + try { + wasChanged = g_app_state.CurrentGame().masterlist.Load(g_app_state.CurrentGame(), language); + } + catch (loot::error &e) { + if (e.code() == loot::error::ok) { + // There was a parsing error, but roll-back was successful, so the process + // should still complete. + g_app_state.CurrentGame().masterlist.messages.push_back(Message(Message::error, e.what())); + wasChanged = true; + } + else + throw e; + } + + // Now regenerate the JS-side masterlist data if the masterlist was changed. + if (wasChanged) { + // The data structure is to be set as 'loot.game'. + YAML::Node gameNode; + + // Store the masterlist revision and date. + gameNode["masterlist"]["revision"] = g_app_state.CurrentGame().masterlist.GetRevision(g_app_state.CurrentGame().MasterlistPath()); + gameNode["masterlist"]["date"] = g_app_state.CurrentGame().masterlist.GetDate(g_app_state.CurrentGame().MasterlistPath()); + + for (const auto& pluginPair : g_app_state.CurrentGame().plugins) { + Plugin mlistPlugin(pluginPair.second); + mlistPlugin.MergeMetadata(g_app_state.CurrentGame().masterlist.FindPlugin(pluginPair.second)); + + YAML::Node pluginNode; + if (!mlistPlugin.HasNameOnly()) { + // Now add the masterlist metadata to the pluginNode. + pluginNode["masterlist"]["after"] = mlistPlugin.LoadAfter(); + pluginNode["masterlist"]["req"] = mlistPlugin.Reqs(); + pluginNode["masterlist"]["inc"] = mlistPlugin.Incs(); + pluginNode["masterlist"]["msg"] = mlistPlugin.Messages(); + pluginNode["masterlist"]["tag"] = mlistPlugin.Tags(); + pluginNode["masterlist"]["dirty"] = mlistPlugin.DirtyInfo(); + } + + // Now merge masterlist and userlist metadata and evaluate, + // putting any resulting metadata into the base of the pluginNode. + YAML::Node derivedNode = GenerateDerivedMetadata(pluginPair.second.Name()); + + for (auto it = derivedNode.begin(); it != derivedNode.end(); ++it) { + const string key = it->first.as(); + pluginNode[key] = it->second; + } + + gameNode["plugins"].push_back(pluginNode); + } + + //Evaluate any conditions in the global messages. + BOOST_LOG_TRIVIAL(debug) << "Evaluating global message conditions."; + list messages = g_app_state.CurrentGame().masterlist.messages; + try { + list::iterator it = messages.begin(); + while (it != messages.end()) { + if (!it->EvalCondition(g_app_state.CurrentGame(), language)) + it = messages.erase(it); + else + ++it; + } + } + catch (std::exception& e) { + BOOST_LOG_TRIVIAL(error) << "A global message contains a condition that could not be evaluated. Details: " << e.what(); + messages.push_back(Message(Message::error, (format(loc::translate("A global message contains a condition that could not be evaluated. Details: %1%")) % e.what()).str())); + } + + // Now store global messages from masterlist. + gameNode["globalMessages"] = messages; + + return JSON::stringify(gameNode); + } + else + return "null"; + } + + std::string Handler::ClearAllMetadata() { + BOOST_LOG_TRIVIAL(debug) << "Clearing all user metadata."; + // Record which plugins have userlist entries. + vector userlistPlugins; + for (const auto &plugin : g_app_state.CurrentGame().userlist.Plugins()) { + userlistPlugins.push_back(plugin.Name()); + } + BOOST_LOG_TRIVIAL(trace) << "User metadata exists for " << userlistPlugins.size() << " plugins."; + + // Clear the user metadata. + g_app_state.CurrentGame().userlist.clear(); + + // Regenerate the derived metadata (priority, messages, tags and dirty state) + // for any plugins with userlist entries. + YAML::Node pluginsNode; + for (const auto &plugin : userlistPlugins) { + pluginsNode.push_back(GenerateDerivedMetadata(plugin)); + } + BOOST_LOG_TRIVIAL(trace) << "Display metadata rederived for " << pluginsNode.size() << " plugins."; + + if (pluginsNode.size() > 0) + return JSON::stringify(pluginsNode); + else + return "[]"; + } + + std::string Handler::SortPlugins() { + //Set language. + unsigned int language; + if (g_app_state.GetSettings()["language"]) + language = Language(g_app_state.GetSettings()["language"].as()).Code(); + else + language = Language::any; + BOOST_LOG_TRIVIAL(info) << "Using message language: " << Language(language).Name(); + + // Check if the plugins have been fully loaded, and if not load all plugins. + if (!g_app_state.CurrentGame().HasBeenLoaded()) + g_app_state.CurrentGame().LoadPlugins(false); + + //Sort plugins into their load order. + list plugins = g_app_state.CurrentGame().Sort(language, [](const string& message){}); + + YAML::Node node; + for (const auto &plugin : plugins) { + node["loadOrder"].push_back(plugin.Name()); + node["crcs"][plugin.Name()] = plugin.Crc(); + } + + if (node.size() > 0) + return JSON::stringify(node); + else + return "null"; + } + + YAML::Node Handler::GenerateDerivedMetadata(const Plugin& file, const Plugin& masterlist, const Plugin& userlist) { + //Set language. + unsigned int language; + if (g_app_state.GetSettings()["language"]) + language = Language(g_app_state.GetSettings()["language"].as()).Code(); + else + language = Language::any; + BOOST_LOG_TRIVIAL(info) << "Using message language: " << Language(language).Name(); + + // Now rederive the displayed metadata from the masterlist and userlist. + Plugin tempPlugin(file); + + tempPlugin.MergeMetadata(masterlist); + tempPlugin.MergeMetadata(userlist); + + //Evaluate any conditions + BOOST_LOG_TRIVIAL(trace) << "Evaluate conditions for merged plugin data."; + try { + tempPlugin.EvalAllConditions(g_app_state.CurrentGame(), language); + } + catch (std::exception& e) { + BOOST_LOG_TRIVIAL(error) << "\"" << tempPlugin.Name() << "\" contains a condition that could not be evaluated. Details: " << e.what(); + list messages(tempPlugin.Messages()); + messages.push_back(Message(Message::error, (format(loc::translate("\"%1%\" contains a condition that could not be evaluated. Details: %2%")) % tempPlugin.Name() % e.what()).str())); + tempPlugin.Messages(messages); + } + + //Also check install validity. + BOOST_LOG_TRIVIAL(trace) << "Checking that the current install is valid according to this plugin's data."; + bool isDirty = tempPlugin.CheckInstallValidity(g_app_state.CurrentGame()); + + // Now add to pluginNode. + YAML::Node pluginNode; + pluginNode["name"] = tempPlugin.Name(); + pluginNode["modPriority"] = modulo(tempPlugin.Priority(), max_priority); + pluginNode["isGlobalPriority"] = (abs(tempPlugin.Priority()) >= max_priority); + pluginNode["messages"] = tempPlugin.Messages(); + pluginNode["tags"] = tempPlugin.Tags(); + pluginNode["isDirty"] = isDirty; + + return pluginNode; + } + + YAML::Node Handler::GenerateDerivedMetadata(const std::string& pluginName) { + + // Now rederive the displayed metadata from the masterlist and userlist. + auto pluginIt = g_app_state.CurrentGame().plugins.find(boost::locale::to_lower(pluginName)); + if (pluginIt != g_app_state.CurrentGame().plugins.end()) { + + Plugin master(g_app_state.CurrentGame().masterlist.FindPlugin(pluginIt->second)); + Plugin user(g_app_state.CurrentGame().userlist.FindPlugin(pluginIt->second)); + + return this->GenerateDerivedMetadata(pluginIt->second, master, user); + } + + return YAML::Node(); + } + + void Handler::CopyToClipboard(const std::string& text) { +#ifdef _WIN32 + if (!OpenClipboard(NULL)) { + throw loot::error(loot::error::windows_error, "Failed to open the Windows clipboard."); + } + + if (!EmptyClipboard()) { + throw loot::error(loot::error::windows_error, "Failed to empty the Windows clipboard."); + } + + // The clipboard takes a Unicode (ie. UTF-16) string that it then owns and must not + // be destroyed by LOOT. Convert the string, then copy it into a new block of + // memory for the clipboard. + wstring wtext = ToWinWide(text); + wchar_t * wcstr = new wchar_t[wtext.length() + 1]; + wcscpy(wcstr, wtext.c_str()); + + if (SetClipboardData(CF_UNICODETEXT, wcstr) == NULL) { + throw loot::error(loot::error::windows_error, "Failed to copy metadata to the Windows clipboard."); + } + + if (!CloseClipboard()) { + throw loot::error(loot::error::windows_error, "Failed to close the Windows clipboard."); + } +#endif + } + + // LootHandler methods + //-------------------- + + LootHandler::LootHandler() : is_closing_(false) { + assert(!g_instance); + g_instance = this; + } + + LootHandler::~LootHandler() { + g_instance = NULL; + } + + LootHandler* LootHandler::GetInstance() { + return g_instance; + } + + // CefClient methods + //------------------ + + CefRefPtr LootHandler::GetDisplayHandler() { + return this; + } + + CefRefPtr LootHandler::GetLifeSpanHandler() { + return this; + } + + CefRefPtr LootHandler::GetLoadHandler() { + return this; + } + + bool LootHandler::OnProcessMessageReceived( CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) { + return browser_side_router_->OnProcessMessageReceived(browser, source_process, message); + } + + // CefDisplayHandler methods + //-------------------------- + + void LootHandler::OnTitleChange(CefRefPtr browser, + const CefString& title) { + assert(CefCurrentlyOn(TID_UI)); + + CefWindowHandle hwnd = browser->GetHost()->GetWindowHandle(); +#ifdef _WIN32 + SetWindowText(hwnd, ToWinWide(title).c_str()); +#endif + } + + // CefLifeSpanHandler methods + //--------------------------- + + void LootHandler::OnAfterCreated(CefRefPtr browser) { + assert(CefCurrentlyOn(TID_UI)); + + // Set the title bar icon. + HWND hWnd = browser->GetHost()->GetWindowHandle(); + HANDLE hIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(MAINICON), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); + HANDLE hIconSm = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(MAINICON), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); + SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon); + SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm); + + // Set window size & position. + YAML::Node settings = g_app_state.GetSettings(); + + if (settings["window"]["left"] && settings["window"]["top"] && settings["window"]["right"] && settings["window"]["bottom"]) { +#ifdef _WIN32 + RECT rc; + rc.left = settings["window"]["left"].as(); + rc.top = settings["window"]["top"].as(); + rc.right = settings["window"]["right"].as(); + rc.bottom = settings["window"]["bottom"].as(); + + // Fit the saved window size/position to the current monitor setup. + + // Get the nearest monitor to the saved size/pos. + HMONITOR hMonitor; + hMonitor = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST); + + // Get the rect for the monitor's working area. + MONITORINFO mi; + mi.cbSize = sizeof(mi); + GetMonitorInfo(hMonitor, &mi); + + // Clip the saved rect to fit inside the monitor rect. + int width = rc.right - rc.left; + int height = rc.bottom - rc.top; + rc.left = max(mi.rcWork.left, min(mi.rcWork.right - width, rc.left)); + rc.top = max(mi.rcWork.top, min(mi.rcWork.bottom - height, rc.top)); + rc.right = rc.left + width; + rc.bottom = rc.top + height; + + SetWindowPos(hWnd, HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW); +#endif + } + + // Add to the list of existing browsers. + browser_list_.push_back(browser); + + // Create a message router. + CefMessageRouterConfig config; + browser_side_router_ = CefMessageRouterBrowserSide::Create(config); + + browser_side_router_->AddHandler(new Handler(), false); + } + + bool LootHandler::DoClose(CefRefPtr browser) { + assert(CefCurrentlyOn(TID_UI)); + + // Closing the main window requires special handling. See the DoClose() + // documentation in the CEF header for a detailed destription of this + // process. + if (browser_list_.size() == 1) { + // Set a flag to indicate that the window close should be allowed. + is_closing_ = true; + } + + // Allow the close. For windowed browsers this will result in the OS close + // event being sent. + return false; + } + + void LootHandler::OnBeforeClose(CefRefPtr browser) { + assert(CefCurrentlyOn(TID_UI)); + + // Save window size & position. + YAML::Node settings = g_app_state.GetSettings(); + +#ifdef _WIN32 + RECT rc; + GetWindowRect(browser->GetHost()->GetWindowHandle(), &rc); + + settings["window"]["left"] = rc.left; + settings["window"]["top"] = rc.top; + settings["window"]["right"] = rc.right; + settings["window"]["bottom"] = rc.bottom; +#endif + + g_app_state.UpdateSettings(settings); + + // Cancel any javascript callbacks. + browser_side_router_->OnBeforeClose(browser); + + // Remove from the list of existing browsers. + for (BrowserList::iterator bit = browser_list_.begin(); bit != browser_list_.end(); ++bit) { + if ((*bit)->IsSame(browser)) { + browser_list_.erase(bit); + break; + } + } + + if (browser_list_.empty()) { + // All browser windows have closed. Quit the application message loop. + CefQuitMessageLoop(); + } + } + + // CefLoadHandler methods + //----------------------- + + void LootHandler::OnLoadError(CefRefPtr browser, + CefRefPtr frame, + ErrorCode errorCode, + const CefString& errorText, + const CefString& failedUrl) { + assert(CefCurrentlyOn(TID_UI)); + + // Don't display an error for downloaded files. + if (errorCode == ERR_ABORTED) + return; + + // Display a load error message. + std::stringstream ss; + ss << "" + << "

    Failed to load URL " << std::string(failedUrl) + << " with error " << std::string(errorText) << " (" << errorCode + << ").

    "; + + frame->LoadString(ss.str(), failedUrl); + } + + // CefRequestHandler methods + //-------------------------- + + bool LootHandler::OnBeforeBrowse(CefRefPtr< CefBrowser > browser, + CefRefPtr< CefFrame > frame, + CefRefPtr< CefRequest > request, + bool is_redirect) { + + BOOST_LOG_TRIVIAL(trace) << "Attemping to open link: " << request->GetURL().ToString(); + BOOST_LOG_TRIVIAL(trace) << "Comparing with URL: " << ToFileURL(g_path_report); + + if (request->GetURL() == ToFileURL(g_path_report)) { + BOOST_LOG_TRIVIAL(trace) << "Link is to LOOT page, allowing CEF's default handling."; + return false; + } + + BOOST_LOG_TRIVIAL(info) << "Opening link in Windows' default handler."; + // Open readme in default application. + HINSTANCE ret = ShellExecute(0, NULL, request->GetURL().ToWString().c_str(), NULL, NULL, SW_SHOWNORMAL); + if ((int)ret <= 32) + throw error(error::windows_error, "Shell execute failed."); + + return true; + } + + void LootHandler::CloseAllBrowsers(bool force_close) { + + if (!CefCurrentlyOn(TID_UI)) { + // Execute on the UI thread. + CefPostTask(TID_UI, + NewCefRunnableMethod(this, &LootHandler::CloseAllBrowsers, force_close)); + return; + } + + if (browser_list_.empty()) + return; + + for (BrowserList::const_iterator it = browser_list_.begin(); it != browser_list_.end(); ++it) { + (*it)->GetHost()->CloseBrowser(force_close); + } + } + +} \ No newline at end of file diff --git a/src/gui/handler.h b/src/gui/handler.h new file mode 100644 index 00000000..d7d52ff3 --- /dev/null +++ b/src/gui/handler.h @@ -0,0 +1,153 @@ +/* LOOT + + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. + + Copyright (C) 2014 WrinklyNinja + + This file is part of LOOT. + + LOOT 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. + + LOOT 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 LOOT. If not, see + . +*/ + +#ifndef __LOOT_GUI_HANDLER__ +#define __LOOT_GUI_HANDLER__ + +#include "../backend/globals.h" +#include "../backend/helpers.h" + +#include +#include + +#include + +#include + +namespace loot { + + class Handler : public CefMessageRouterBrowserSide::Handler { + public: + Handler(); + + // Called due to cefQuery execution in binding.html. + virtual bool OnQuery(CefRefPtr browser, + CefRefPtr frame, + int64 query_id, + const CefString& request, + bool persistent, + CefRefPtr callback) OVERRIDE; + private: + void OpenReadme(); + void OpenLogLocation(); + std::string GetVersion(); + std::string GetSettings(); + std::string GetLanguages(); + std::string GetGameTypes(); + std::string GetInstalledGames(); + std::string GetGameData(); + std::string UpdateMasterlist(); + std::string ClearAllMetadata(); + std::string SortPlugins(); + + // Handle queries with input arguments. + bool HandleComplexQuery(CefRefPtr browser, YAML::Node& request, + CefRefPtr callback); + + void Find(CefRefPtr browser, const std::string& search); + std::string GetConflictingPlugins(const std::string& pluginName); + void CopyMetadata(const std::string& pluginName); + std::string ClearPluginMetadata(const std::string& pluginName); + void SaveFilterState(const std::string& filterId, const std::string& value); + std::string ApplyUserEdits(const YAML::Node& pluginMetadata); + + YAML::Node Handler::GenerateDerivedMetadata(const std::string& pluginName); + YAML::Node Handler::GenerateDerivedMetadata(const Plugin& file, const Plugin& masterlist, const Plugin& userlist); + + void CopyToClipboard(const std::string& text); + }; + + class LootHandler : public CefClient, + public CefDisplayHandler, + public CefLifeSpanHandler, + public CefLoadHandler, + public CefRequestHandler { + public: + LootHandler(); + ~LootHandler(); + + // Provide access to the single global instance of this object. + static LootHandler * GetInstance(); + + // CefClient methods + //------------------ + virtual CefRefPtr GetDisplayHandler() OVERRIDE; + virtual CefRefPtr GetLifeSpanHandler() OVERRIDE; + virtual CefRefPtr GetLoadHandler() OVERRIDE; + + virtual bool OnProcessMessageReceived(CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) OVERRIDE; + + // CefDisplayHandler methods + //-------------------------- + virtual void OnTitleChange(CefRefPtr browser, + const CefString& title) OVERRIDE; + + // CefLifeSpanHandler methods + //--------------------------- + virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE; + virtual bool DoClose(CefRefPtr browser) OVERRIDE; + virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; + + // CefLoadHandler methods + //----------------------- + virtual void OnLoadError(CefRefPtr browser, + CefRefPtr frame, + ErrorCode errorCode, + const CefString& errorText, + const CefString& failedUrl) OVERRIDE; + + // CefRequestHandler methods + //-------------------------- + + + virtual CefRefPtr GetRequestHandler() OVERRIDE{ + return this; + } + + virtual bool OnBeforeBrowse(CefRefPtr< CefBrowser > browser, + CefRefPtr< CefFrame > frame, + CefRefPtr< CefRequest > request, + bool is_redirect) OVERRIDE; + + // Request that all existing browser windows close. + void CloseAllBrowsers(bool force_close); + + bool IsClosing() const { return is_closing_; } + + private: + // List of existing browser windows. Only accessed on the CEF UI thread. + typedef std::list > BrowserList; + BrowserList browser_list_; + CefRefPtr browser_side_router_; + + bool is_closing_; + + // Include the default reference counting implementation. + IMPLEMENT_REFCOUNTING(LootHandler); + }; +} + +#endif \ No newline at end of file diff --git a/src/gui/ids.cpp b/src/gui/ids.cpp deleted file mode 100644 index 183f5e37..00000000 --- a/src/gui/ids.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2013-2014 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ - -#include "ids.h" -#include "../backend/globals.h" - -#include -#include - -wxString translate(const std::string& str) { - return wxString::FromUTF8(boost::locale::translate(str).str().c_str()); -} - -wxString FromUTF8(const std::string& str) { - return wxString::FromUTF8(str.c_str()); -} - -wxString FromUTF8(const boost::format& f) { - return FromUTF8(f.str()); -} \ No newline at end of file diff --git a/src/gui/ids.h b/src/gui/ids.h deleted file mode 100644 index e28fdff9..00000000 --- a/src/gui/ids.h +++ /dev/null @@ -1,83 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2013-2014 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ - -#ifndef __BOSS_GUI_IDS__ -#define __BOSS_GUI_IDS__ - -#include -#include -#include "wx/wxprec.h" - -#ifndef WX_PRECOMP -# include "wx/wx.h" -#endif - - -enum { - //Main window. - OPTION_EditMetadata = wxID_HIGHEST + 1, // declares an id which will be used to call our button - OPTION_ViewLastReport, - OPTION_SortPlugins, - MENU_ViewDebugLog, - MENU_ShowSettings, - MENU_RedatePlugins, - //Settings window. - LIST_Games, - BUTTON_AddGame, - BUTTON_EditGame, - BUTTON_RemoveGame, - //Editor window. - LIST_Plugins, - LIST_Reqs, - LIST_Incs, - LIST_LoadAfter, - LIST_Messages, - LIST_BashTags, - LIST_DirtyInfo, - LIST_MessageContent, - BUTTON_AddRow, - BUTTON_EditRow, - BUTTON_RemoveRow, - BUTTON_AddContent, - BUTTON_EditContent, - BUTTON_RemoveContent, - BUTTON_Apply, - BUTTON_Cancel, - BOOK_Lists, - MENU_CopyName, - MENU_CopyMetadata, - MENU_ClearMetadata, - //Main window - dynamically created IDs. - MENU_LowestDynamicGameID, - LIST_LoadOrder, - BUTTON_MoveUp, - BUTTON_MoveDown, -}; - -wxString translate(const std::string& str); - -wxString FromUTF8(const std::string& str); - -wxString FromUTF8(const boost::format& f); - -#endif diff --git a/src/gui/main.cpp b/src/gui/main.cpp deleted file mode 100644 index 75c0f89b..00000000 --- a/src/gui/main.cpp +++ /dev/null @@ -1,1128 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2013-2014 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ -#include "main.h" -#include "settings.h" -#include "editor.h" -#include "viewer.h" -#include "misc.h" - -#include "../backend/globals.h" -#include "../backend/metadata.h" -#include "../backend/parsers.h" -#include "../backend/error.h" -#include "../backend/helpers.h" -#include "../backend/generators.h" -#include "../backend/network.h" -#include "../backend/streams.h" -#include "../backend/graph.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define BOOST_THREAD_VERSION 4 - -wxIMPLEMENT_APP(BossGUI); - -using namespace boss; -using namespace std; -using boost::format; - -namespace fs = boost::filesystem; -namespace loc = boost::locale; - - -struct plugin_loader { - plugin_loader(boss::Plugin& plugin, boss::Game& game) : _plugin(plugin), _game(game) { - } - - void operator () () { - _plugin = boss::Plugin(_game, _plugin.Name(), false); - } - - boss::Plugin& _plugin; - boss::Game& _game; - string _filename; - bool _b; -}; - -struct plugin_list_loader { - plugin_list_loader(PluginGraph& graph, boss::Game& game) : _graph(graph), _game(game) {} - - void operator () () { - boss::vertex_it vit, vitend; - for (boost::tie(vit, vitend) = boost::vertices(_graph); vit != vitend; ++vit) { - if (skipPlugins.find(_graph[*vit].Name()) == skipPlugins.end()) { - _graph[*vit] = boss::Plugin(_game, _graph[*vit].Name(), false); - } - } - } - - PluginGraph& _graph; - boss::Game& _game; - set skipPlugins; -}; - -struct masterlist_updater_parser { - masterlist_updater_parser(bool doUpdate, boss::Game& game, list& errors, list& plugins, list& messages, string& revision) : _doUpdate(doUpdate), _game(game), _errors(errors), _plugins(plugins), _messages(messages), _revision(revision) {} - - void operator () () { - - if (_doUpdate) { - BOOST_LOG_TRIVIAL(debug) << "Updating masterlist"; - try { - _revision = UpdateMasterlist(_game, _errors, _plugins, _messages); - } catch (boss::error& e) { - _plugins.clear(); - _messages.clear(); - BOOST_LOG_TRIVIAL(error) << "Masterlist update failed. Details: " << e.what(); - _errors.push_back(boss::Message(boss::g_message_error, (format(loc::translate("Masterlist update failed. Details: %1%")) % e.what()).str())); - } - } - - if (_plugins.empty() && _messages.empty() && fs::exists(_game.MasterlistPath())) { - - BOOST_LOG_TRIVIAL(debug) << "Parsing masterlist..."; - try { - boss::ifstream in(_game.MasterlistPath()); - YAML::Node mlist = YAML::Load(in); - in.close(); - - if (mlist["globals"]) - _messages = mlist["globals"].as< list >(); - if (mlist["plugins"]) - _plugins = mlist["plugins"].as< list >(); - } catch (YAML::Exception& e) { - BOOST_LOG_TRIVIAL(error) << "Masterlist parsing failed. Details: " << e.what(); - _errors.push_back(boss::Message(boss::g_message_error, (format(loc::translate("Masterlist parsing failed. Details: %1%")) % e.what()).str())); - } - BOOST_LOG_TRIVIAL(debug) << "Finished parsing masterlist."; - - } - - if (_revision.empty()) { - if (fs::exists(_game.MasterlistPath())) - _revision = loc::translate("Unknown"); - else - _revision = loc::translate("No masterlist"); - } - } - - bool _doUpdate; - boss::Game& _game; - list& _errors; - list& _plugins; - list& _messages; - string& _revision; -}; - -bool BossGUI::OnInit() { - - //Check if GUI is already running. - wxSingleInstanceChecker *checker = new wxSingleInstanceChecker; - - if (checker->IsAnotherRunning()) { - wxMessageBox( - translate("Error: BOSS is already running. This instance will now quit."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - NULL); - delete checker; // OnExit() won't be called if we return false - checker = NULL; - - return false; - } - - //Load settings. - if (!fs::exists(g_path_settings)) { - try { - if (!fs::exists(g_path_settings.parent_path())) - fs::create_directory(g_path_settings.parent_path()); - } catch (fs::filesystem_error& e) { - wxMessageBox( - translate("Error: Could not create local app data BOSS folder."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - NULL); - return false; - } - GenerateDefaultSettingsFile(g_path_settings.string()); - } - if (fs::exists(g_path_settings)) { - try { - boss::ifstream in(g_path_settings); - _settings = YAML::Load(in); - in.close(); - } catch (YAML::ParserException& e) { - wxMessageBox( - FromUTF8(format(loc::translate("Error: Settings parsing failed. %1%")) % e.what()), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - NULL); - return false; - } - } - - //Set up logging. - boost::log::add_file_log( - boost::log::keywords::file_name = g_path_log.string().c_str(), - boost::log::keywords::format = ( - boost::log::expressions::stream - << "[" << boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%H:%M:%S") << "]" - << " [" << boost::log::trivial::severity << "]: " - << boost::log::expressions::smessage - ) - ); - boost::log::add_common_attributes(); - if (_settings["Debug Verbosity"]) { - unsigned int verbosity = _settings["Debug Verbosity"].as(); - if (verbosity == 0) - boost::log::core::get()->set_logging_enabled(false); - else { - boost::log::core::get()->set_logging_enabled(true); - - if (verbosity == 1) - boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::warning); //Log all warnings, errors and fatals. - else if (verbosity == 2) - boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::debug); //Log debugs, infos, warnings, errors and fatals. - else - boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::trace); //Log everything. - } - } - - - //Set the locale to get encoding and language conversions working correctly. - BOOST_LOG_TRIVIAL(debug) << "Initialising language settings."; - //Defaults in case language string is empty or setting is missing. - string localeId = boss::Language(boss::g_lang_any).Locale() + ".UTF-8"; - wxLanguage wxLang = wxLANGUAGE_ENGLISH; - if (_settings["Language"]) { - boss::Language lang(_settings["Language"].as()); - BOOST_LOG_TRIVIAL(debug) << "Selected language: " << lang.Name(); - localeId = lang.Locale() + ".UTF-8"; - if (lang.Code() == boss::g_lang_english) - wxLang = wxLANGUAGE_ENGLISH; - else if (lang.Code() == boss::g_lang_spanish) - wxLang = wxLANGUAGE_SPANISH; - else if (lang.Code() == boss::g_lang_russian) - wxLang = wxLANGUAGE_RUSSIAN; - else if (lang.Code() == boss::g_lang_french) - wxLang = wxLANGUAGE_FRENCH; - else if (lang.Code() == boss::g_lang_chinese) - wxLang = wxLANGUAGE_CHINESE; - else if (lang.Code() == boss::g_lang_polish) - wxLang = wxLANGUAGE_POLISH; - else if (lang.Code() == boss::g_lang_brazilian_portuguese) - wxLang = wxLANGUAGE_PORTUGUESE_BRAZILIAN; - else if (lang.Code() == boss::g_lang_danish) - wxLang = wxLANGUAGE_DANISH; - } - - //Boost.Locale initialisation: Specify location of language dictionaries. - boost::locale::generator gen; - gen.add_messages_path(g_path_l10n.string()); - gen.add_messages_domain("boss"); - - //Boost.Locale initialisation: Generate and imbue locales. - locale::global(gen(localeId)); - cout.imbue(locale()); - boost::filesystem::path::imbue(locale()); - - //wxWidgets initalisation. - if (wxLocale::IsAvailable(wxLang)) { - BOOST_LOG_TRIVIAL(trace) << "Selected language is available, setting language file paths."; - wxLoc = new wxLocale(wxLang); - - wxLocale::AddCatalogLookupPathPrefix(g_path_l10n.string().c_str()); - - wxLoc->AddCatalog("wxstd"); - - if (!wxLoc->IsOk()) { - BOOST_LOG_TRIVIAL(error) << "Could not load translations."; - wxMessageBox( - translate("Error: Could not apply translation."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - NULL); - } - } else { - wxLoc = new wxLocale(wxLANGUAGE_ENGLISH); - - BOOST_LOG_TRIVIAL(error) << "The selected language is not available on this system."; - wxMessageBox( - translate("Error: The selected language is not available on this system."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - NULL); - } - - //Detect installed games. - BOOST_LOG_TRIVIAL(debug) << "Detecting installed games."; - try { - _games = GetGames(_settings); - } catch (boss::error& e) { - BOOST_LOG_TRIVIAL(error) << "Game-specific settings could not be initialised. " << e.what(); - wxMessageBox( - FromUTF8(format(loc::translate("Error: Game-specific settings could not be initialised. %1%")) % e.what()), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - NULL); - return false; - } catch (YAML::Exception& e) { - BOOST_LOG_TRIVIAL(error) << "Games' settings parsing failed. " << e.what(); - wxMessageBox( - FromUTF8(format(loc::translate("Error: Games' settings parsing failed. %1%")) % e.what()), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - NULL); - return false; - } - - BOOST_LOG_TRIVIAL(debug) << "Selecting game."; - string target; - if (_settings["Game"] && _settings["Game"].as() != "auto") - target = _settings["Game"].as(); - else if (_settings["Last Game"] && _settings["Last Game"].as() != "auto") - target = _settings["Last Game"].as(); - - if (!target.empty()) { - for (size_t i=0, max=_games.size(); i < max; ++i) { - if (target == _games[i].FolderName() && _games[i].IsInstalled()) - _game = _games[i]; - } - } - if (_game == Game()) { - //Set _game to the first installed game. - for (size_t i=0, max=_games.size(); i < max; ++i) { - if (_games[i].IsInstalled()) { - _game = _games[i]; - break; - } - } - if (_game == Game()) { - BOOST_LOG_TRIVIAL(error) << "None of the supported games were detected."; - wxMessageBox( - translate("Error: None of the supported games were detected."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - NULL); - return false; - } - } - BOOST_LOG_TRIVIAL(debug) << "Game selected is " << _game.Name(); - - //Now that game is selected, initialise it. - BOOST_LOG_TRIVIAL(debug) << "Initialising game-specific settings."; - try { - _game.Init(); - *find(_games.begin(), _games.end(), _game) = _game; //Sync changes. - } catch (boss::error& e) { - BOOST_LOG_TRIVIAL(error) << "Game-specific settings could not be initialised. " << e.what(); - wxMessageBox( - FromUTF8(format(loc::translate("Error: Game-specific settings could not be initialised. %1%")) % e.what()), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - NULL); - return false; - } - - //Create launcher window. - BOOST_LOG_TRIVIAL(debug) << "Opening the main BOSS window."; - Launcher * launcher = new Launcher(wxT("BOSS"), _settings, _game, _games); - - launcher->SetIcon(wxIconLocation("BOSS.exe")); - launcher->Show(); - SetTopWindow(launcher); - - return true; -} - -Launcher::Launcher(const wxChar *title, YAML::Node& settings, Game& game, vector& games) : wxFrame(NULL, wxID_ANY, title), _game(game), _settings(settings), _games(games) { - - //Initialise menu items. - wxMenuBar * MenuBar = new wxMenuBar(); - wxMenu * FileMenu = new wxMenu(); - wxMenu * EditMenu = new wxMenu(); - GameMenu = new wxMenu(); - wxMenu * HelpMenu = new wxMenu(); - - //Initialise controls. - wxButton * EditButton = new wxButton(this, OPTION_EditMetadata, translate("Edit Metadata")); - wxButton * SortButton = new wxButton(this, OPTION_SortPlugins, translate("Sort Plugins")); - ViewButton = new wxButton(this,OPTION_ViewLastReport, translate("View Last Report")); - - //Construct menus. - //File Menu - FileMenu->Append(OPTION_ViewLastReport, translate("&View Last Report")); - FileMenu->Append(MENU_ViewDebugLog, translate("View &Debug Log")); - FileMenu->Append(OPTION_SortPlugins, translate("&Sort Plugins")); - RedatePluginsItem = FileMenu->Append(MENU_RedatePlugins, translate("&Redate Plugins")); - FileMenu->AppendSeparator(); - FileMenu->Append(wxID_EXIT); - MenuBar->Append(FileMenu, translate("&File")); - //Edit Menu - EditMenu->Append(OPTION_EditMetadata, translate("&Metadata...")); - EditMenu->Append(MENU_ShowSettings, translate("&Settings...")); - MenuBar->Append(EditMenu, translate("&Edit")); - //Game menu - set up initial item states here too. - for (size_t i=0,max=_games.size(); i < max; ++i) { - wxMenuItem * item = GameMenu->AppendRadioItem(MENU_LowestDynamicGameID + i, FromUTF8(_games[i].Name())); - if (_game == _games[i]) - item->Check(); - - if (_games[i].IsInstalled()) - Bind(wxEVT_MENU, &Launcher::OnGameChange, this, MENU_LowestDynamicGameID + i); - else - item->Enable(false); - } - MenuBar->Append(GameMenu, translate("&Game")); - //About menu - HelpMenu->Append(wxID_HELP); - HelpMenu->AppendSeparator(); - HelpMenu->Append(wxID_ABOUT); - MenuBar->Append(HelpMenu, translate("&Help")); - - //Set up layout. - wxBoxSizer *buttonBox = new wxBoxSizer(wxVERTICAL); - buttonBox->Add(EditButton, 1, wxEXPAND|wxALIGN_CENTRE|wxALL, 10); - buttonBox->Add(SortButton, 1, wxEXPAND|wxALIGN_CENTRE|wxLEFT|wxRIGHT, 10); - buttonBox->Add(ViewButton, 1, wxEXPAND|wxALIGN_CENTRE|wxALL, 10); - - //Bind event handlers. - Bind(wxEVT_MENU, &Launcher::OnQuit, this, wxID_EXIT); - Bind(wxEVT_MENU, &Launcher::OnViewLastReport, this, OPTION_ViewLastReport); - Bind(wxEVT_MENU, &Launcher::OnOpenDebugLog, this, MENU_ViewDebugLog); - Bind(wxEVT_MENU, &Launcher::OnSortPlugins, this, OPTION_SortPlugins); - Bind(wxEVT_MENU, &Launcher::OnEditMetadata, this, OPTION_EditMetadata); - Bind(wxEVT_MENU, &Launcher::OnRedatePlugins, this, MENU_RedatePlugins); - Bind(wxEVT_MENU, &Launcher::OnOpenSettings, this, MENU_ShowSettings); - Bind(wxEVT_MENU, &Launcher::OnHelp, this, wxID_HELP); - Bind(wxEVT_MENU, &Launcher::OnAbout, this, wxID_ABOUT); - Bind(wxEVT_BUTTON, &Launcher::OnSortPlugins, this, OPTION_SortPlugins); - Bind(wxEVT_BUTTON, &Launcher::OnEditMetadata, this, OPTION_EditMetadata); - Bind(wxEVT_BUTTON, &Launcher::OnViewLastReport, this, OPTION_ViewLastReport); - Bind(wxEVT_CLOSE_WINDOW, &Launcher::OnClose, this); - - //Set up tooltips. - EditButton->SetToolTip(translate("Opens the Metadata Editor, where plugins' sorting metadata, messages, dirty info and Bash Tag suggestions can be edited.")); - SortButton->SetToolTip(translate("Sorts your plugins, then displays a report of the results.")); - ViewButton->SetToolTip(translate("Opens the last report generated for the current game.")); - - //Set up initial state. - SortButton->SetDefault(); - - if (!fs::exists(_game.ReportPath())) - ViewButton->Enable(false); - - if (_game.Id() == boss::g_game_tes5) - RedatePluginsItem->Enable(true); - else - RedatePluginsItem->Enable(false); - - //Set title bar text. - SetTitle(FromUTF8("BOSS - " + _game.Name())); - - //Now set the layout and sizes. - SetMenuBar(MenuBar); - SetBackgroundColour(wxColour(255,255,255)); - SetSizerAndFit(buttonBox); - SetSize(wxSize(250, 200)); - - SortButton->SetFocus(); -} - -//Called when the frame exits. -void Launcher::OnQuit(wxCommandEvent& event) { - - Close(true); // Tells the OS to quit running this process -} - -void Launcher::OnClose(wxCloseEvent& event) { - BOOST_LOG_TRIVIAL(debug) << "Quiting BOSS."; - - _settings["Last Game"] = _game.FolderName(); - - _settings["Games"] = _games; - - //Save settings. - BOOST_LOG_TRIVIAL(debug) << "Saving BOSS settings."; - YAML::Emitter yout; - yout.SetIndent(2); - yout << _settings; - - boss::ofstream out(boss::g_path_settings); - out << yout.c_str(); - out.close(); - - Destroy(); -} - -void Launcher::OnViewLastReport(wxCommandEvent& event) { - if (_settings["View Report Externally"] && _settings["View Report Externally"].as()) { - BOOST_LOG_TRIVIAL(debug) << "Opening report in external application..."; - wxLaunchDefaultBrowser(FromUTF8(ToFileURL(_game.ReportPath().string()))); - } - else { - //Create viewer window. - BOOST_LOG_TRIVIAL(debug) << "Opening viewer window..."; - Viewer *viewer = new Viewer(this, translate("BOSS: Report Viewer"), FromUTF8(ToFileURL(_game.ReportPath().string()))); - viewer->Show(); - } - BOOST_LOG_TRIVIAL(debug) << "Report displayed."; -} - -void Launcher::OnOpenSettings(wxCommandEvent& event) { - BOOST_LOG_TRIVIAL(debug) << "Opening settings window..."; - SettingsFrame *settings = new SettingsFrame(this, translate("BOSS: Settings"), _settings, _games); - settings->ShowModal(); - BOOST_LOG_TRIVIAL(debug) << "Settings window opened."; -} - -void Launcher::OnGameChange(wxCommandEvent& event) { - BOOST_LOG_TRIVIAL(debug) << "Changing current game..."; - _game = _games[event.GetId() - MENU_LowestDynamicGameID]; - try { - _game.Init(); //In case it hasn't already been done. - *find(_games.begin(), _games.end(), _game) = _game; //Sync changes. - BOOST_LOG_TRIVIAL(debug) << "New game is " << _game.Name(); - } - catch (boss::error& e) { - BOOST_LOG_TRIVIAL(error) << "Game-specific settings could not be initialised." << e.what(); - wxMessageBox( - FromUTF8(format(loc::translate("Error: Game-specific settings could not be initialised. %1%")) % e.what()), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - NULL); - } - SetTitle(FromUTF8("BOSS - " + _game.Name())); - if (_game.Id() == boss::g_game_tes5) - RedatePluginsItem->Enable(true); - else - RedatePluginsItem->Enable(false); -} - -void Launcher::OnHelp(wxCommandEvent& event) { - //Look for file. - BOOST_LOG_TRIVIAL(debug) << "Opening readme at: " << g_path_readme; - if (fs::exists(g_path_readme)) { - wxLaunchDefaultBrowser(FromUTF8(ToFileURL(g_path_readme.string()))); - } - else { //No readme exists, show a pop-up message saying so. - BOOST_LOG_TRIVIAL(error) << "File \"" << g_path_readme.string() << "\" could not be found."; - wxMessageBox( - FromUTF8(format(loc::translate("Error: \"%1%\" cannot be found.")) % g_path_readme.string()), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - } -} - -void Launcher::OnOpenDebugLog(wxCommandEvent& event) { - //Look for file. - BOOST_LOG_TRIVIAL(debug) << "Opening debug log at: " << g_path_log; - if (fs::exists(g_path_log)) { - wxLaunchDefaultApplication(FromUTF8(g_path_log.string())); - } - else { //No log exists, show a pop-up message saying so. - BOOST_LOG_TRIVIAL(error) << "File \"" << g_path_log.string() << "\" could not be found."; - wxMessageBox( - FromUTF8(format(loc::translate("Error: \"%1%\" cannot be found.")) % g_path_log.string()), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - } -} - -void Launcher::OnAbout(wxCommandEvent& event) { - BOOST_LOG_TRIVIAL(debug) << "Opening About dialog."; - wxAboutDialogInfo aboutInfo; - aboutInfo.SetName("BOSS"); - aboutInfo.SetVersion(IntToString(g_version_major) + "." + IntToString(g_version_minor) + "." + IntToString(g_version_patch)); - aboutInfo.SetDescription(translate("Load order optimisation for Oblivion, Skyrim, Fallout 3 and Fallout: New Vegas.")); - aboutInfo.SetCopyright("Copyright (C) 2009-2014 BOSS Development Team."); - aboutInfo.SetWebSite("http://boss-developers.github.io"); - aboutInfo.SetLicence("This program is free software: you can redistribute it and/or modify\n" - "it under the terms of the GNU General Public License as published by\n" - "the Free Software Foundation, either version 3 of the License, or\n" - "(at your option) any later version.\n" - "\n" - "This program is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" - "GNU General Public License for more details.\n" - "\n" - "You should have received a copy of the GNU General Public License\n" - "along with this program. If not, see ."); - aboutInfo.SetIcon(wxIconLocation("BOSS.exe")); - wxAboutBox(aboutInfo); -} - -void Launcher::OnSortPlugins(wxCommandEvent& event) { - - BOOST_LOG_TRIVIAL(debug) << "Beginning sorting process."; - - YAML::Node mlist, ulist; - list messages, mlist_messages, ulist_messages; - list mlist_plugins, ulist_plugins; - list plugins; - boost::thread_group group; - boss::PluginGraph graph; - string revision; - - wxProgressDialog *progDia = new wxProgressDialog(translate("BOSS: Working..."),translate("BOSS working..."), 1000, this, wxPD_APP_MODAL|wxPD_AUTO_HIDE|wxPD_ELAPSED_TIME); - - /////////////////////////////////////////////////////// - // Load Plugins & Lists - /////////////////////////////////////////////////////// - - bool doUpdate = _settings["Update Masterlist"] && _settings["Update Masterlist"].as(); - masterlist_updater_parser mup(doUpdate, _game, messages, mlist_plugins, mlist_messages, revision); - group.create_thread(mup); - - //First calculate the mean plugin size. Store it temporarily in a map to reduce filesystem lookups and file size recalculation. - size_t meanFileSize = 0; - boost::unordered_map tempMap; - for (fs::directory_iterator it(_game.DataPath()); it != fs::directory_iterator(); ++it) { - if (fs::is_regular_file(it->status()) && IsPlugin(it->path().string())) { - - size_t fileSize = fs::file_size(it->path()); - meanFileSize += fileSize; - - tempMap.emplace(it->path().filename().string(), fileSize); - plugins.push_back(boss::Plugin(it->path().filename().string())); //Just in case there's an error with the graph. - } - } - meanFileSize /= tempMap.size(); - - //Now load plugins. - plugin_list_loader pll(graph, _game); - for (boost::unordered_map::const_iterator it=tempMap.begin(), endit=tempMap.end(); it != endit; ++it) { - - BOOST_LOG_TRIVIAL(trace) << "Found plugin: " << it->first; - - vertex_t v = boost::add_vertex(boss::Plugin(it->first), graph); - - if (it->second > meanFileSize) { - pll.skipPlugins.insert(it->first); - plugin_loader pl(graph[v], _game); - group.create_thread(pl); - } - - progDia->Pulse(); - } - group.create_thread(pll); - group.join_all(); - - //Now load userlist. - if (fs::exists(_game.UserlistPath())) { - BOOST_LOG_TRIVIAL(debug) << "Parsing userlist at: " << _game.UserlistPath(); - - try { - boss::ifstream in(_game.UserlistPath()); - YAML::Node ulist = YAML::Load(in); - in.close(); - - if (ulist["plugins"]) - ulist_plugins = ulist["plugins"].as< list >(); - } catch (YAML::ParserException& e) { - BOOST_LOG_TRIVIAL(error) << "Userlist parsing failed. Details: " << e.what(); - messages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("Userlist parsing failed. Details: %1%")) % e.what()).str())); - } - if (ulist["plugins"]) - ulist_plugins = ulist["plugins"].as< list >(); - } - - progDia->Pulse(); - - /////////////////////////////////////////////////////// - // Merge & Check Metadata - /////////////////////////////////////////////////////// - - if (fs::exists(_game.MasterlistPath()) || fs::exists(_game.UserlistPath())) { - - //Set language. - unsigned int lang; - if (_settings["Language"]) - lang = Language(_settings["Language"].as()).Code(); - else - lang = boss::g_lang_any; - - - //Merge all global message lists. - BOOST_LOG_TRIVIAL(trace) << "Merging all global message lists."; - if (!mlist_messages.empty()) - messages.insert(messages.end(), mlist_messages.begin(), mlist_messages.end()); - if (!ulist_messages.empty()) - messages.insert(messages.end(), ulist_messages.begin(), ulist_messages.end()); - - //Evaluate any conditions in the global messages. - BOOST_LOG_TRIVIAL(trace) << "Evaluating global message conditions."; - try { - list::iterator it=messages.begin(); - while (it != messages.end()) { - if (!it->EvalCondition(_game, lang)) - it = messages.erase(it); - else - ++it; - } - } catch (boss::error& e) { - BOOST_LOG_TRIVIAL(error) << "A global message contains a condition that could not be evaluated. Details: " << e.what(); - messages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("A global message contains a condition that could not be evaluated. Details: %1%")) % e.what()).str())); - } - - //Merge plugin list, masterlist and userlist plugin data. - BOOST_LOG_TRIVIAL(debug) << "Merging plugin list, masterlist and userlist data, evaluating conditions and checking for install validity."; - boss::vertex_it vit, vitend; - for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) { - BOOST_LOG_TRIVIAL(trace) << "Merging for plugin \"" << graph[*vit].Name() << "\""; - - //Check if there is a plugin entry in the masterlist. This will also find matching regex entries. - list::iterator pos = std::find(mlist_plugins.begin(), mlist_plugins.end(), graph[*vit]); - - if (pos != mlist_plugins.end()) { - BOOST_LOG_TRIVIAL(trace) << "Merging masterlist data down to plugin list data."; - graph[*vit].MergeMetadata(*pos); - } - - //Check if there is a plugin entry in the userlist. This will also find matching regex entries. - pos = std::find(ulist_plugins.begin(), ulist_plugins.end(), graph[*vit]); - - if (pos != ulist_plugins.end() && pos->Enabled()) { - BOOST_LOG_TRIVIAL(trace) << "Merging userlist data down to plugin list data."; - graph[*vit].MergeMetadata(*pos); - } - - progDia->Pulse(); - - //Now that items are merged, evaluate any conditions they have. - BOOST_LOG_TRIVIAL(trace) << "Evaluate conditions for merged plugin data."; - try { - graph[*vit].EvalAllConditions(_game, lang); - } catch (boss::error& e) { - BOOST_LOG_TRIVIAL(error) << "\"" << graph[*vit].Name() << "\" contains a condition that could not be evaluated. Details: " << e.what(); - messages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("\"%1%\" contains a condition that could not be evaluated. Details: %2%")) % graph[*vit].Name() % e.what()).str())); - } - - progDia->Pulse(); - - //Also check install validity. - BOOST_LOG_TRIVIAL(trace) << "Checking that the current install is valid according to this plugin's data."; - vector issues = graph[*vit].CheckInstallValidity(_game); - list pluginMessages = graph[*vit].Messages(); - for (vector::const_iterator jt = issues.begin(), jtend = issues.end(); jt != jtend; ++jt) { - pluginMessages.push_back(boss::Message(boss::g_message_error, *jt)); - } - if (!issues.empty()) - graph[*vit].Messages(pluginMessages); - - progDia->Pulse(); - } - } - - progDia->Update(800, translate("Building plugin graph...")); - - /////////////////////////////////////////////////////// - // Build Graph Edges & Sort - /////////////////////////////////////////////////////// - - /* Need to loop this section. There are 3 ways to exit the loop: - - 1. Accept the load order at the preview with no changes. - 2. Cancel at the preview. - 3. Cancel making changes. - - Otherwise, the sorting must loop. - - */ - - //Check for back-edges, then perform a topological sort. - try { - bool applyLoadOrder = false; - long ret; - do { - BOOST_LOG_TRIVIAL(debug) << "Building the plugin dependency graph..."; - - //Now add the interactions between plugins to the graph as edges. - BOOST_LOG_TRIVIAL(trace) << "Adding non-overlap edges."; - AddSpecificEdges(graph); - - BOOST_LOG_TRIVIAL(trace) << "Adding priority edges."; - AddPriorityEdges(graph); - - BOOST_LOG_TRIVIAL(trace) << "Adding overlap edges."; - AddOverlapEdges(graph); - - BOOST_LOG_TRIVIAL(debug) << "Checking to see if the graph is cyclic."; - boss::CheckForCycles(graph); - - progDia->Pulse(); - - BOOST_LOG_TRIVIAL(debug) << "Performing a topological sort."; - boss::Sort(graph, plugins); - - progDia->Destroy(); - progDia = NULL; - - BOOST_LOG_TRIVIAL(debug) << "Displaying load order preview."; - MiniEditor editor(this, translate("BOSS: Calculated Load Order"), plugins, _game); - - long ret = editor.ShowModal(); - const std::list edits = editor.GetEditedPlugins(); - - if (ret != wxID_APPLY) { - applyLoadOrder = false; - break; - } - else if (edits.empty()) { - applyLoadOrder = true; - break; - } - else { - //Recreate progress dialog. - progDia = new wxProgressDialog(translate("BOSS: Working..."), translate("Recalculating load order..."), 1000, this, wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_ELAPSED_TIME); - - //User accepted edits, now apply them, then loop. - //Apply edits to the graph vertices. - boss::vertex_it vit, vitend; - for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) { - std::list::const_iterator pos = std::find(edits.begin(), edits.end(), graph[*vit]); - - if (pos != edits.end()) { - BOOST_LOG_TRIVIAL(trace) << "Merging edits down to plugin list data."; - graph[*vit].MergeMetadata(*pos); - } - } - - //Clear all existing edges from the graph. - BOOST_LOG_TRIVIAL(trace) << "Clearing all existing edges from the plugin graph."; - for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) { - boost::clear_vertex(*vit, graph); - } - - //Merge edits down to the userlist entries. - BOOST_LOG_TRIVIAL(trace) << "Merging down edits to the userlist."; - for (list::const_iterator it = edits.begin(), endit = edits.end(); it != endit; ++it) { - list::iterator jt = find(ulist_plugins.begin(), ulist_plugins.end(), *it); - - if (jt != ulist_plugins.end()) { - jt->MergeMetadata(*it); - } - else { - ulist_plugins.push_back(*it); - } - } - - //Save edits to userlist. - BOOST_LOG_TRIVIAL(debug) << "Saving edited userlist."; - YAML::Emitter yout; - yout.SetIndent(2); - yout << YAML::BeginMap - << YAML::Key << "plugins" << YAML::Value << ulist_plugins - << YAML::EndMap; - - boss::ofstream uout(_game.UserlistPath()); - uout << yout.c_str(); - uout.close(); - - //Now loop. - } - } while (true); - - if (applyLoadOrder) { - //User doesn't want to make any changes. Just go straight to applying the load order. - BOOST_LOG_TRIVIAL(debug) << "Setting load order."; - try { - _game.SetLoadOrder(plugins); - } - catch (boss::error& e) { - BOOST_LOG_TRIVIAL(error) << "Failed to set the load order. Details: " << e.what(); - messages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("Failed to set the load order. Details: %1%")) % e.what()).str())); - } - BOOST_LOG_TRIVIAL(trace) << "Load order set:"; - for (list::iterator it = plugins.begin(), endIt = plugins.end(); it != endIt; ++it) { - BOOST_LOG_TRIVIAL(trace) << '\t' << it->Name(); - } - } - else { - //User decided to cancel sorting. Just go straight to displaying the report. - BOOST_LOG_TRIVIAL(info) << "The load order calculated was not applied as sorting was canceled."; - messages.push_back(boss::Message(boss::g_message_warn, loc::translate("The load order displayed in the Details tab was not applied as sorting was canceled."))); - } - - } catch (std::exception& e) { - BOOST_LOG_TRIVIAL(error) << "Failed to calculate the load order. Details: " << e.what(); - messages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("Failed to calculate the load order. Details: %1%")) % e.what()).str())); - - progDia->Destroy(); - progDia = NULL; - } - - /////////////////////////////////////////////////////// - // Build & Display Report - /////////////////////////////////////////////////////// - - //Read the details section of the previous report, if it exists. - string oldDetails; - if (fs::exists(_game.ReportPath().string())) { - BOOST_LOG_TRIVIAL(debug) << "Reading the previous report's details section."; - //Read the whole file in. - boss::ifstream in(_game.ReportPath(), ios::binary); - in.seekg(0, std::ios::end); - oldDetails.resize(in.tellg()); - in.seekg(0, std::ios::beg); - in.read(&oldDetails[0], oldDetails.size()); - in.close(); - - //Slim down to only the details section. - size_t pos1 = oldDetails.find("
    ", pos1); - if (pos1 != string::npos) { - size_t pos2 = oldDetails.find("
    ", pos1); - if (pos2 != string::npos) { - pos2 -= 6; // "
    " - oldDetails = oldDetails.substr(pos1, pos2 - pos1); - } - } - } - } - - BOOST_LOG_TRIVIAL(debug) << "Generating report..."; - try { - GenerateReport(_game.ReportPath(), - messages, - plugins, - oldDetails, - revision, - doUpdate); - } catch (boss::error& e) { - wxMessageBox( - FromUTF8(format(loc::translate("Error: %1%")) % e.what()), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - if (progDia != NULL) - progDia->Destroy(); - return; - } - - //Now a results report definitely exists. - ViewButton->Enable(true); - - BOOST_LOG_TRIVIAL(debug) << "Displaying report..."; - if (_settings["View Report Externally"] && _settings["View Report Externally"].as()) { - wxLaunchDefaultBrowser(FromUTF8(ToFileURL(_game.ReportPath().string()))); - } else { - //Create viewer window. - Viewer *viewer = new Viewer(this, translate("BOSS: Report Viewer"), FromUTF8(ToFileURL(_game.ReportPath().string()))); - viewer->Show(); - } - - BOOST_LOG_TRIVIAL(debug) << "Report display successful. Sorting process complete."; -} - -void Launcher::OnEditMetadata(wxCommandEvent& event) { - - //Should probably check for masterlist updates before opening metadata editor. - list installed, mlist_plugins, ulist_plugins; - - wxProgressDialog *progDia = new wxProgressDialog(translate("BOSS: Working..."),translate("BOSS working..."), 1000, this, wxPD_APP_MODAL|wxPD_AUTO_HIDE|wxPD_ELAPSED_TIME); - - //Scan for installed plugins. - BOOST_LOG_TRIVIAL(debug) << "Reading installed plugins' headers."; - for (fs::directory_iterator it(_game.DataPath()); it != fs::directory_iterator(); ++it) { - if (fs::is_regular_file(it->status()) && IsPlugin(it->path().string())) { - installed.push_back(boss::Plugin(_game, it->path().filename().string(), true)); - - progDia->Pulse(); - } - } - - //Parse masterlist. - if (fs::exists(_game.MasterlistPath())) { - BOOST_LOG_TRIVIAL(debug) << "Parsing masterlist."; - YAML::Node mlist; - try { - boss::ifstream in(_game.MasterlistPath()); - mlist = YAML::Load(in); - in.close(); - } catch (YAML::ParserException& e) { - BOOST_LOG_TRIVIAL(error) << "Masterlist parsing failed. " << e.what(); - wxMessageBox( - FromUTF8(format(loc::translate("Error: Masterlist parsing failed. %1%")) % e.what()), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - } - if (mlist["plugins"]) - mlist_plugins = mlist["plugins"].as< list >(); - } - - progDia->Pulse(); - - //Parse userlist. - if (fs::exists(_game.UserlistPath())) { - BOOST_LOG_TRIVIAL(debug) << "Parsing userlist."; - YAML::Node ulist; - try { - boss::ifstream in(_game.UserlistPath()); - ulist = YAML::Load(in); - in.close(); - } catch (YAML::ParserException& e) { - BOOST_LOG_TRIVIAL(error) << "Userlist parsing failed. " << e.what(); - wxMessageBox( - FromUTF8(format(loc::translate("Error: Userlist parsing failed. %1%")) % e.what()), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - } - if (ulist["plugins"]) - ulist_plugins = ulist["plugins"].as< list >(); - } - - progDia->Pulse(); - - //Merge the masterlist down into the installed mods list. - BOOST_LOG_TRIVIAL(debug) << "Merging the masterlist down into the installed mods list."; - for (list::const_iterator it = mlist_plugins.begin(), endit = mlist_plugins.end(); it != endit; ++it) { - list::iterator pos = find(installed.begin(), installed.end(), *it); - - if (pos != installed.end()) - pos->MergeMetadata(*it); - } - - progDia->Pulse(); - - //Add empty entries for any userlist entries that aren't installed. - BOOST_LOG_TRIVIAL(debug) << "Padding the installed mods list to match the plugins in the userlist."; - for (list::const_iterator it = ulist_plugins.begin(), endit = ulist_plugins.end(); it != endit; ++it) { - if (find(installed.begin(), installed.end(), *it) == installed.end()) - installed.push_back(boss::Plugin(it->Name())); - } - - progDia->Pulse(); - - //Sort into alphabetical order. - BOOST_LOG_TRIVIAL(debug) << "Sorting plugin list into alphabetical order."; - installed.sort(boss::alpha_sort); - - progDia->Pulse(); - - //Set language. - unsigned int lang; - if (_settings["Language"]) - lang = Language(_settings["Language"].as()).Code(); - else - lang = boss::g_lang_any; - - //Create editor window. - BOOST_LOG_TRIVIAL(debug) << "Opening editor window."; - Editor *editor = new Editor(this, translate("BOSS: Metadata Editor"), _game.UserlistPath().string(), installed, ulist_plugins, lang, _game); - - progDia->Destroy(); - - editor->Show(); - BOOST_LOG_TRIVIAL(debug) << "Editor window opened."; -} - -void Launcher::OnRedatePlugins(wxCommandEvent& event) { - wxMessageDialog * dia = new wxMessageDialog(this, translate("This feature is provided so that modders using the Creation Kit may set the load order it uses. A side-effect is that any subscribed Steam Workshop mods will be re-downloaded by Steam. Do you wish to continue?"), translate("BOSS: Warning"), wxYES_NO|wxCANCEL|wxICON_EXCLAMATION); - - if (dia->ShowModal() == wxID_YES) { - BOOST_LOG_TRIVIAL(debug) << "Redating plugins."; - list loadorder; - try { - _game.GetLoadOrder(loadorder); - } catch (boss::error& e) { - BOOST_LOG_TRIVIAL(error) << "Failed to get load order. " << e.what(); - wxMessageBox( - FromUTF8(format(loc::translate("Error: Failed to get load order. %1%")) % e.what()), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - } - - try { - if (!loadorder.empty()) { - - time_t lastTime, thisTime; - fs::path filepath = _game.DataPath() / loadorder.begin()->Name(); - if (!fs::exists(filepath) && fs::exists(filepath.string() + ".ghost")) - filepath += ".ghost"; - - lastTime = fs::last_write_time(filepath); - - for (list::const_iterator it=loadorder.begin(), itend=loadorder.end(); it != itend; ++it) { - - filepath = _game.DataPath() / it->Name(); - if (!fs::exists(filepath) && fs::exists(filepath.string() + ".ghost")) - filepath += ".ghost"; - - time_t thisTime = fs::last_write_time(filepath); - BOOST_LOG_TRIVIAL(info) << "Current timestamp for \"" << filepath.filename().string() << "\": " << thisTime; - if (thisTime >= lastTime) { - lastTime = thisTime; - BOOST_LOG_TRIVIAL(trace) << "No need to redate \"" << filepath.filename().string() << "\"."; - } else { - lastTime += 60; - fs::last_write_time(filepath, lastTime); //Space timestamps by a minute. - BOOST_LOG_TRIVIAL(info) << "Redated \"" << filepath.filename().string() << "\" to: " << lastTime; - } - } - } - } catch(fs::filesystem_error& e) { - BOOST_LOG_TRIVIAL(error) << "Failed to set plugin timestamps. " << e.what(); - wxMessageBox( - FromUTF8(format(loc::translate("Error: Failed to set plugin timestamps. %1%")) % e.what()), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - } - - wxMessageBox( - translate("Plugins were successfully redated."), - translate("BOSS: Plugin Redate"), - wxOK|wxCENTRE, - this); - } -} diff --git a/src/gui/main.h b/src/gui/main.h deleted file mode 100644 index ce6d59a7..00000000 --- a/src/gui/main.h +++ /dev/null @@ -1,73 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2013-2014 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ - -#ifndef __BOSS_GUI_MAIN__ -#define __BOSS_GUI_MAIN__ - -#include "ids.h" -#include "../backend/game.h" - -#include -#include -#include - -//Program class. -class BossGUI : public wxApp { -public: - bool OnInit(); //Load settings, apply logging and language settings, check if BOSS is already running, detect games, set game to last game or to first detected game if auto, create launcher window. -private: - wxLocale * wxLoc; - - YAML::Node _settings; - std::vector _games; - boss::Game _game; -}; - -class Launcher : public wxFrame { -public: - Launcher(const wxChar *title, YAML::Node& settings, boss::Game& inGame, std::vector& games); - - void OnSortPlugins(wxCommandEvent& event); - void OnEditMetadata(wxCommandEvent& event); - void OnViewLastReport(wxCommandEvent& event); - void OnRedatePlugins(wxCommandEvent& event); - - void OnOpenSettings(wxCommandEvent& event); - void OnOpenDebugLog(wxCommandEvent& event); - void OnGameChange(wxCommandEvent& event); - void OnHelp(wxCommandEvent& event); - void OnAbout(wxCommandEvent& event); - void OnQuit(wxCommandEvent& event); - - void OnClose(wxCloseEvent& event); -private: - wxMenu * GameMenu; - wxMenuItem * RedatePluginsItem; - wxButton * ViewButton; - - boss::Game& _game; - YAML::Node& _settings; //BOSS Settings. - std::vector& _games; -}; - -#endif diff --git a/src/gui/main_win.cpp b/src/gui/main_win.cpp new file mode 100644 index 00000000..526509c0 --- /dev/null +++ b/src/gui/main_win.cpp @@ -0,0 +1,148 @@ +/* LOOT + + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. + + Copyright (C) 2014 WrinklyNinja + + This file is part of LOOT. + + LOOT 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. + + LOOT 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 LOOT. If not, see + . +*/ + +#include "app.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace fs = boost::filesystem; + +using namespace std; +using namespace loot; +using boost::locale::translate; +using boost::format; + +CefSettings GetCefSettings() { + CefSettings cef_settings; + + //Disable CEF command line args. + cef_settings.command_line_args_disabled = true; + + // Set CEF logging. + CefString(&cef_settings.log_file).FromString((g_path_local / "CEFDebugLog.txt").string()); + + // Enable remote debugging. + cef_settings.remote_debugging_port = 8080; + + return cef_settings; +} + +#ifdef _WIN32 +int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { +#endif + + // Do all the standard CEF setup stuff. + //------------------------------------- + + // Set up CEF sandbox. + CefScopedSandboxInfo scoped_sandbox; + void * sandbox_info = scoped_sandbox.sandbox_info(); + + // Read command line arguments. +#ifdef _WIN32 + CefMainArgs main_args(hInstance); +#endif + + // Create the process reference. + CefRefPtr app(new loot::LootApp); + + // Run the process. + int exit_code = CefExecuteProcess(main_args, app.get(), sandbox_info); + if (exit_code >= 0) { + // The sub-process has completed so return here. + return exit_code; + } + + + // Check if LOOT is already running + //--------------------------------- + + HANDLE hMutex = ::OpenMutex(MUTEX_ALL_ACCESS, FALSE, L"LOOT.Shell.Instance"); + if (hMutex != NULL) { + // An instance of LOOT is already running, so quit. + return 0; + } + else { + //Create the mutex so that future instances will not run. + hMutex = ::CreateMutex(NULL, FALSE, L"LOOT.Shell.Instance"); + } + + // Handle command line args (not CEF args) + //---------------------------------------- + + string gameStr; + + // Record command line arguments. + CefRefPtr command_line = CefCommandLine::CreateCommandLine(); +#ifdef _WIN32 + command_line->InitFromString(::GetCommandLineW()); +#endif + if (command_line->HasSwitch("game")) { // Format is: --game= + gameStr = command_line->GetSwitchValue("game"); + } + + loot::g_app_state.Init(gameStr); + + // Back to CEF + //------------ + + // Initialise CEF settings. + CefSettings cef_settings = GetCefSettings(); + + // Initialize CEF. + CefInitialize(main_args, cef_settings, app.get(), sandbox_info); + + // Do application init + //-------------------- + + // Run the CEF message loop. This will block until CefQuitMessageLoop() is called. + CefRunMessageLoop(); + + // Shut down CEF. + CefShutdown(); + + // Release the program instance mutex. + if (hMutex != NULL) + ReleaseMutex(hMutex); + + // Now save LOOT's settings and user metadata. + g_app_state.CurrentGame().userlist.Save(g_app_state.CurrentGame().UserlistPath()); + g_app_state.SaveSettings(); + + // Delete the folders CEF generates that LOOT doesn't need. + boost::filesystem::remove_all(boost::filesystem::current_path() / "locales"); + boost::filesystem::remove_all(boost::filesystem::current_path() / "pdf.dll"); + + return 0; +} \ No newline at end of file diff --git a/src/gui/misc.cpp b/src/gui/misc.cpp deleted file mode 100644 index 850a0725..00000000 --- a/src/gui/misc.cpp +++ /dev/null @@ -1,480 +0,0 @@ -/* BOSS - -A plugin load order optimiser for games that use the esp/esm plugin system. - -Copyright (C) 2013-2014 WrinklyNinja - -This file is part of BOSS. - -BOSS 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. - -BOSS 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 BOSS. If not, see -. -*/ - -#include "misc.h" -#include "../backend/helpers.h" - -#include - - - -using namespace std; - -MessageList::MessageList(wxWindow * parent, wxWindowID id, const unsigned int language) : wxListView(parent, id, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_VIRTUAL | wxLC_SINGLE_SEL), _language(language) { - InsertColumn(0, translate("Type")); - InsertColumn(1, translate("Content")); - InsertColumn(2, translate("Condition")); - InsertColumn(3, translate("Language")); - - Bind(wxEVT_LIST_DELETE_ITEM, &MessageList::OnDeleteItem, this); - - SetItemCount(0); -} - -std::vector MessageList::GetItems() const { - return _messages; -} - -void MessageList::SetItems(const std::vector& messages) { - _messages = messages; - SetItemCount(_messages.size()); - RefreshItems(0, _messages.size() - 1); -} - -boss::Message MessageList::GetItem(long item) const { - return _messages[item]; -} - -void MessageList::SetItem(long item, const boss::Message& message) { - _messages[item] = message; - RefreshItem(item); -} - -void MessageList::AppendItem(const boss::Message& message) { - _messages.push_back(message); - SetItemCount(_messages.size()); - RefreshItem(_messages.size() - 1); -} - -void MessageList::OnDeleteItem(wxListEvent& event) { - _messages.erase(_messages.begin() + event.GetIndex()); - SetItemCount(_messages.size()); - RefreshItems(event.GetIndex(), _messages.size() - 1); -} - -wxString MessageList::OnGetItemText(long item, long column) const { - if (column < 0 || column > 3 || item < 0 || item > _messages.size() - 1) - return wxString(); - - if (column == 0) { - if (_messages[item].Type() == boss::g_message_say) - return Type[0]; - else if (_messages[item].Type() == boss::g_message_warn) - return Type[1]; - else - return Type[2]; - } - else if (column == 1) { - return FromUTF8(_messages[item].ChooseContent(_language).Str()); - } - else if (column == 2) { - return FromUTF8(_messages[item].Condition()); - } - else { - return FromUTF8(boss::Language(_messages[item].ChooseContent(_language).Language()).Name()); - } -} - - -FileEditDialog::FileEditDialog(wxWindow *parent, const wxString& title) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - - _name = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_EMPTY)); - _display = new wxTextCtrl(this, wxID_ANY); - _condition = new wxTextCtrl(this, wxID_ANY); - - wxSizerFlags leftItem(0); - leftItem.Left(); - - wxSizerFlags rightItem(1); - rightItem.Right().Expand(); - - wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL); - - wxFlexGridSizer * GridSizer = new wxFlexGridSizer(2, 5, 5); - GridSizer->AddGrowableCol(1, 1); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Filename (required):")), leftItem); - GridSizer->Add(_name, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Displayed Name:")), leftItem); - GridSizer->Add(_display, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Condition:")), leftItem); - GridSizer->Add(_condition, rightItem); - - bigBox->Add(GridSizer, 0, wxEXPAND | wxALL, 15); - - bigBox->AddSpacer(10); - bigBox->AddStretchSpacer(1); - - //Need to add 'OK' and 'Cancel' buttons. - wxSizer * sizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL); - if (sizer != NULL) - bigBox->Add(sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 15); - - SetBackgroundColour(wxColour(255, 255, 255)); - SetIcon(wxIconLocation("BOSS.exe")); - SetSizerAndFit(bigBox); -} - -void FileEditDialog::SetValues(const wxString& name, const wxString& display, const wxString& condition) { - - _name->SetValue(name); - _display->SetValue(display); - _condition->SetValue(condition); -} - -wxString FileEditDialog::GetName() const { - return _name->GetValue(); -} - -wxString FileEditDialog::GetDisplayName() const { - return _display->GetValue(); -} - -wxString FileEditDialog::GetCondition() const { - return _condition->GetValue(); -} - -MessageEditDialog::MessageEditDialog(wxWindow *parent, const wxString& title) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - - wxArrayString languages; - vector langs = boss::Language::Names(); - for (size_t i = 0; i < langs.size(); i++) { - languages.Add(FromUTF8(langs[i])); - } - - //Initialise controls. - _type = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 3, Type); - _language = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, languages); - - _condition = new wxTextCtrl(this, wxID_ANY); - _str = new wxTextCtrl(this, wxID_ANY); - - _content = new wxListView(this, LIST_MessageContent, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL); - - addBtn = new wxButton(this, BUTTON_AddContent, translate("Add Content")); - editBtn = new wxButton(this, BUTTON_EditContent, translate("Edit Content")); - removeBtn = new wxButton(this, BUTTON_RemoveContent, translate("Remove Content")); - - _content->InsertColumn(0, translate("Language")); - _content->InsertColumn(1, translate("String")); - - //Set up event handling. - Bind(wxEVT_BUTTON, &MessageEditDialog::OnAdd, this, BUTTON_AddContent); - Bind(wxEVT_BUTTON, &MessageEditDialog::OnEdit, this, BUTTON_EditContent); - Bind(wxEVT_BUTTON, &MessageEditDialog::OnRemove, this, BUTTON_RemoveContent); - Bind(wxEVT_LIST_ITEM_SELECTED, &MessageEditDialog::OnSelect, this, LIST_MessageContent); - - wxSizerFlags leftItem(0); - leftItem.Left(); - - wxSizerFlags rightItem(1); - rightItem.Right(); - - wxSizerFlags wholeItem(0); - wholeItem.Expand().Border(wxLEFT | wxRIGHT | wxBOTTOM, 15); - - wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL); - - wxFlexGridSizer * GridSizer = new wxFlexGridSizer(2, 5, 5); - GridSizer->AddGrowableCol(1, 1); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Type:")), leftItem); - GridSizer->Add(_type, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Condition:")), leftItem); - GridSizer->Add(_condition, rightItem); - - bigBox->AddSpacer(15); - - bigBox->Add(GridSizer, wholeItem); - - bigBox->Add(_content, wholeItem); - - wxFlexGridSizer * GridSizer2 = new wxFlexGridSizer(2, 5, 5); - GridSizer2->AddGrowableCol(1, 1); - - GridSizer2->Add(new wxStaticText(this, wxID_ANY, translate("Language:")), leftItem); - GridSizer2->Add(_language, rightItem); - - GridSizer2->Add(new wxStaticText(this, wxID_ANY, translate("Content:")), leftItem); - GridSizer2->Add(_str, rightItem); - - bigBox->Add(GridSizer2, wholeItem); - - wxBoxSizer * hbox = new wxBoxSizer(wxHORIZONTAL); - hbox->Add(addBtn, 0, wxRIGHT, 5); - hbox->Add(editBtn, 0, wxLEFT | wxRIGHT, 5); - hbox->Add(removeBtn, 0, wxLEFT, 5); - bigBox->Add(hbox, 0, wxALIGN_RIGHT | wxLEFT | wxRIGHT, 15); - - bigBox->AddSpacer(10); - bigBox->AddStretchSpacer(1); - - //Need to add 'OK' and 'Cancel' buttons. - wxSizer * sizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL); - if (sizer != NULL) - bigBox->Add(sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 15); - - //Set defaults. - _type->SetSelection(0); - _language->SetSelection(0); - editBtn->Enable(false); - removeBtn->Enable(false); - - SetBackgroundColour(wxColour(255, 255, 255)); - SetIcon(wxIconLocation("BOSS.exe")); - SetSizerAndFit(bigBox); -} - -void MessageEditDialog::SetMessage(const boss::Message& message) { - - if (message.Type() == boss::g_message_say) - _type->SetSelection(0); - else if (message.Type() == boss::g_message_warn) - _type->SetSelection(1); - else - _type->SetSelection(2); - - _condition->SetValue(FromUTF8(message.Condition())); - - vector contents = message.Content(); - for (size_t i = 0, max = contents.size(); i < max; ++i) { - _content->InsertItem(i, FromUTF8(boss::Language(contents[i].Language()).Name())); - _content->SetItem(i, 1, FromUTF8(contents[i].Str())); - } -} - -boss::Message MessageEditDialog::GetMessage() const { - - unsigned int type; - string condition; - if (_type->GetSelection() == 0) - type = boss::g_message_say; - else if (_type->GetSelection() == 1) - type = boss::g_message_warn; - else - type = boss::g_message_error; - - condition = string(_condition->GetValue().ToUTF8()); - - vector contents; - for (size_t i = 0, max = _content->GetItemCount(); i < max; ++i) { - - string str = string(_content->GetItemText(i, 1).ToUTF8()); - unsigned int lang = boss::Language(string(_content->GetItemText(i, 0).ToUTF8())).Code(); - - contents.push_back(boss::MessageContent(str, lang)); - } - - return boss::Message(type, contents, condition); -} - -void MessageEditDialog::OnSelect(wxListEvent& event) { - _language->SetSelection(boss::Language(string(_content->GetItemText(event.GetIndex(), 0).ToUTF8())).Code()); - _str->SetValue(_content->GetItemText(event.GetIndex(), 1)); - editBtn->Enable(true); - removeBtn->Enable(true); -} - -void MessageEditDialog::OnAdd(wxCommandEvent& event) { - long i = _content->GetItemCount(); - _content->InsertItem(i, FromUTF8(boss::Language(_language->GetSelection()).Name())); - _content->SetItem(i, 1, _str->GetValue()); -} - -void MessageEditDialog::OnEdit(wxCommandEvent& event) { - if (_content->GetFirstSelected() == -1) { - BOOST_LOG_TRIVIAL(error) << "Attempting to edit message content, but no content row selected."; - wxMessageBox( - translate("Error: No content row selected."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - NULL); - return; - } - long i = _content->GetFirstSelected(); - _content->SetItem(i, 0, FromUTF8(boss::Language(_language->GetSelection()).Name())); - _content->SetItem(i, 1, _str->GetValue()); -} - -void MessageEditDialog::OnRemove(wxCommandEvent& event) { - if (_content->GetFirstSelected() == -1) { - BOOST_LOG_TRIVIAL(error) << "Attempting to remove message content, but no content row selected."; - wxMessageBox( - translate("Error: No content row selected."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - NULL); - return; - } - _content->DeleteItem(_content->GetFirstSelected()); - editBtn->Enable(false); - removeBtn->Enable(false); -} - -TagEditDialog::TagEditDialog(wxWindow *parent, const wxString& title) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - - //Initialise controls. - _state = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 2, State); - - _name = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_EMPTY)); - _condition = new wxTextCtrl(this, wxID_ANY); - - wxSizerFlags leftItem(0); - leftItem.Left(); - - wxSizerFlags rightItem(1); - rightItem.Right().Expand(); - - wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL); - - wxFlexGridSizer * GridSizer = new wxFlexGridSizer(2, 5, 5); - GridSizer->AddGrowableCol(1, 1); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Add/Remove:")), leftItem); - GridSizer->Add(_state, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Name (required):")), leftItem); - GridSizer->Add(_name, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Condition:")), leftItem); - GridSizer->Add(_condition, rightItem); - - bigBox->Add(GridSizer, 0, wxEXPAND | wxALL, 15); - - bigBox->AddSpacer(10); - bigBox->AddStretchSpacer(1); - - //Need to add 'OK' and 'Cancel' buttons. - wxSizer * sizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL); - if (sizer != NULL) - bigBox->Add(sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 15); - - //Set defaults. - _state->SetSelection(0); - - SetBackgroundColour(wxColour(255, 255, 255)); - SetIcon(wxIconLocation("BOSS.exe")); - SetSizerAndFit(bigBox); -} - -void TagEditDialog::SetValues(int state, const wxString& name, const wxString& condition) { - - _state->SetSelection(state); - _name->SetValue(name); - _condition->SetValue(condition); -} - -wxString TagEditDialog::GetState() const { - return State[_state->GetSelection()]; -} - -wxString TagEditDialog::GetName() const { - return _name->GetValue(); -} - -wxString TagEditDialog::GetCondition() const { - return _condition->GetValue(); -} - -DirtInfoEditDialog::DirtInfoEditDialog(wxWindow * parent, const wxString& title) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - //Initialise controls. - wxTextValidator val(wxFILTER_EMPTY | wxFILTER_INCLUDE_CHAR_LIST); - val.SetCharIncludes("0123456789ABCDEFabcdef"); - - _itm = new wxSpinCtrl(this, wxID_ANY, "0"); - _udr = new wxSpinCtrl(this, wxID_ANY, "0"); - _nav = new wxSpinCtrl(this, wxID_ANY, "0"); - _crc = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, val); - _utility = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_EMPTY)); - - wxSizerFlags leftItem(0); - leftItem.Left(); - - wxSizerFlags rightItem(1); - rightItem.Right().Expand(); - - wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL); - - wxFlexGridSizer * GridSizer = new wxFlexGridSizer(2, 5, 5); - GridSizer->AddGrowableCol(1, 1); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("CRC (required):")), leftItem); - GridSizer->Add(_crc, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("ITM Count:")), leftItem); - GridSizer->Add(_itm, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("UDR Count:")), leftItem); - GridSizer->Add(_udr, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Deleted Navmesh Count:")), leftItem); - GridSizer->Add(_nav, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Cleaning Utility (required):")), leftItem); - GridSizer->Add(_utility, rightItem); - - bigBox->Add(GridSizer, 0, wxEXPAND | wxALL, 15); - - bigBox->AddSpacer(10); - bigBox->AddStretchSpacer(1); - - //Need to add 'OK' and 'Cancel' buttons. - wxSizer * sizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL); - if (sizer != NULL) - bigBox->Add(sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 15); - - SetBackgroundColour(wxColour(255, 255, 255)); - SetIcon(wxIconLocation("BOSS.exe")); - SetSizerAndFit(bigBox); -} - -void DirtInfoEditDialog::SetValues(const wxString& crc, unsigned int itm, unsigned int udr, unsigned int nav, const wxString& utility) { - _crc->SetValue(crc); - _itm->SetValue(itm); - _udr->SetValue(udr); - _nav->SetValue(nav); - _utility->SetValue(utility); -} - -wxString DirtInfoEditDialog::GetCRC() const { - return _crc->GetValue(); -} - -unsigned int DirtInfoEditDialog::GetITMs() const { - return _itm->GetValue(); -} - -unsigned int DirtInfoEditDialog::GetUDRs() const { - return _udr->GetValue(); -} - -unsigned int DirtInfoEditDialog::GetDeletedNavmeshes() const { - return _nav->GetValue(); -} - -wxString DirtInfoEditDialog::GetUtility() const { - return _utility->GetValue(); -} \ No newline at end of file diff --git a/src/gui/misc.h b/src/gui/misc.h deleted file mode 100644 index ad537d24..00000000 --- a/src/gui/misc.h +++ /dev/null @@ -1,132 +0,0 @@ -/* BOSS - -A plugin load order optimiser for games that use the esp/esm plugin system. - -Copyright (C) 2013-2014 WrinklyNinja - -This file is part of BOSS. - -BOSS 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. - -BOSS 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 BOSS. If not, see -. -*/ -#ifndef __BOSS_GUI_MISC__ -#define __BOSS_GUI_MISC__ - -#include "ids.h" -#include "../backend/metadata.h" - -#include -#include -#include -#include - -const wxString Type[3] = { - translate("Note"), - translate("Warning"), - translate("Error") -}; - -const wxString State[2] = { - translate("Add"), - translate("Remove") -}; - -class MessageList : public wxListView { -public: - MessageList(wxWindow * parent, wxWindowID id, const unsigned int language); - - void SetItems(const std::vector& messages); - std::vector GetItems() const; - - boss::Message GetItem(long item) const; - void SetItem(long item, const boss::Message& message); - void AppendItem(const boss::Message& message); - - void OnDeleteItem(wxListEvent& event); -protected: - wxString OnGetItemText(long item, long column) const; - -private: - std::vector _messages; - const unsigned int _language; -}; - -class FileEditDialog : public wxDialog { -public: - FileEditDialog(wxWindow *parent, const wxString& title); - - void SetValues(const wxString& name, const wxString& display, const wxString& condition); - wxString GetName() const; - wxString GetDisplayName() const; - wxString GetCondition() const; -private: - wxTextCtrl * _name; - wxTextCtrl * _display; - wxTextCtrl * _condition; -}; - -class MessageEditDialog : public wxDialog { -public: - MessageEditDialog(wxWindow *parent, const wxString& title); - - void SetMessage(const boss::Message& message); - boss::Message GetMessage() const; - - void OnSelect(wxListEvent& event); - void OnAdd(wxCommandEvent& event); - void OnEdit(wxCommandEvent& event); - void OnRemove(wxCommandEvent& event); -private: - wxButton * addBtn; - wxButton * editBtn; - wxButton * removeBtn; - wxChoice * _type; - wxChoice * _language; - wxListView * _content; - wxTextCtrl * _condition; - wxTextCtrl * _str; -}; - -class TagEditDialog : public wxDialog { -public: - TagEditDialog(wxWindow *parent, const wxString& title); - - void SetValues(int state, const wxString& name, const wxString& condition); - wxString GetState() const; - wxString GetName() const; - wxString GetCondition() const; -private: - wxChoice * _state; - wxTextCtrl * _name; - wxTextCtrl * _condition; -}; - -class DirtInfoEditDialog : public wxDialog { -public: - DirtInfoEditDialog(wxWindow * parent, const wxString& title); - - void SetValues(const wxString& crc, unsigned int itm, unsigned int udr, unsigned int nav, const wxString& utility); - wxString GetCRC() const; - wxString GetUtility() const; - unsigned int GetITMs() const; - unsigned int GetUDRs() const; - unsigned int GetDeletedNavmeshes() const; -private: - wxTextCtrl * _crc; - wxSpinCtrl * _itm; - wxSpinCtrl * _udr; - wxSpinCtrl * _nav; - wxTextCtrl * _utility; -}; -#endif \ No newline at end of file diff --git a/src/gui/resource.h b/src/gui/resource.h new file mode 100644 index 00000000..62e56a4c --- /dev/null +++ b/src/gui/resource.h @@ -0,0 +1,32 @@ +/* LOOT + +A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and +Fallout: New Vegas. + +Copyright (C) 2014 WrinklyNinja + +This file is part of LOOT. + +LOOT 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. + +LOOT 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 LOOT. If not, see +. +*/ + +#ifndef __LOOT_GUI_RESOURCE__ +#define __LOOT_GUI_RESOURCE__ + +#include + +#define MAINICON 101 + +#endif diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp deleted file mode 100644 index 8d41831c..00000000 --- a/src/gui/settings.cpp +++ /dev/null @@ -1,522 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2013-2014 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ - -#include "settings.h" -#include "../backend/helpers.h" -#include "../backend/globals.h" -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -SettingsFrame::SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings, std::vector& games) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER), _settings(settings), _games(games) { - - //Initialise drop-down list contents. - wxString DebugVerbosity[] = { - translate("None"), - translate("Low"), - translate("Medium"), - translate("High") - }; - - wxArrayString Games; - Games.Add(translate("Autodetect")); - for (size_t i=0,max=_games.size(); i < max; ++i) { - Games.Add(FromUTF8(_games[i].Name())); - } - - wxArrayString languages; - vector langs = boss::Language::Names(); - for (size_t i = 0; i < langs.size(); i++) { - languages.Add(FromUTF8(langs[i])); - } - - //Initialise controls. - GameChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Games); - LanguageChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, languages); - DebugVerbosityChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 4, DebugVerbosity); - - gamesList = new wxListView(this, LIST_Games, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL); - - addBtn = new wxButton(this, BUTTON_AddGame, translate("Add Game")); - editBtn = new wxButton(this, BUTTON_EditGame, translate("Edit Game")); - removeBtn = new wxButton(this, BUTTON_RemoveGame, translate("Remove Game")); - - UpdateMasterlistBox = new wxCheckBox(this, wxID_ANY, translate("Update masterlist before sorting.")); - reportViewBox = new wxCheckBox(this, wxID_ANY, translate("View reports externally in default browser.")); - - //Set up list columns. - gamesList->AppendColumn(translate("Name")); - gamesList->AppendColumn(translate("Base Game Type")); - gamesList->AppendColumn(translate("BOSS Folder Name")); - gamesList->AppendColumn(translate("Master File")); - gamesList->AppendColumn(translate("Masterlist Repository URL")); - gamesList->AppendColumn(translate("Masterlist Repository Branch")); - gamesList->AppendColumn(translate("Install Path")); - gamesList->AppendColumn(translate("Install Path Registry Key")); - - //Set up event handling. - Bind(wxEVT_LIST_ITEM_SELECTED, &SettingsFrame::OnGameSelect, this, LIST_Games); - Bind(wxEVT_BUTTON, &SettingsFrame::OnQuit, this, wxID_OK); - Bind(wxEVT_BUTTON, &SettingsFrame::OnAddGame, this, BUTTON_AddGame); - Bind(wxEVT_BUTTON, &SettingsFrame::OnEditGame, this, BUTTON_EditGame); - Bind(wxEVT_BUTTON, &SettingsFrame::OnRemoveGame, this, BUTTON_RemoveGame); - - //Set up layout. - wxSizerFlags leftItem(0); - leftItem.Left(); - - wxSizerFlags rightItem(1); - rightItem.Right(); - - wxSizerFlags wholeItem(0); - wholeItem.Border(wxLEFT|wxRIGHT|wxBOTTOM, 15); - - wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL); - - wxFlexGridSizer * GridSizer = new wxFlexGridSizer(2, 5, 5); - GridSizer->AddGrowableCol(1,1); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Default Game:")), leftItem); - GridSizer->Add(GameChoice, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Language:")), leftItem); - GridSizer->Add(LanguageChoice, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Debug Verbosity:")), leftItem); - GridSizer->Add(DebugVerbosityChoice, rightItem); - - bigBox->Add(GridSizer, 0, wxEXPAND|wxALL, 15); - - bigBox->Add(gamesList, 1, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 15); - - wxBoxSizer * hbox2 = new wxBoxSizer(wxHORIZONTAL); - hbox2->Add(addBtn, 0, wxRIGHT, 5); - hbox2->Add(editBtn, 0, wxLEFT|wxRIGHT, 5); - hbox2->Add(removeBtn, 0, wxLEFT, 5); - bigBox->Add(hbox2, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT, 15); - - bigBox->Add(UpdateMasterlistBox, wholeItem); - - bigBox->Add(reportViewBox, wholeItem); - - bigBox->AddSpacer(10); - - bigBox->Add(new wxStaticText(this, wxID_ANY, translate("Language and game changes will be applied after BOSS is restarted.")), wholeItem); - - //Need to add 'OK' and 'Cancel' buttons. - wxSizer * sizer = CreateSeparatedButtonSizer(wxOK|wxCANCEL); - - //Now add TabHolder and OK button to window sizer. - if (sizer != NULL) - bigBox->Add(sizer, 0, wxEXPAND|wxLEFT|wxBOTTOM|wxRIGHT, 15); - - //Initialise options with values. For checkboxes, they are off by default. - SetDefaultValues(); - - //Tooltips. - DebugVerbosityChoice->SetToolTip(translate("The output is logged to the BOSSDebugLog.txt file.")); - - //Now set the layout and sizes. - SetBackgroundColour(wxColour(255,255,255)); - SetIcon(wxIconLocation("BOSS.exe")); - SetSizerAndFit(bigBox); -} - -void SettingsFrame::SetDefaultValues() { - - BOOST_LOG_TRIVIAL(debug) << "Setting default values for BOSS's settings."; - - if (_settings["Language"]) { - LanguageChoice->SetSelection(boss::Language(_settings["Language"].as()).Code()); - } - - if (_settings["Game"]) { - string game = _settings["Game"].as(); - if (boost::iequals(game, "auto")) - GameChoice->SetSelection(0); - else { - for (size_t i=0,max=_games.size(); i < max; ++i) { - if (boost::iequals(game, _games[i].FolderName())) - GameChoice->SetSelection(i+1); - } - } - } - - if (_settings["Debug Verbosity"]) { - unsigned int verbosity = _settings["Debug Verbosity"].as(); - DebugVerbosityChoice->SetSelection(verbosity); - } - - if (_settings["Update Masterlist"]) { - bool update = _settings["Update Masterlist"].as(); - UpdateMasterlistBox->SetValue(update); - } - - if (_settings["View Report Externally"]) { - bool view = _settings["View Report Externally"].as(); - reportViewBox->SetValue(view); - } - - for (size_t i=0, max=_games.size(); i < max; ++i) { - gamesList->InsertItem(i, FromUTF8(_games[i].Name())); - gamesList->SetItem(i, 1, FromUTF8(boss::Game(_games[i].Id()).FolderName())); - gamesList->SetItem(i, 2, FromUTF8(_games[i].FolderName())); - gamesList->SetItem(i, 3, FromUTF8(_games[i].Master())); - gamesList->SetItem(i, 4, FromUTF8(_games[i].RepoURL())); - gamesList->SetItem(i, 5, FromUTF8(_games[i].RepoBranch())); - gamesList->SetItem(i, 6, FromUTF8(_games[i].GamePath().string())); - gamesList->SetItem(i, 7, FromUTF8(_games[i].RegistryKey())); - } - - addBtn->Enable(true); - editBtn->Enable(false); - removeBtn->Enable(false); -} - -void SettingsFrame::OnQuit(wxCommandEvent& event) { - if (event.GetId() == wxID_OK) { - - BOOST_LOG_TRIVIAL(debug) << "Applying settings."; - - if (GameChoice->GetSelection() == 0) - _settings["Game"] = "auto"; - else - _settings["Game"] = _games[GameChoice->GetSelection() - 1].FolderName(); - - _settings["Language"] = boss::Language(LanguageChoice->GetSelection()).Locale(); - - _settings["Debug Verbosity"] = DebugVerbosityChoice->GetSelection(); - - unsigned int verbosity = _settings["Debug Verbosity"].as(); - if (verbosity == 0) - boost::log::core::get()->set_logging_enabled(false); - else { - boost::log::core::get()->set_logging_enabled(true); - - if (verbosity == 1) - boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::warning); //Log all warnings, errors and fatals. - else if (verbosity == 2) - boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::debug); //Log debugs, infos, warnings, errors and fatals. - else - boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::trace); //Log everything. - } - - _settings["Update Masterlist"] = UpdateMasterlistBox->IsChecked(); - - _settings["View Report Externally"] = reportViewBox->IsChecked(); - - _games.clear(); - for (size_t i=0,max=gamesList->GetItemCount(); i < max; ++i) { - string name, folder, master, repo, branch, path, registry; - unsigned int id; - - name = gamesList->GetItemText(i, 0).ToUTF8(); - folder = gamesList->GetItemText(i, 2).ToUTF8(); - master = gamesList->GetItemText(i, 3).ToUTF8(); - repo = gamesList->GetItemText(i, 4).ToUTF8(); - branch = gamesList->GetItemText(i, 5).ToUTF8(); - path = gamesList->GetItemText(i, 6).ToUTF8(); - registry = gamesList->GetItemText(i, 7).ToUTF8(); - - if (gamesList->GetItemText(i, 1).ToUTF8() == boss::Game(boss::g_game_tes4).FolderName()) - id = boss::g_game_tes4; - else if (gamesList->GetItemText(i, 1).ToUTF8() == boss::Game(boss::g_game_tes5).FolderName()) - id = boss::g_game_tes5; - else if (gamesList->GetItemText(i, 1).ToUTF8() == boss::Game(boss::g_game_fo3).FolderName()) - id = boss::g_game_fo3; - else - id = boss::g_game_fonv; - - _games.push_back(boss::Game(id, folder).SetDetails(name, master, repo, branch, path, registry)); - } - } - - EndModal(0); -} - -void SettingsFrame::OnGameSelect(wxListEvent& event) { - wxString name = gamesList->GetItemText(event.GetIndex()); - if (name == boss::Game(boss::g_game_tes4).Name() - || name == boss::Game(boss::g_game_tes5).Name() - || name == boss::Game(boss::g_game_fo3).Name() - || name == boss::Game(boss::g_game_fonv).Name()) { - removeBtn->Enable(false); - } else { - removeBtn->Enable(true); - } - editBtn->Enable(true); -} - -void SettingsFrame::OnAddGame(wxCommandEvent& event) { - BOOST_LOG_TRIVIAL(debug) << "Adding new game to settings."; - - GameEditDialog * rowDialog = new GameEditDialog(this, translate("BOSS: Add Game")); - - if (rowDialog->ShowModal() == wxID_OK) { - - if (rowDialog->GetPath().empty() && rowDialog->GetRegistryKey().empty()) { - BOOST_LOG_TRIVIAL(error) << "Tried to add a new game with no path or registry key given."; - wxMessageBox( - translate("Error: A path and/or registry key is required. Row will not be added."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - return; - } - - //Also check that name and folder name don't already exist in the list. - for (size_t i=0,max=gamesList->GetItemCount(); i < max; ++i) { - if (rowDialog->GetName() == gamesList->GetItemText(i, 0)) { - BOOST_LOG_TRIVIAL(error) << "Tried to add a new game with the same name as one that is already defined."; - wxMessageBox( - translate("Error: A game with this name is already defined. Row will not be added."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - return; - } else if (rowDialog->GetFolderName() == gamesList->GetItemText(i, 2)) { - BOOST_LOG_TRIVIAL(error) << "Tried to add a new game with the same folder as one that is already defined."; - wxMessageBox( - translate("Error: A game with this folder name is already defined. Row will not be added."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - return; - } - } - - long i = gamesList->GetItemCount(); - gamesList->InsertItem(i, rowDialog->GetName()); - gamesList->SetItem(i, 1, rowDialog->GetType().ToUTF8()); - gamesList->SetItem(i, 2, rowDialog->GetFolderName()); - gamesList->SetItem(i, 3, rowDialog->GetMaster()); - gamesList->SetItem(i, 4, rowDialog->GetRepoURL()); - gamesList->SetItem(i, 5, rowDialog->GetRepoBranch()); - gamesList->SetItem(i, 6, rowDialog->GetPath()); - gamesList->SetItem(i, 7, rowDialog->GetRegistryKey()); - } -} - -void SettingsFrame::OnEditGame(wxCommandEvent& event) { - BOOST_LOG_TRIVIAL(debug) << "Editing game settings."; - - GameEditDialog * rowDialog = new GameEditDialog(this, translate("BOSS: Edit Game")); - - long i = gamesList->GetFirstSelected(); - - int stateNo; - if (gamesList->GetItemText(i, 1) == boss::Game(boss::g_game_tes4).FolderName()) - stateNo = boss::g_game_tes4; - else if (gamesList->GetItemText(i, 1) == boss::Game(boss::g_game_tes5).FolderName()) - stateNo = boss::g_game_tes5; - else if (gamesList->GetItemText(i, 1) == boss::Game(boss::g_game_fo3).FolderName()) - stateNo = boss::g_game_fo3; - else - stateNo = boss::g_game_fonv; - - rowDialog->SetValues(stateNo, gamesList->GetItemText(i, 0), gamesList->GetItemText(i, 2), gamesList->GetItemText(i, 3), gamesList->GetItemText(i, 4), gamesList->GetItemText(i, 5), gamesList->GetItemText(i, 6), gamesList->GetItemText(i, 7)); - - if (rowDialog->ShowModal() == wxID_OK) { - - if (rowDialog->GetName().empty()) { - BOOST_LOG_TRIVIAL(error) << "Tried to blank a game's name field."; - wxMessageBox( - translate("Error: Name is required. Row will not be added."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - return; - } else if (rowDialog->GetFolderName().empty()) { - BOOST_LOG_TRIVIAL(error) << "Tried to blank a game's folder field."; - wxMessageBox( - translate("Error: Folder is required. Row will not be added."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - return; - } else if (rowDialog->GetPath().empty() && rowDialog->GetRegistryKey().empty()) { - BOOST_LOG_TRIVIAL(error) << "Tried to edit a game with no path or registry key given."; - wxMessageBox( - translate("Error: A path and/or registry key is required. Row will not be added."), - translate("BOSS: Error"), - wxOK | wxICON_ERROR, - this); - return; - } - - gamesList->SetItem(i, 0, rowDialog->GetName()); - gamesList->SetItem(i, 1, rowDialog->GetType()); - gamesList->SetItem(i, 2, rowDialog->GetFolderName()); - gamesList->SetItem(i, 3, rowDialog->GetMaster()); - gamesList->SetItem(i, 4, rowDialog->GetRepoURL()); - gamesList->SetItem(i, 5, rowDialog->GetRepoBranch()); - gamesList->SetItem(i, 6, rowDialog->GetPath()); - gamesList->SetItem(i, 7, rowDialog->GetRegistryKey()); - } -} - -void SettingsFrame::OnRemoveGame(wxCommandEvent& event) { - BOOST_LOG_TRIVIAL(debug) << "Removing game from settings."; - - gamesList->DeleteItem(gamesList->GetFirstSelected()); - - editBtn->Enable(false); - removeBtn->Enable(false); -} - -GameEditDialog::GameEditDialog(wxWindow *parent, const wxString& title) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) { - - wxString Types[] = { - FromUTF8(boss::Game(boss::g_game_tes4).FolderName()), - FromUTF8(boss::Game(boss::g_game_tes5).FolderName()), - FromUTF8(boss::Game(boss::g_game_fo3).FolderName()), - FromUTF8(boss::Game(boss::g_game_fonv).FolderName()) - }; - - //Initialise controls. - _type = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 4, Types); - - _name = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_EMPTY)); - _folderName = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_EMPTY)); - _master = new wxTextCtrl(this, wxID_ANY); - _repo = new wxTextCtrl(this, wxID_ANY); - _branch = new wxTextCtrl(this, wxID_ANY); - _path = new wxTextCtrl(this, wxID_ANY); - _registry = new wxTextCtrl(this, wxID_ANY); - - //Sizers stuff. - wxSizerFlags leftItem(0); - leftItem.Left(); - - wxSizerFlags rightItem(1); - rightItem.Right().Expand(); - - wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL); - - wxFlexGridSizer * GridSizer = new wxFlexGridSizer(2, 5, 5); - GridSizer->AddGrowableCol(1,1); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Name (required):")), leftItem); - GridSizer->Add(_name, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Type:")), leftItem); - GridSizer->Add(_type, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("BOSS Folder Name (required):")), leftItem); - GridSizer->Add(_folderName, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Master File:")), leftItem); - GridSizer->Add(_master, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Masterlist Repository URL:")), leftItem); - GridSizer->Add(_repo, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Masterlist Repository Branch:")), leftItem); - GridSizer->Add(_branch, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Install Path:")), leftItem); - GridSizer->Add(_path, rightItem); - - GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Install Path Registry Key:")), leftItem); - GridSizer->Add(_registry, rightItem); - - bigBox->Add(GridSizer, 0, wxEXPAND|wxALL, 15); - - bigBox->AddSpacer(10); - bigBox->AddStretchSpacer(1); - - //Need to add 'OK' and 'Cancel' buttons. - wxSizer * sizer = CreateSeparatedButtonSizer(wxOK|wxCANCEL); - if (sizer != NULL) - bigBox->Add(sizer, 0, wxEXPAND|wxLEFT|wxBOTTOM|wxRIGHT, 15); - - //Set defaults. - _type->SetSelection(0); - - SetBackgroundColour(wxColour(255,255,255)); - SetIcon(wxIconLocation("BOSS.exe")); - SetSizerAndFit(bigBox); -} - -void GameEditDialog::SetValues(unsigned int type, const wxString& name, const wxString& folderName, const wxString& master, - const wxString& repo, const wxString& branch, const wxString& path, const wxString& registry) { - if (type == boss::g_game_tes4) - _type->SetSelection(0); - else if (type == boss::g_game_tes5) - _type->SetSelection(1); - else if (type == boss::g_game_fo3) - _type->SetSelection(2); - else - _type->SetSelection(3); - - _name->SetValue(name); - _folderName->SetValue(folderName); - _master->SetValue(master); - _repo->SetValue(repo); - _branch->SetValue(branch); - _path->SetValue(path); - _registry->SetValue(registry); - - //Also disable the name and folder name text controls to prevent them being changed for games that already exist. - _name->Enable(false); - _folderName->Enable(false); -} - -wxString GameEditDialog::GetName() const { - return _name->GetValue(); -} - -wxString GameEditDialog::GetType() const { - return _type->GetString(_type->GetSelection()); -} - -wxString GameEditDialog::GetFolderName() const { - return _folderName->GetValue(); -} - -wxString GameEditDialog::GetMaster() const { - return _master->GetValue(); -} - -wxString GameEditDialog::GetRepoURL() const { - return _repo->GetValue(); -} - -wxString GameEditDialog::GetRepoBranch() const { - return _branch->GetValue(); -} - -wxString GameEditDialog::GetPath() const { - return _path->GetValue(); -} - -wxString GameEditDialog::GetRegistryKey() const { - return _registry->GetValue(); -} - diff --git a/src/gui/settings.h b/src/gui/settings.h deleted file mode 100644 index 05f839b5..00000000 --- a/src/gui/settings.h +++ /dev/null @@ -1,85 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2013-2014 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ - -#ifndef __BOSS_GUI_SETTINGS__ -#define __BOSS_GUI_SETTINGS__ - -#include "ids.h" -#include "../backend/game.h" - -#include -#include - -class SettingsFrame : public wxDialog { -public: - SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings, std::vector& games); - - void OnQuit(wxCommandEvent& event); - void OnGameSelect(wxListEvent& event); - void OnAddGame(wxCommandEvent& event); - void OnEditGame(wxCommandEvent& event); - void OnRemoveGame(wxCommandEvent& event); - - void SetDefaultValues(); -private: - wxChoice *DebugVerbosityChoice; - wxChoice *GameChoice; - wxChoice *LanguageChoice; - wxCheckBox *UpdateMasterlistBox; - wxCheckBox *reportViewBox; - - wxListView *gamesList; - wxButton * addBtn; - wxButton * editBtn; - wxButton * removeBtn; - - YAML::Node& _settings; - std::vector& _games; -}; - -class GameEditDialog : public wxDialog { -public: - GameEditDialog(wxWindow *parent, const wxString& title); - - void SetValues(unsigned int type, const wxString& name, const wxString& folderName, const wxString& master, - const wxString& repo, const wxString& branch, const wxString& path, const wxString& registry); - wxString GetName() const; - wxString GetType() const; - wxString GetFolderName() const; - wxString GetMaster() const; - wxString GetRepoURL() const; - wxString GetRepoBranch() const; - wxString GetPath() const; - wxString GetRegistryKey() const; -private: - wxChoice * _type; - wxTextCtrl * _name; - wxTextCtrl * _folderName; - wxTextCtrl * _master; - wxTextCtrl * _repo; - wxTextCtrl * _branch; - wxTextCtrl * _path; - wxTextCtrl * _registry; -}; - -#endif diff --git a/src/gui/viewer.cpp b/src/gui/viewer.cpp deleted file mode 100644 index 19f166aa..00000000 --- a/src/gui/viewer.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2013-2014 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ - -#include "viewer.h" -#include "../backend/helpers.h" - -#include - -Viewer::Viewer(wxWindow *parent, const wxString& title, const wxString& url) : wxFrame(parent, wxID_ANY, title) { - wxWebView * web = wxWebView::New(this, wxID_ANY, url); - - web->Bind(wxEVT_WEBVIEW_NAVIGATING, &Viewer::OnNavigationStart, this); - - wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL); - - topsizer->Add(web, 1, wxEXPAND); - - SetSizer(topsizer); - SetSize(800,600); - SetIcon(wxIconLocation("BOSS.exe")); -} - -void Viewer::OnNavigationStart(wxWebViewEvent& event) { - wxLaunchDefaultBrowser(event.GetURL()); - event.Veto(); -} diff --git a/src/gui/viewer.h b/src/gui/viewer.h deleted file mode 100644 index 8e21ad96..00000000 --- a/src/gui/viewer.h +++ /dev/null @@ -1,38 +0,0 @@ -/* BOSS - - A plugin load order optimiser for games that use the esp/esm plugin system. - - Copyright (C) 2013-2014 WrinklyNinja - - This file is part of BOSS. - - BOSS 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. - - BOSS 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 BOSS. If not, see - . -*/ - -#ifndef __BOSS_GUI_VIEWER__ -#define __BOSS_GUI_VIEWER__ - -#include "ids.h" - -#include - -class Viewer : public wxFrame { -public: - Viewer(wxWindow *parent, const wxString& title, const wxString& url); - - void OnNavigationStart(wxWebViewEvent& event); -}; - -#endif diff --git a/src/installer.nsi b/src/installer.nsi index 7b9a4d0c..7eba1cc9 100644 --- a/src/installer.nsi +++ b/src/installer.nsi @@ -1,4 +1,4 @@ -;BOSS NSIS Installer Script +;LOOT NSIS Installer Script ;-------------------------------- ;Include NSIS files. @@ -74,9 +74,9 @@ FunctionEnd ;General ;Name, file and version info for installer. - Name "BOSS v3.0.0" - OutFile "..\build\BOSS Installer.exe" - VIProductVersion 3.0.0.0 + Name "LOOT v0.7.0" + OutFile "..\build\LOOT Installer.exe" + VIProductVersion 0.7.0.0 ;Request application privileges for Windows Vista/7 RequestExecutionLevel admin @@ -89,15 +89,15 @@ FunctionEnd !define MUI_ABORTWARNING !define MUI_UNABORTWARNING - ;Checks that the installer's CRC is correct (means we can remove installer CRC checking from BOSS). + ;Checks that the installer's CRC is correct. CRCCheck force ;The SOLID lzma compressor gives the best compression ratio. SetCompressor /SOLID lzma ;Default install directory. - InstallDir "$PROGRAMFILES\BOSS" - InstallDirRegKey HKLM "Software\BOSS" "Installed Path" + InstallDir "$PROGRAMFILES\LOOT" + InstallDirRegKey HKLM "Software\LOOT" "Installed Path" ;-------------------------------- ;Pages @@ -108,9 +108,9 @@ FunctionEnd !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !define MUI_FINISHPAGE_NOAUTOCLOSE - !define MUI_FINISHPAGE_RUN "$INSTDIR\BOSS.exe" + !define MUI_FINISHPAGE_RUN "$INSTDIR\LOOT.exe" !define MUI_FINISHPAGE_RUN_TEXT "$(Text_Run)" - !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\Docs\BOSS Readme.html" + !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\Docs\LOOT Readme.html" !define MUI_FINISHPAGE_SHOWREADME_TEXT "$(Text_ShowReadme)" !insertmacro MUI_PAGE_FINISH @@ -124,138 +124,154 @@ FunctionEnd !insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "Russian" - ;!insertmacro MUI_LANGUAGE "German" + !insertmacro MUI_LANGUAGE "German" !insertmacro MUI_LANGUAGE "Spanish" !insertmacro MUI_LANGUAGE "SimpChinese" !insertmacro MUI_LANGUAGE "French" !insertmacro MUI_LANGUAGE "Polish" + !insertmacro MUI_LANGUAGE "Finnish" !insertmacro MUI_LANGUAGE "Danish" !insertmacro MUI_RESERVEFILE_LANGDLL ;-------------------------------- ;English Strings - VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "BOSS" - VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "BOSS Development Team" - VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "© 2009-2014 BOSS Development Team" - VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Installer for BOSS 3.0.0" - VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "3.0.0" + VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "LOOT" + VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "LOOT Team" + VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "© 2009-2014 LOOT Team" + VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Installer for LOOT 0.7.0" + VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "0.7.0" - LangString TEXT_MESSAGEBOX ${LANG_ENGLISH} "BOSS is already installed, and must be uninstalled before continuing. $\n$\nClick `OK` to remove the previous version or `Cancel` to cancel this upgrade." - LangString TEXT_RUN ${LANG_ENGLISH} "Run BOSS" + LangString TEXT_MESSAGEBOX ${LANG_ENGLISH} "LOOT is already installed, and must be uninstalled before continuing. $\n$\nClick `OK` to remove the previous version or `Cancel` to cancel this upgrade." + LangString TEXT_RUN ${LANG_ENGLISH} "Run LOOT" LangString TEXT_SHOWREADME ${LANG_ENGLISH} "View Readme" - LangString TEXT_MAIN ${LANG_ENGLISH} "All BOSS's files, minus userlists and settings file." - LangString TEXT_USERFILES ${LANG_ENGLISH} "BOSS's userlist files and settings file." + LangString TEXT_MAIN ${LANG_ENGLISH} "All LOOT's files, minus userlists and settings file." + LangString TEXT_USERFILES ${LANG_ENGLISH} "LOOT's userlist files and settings file." ;-------------------------------- ;Russian (Русский) Strings - VIAddVersionKey /LANG=${LANG_RUSSIAN} "ProductName" "BOSS" - VIAddVersionKey /LANG=${LANG_RUSSIAN} "CompanyName" "BOSS Development Team" - VIAddVersionKey /LANG=${LANG_RUSSIAN} "LegalCopyright" "© 2009-2014 BOSS Development Team" - VIAddVersionKey /LANG=${LANG_RUSSIAN} "FileDescription" "Установщик для BOSS 3.0.0" - VIAddVersionKey /LANG=${LANG_RUSSIAN} "FileVersion" "3.0.0" + VIAddVersionKey /LANG=${LANG_RUSSIAN} "ProductName" "LOOT" + VIAddVersionKey /LANG=${LANG_RUSSIAN} "CompanyName" "LOOT Team" + VIAddVersionKey /LANG=${LANG_RUSSIAN} "LegalCopyright" "© 2009-2014 LOOT Team" + VIAddVersionKey /LANG=${LANG_RUSSIAN} "FileDescription" "Установщик для LOOT 0.7.0" + VIAddVersionKey /LANG=${LANG_RUSSIAN} "FileVersion" "0.7.0" - LangString TEXT_MESSAGEBOX ${LANG_RUSSIAN} "BOSS уже установлен и должен быть удален перед продолжением. $\n$\nНажмите `OK` для удаления предыдущей версии или `Отмена` для отмены обновления." - LangString TEXT_RUN ${LANG_RUSSIAN} "Запустить BOSS" + LangString TEXT_MESSAGEBOX ${LANG_RUSSIAN} "LOOT уже установлен и должен быть удален перед продолжением. $\n$\nНажмите `OK` для удаления предыдущей версии или `Отмена` для отмены обновления." + LangString TEXT_RUN ${LANG_RUSSIAN} "Запустить LOOT" LangString TEXT_SHOWREADME ${LANG_RUSSIAN} "Просмотр документации" - LangString TEXT_MAIN ${LANG_RUSSIAN} "Все файлы BOSS, кроме пользовательских списков и файла настроек" - LangString TEXT_USERFILES ${LANG_RUSSIAN} "Файлы пользовательских списков BOSS и файл настроек." - -;-------------------------------- -;German (Deutsch) Strings - - ;VIAddVersionKey /LANG=${LANG_GERMAN} "ProductName" "BOSS" - ;VIAddVersionKey /LANG=${LANG_GERMAN} "CompanyName" "BOSS Development Team" - ;VIAddVersionKey /LANG=${LANG_GERMAN} "LegalCopyright" "© 2009-2014 BOSS Development Team" - ;VIAddVersionKey /LANG=${LANG_GERMAN} "FileDescription" "Installer für BOSS 3.0.0" - ;VIAddVersionKey /LANG=${LANG_GERMAN} "FileVersion" "3.0.0" - - ;LangString TEXT_MESSAGEBOX ${LANG_GERMAN} "BOSS ist bereits installiert und muss deinstalliert werden, bevor fortgefahren wird. $\n$\nKlicke auf `Ok` um die vorherige Version zu entfernen oder auf `Abbrechen` um das Upgrade abzubrechen." - ;LangString TEXT_RUN ${LANG_GERMAN} "BOSS starten" - ;LangString TEXT_SHOWREADME ${LANG_GERMAN} "Readme lesen" - ;LangString TEXT_MAIN ${LANG_GERMAN} "Alle Dateien von BOSS ohne die Benutzerlisten und die BOSS.ini." - ;LangString TEXT_USERFILES ${LANG_GERMAN} "Benutzerliste von BOSS und die BOSS.ini-Datei." + LangString TEXT_MAIN ${LANG_RUSSIAN} "Все файлы LOOT, кроме пользовательских списков и файла настроек" + LangString TEXT_USERFILES ${LANG_RUSSIAN} "Файлы пользовательских списков LOOT и файл настроек." ;-------------------------------- ;French (Français) Strings - VIAddVersionKey /LANG=${LANG_FRENCH} "ProductName" "BOSS" - VIAddVersionKey /LANG=${LANG_FRENCH} "CompanyName" "BOSS Development Team" - VIAddVersionKey /LANG=${LANG_FRENCH} "LegalCopyright" "© 2009-2014 BOSS Development Team" - VIAddVersionKey /LANG=${LANG_FRENCH} "FileDescription" "Programme d'installation pour BOSS 3.0.0" - VIAddVersionKey /LANG=${LANG_FRENCH} "FileVersion" "3.0.0" + VIAddVersionKey /LANG=${LANG_FRENCH} "ProductName" "LOOT" + VIAddVersionKey /LANG=${LANG_FRENCH} "CompanyName" "LOOT Team" + VIAddVersionKey /LANG=${LANG_FRENCH} "LegalCopyright" "© 2009-2014 LOOT Team" + VIAddVersionKey /LANG=${LANG_FRENCH} "FileDescription" "Programme d'installation pour LOOT 0.7.0" + VIAddVersionKey /LANG=${LANG_FRENCH} "FileVersion" "0.7.0" - LangString TEXT_MESSAGEBOX ${LANG_FRENCH} "BOSS est déjà installé, et doit être désinstallé avant de continuer. $\n$\nCliquer sur `OK` pour désinstaller la version précédente ou 'Annuler' pour annuler la mise à jour." - LangString TEXT_RUN ${LANG_FRENCH} "Lancer BOSS" + LangString TEXT_MESSAGEBOX ${LANG_FRENCH} "LOOT est déjà installé, et doit être désinstallé avant de continuer. $\n$\nCliquer sur `OK` pour désinstaller la version précédente ou 'Annuler' pour annuler la mise à jour." + LangString TEXT_RUN ${LANG_FRENCH} "Lancer LOOT" LangString TEXT_SHOWREADME ${LANG_FRENCH} "Afficher la documentation" - LangString TEXT_MAIN ${LANG_FRENCH} "Tous les fichiers de BOSS, sauf les userlists et les règlages." - LangString TEXT_USERFILES ${LANG_FRENCH} "L'userlist de BOSS et les règlages." + LangString TEXT_MAIN ${LANG_FRENCH} "Tous les fichiers de LOOT, sauf les userlists et les règlages." + LangString TEXT_USERFILES ${LANG_FRENCH} "L'userlist de LOOT et les règlages." ;-------------------------------- ;Spanish (castellano) Strings - VIAddVersionKey /LANG=${LANG_SPANISH} "ProductName" "BOSS" - VIAddVersionKey /LANG=${LANG_SPANISH} "CompanyName" "BOSS Development Team" - VIAddVersionKey /LANG=${LANG_SPANISH} "LegalCopyright" "© 2009-2014 BOSS Development Team" - VIAddVersionKey /LANG=${LANG_SPANISH} "FileDescription" "El instalador para BOSS 3.0.0" - VIAddVersionKey /LANG=${LANG_SPANISH} "FileVersion" "3.0.0" + VIAddVersionKey /LANG=${LANG_SPANISH} "ProductName" "LOOT" + VIAddVersionKey /LANG=${LANG_SPANISH} "CompanyName" "LOOT Team" + VIAddVersionKey /LANG=${LANG_SPANISH} "LegalCopyright" "© 2009-2014 LOOT Team" + VIAddVersionKey /LANG=${LANG_SPANISH} "FileDescription" "El instalador para LOOT 0.7.0" + VIAddVersionKey /LANG=${LANG_SPANISH} "FileVersion" "0.7.0" - LangString TEXT_MESSAGEBOX ${LANG_SPANISH} "BOSS está instalado, y debe ser desinstalado antes de continuar. $\n$\nPresione `OK` para eliminar la versión anterior o `Cancel` para cancelar la actualización." - LangString TEXT_RUN ${LANG_SPANISH} "Ejecutar BOSS" + LangString TEXT_MESSAGEBOX ${LANG_SPANISH} "LOOT está instalado, y debe ser desinstalado antes de continuar. $\n$\nPresione `OK` para eliminar la versión anterior o `Cancel` para cancelar la actualización." + LangString TEXT_RUN ${LANG_SPANISH} "Ejecutar LOOT" LangString TEXT_SHOWREADME ${LANG_SPANISH} "Ver Léame" - LangString TEXT_MAIN ${LANG_SPANISH} "Todos los archivos de BOSS, menos la lista de usuario y configuraciónes." + LangString TEXT_MAIN ${LANG_SPANISH} "Todos los archivos de LOOT, menos la lista de usuario y configuraciónes." LangString TEXT_USERFILES ${LANG_SPANISH} "La lista de usuario y configuraciónes." ;-------------------------------- ;Simplified Chinese (简体中文) Strings - VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "ProductName" "BOSS" - VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "CompanyName" "BOSS Development Team" - VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "LegalCopyright" "© 2009-2014 BOSS Development Team" - VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "FileDescription" "BOSS 3.0.0安装包" - VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "FileVersion" "3.0.0" + VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "ProductName" "LOOT" + VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "CompanyName" "LOOT Team" + VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "LegalCopyright" "© 2009-2014 LOOT Team" + VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "FileDescription" "LOOT 0.7.0安装包" + VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "FileVersion" "0.7.0" + + LangString TEXT_MESSAGEBOX ${LANG_SIMPCHINESE} "检测到旧版LOOT,您需要先卸载旧版才能安装新版。$\n$\n点击“确定”卸载旧版本或者“取消”取消更新。" + LangString TEXT_RUN ${LANG_SIMPCHINESE} "运行LOOT" + LangString TEXT_SHOWREADME ${LANG_SIMPCHINESE} "查看说明" + LangString TEXT_MAIN ${LANG_SIMPCHINESE} "所有LOOT文件(除userlist和配置文件)" + LangString TEXT_USERFILES ${LANG_SIMPCHINESE} "LOOT的userlist和配置文件。" - LangString TEXT_MESSAGEBOX ${LANG_SIMPCHINESE} "检测到旧版BOSS,您需要先卸载旧版才能安装新版。$\n$\n点击“确定”卸载旧版本或者“取消”取消更新。" - LangString TEXT_RUN ${LANG_SIMPCHINESE} "运行BOSS" - LangString TEXT_SHOWREADME ${LANG_SIMPCHINESE} "查看说明" - LangString TEXT_MAIN ${LANG_SIMPCHINESE} "所有BOSS文件(除userlist和配置文件)" - LangString TEXT_USERFILES ${LANG_SIMPCHINESE} "BOSS的userlist和配置文件。" - ;-------------------------------- ;Polish (POLSKI) Strings - VIAddVersionKey /LANG=${LANG_POLISH} "ProductName" "BOSS" - VIAddVersionKey /LANG=${LANG_POLISH} "CompanyName" "BOSS Development Team" - VIAddVersionKey /LANG=${LANG_POLISH} "LegalCopyright" "© 2009-2014 BOSS Development Team" - VIAddVersionKey /LANG=${LANG_POLISH} "FileDescription" "Instalator dla BOSS 3.0.0" - VIAddVersionKey /LANG=${LANG_POLISH} "FileVersion" "3.0.0" + VIAddVersionKey /LANG=${LANG_POLISH} "ProductName" "LOOT" + VIAddVersionKey /LANG=${LANG_POLISH} "CompanyName" "LOOT Team" + VIAddVersionKey /LANG=${LANG_POLISH} "LegalCopyright" "© 2009-2014 LOOT Team" + VIAddVersionKey /LANG=${LANG_POLISH} "FileDescription" "Instalator dla LOOT 0.7.0" + VIAddVersionKey /LANG=${LANG_POLISH} "FileVersion" "0.7.0" - LangString TEXT_MESSAGEBOX ${LANG_POLISH} "BOSS jest już zainstalowany i musi zostać odinstalowany przed instalowaniem tej wersji. $\n$\nClick `OK` aby odinstalować lub `Cancel` aby anulować aktualizację." - LangString TEXT_RUN ${LANG_POLISH} " Uruchom BOSS" + LangString TEXT_MESSAGEBOX ${LANG_POLISH} "LOOT jest już zainstalowany i musi zostać odinstalowany przed instalowaniem tej wersji. $\n$\nClick `OK` aby odinstalować lub `Cancel` aby anulować aktualizację." + LangString TEXT_RUN ${LANG_POLISH} " Uruchom LOOT" LangString TEXT_SHOWREADME ${LANG_POLISH} "Czytaj Readme" - LangString TEXT_MAIN ${LANG_POLISH} "Wszystkie pliki BOSS bez ustawień i plików użytkownika." - LangString TEXT_USERFILES ${LANG_POLISH} "Wszystkie pliki BOSS oraz ustawienia użytkownika ." + LangString TEXT_MAIN ${LANG_POLISH} "Wszystkie pliki LOOT bez ustawień i plików użytkownika." + LangString TEXT_USERFILES ${LANG_POLISH} "Wszystkie pliki LOOT oraz ustawienia użytkownika ." + +;-------------------------------- +;Finnish Strings + + VIAddVersionKey /LANG=${LANG_FINNISH} "ProductName" "LOOT" + VIAddVersionKey /LANG=${LANG_FINNISH} "CompanyName" "LOOT Team" + VIAddVersionKey /LANG=${LANG_FINNISH} "LegalCopyright" "© 2009-2014 LOOT Team" + VIAddVersionKey /LANG=${LANG_FINNISH} "FileDescription" "LOOT 0.7.0 Asennusohjelma" + VIAddVersionKey /LANG=${LANG_FINNISH} "FileVersion" "0.7.0" + + LangString TEXT_MESSAGEBOX ${LANG_FINNISH} "LOOT on jo asennettu ja vanha asennus on poistettava ennen jatkamista. $\n$\nKlikkaa 'OK' poistaaksesi vanhan version tai 'Peruuta' peruuttaaksesi päivityksen." + LangString TEXT_RUN ${LANG_FINNISH} "Käynnistä LOOT" + LangString TEXT_SHOWREADME ${LANG_FINNISH} "Näytä readme" + LangString TEXT_MAIN ${LANG_FINNISH} "Kaikki LOOTin tiedostot paitsi käyttäjälistat ja asetukset." + LangString TEXT_USERFILES ${LANG_FINNISH} "LOOTin käyttäjälistat ja asetukset." + +;-------------------------------- +;German Strings + + VIAddVersionKey /LANG=${LANG_GERMAN} "ProductName" "LOOT" + VIAddVersionKey /LANG=${LANG_GERMAN} "CompanyName" "LOOT Team" + VIAddVersionKey /LANG=${LANG_GERMAN} "LegalCopyright" "© 2009-2014 LOOT Team" + VIAddVersionKey /LANG=${LANG_GERMAN} "FileDescription" "Installationsprogramm LOOT 0.7.0" + VIAddVersionKey /LANG=${LANG_GERMAN} "FileVersion" "0.7.0" + + LangString TEXT_MESSAGEBOX ${LANG_GERMAN} "LOOT ist bereits installiert und muss zunächst deinstalliert werden. $\n$\nKlicken Sie auf 'OK', um die frühere Version zu deinstallieren oder auf 'Abbrechen', um diese Installation abzubrechen." + LangString TEXT_RUN ${LANG_GERMAN} "LOOT starten" + LangString TEXT_SHOWREADME ${LANG_GERMAN} "Readme öffnen" + LangString TEXT_MAIN ${LANG_GERMAN} "Alle LOOT Dateien mit Ausnahme der Benutzerlisten-Dateien und Konfigurationsdateien." + LangString TEXT_USERFILES ${LANG_GERMAN} "LOOT Benutzerlisten-Dateien und Konfigurationsdateien." ;-------------------------------- ;Danish (dansk) Strings - VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "BOSS" - VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "BOSS Development Team" - VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "© 2009-2014 BOSS Development Team" - VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Installationsprogram for BOSS 3.0.0" - VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "3.0.0" + VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "LOOT" + VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "LOOT Team" + VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "© 2009-2014 LOOT Team" + VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Installationsprogram for LOOT 0.7.0" + VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "0.7.0" - LangString TEXT_MESSAGEBOX ${LANG_ENGLISH} "BOSS er allerede installeret og skal afinstalleres før du fortsætter. $\n$\nTryk på »OK« for at fjerne den forrige version eller »Annuller« for at annullere opdateringen." - LangString TEXT_RUN ${LANG_ENGLISH} "Kør BOSS" + LangString TEXT_MESSAGEBOX ${LANG_ENGLISH} "LOOT er allerede installeret og skal afinstalleres før du fortsætter. $\n$\nTryk på »OK« for at fjerne den forrige version eller »Annuller« for at annullere opdateringen." + LangString TEXT_RUN ${LANG_ENGLISH} "Kør LOOT" LangString TEXT_SHOWREADME ${LANG_ENGLISH} "Vis Readme" - LangString TEXT_MAIN ${LANG_ENGLISH} "Alle BOSS's filer, undtagen brugerlister og indstillingsfiler." - LangString TEXT_USERFILES ${LANG_ENGLISH} "BOSS's brugerliste- og indstillingsfile." + LangString TEXT_MAIN ${LANG_ENGLISH} "Alle LOOT's filer, undtagen brugerlister og indstillingsfiler." + LangString TEXT_USERFILES ${LANG_ENGLISH} "LOOT's brugerliste- og indstillingsfile." ;-------------------------------- ;Initialisations - Var InstallPath ;Path to existing BOSS install. + Var InstallPath ;Path to existing LOOT install. Function .onInit @@ -264,8 +280,8 @@ FunctionEnd FunctionEnd Function onGUIInit - ; First check to see if BOSS is already installed via installer, and launch the existing uninstaller if so. - ReadRegStr $InstallPath HKLM "Software\BOSS" "Installed Path" + ; First check to see if LOOT is already installed via installer, and launch the existing uninstaller if so. + ReadRegStr $InstallPath HKLM "Software\LOOT" "Installed Path" ${If} $InstallPath != "" IfFileExists "$InstallPath\Uninstall.exe" 0 +8 MessageBox MB_OKCANCEL|MB_ICONQUESTION "$(Text_MessageBox)" IDOK cont IDCANCEL cancel @@ -291,18 +307,34 @@ FunctionEnd ;Install executable. SetOutPath "$INSTDIR" - File "..\build\BOSS.exe" - - ;Now install API DLLs. - ;SetOutPath "$INSTDIR\API" - ;File "..\build\libboss32.dll" - ;File "..\build\libboss64.dll" + File "..\build\Release\LOOT.exe" + File "..\build\Release\d3dcompiler_43.dll" + File "..\build\Release\d3dcompiler_46.dll" + File "..\build\Release\libEGL.dll" + File "..\build\Release\libGLESv2.dll" + File "..\build\Release\libcef.dll" + File "..\build\Release\cef.pak" + File "..\build\Release\cef_100_percent.pak" + File "..\build\Release\cef_200_percent.pak" + File "..\build\Release\devtools_resources.pak" + File "..\build\Release\icudtl.dat" ;Install resource files. + SetOutPath "$INSTDIR\resources\report" + File "..\resources\report\report.html" + File "..\resources\report\js\custom.js" + File "..\resources\report\js\marked.js" + File "..\resources\report\js\order.js" + File "..\resources\report\js\plugin.js" + File "..\resources\report\js\require.js" + File "..\resources\report\js\script.js" + File "..\resources\report\css\style.css" + File "..\resources\report\css\font-awesome.min.css" + File "..\resources\report\fonts\fontawesome-webfont.woff" + + ;Install icon image. SetOutPath "$INSTDIR\resources" - File "..\resources\polyfill.js" - File "..\resources\script.js" - File "..\resources\style.css" + FIle "..\resources\icon.ico" ;Install documentation images. SetOutPath "$INSTDIR\docs\images" @@ -314,166 +346,124 @@ FunctionEnd ;Now install readme files. SetOutPath "$INSTDIR\docs" - ;File "..\docs\BOSS API Readme.html" - File "..\docs\BOSS Metadata Syntax.html" - File "..\docs\BOSS Readme.html" + File "..\docs\LOOT Metadata Syntax.html" + File "..\docs\LOOT Readme.html" ;Now install language files. SetOutPath "$INSTDIR\resources\l10n\ru\LC_MESSAGES" - File "..\resources\l10n\ru\LC_MESSAGES\boss.mo" - File "..\resources\l10n\ru\LC_MESSAGES\wxstd.mo" + File "..\resources\l10n\ru\LC_MESSAGES\loot.mo" SetOutPath "$INSTDIR\resources\l10n\es\LC_MESSAGES" - File "..\resources\l10n\es\LC_MESSAGES\wxstd.mo" - File "..\resources\l10n\es\LC_MESSAGES\boss.mo" - ;SetOutPath "$INSTDIR\resources\l10n\de\LC_MESSAGES" - ;File "..\resources\l10n\de\LC_MESSAGES\wxstd.mo" + File "..\resources\l10n\es\LC_MESSAGES\loot.mo" SetOutPath "$INSTDIR\resources\l10n\zh_CN\LC_MESSAGES" - File "..\resources\l10n\zh_CN\LC_MESSAGES\boss.mo" - File "..\resources\l10n\zh_CN\LC_MESSAGES\wxstd.mo" + File "..\resources\l10n\zh_CN\LC_MESSAGES\loot.mo" SetOutPath "$INSTDIR\resources\l10n\fr\LC_MESSAGES" - File "..\resources\l10n\fr\LC_MESSAGES\wxstd.mo" - File "..\resources\l10n\fr\LC_MESSAGES\boss.mo" + File "..\resources\l10n\fr\LC_MESSAGES\loot.mo" SetOutPath "$INSTDIR\resources\l10n\pl\LC_MESSAGES" - File "..\resources\l10n\pl\LC_MESSAGES\wxstd.mo" - File "..\resources\l10n\pl\LC_MESSAGES\boss.mo" + File "..\resources\l10n\pl\LC_MESSAGES\loot.mo" SetOutPath "$INSTDIR\resources\l10n\pt_BR\LC_MESSAGES" - File "..\resources\l10n\pt_BR\LC_MESSAGES\wxstd.mo" - File "..\resources\l10n\pt_BR\LC_MESSAGES\boss.mo" - + File "..\resources\l10n\pt_BR\LC_MESSAGES\loot.mo" + SetOutPath "$INSTDIR\resources\l10n\fi\LC_MESSAGES" + File "..\resources\l10n\fi\LC_MESSAGES\loot.mo" + SetOutPath "$INSTDIR\resources\l10n\de\LC_MESSAGES" + File "..\resources\l10n\de\LC_MESSAGES\loot.mo" + + ;Install settings file. - SetOutPath "$LOCALAPPDATA\BOSS" + SetOutPath "$LOCALAPPDATA\LOOT" File "..\resources\settings.yaml" ;Write language setting to settings.yaml. StrCmp $LANGUAGE ${LANG_RUSSIAN} 0 +5 - Push "$LOCALAPPDATA\BOSS\settings.yaml" + Push "$LOCALAPPDATA\LOOT\settings.yaml" Push "Language:" Push "Language: ru" Call ReplaceLineStr - ;StrCmp $LANGUAGE ${LANG_GERMAN} 0 +5 - ; Push "$LOCALAPPDATA\BOSS\settings.yaml" - ; Push "Language:" - ; Push "Language: de" - ; Call ReplaceLineStr StrCmp $LANGUAGE ${LANG_SPANISH} 0 +5 - Push "$LOCALAPPDATA\BOSS\settings.yaml" + Push "$LOCALAPPDATA\LOOT\settings.yaml" Push "Language:" Push "Language: es" Call ReplaceLineStr StrCmp $LANGUAGE ${LANG_SIMPCHINESE} 0 +5 - Push "$LOCALAPPDATA\BOSS\settings.yaml" + Push "$LOCALAPPDATA\LOOT\settings.yaml" Push "Language:" Push "Language: zh_CN" Call ReplaceLineStr StrCmp $LANGUAGE ${LANG_FRENCH} 0 +5 - Push "$LOCALAPPDATA\BOSS\settings.yaml" + Push "$LOCALAPPDATA\LOOT\settings.yaml" Push "Language:" Push "Language: fr" Call ReplaceLineStr StrCmp $LANGUAGE ${LANG_POLISH} 0 +5 - Push "$LOCALAPPDATA\BOSS\settings.yaml" + Push "$LOCALAPPDATA\LOOT\settings.yaml" Push "Language:" Push "Language: pl" Call ReplaceLineStr ;StrCmp $LANGUAGE ${LANG_PORTUGUESEBR} 0 +5 - ; Push "$LOCALAPPDATA\BOSS\settings.yaml" + ; Push "$LOCALAPPDATA\LOOT\settings.yaml" ; Push "Language:" ; Push "Language: pt_BR" ; Call ReplaceLineStr + StrCmp $LANGUAGE ${LANG_FINNISH} 0 +5 + Push "$LOCALAPPDATA\LOOT\settings.yaml" + Push "Language:" + Push "Language: fi" + Call ReplaceLineStr + StrCmp $LANGUAGE ${LANG_GERMAN} 0 +5 + Push "$LOCALAPPDATA\LOOT\settings.yaml" + Push "Language:" + Push "Language: de" + Call ReplaceLineStr StrCmp $LANGUAGE ${LANG_DANISH} 0 +5 - Push "$LOCALAPPDATA\BOSS\settings.yaml" + Push "$LOCALAPPDATA\LOOT\settings.yaml" Push "Language:" Push "Language: da" Call ReplaceLineStr - + ;Add Start Menu shortcuts. Set out path back to $INSTDIR otherwise the shortcuts start in the wrong place. ;Set Shell Var Context to all so that shortcuts are installed for all users, not just admin. SetOutPath "$INSTDIR" SetShellVarContext all - CreateDirectory "$SMPROGRAMS\BOSS" - CreateShortCut "$SMPROGRAMS\BOSS\BOSS.lnk" "$INSTDIR\BOSS.exe" - CreateShortCut "$SMPROGRAMS\BOSS\Uninstall.lnk" "$INSTDIR\Uninstall.exe" - CreateShortCut "$SMPROGRAMS\BOSS\Readme.lnk" "$INSTDIR\Docs\BOSS Readme.html" + CreateDirectory "$SMPROGRAMS\LOOT" + CreateShortCut "$SMPROGRAMS\LOOT\LOOT.lnk" "$INSTDIR\LOOT.exe" + CreateShortCut "$SMPROGRAMS\LOOT\Uninstall.lnk" "$INSTDIR\Uninstall.exe" + CreateShortCut "$SMPROGRAMS\LOOT\Readme.lnk" "$INSTDIR\Docs\LOOT Readme.html" ;Store installation folder in registry key. - WriteRegStr HKLM "Software\BOSS" "Installed Path" "$INSTDIR" + WriteRegStr HKLM "Software\LOOT" "Installed Path" "$INSTDIR" ;Write registry keys for Windows' uninstaller. - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BOSS" "DisplayName" "BOSS" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BOSS" "UninstallString" '"$INSTDIR\Uninstall.exe"' - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BOSS" "URLInfoAbout" 'http://boss-developers.github.io/' - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BOSS" "HelpLink" 'http://boss-developers.github.io/' - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BOSS" "Publisher" 'BOSS Development Team' - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BOSS" "DisplayVersion" '3.0.0' - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BOSS" "NoModify" 1 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BOSS" "NoRepair" 1 + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LOOT" "DisplayName" "LOOT" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LOOT" "UninstallString" '"$INSTDIR\Uninstall.exe"' + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LOOT" "URLInfoAbout" 'http://loot.github.io/' + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LOOT" "HelpLink" 'http://loot.github.io/' + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LOOT" "Publisher" 'LOOT Development Team' + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LOOT" "DisplayVersion" '0.7.0' + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LOOT" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LOOT" "NoRepair" 1 ;Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" SectionEnd - - Section "Microsoft Visual C++ 2013 SP1 Redist" - ; Thanks to the pcsx2 installer for providing this! - - ; Detection made easy: Unlike previous redists, VC2013 now generates a platform - ; independent key for checking availability. - ; HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\VC\Runtimes\x86 for x64 Windows - ; HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\12.0\VC\Runtimes\x86 for x86 Windows - - ; Download from: - ; http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe - - ClearErrors - - ${If} ${RunningX64} - ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\VC\Runtimes\x86" "Installed" - ${Else} - ReadRegDword $R0 HKLM "SOFTWARE\Microsoft\VisualStudio\12.0\VC\Runtimes\x86" "Installed" - ${EndIf} - - IfErrors 0 +2 - DetailPrint "Visual C++ 2013 Redistributable registry key was not found; assumed to be uninstalled." - StrCmp $R0 "1" 0 +3 - DetailPrint "Visual C++ 2013 Redistributable is already installed; skipping!" - Goto done - - ; Use bundled VC redist, more important that the install doesn't fail than it gets whatever is the latest update. - SetOutPath "$TEMP" - File "..\build\vcredist_x86.exe" - - ;DetailPrint "Downloading Visual C++ 2013 Redistributable Setup..." - ;DetailPrint "Contacting Microsoft.com..." - ;NSISdl::download /TIMEOUT=15000 "http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe" "vcredist_x86.exe" - - ;Pop $R0 ;Get the return value - ;StrCmp $R0 "success" OnSuccess - ;DetailPrint "Could not contact Microsoft.com, or the file has been (re)moved!" - ;Goto done - - ;OnSuccess: - DetailPrint "Running Visual C++ 2013 Redistributable Setup..." - ExecWait '"$TEMP\vcredist_x86.exe" /qb' - DetailPrint "Finished Visual C++ 2013 SP1 Redistributable Setup" - - Delete "$TEMP\vcredist_x86.exe" - - done: - SectionEnd ;-------------------------------- ;Uninstaller Section - Section "un.BOSS" Main + Section "un.LOOT" Main ;Remove main executables. - Delete "$INSTDIR\BOSS.exe" - - ;Remove API DLLs. - ;Delete "$INSTDIR\API\libboss32.dll" - ;Delete "$INSTDIR\API\libboss64.dll" - ;RMDir "$INSTDIR\API" + Delete "$INSTDIR\LOOT.exe" + Delete "$INSTDIR\d3dcompiler_43.dll" + Delete "$INSTDIR\d3dcompiler_46.dll" + Delete "$INSTDIR\libEGL.dll" + Delete "$INSTDIR\libGLESv2.dll" + Delete "$INSTDIR\libcef.dll" + Delete "$INSTDIR\cef.pak" + Delete "$INSTDIR\cef_100_percent.pak" + Delete "$INSTDIR\cef_200_percent.pak" + Delete "$INSTDIR\devtools_resources.pak" + Delete "$INSTDIR\icudtl.dat" ;Remove readme images. RMDir /r "$INSTDIR\docs\images" @@ -482,38 +472,37 @@ FunctionEnd RMDir /r "$INSTDIR\docs\licenses" ;Remove readme files. - ;Delete "$INSTDIR\docs\BOSS API Readme.html" - Delete "$INSTDIR\docs\BOSS Metadata Syntax.html" - Delete "$INSTDIR\docs\BOSS Readme.html" + Delete "$INSTDIR\docs\LOOT Metadata Syntax.html" + Delete "$INSTDIR\docs\LOOT Readme.html" RMDir "$INSTDIR\docs" ;Remove resource files. - Delete "$INSTDIR\resources\polyfill.js" - Delete "$INSTDIR\resources\script.js" - Delete "$INSTDIR\resources\style.css" + Delete "$INSTDIR\resources\report\report.html" + Delete "$INSTDIR\resources\report\js\custom.js" + Delete "$INSTDIR\resources\report\js\marked.js" + Delete "$INSTDIR\resources\report\js\order.js" + Delete "$INSTDIR\resources\report\js\plugin.js" + Delete "$INSTDIR\resources\report\js\require.js" + Delete "$INSTDIR\resources\report\js\script.js" + Delete "$INSTDIR\resources\report\css\style.css" + Delete "$INSTDIR\resources\report\css\font-awesome.min.css" + Delete "$INSTDIR\resources\report\fonts\fontawesome-webfont.woff" + + Delete "$INSTDIR\resources\icon.ico" ;Remove language files. - Delete "$INSTDIR\resources\l10n\ru\LC_MESSAGES\boss.mo" - Delete "$INSTDIR\resources\l10n\ru\LC_MESSAGES\wxstd.mo" - Delete "$INSTDIR\resources\l10n\es\LC_MESSAGES\boss.mo" - Delete "$INSTDIR\resources\l10n\es\LC_MESSAGES\wxstd.mo" - ;Delete "$INSTDIR\resources\l10n\de\LC_MESSAGES\wxstd.mo" - Delete "$INSTDIR\resources\l10n\zh_CN\LC_MESSAGES\boss.mo" - Delete "$INSTDIR\resources\l10n\zh_CN\LC_MESSAGES\wxstd.mo" - Delete "$INSTDIR\resources\l10n\fr\LC_MESSAGES\boss.mo" - Delete "$INSTDIR\resources\l10n\fr\LC_MESSAGES\wxstd.mo" - Delete "$INSTDIR\resources\l10n\pl\LC_MESSAGES\boss.mo" - Delete "$INSTDIR\resources\l10n\pl\LC_MESSAGES\wxstd.mo" - Delete "$INSTDIR\resources\l10n\pt_BR\LC_MESSAGES\boss.mo" - Delete "$INSTDIR\resources\l10n\pt_BR\LC_MESSAGES\wxstd.mo" - Delete "$INSTDIR\resources\l10n\da\LC_MESSAGES\boss.mo" - Delete "$INSTDIR\resources\l10n\da\LC_MESSAGES\wxstd.mo" + Delete "$INSTDIR\resources\l10n\ru\LC_MESSAGES\loot.mo" + Delete "$INSTDIR\resources\l10n\es\LC_MESSAGES\loot.mo" + Delete "$INSTDIR\resources\l10n\zh_CN\LC_MESSAGES\loot.mo" + Delete "$INSTDIR\resources\l10n\fr\LC_MESSAGES\loot.mo" + Delete "$INSTDIR\resources\l10n\pl\LC_MESSAGES\loot.mo" + Delete "$INSTDIR\resources\l10n\pt_BR\LC_MESSAGES\loot.mo" + Delete "$INSTDIR\resources\l10n\fi\LC_MESSAGES\loot.mo" + Delete "$INSTDIR\resources\l10n\da\LC_MESSAGES\loot.mo" RMDir "$INSTDIR\resources\l10n\ru\LC_MESSAGES" RMDir "$INSTDIR\resources\l10n\ru" RMDir "$INSTDIR\resources\l10n\es\LC_MESSAGES" RMDir "$INSTDIR\resources\l10n\es" - ;RMDir "$INSTDIR\resources\l10n\de\LC_MESSAGES" - ;RMDir "$INSTDIR\resources\l10n\de" RMDir "$INSTDIR\resources\l10n\zh_CN\LC_MESSAGES" RMDir "$INSTDIR\resources\l10n\zh_CN" RMDir "$INSTDIR\resources\l10n\fr\LC_MESSAGES" @@ -521,32 +510,36 @@ FunctionEnd RMDir "$INSTDIR\resources\l10n\pl\LC_MESSAGES" RMDir "$INSTDIR\resources\l10n\pl" RMDir "$INSTDIR\resources\l10n\pt_BR\LC_MESSAGES" - RMDir "$INSTDIR\resources\l10n\pt_BR" + RMDir "$INSTDIR\resources\l10n\pt_BR" + RMDir "$INSTDIR\resources\l10n\fi\LC_MESSAGES" + RMDir "$INSTDIR\resources\l10n\fi" + RMDir "$INSTDIR\resources\l10n\de\LC_MESSAGES" + RMDir "$INSTDIR\resources\l10n\de" RMDir "$INSTDIR\resources\l10n\da\LC_MESSAGES" RMDir "$INSTDIR\resources\l10n\da" RMDir "$INSTDIR\resources\l10n" RMDir "$INSTDIR\resources" - ;Now we have to remove the files BOSS generates when it runs. - Delete "$LOCALAPPDATA\BOSS\BOSSDebugLog.txt" + ;Now we have to remove the files LOOT generates when it runs. + Delete "$LOCALAPPDATA\LOOT\LOOTDebugLog.txt" ;Trying to delete a file that doesn't exist doesn't cause an error, so delete all games' files. ;This doesn't handle user-defined games. - Delete "$LOCALAPPDATA\BOSS\Oblivion\report.html" - Delete "$LOCALAPPDATA\BOSS\Oblivion\masterlist.yaml" - Delete "$LOCALAPPDATA\BOSS\Nehrim\report.html" - Delete "$LOCALAPPDATA\BOSS\Nehrim\masterlist.yaml" - Delete "$LOCALAPPDATA\BOSS\Skyrim\report.html" - Delete "$LOCALAPPDATA\BOSS\Skyrim\masterlist.yaml" - Delete "$LOCALAPPDATA\BOSS\Fallout3\report.html" - Delete "$LOCALAPPDATA\BOSS\Fallout3\masterlist.yaml" - Delete "$LOCALAPPDATA\BOSS\FalloutNV\report.html" - Delete "$LOCALAPPDATA\BOSS\FalloutNV\masterlist.yaml" - RMDir "$LOCALAPPDATA\BOSS\Oblivion" - RMDir "$LOCALAPPDATA\BOSS\Nehrim" - RMDir "$LOCALAPPDATA\BOSS\Skyrim" - RMDir "$LOCALAPPDATA\BOSS\Fallout3" - RMDir "$LOCALAPPDATA\BOSS\FalloutNV" - RMDir "$LOCALAPPDATA\BOSS" + Delete "$LOCALAPPDATA\LOOT\Oblivion\masterlist.yaml" + Delete "$LOCALAPPDATA\LOOT\Skyrim\masterlist.yaml" + Delete "$LOCALAPPDATA\LOOT\Fallout3\masterlist.yaml" + Delete "$LOCALAPPDATA\LOOT\FalloutNV\masterlist.yaml" + ;Delete repositories. + RMDir /r "$LOCALAPPDATA\LOOT\Oblivion\.git" + RMDir /r "$LOCALAPPDATA\LOOT\Skyrim\.git" + RMDir /r "$LOCALAPPDATA\LOOT\Fallout3\.git" + RMDir /r "$LOCALAPPDATA\LOOT\FalloutNV\.git" + ;Try deleting folders. + RMDir "$LOCALAPPDATA\LOOT\Oblivion" + RMDir "$LOCALAPPDATA\LOOT\Skyrim" + RMDir "$LOCALAPPDATA\LOOT\Fallout3" + RMDir "$LOCALAPPDATA\LOOT\FalloutNV" + RMDir "$LOCALAPPDATA\LOOT" + ;Remove uninstaller. Delete "$INSTDIR\Uninstall.exe" @@ -555,45 +548,43 @@ FunctionEnd RMDir "$INSTDIR" ;Delete registry key. - DeleteRegKey HKLM "Software\BOSS" + DeleteRegKey HKLM "Software\LOOT" ;Delete stupid Windows created registry keys: - DeleteRegKey HKCU "Software\BOSS" - DeleteRegKey HKLM "Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\BOSS" - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BOSS" - DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\App Management\ARPCache\BOSS" + DeleteRegKey HKCU "Software\LOOT" + DeleteRegKey HKLM "Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\LOOT" + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LOOT" + DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\App Management\ARPCache\LOOT" DeleteRegValue HKCR "Local Settings\Software\Microsoft\Windows\Shell\MuiCache" "$INSTDIR" - DeleteRegValue HKCR "Local Settings\Software\Microsoft\Windows\Shell\MuiCache" "$INSTDIR\BOSS.exe" + DeleteRegValue HKCR "Local Settings\Software\Microsoft\Windows\Shell\MuiCache" "$INSTDIR\LOOT.exe" DeleteRegValue HKCR "Local Settings\Software\Microsoft\Windows\Shell\MuiCache" "$INSTDIR\Uninstall.exe" DeleteRegValue HKCU "Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache" "$INSTDIR" - DeleteRegValue HKCU "Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache" "$INSTDIR\BOSS.exe" + DeleteRegValue HKCU "Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache" "$INSTDIR\LOOT.exe" DeleteRegValue HKCU "Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache" "$INSTDIR\Uninstall.exe" DeleteRegValue HKCU "Software\Microsoft\Windows\ShellNoRoam\MuiCache" "$INSTDIR" - DeleteRegValue HKCU "Software\Microsoft\Windows\ShellNoRoam\MuiCache" "$INSTDIR\BOSS.exe" + DeleteRegValue HKCU "Software\Microsoft\Windows\ShellNoRoam\MuiCache" "$INSTDIR\LOOT.exe" DeleteRegValue HKCU "Software\Microsoft\Windows\ShellNoRoam\MuiCache" "$INSTDIR\Uninstall.exe" ;Delete Start Menu folder. SetShellVarContext all - RMDir /r "$SMPROGRAMS\BOSS" + RMDir /r "$SMPROGRAMS\LOOT" SectionEnd Section /o "un.User Files" UserFiles ;The following user files are only removed if set to. - Delete "$LOCALAPPDATA\BOSS\settings.yaml" - Delete "$LOCALAPPDATA\BOSS\Oblivion\userlist.yaml" - Delete "$LOCALAPPDATA\BOSS\Nehrim\userlist.yaml" - Delete "$LOCALAPPDATA\BOSS\Skyrim\userlist.yaml" - Delete "$LOCALAPPDATA\BOSS\Fallout3\userlist.yaml" - Delete "$LOCALAPPDATA\BOSS\FalloutNV\userlist.yaml" + Delete "$LOCALAPPDATA\LOOT\settings.yaml" + Delete "$LOCALAPPDATA\LOOT\Oblivion\userlist.yaml" + Delete "$LOCALAPPDATA\LOOT\Skyrim\userlist.yaml" + Delete "$LOCALAPPDATA\LOOT\Fallout3\userlist.yaml" + Delete "$LOCALAPPDATA\LOOT\FalloutNV\userlist.yaml" ;Also try removing the folders storing them, in case they are otherwise empty. - RMDir "$LOCALAPPDATA\BOSS\Oblivion" - RMDir "$LOCALAPPDATA\BOSS\Nehrim" - RMDir "$LOCALAPPDATA\BOSS\Skyrim" - RMDir "$LOCALAPPDATA\BOSS\Fallout3" - RMDir "$LOCALAPPDATA\BOSS\FalloutNV" + RMDir "$LOCALAPPDATA\LOOT\Oblivion" + RMDir "$LOCALAPPDATA\LOOT\Skyrim" + RMDir "$LOCALAPPDATA\LOOT\Fallout3" + RMDir "$LOCALAPPDATA\LOOT\FalloutNV" ;Try removing install directory. - RMDir "$LOCALAPPDATA\BOSS" + RMDir "$LOCALAPPDATA\LOOT" SectionEnd ;-------------------------------- diff --git a/src/resource.rc b/src/resource.rc index 67fd7a22..b32b64cc 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -1,7 +1,7 @@ -#include "wx/msw/wx.rc" +#include "gui/resource.h" 1 VERSIONINFO - FILEVERSION 3,0,0,0 - PRODUCTVERSION 3,0,0,0 + FILEVERSION 0,7,0,0 + PRODUCTVERSION 0,7,0,0 FILEOS VOS__WINDOWS32 FILETYPE VFT_APP BEGIN @@ -9,9 +9,9 @@ BEGIN BEGIN BLOCK "040904b0" BEGIN - VALUE "FileVersion", "3.0.0" + VALUE "FileVersion", "0.7.0" VALUE "LegalCopyright", "Copyright (C) 2013-2014 WrinklyNinja" - VALUE "ProductVersion", "3.0.0" + VALUE "ProductVersion", "0.7.0" END END BLOCK "VarFileInfo"