forked from teamnwah/openmw-tes3coop
Merge branch 'master' of https://github.com/zinnschlag/openmw into saveOnClose
This commit is contained in:
commit
c17821e6c8
272 changed files with 8155 additions and 5423 deletions
|
@ -29,6 +29,7 @@ option(OGRE_STATIC "Link static build of Ogre and Ogre Plugins into the binarie
|
|||
option(BOOST_STATIC "Link static build of Boost into the binaries" FALSE)
|
||||
|
||||
# Apps and tools
|
||||
option(BUILD_BSATOOL "build BSA extractor" OFF)
|
||||
option(BUILD_ESMTOOL "build ESM inspector" ON)
|
||||
option(BUILD_LAUNCHER "build Launcher" ON)
|
||||
option(BUILD_MWINIIMPORTER "build MWiniImporter" ON)
|
||||
|
@ -352,7 +353,7 @@ if(DPKG_PROGRAM)
|
|||
Data files from the original game is required to run it.")
|
||||
SET(CPACK_DEBIAN_PACKAGE_NAME "openmw")
|
||||
SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}")
|
||||
SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW esmtool;Esmtool omwlauncher;OMWLauncher mwiniimporter;MWiniImporter")
|
||||
SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW bsatool;Bsatool esmtool;Esmtool omwlauncher;OMWLauncher mwiniimporter;MWiniImporter")
|
||||
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.3.0 (>= 1.3.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)")
|
||||
|
||||
SET(CPACK_DEBIAN_PACKAGE_SECTION "Games")
|
||||
|
@ -379,7 +380,6 @@ if(WIN32)
|
|||
"${OpenMW_SOURCE_DIR}/OFL.txt"
|
||||
"${OpenMW_SOURCE_DIR}/DejaVu Font License.txt"
|
||||
"${OpenMW_SOURCE_DIR}/Daedric Font License.txt"
|
||||
"${OpenMW_BINARY_DIR}/launcher.qss"
|
||||
"${OpenMW_BINARY_DIR}/settings-default.cfg"
|
||||
"${OpenMW_BINARY_DIR}/transparency-overrides.cfg"
|
||||
"${OpenMW_BINARY_DIR}/Release/omwlauncher.exe"
|
||||
|
@ -447,6 +447,10 @@ add_subdirectory (components)
|
|||
# Apps and tools
|
||||
add_subdirectory( apps/openmw )
|
||||
|
||||
if (BUILD_BSATOOL)
|
||||
add_subdirectory( apps/bsatool )
|
||||
endif()
|
||||
|
||||
if (BUILD_ESMTOOL)
|
||||
add_subdirectory( apps/esmtool )
|
||||
endif()
|
||||
|
@ -533,6 +537,9 @@ if (WIN32)
|
|||
set_target_properties(omwlauncher PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
||||
endif (BUILD_LAUNCHER)
|
||||
set_target_properties(openmw PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
||||
if (BUILD_BSATOOL)
|
||||
set_target_properties(bsatool PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
||||
endif (BUILD_BSATOOL)
|
||||
if (BUILD_ESMTOOL)
|
||||
set_target_properties(esmtool PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
||||
endif (BUILD_ESMTOOL)
|
||||
|
@ -566,8 +573,6 @@ if (APPLE)
|
|||
install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
install(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
install(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" RENAME "openmw.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
install(FILES "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
|
||||
install(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
install(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
|
||||
|
@ -659,6 +664,9 @@ if (NOT WIN32 AND NOT DPKG_PROGRAM AND NOT APPLE)
|
|||
IF(BUILD_LAUNCHER)
|
||||
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/omwlauncher" DESTINATION "${BINDIR}" )
|
||||
ENDIF(BUILD_LAUNCHER)
|
||||
IF(BUILD_BSATOOL)
|
||||
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/bsatool" DESTINATION "${BINDIR}" )
|
||||
ENDIF(BUILD_BSATOOL)
|
||||
IF(BUILD_ESMTOOL)
|
||||
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/esmtool" DESTINATION "${BINDIR}" )
|
||||
ENDIF(BUILD_ESMTOOL)
|
||||
|
@ -681,7 +689,4 @@ if (NOT WIN32 AND NOT DPKG_PROGRAM AND NOT APPLE)
|
|||
|
||||
# Install resources
|
||||
INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${DATADIR}" )
|
||||
IF(BUILD_LAUNCHER)
|
||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION "${DATADIR}/resources" )
|
||||
ENDIF(BUILD_LAUNCHER)
|
||||
endif(NOT WIN32 AND NOT DPKG_PROGRAM AND NOT APPLE)
|
||||
|
|
19
apps/bsatool/CMakeLists.txt
Normal file
19
apps/bsatool/CMakeLists.txt
Normal file
|
@ -0,0 +1,19 @@
|
|||
set(BSATOOL
|
||||
bsatool.cpp
|
||||
)
|
||||
source_group(apps\\bsatool FILES ${BSATOOL})
|
||||
|
||||
# Main executable
|
||||
add_executable(bsatool
|
||||
${BSATOOL}
|
||||
)
|
||||
|
||||
target_link_libraries(bsatool
|
||||
${Boost_LIBRARIES}
|
||||
components
|
||||
)
|
||||
|
||||
if (BUILD_WITH_CODE_COVERAGE)
|
||||
add_definitions (--coverage)
|
||||
target_link_libraries(bsatool gcov)
|
||||
endif()
|
288
apps/bsatool/bsatool.cpp
Normal file
288
apps/bsatool/bsatool.cpp
Normal file
|
@ -0,0 +1,288 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <exception>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
#include <components/bsa/bsa_file.hpp>
|
||||
|
||||
#define BSATOOL_VERSION 1.1
|
||||
|
||||
// Create local aliases for brevity
|
||||
namespace bpo = boost::program_options;
|
||||
namespace bfs = boost::filesystem;
|
||||
|
||||
struct Arguments
|
||||
{
|
||||
std::string mode;
|
||||
std::string filename;
|
||||
std::string extractfile;
|
||||
std::string outdir;
|
||||
|
||||
bool longformat;
|
||||
bool fullpath;
|
||||
};
|
||||
|
||||
void replaceAll(std::string& str, const std::string& needle, const std::string& substitute)
|
||||
{
|
||||
int pos = str.find(needle);
|
||||
while(pos != -1)
|
||||
{
|
||||
str.replace(pos, needle.size(), substitute);
|
||||
pos = str.find(needle);
|
||||
}
|
||||
}
|
||||
|
||||
bool parseOptions (int argc, char** argv, Arguments &info)
|
||||
{
|
||||
bpo::options_description desc("Inspect and extract files from Bethesda BSA archives\n\n"
|
||||
"Usages:\n"
|
||||
" bsatool list [-l] archivefile\n"
|
||||
" List the files presents in the input archive.\n\n"
|
||||
" bsatool extract [-f] archivefile [file_to_extract] [output_directory]\n"
|
||||
" Extract a file from the input archive.\n\n"
|
||||
" bsatool extractall archivefile [output_directory]\n"
|
||||
" Extract all files from the input archive.\n\n"
|
||||
"Allowed options");
|
||||
|
||||
desc.add_options()
|
||||
("help,h", "print help message.")
|
||||
("version,v", "print version information and quit.")
|
||||
("long,l", "Include extra information in archive listing.")
|
||||
("full-path,f", "Create diretory hierarchy on file extraction "
|
||||
"(always true for extractall).")
|
||||
;
|
||||
|
||||
// input-file is hidden and used as a positional argument
|
||||
bpo::options_description hidden("Hidden Options");
|
||||
|
||||
hidden.add_options()
|
||||
( "mode,m", bpo::value<std::string>(), "bsatool mode")
|
||||
( "input-file,i", bpo::value< std::vector<std::string> >(), "input file")
|
||||
;
|
||||
|
||||
bpo::positional_options_description p;
|
||||
p.add("mode", 1).add("input-file", 3);
|
||||
|
||||
// there might be a better way to do this
|
||||
bpo::options_description all;
|
||||
all.add(desc).add(hidden);
|
||||
|
||||
bpo::variables_map variables;
|
||||
try
|
||||
{
|
||||
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv)
|
||||
.options(all).positional(p).run();
|
||||
bpo::store(valid_opts, variables);
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
std::cout << "ERROR parsing arguments: " << e.what() << "\n\n"
|
||||
<< desc << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
bpo::notify(variables);
|
||||
|
||||
if (variables.count ("help"))
|
||||
{
|
||||
std::cout << desc << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (variables.count ("version"))
|
||||
{
|
||||
std::cout << "BSATool version " << BSATOOL_VERSION << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (!variables.count("mode"))
|
||||
{
|
||||
std::cout << "ERROR: no mode specified!\n\n"
|
||||
<< desc << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
info.mode = variables["mode"].as<std::string>();
|
||||
if (!(info.mode == "list" || info.mode == "extract" || info.mode == "extractall"))
|
||||
{
|
||||
std::cout << std::endl << "ERROR: invalid mode \"" << info.mode << "\"\n\n"
|
||||
<< desc << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!variables.count("input-file"))
|
||||
{
|
||||
std::cout << "\nERROR: missing BSA archive\n\n"
|
||||
<< desc << std::endl;
|
||||
return false;
|
||||
}
|
||||
info.filename = variables["input-file"].as< std::vector<std::string> >()[0];
|
||||
|
||||
// Default output to the working directory
|
||||
info.outdir = ".";
|
||||
|
||||
if (info.mode == "extract")
|
||||
{
|
||||
if (variables["input-file"].as< std::vector<std::string> >().size() < 2)
|
||||
{
|
||||
std::cout << "\nERROR: file to extract unspecified\n\n"
|
||||
<< desc << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (variables["input-file"].as< std::vector<std::string> >().size() > 1)
|
||||
info.extractfile = variables["input-file"].as< std::vector<std::string> >()[1];
|
||||
if (variables["input-file"].as< std::vector<std::string> >().size() > 2)
|
||||
info.outdir = variables["input-file"].as< std::vector<std::string> >()[2];
|
||||
}
|
||||
else if (variables["input-file"].as< std::vector<std::string> >().size() > 1)
|
||||
info.outdir = variables["input-file"].as< std::vector<std::string> >()[1];
|
||||
|
||||
info.longformat = variables.count("long");
|
||||
info.fullpath = variables.count("full-path");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int list(Bsa::BSAFile& bsa, Arguments& info);
|
||||
int extract(Bsa::BSAFile& bsa, Arguments& info);
|
||||
int extractAll(Bsa::BSAFile& bsa, Arguments& info);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
Arguments info;
|
||||
if(!parseOptions (argc, argv, info))
|
||||
return 1;
|
||||
|
||||
// Open file
|
||||
Bsa::BSAFile bsa;
|
||||
try
|
||||
{
|
||||
bsa.open(info.filename);
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
std::cout << "ERROR reading BSA archive '" << info.filename
|
||||
<< "'\nDetails:\n" << e.what() << std::endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (info.mode == "list")
|
||||
return list(bsa, info);
|
||||
else if (info.mode == "extract")
|
||||
return extract(bsa, info);
|
||||
else if (info.mode == "extractall")
|
||||
return extractAll(bsa, info);
|
||||
else
|
||||
{
|
||||
std::cout << "Unsupported mode. That is not supposed to happen." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int list(Bsa::BSAFile& bsa, Arguments& info)
|
||||
{
|
||||
// List all files
|
||||
const Bsa::BSAFile::FileList &files = bsa.getList();
|
||||
for(int i=0; i<files.size(); i++)
|
||||
{
|
||||
if(info.longformat)
|
||||
{
|
||||
// Long format
|
||||
std::cout << std::setw(50) << std::left << files[i].name;
|
||||
std::cout << std::setw(8) << std::left << std::dec << files[i].fileSize;
|
||||
std::cout << "@ 0x" << std::hex << files[i].offset << std::endl;
|
||||
}
|
||||
else
|
||||
std::cout << files[i].name << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int extract(Bsa::BSAFile& bsa, Arguments& info)
|
||||
{
|
||||
std::string archivePath = info.extractfile;
|
||||
replaceAll(archivePath, "/", "\\");
|
||||
|
||||
std::string extractPath = info.extractfile;
|
||||
replaceAll(extractPath, "\\", "/");
|
||||
|
||||
if (!bsa.exists(archivePath.c_str()))
|
||||
{
|
||||
std::cout << "ERROR: file '" << archivePath << "' not found\n";
|
||||
std::cout << "In archive: " << info.filename << std::endl;
|
||||
return 3;
|
||||
}
|
||||
|
||||
// Get the target path (the path the file will be extracted to)
|
||||
bfs::path relPath (extractPath);
|
||||
bfs::path outdir (info.outdir);
|
||||
|
||||
bfs::path target;
|
||||
if (info.fullpath)
|
||||
target = outdir / relPath;
|
||||
else
|
||||
target = outdir / relPath.filename();
|
||||
|
||||
// Create the directory hierarchy
|
||||
bfs::create_directories(target.parent_path());
|
||||
|
||||
bfs::file_status s = bfs::status(target.parent_path());
|
||||
if (!bfs::is_directory(s))
|
||||
{
|
||||
std::cout << "ERROR: " << target.parent_path() << " is not a directory." << std::endl;
|
||||
return 3;
|
||||
}
|
||||
|
||||
// Get a stream for the file to extract
|
||||
Ogre::DataStreamPtr data = bsa.getFile(archivePath.c_str());
|
||||
bfs::ofstream out(target, std::ios::binary);
|
||||
|
||||
// Write the file to disk
|
||||
std::cout << "Extracting " << info.extractfile << " to " << target << std::endl;
|
||||
out.write(data->getAsString().c_str(), data->size());
|
||||
out.close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int extractAll(Bsa::BSAFile& bsa, Arguments& info)
|
||||
{
|
||||
// Get the list of files present in the archive
|
||||
Bsa::BSAFile::FileList list = bsa.getList();
|
||||
|
||||
// Iter on the list
|
||||
for(Bsa::BSAFile::FileList::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
const char* archivePath = it->name;
|
||||
|
||||
std::string extractPath (archivePath);
|
||||
replaceAll(extractPath, "\\", "/");
|
||||
|
||||
// Get the target path (the path the file will be extracted to)
|
||||
bfs::path target (info.outdir);
|
||||
target /= extractPath;
|
||||
|
||||
// Create the directory hierarchy
|
||||
bfs::create_directories(target.parent_path());
|
||||
|
||||
bfs::file_status s = bfs::status(target.parent_path());
|
||||
if (!bfs::is_directory(s))
|
||||
{
|
||||
std::cout << "ERROR: " << target.parent_path() << " is not a directory." << std::endl;
|
||||
return 3;
|
||||
}
|
||||
|
||||
// Get a stream for the file to extract
|
||||
// (inefficient because getFile iter on the list again)
|
||||
Ogre::DataStreamPtr data = bsa.getFile(archivePath);
|
||||
bfs::ofstream out(target, std::ios::binary);
|
||||
|
||||
// Write the file to disk
|
||||
std::cout << "Extracting " << target << std::endl;
|
||||
out.write(data->getAsString().c_str(), data->size());
|
||||
out.close();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -112,14 +112,11 @@ std::string ruleString(ESM::DialInfo::SelectStruct ss)
|
|||
case '5': oper_str = ">="; break;
|
||||
}
|
||||
|
||||
std::string value_str = "??";
|
||||
if (ss.mType == ESM::VT_Int)
|
||||
value_str = str(boost::format("%d") % ss.mI);
|
||||
else if (ss.mType == ESM::VT_Float)
|
||||
value_str = str(boost::format("%f") % ss.mF);
|
||||
std::ostringstream stream;
|
||||
stream << ss.mValue;
|
||||
|
||||
std::string result = str(boost::format("%-12s %-32s %2s %s")
|
||||
% type_str % func_str % oper_str % value_str);
|
||||
% type_str % func_str % oper_str % stream.str());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -713,31 +710,13 @@ void Record<ESM::Faction>::print()
|
|||
template<>
|
||||
void Record<ESM::Global>::print()
|
||||
{
|
||||
// nothing to print (well, nothing that's correct anyway)
|
||||
std::cout << " Type: " << mData.mType << std::endl;
|
||||
std::cout << " Value: " << mData.mValue << std::endl;
|
||||
std::cout << " " << mData.mValue << std::endl;
|
||||
}
|
||||
|
||||
template<>
|
||||
void Record<ESM::GameSetting>::print()
|
||||
{
|
||||
std::cout << " Value: ";
|
||||
switch (mData.mType) {
|
||||
case ESM::VT_String:
|
||||
std::cout << "'" << mData.mStr << "' (std::string)";
|
||||
break;
|
||||
|
||||
case ESM::VT_Float:
|
||||
std::cout << mData.mF << " (float)";
|
||||
break;
|
||||
|
||||
case ESM::VT_Int:
|
||||
std::cout << mData.mI << " (int)";
|
||||
break;
|
||||
|
||||
default:
|
||||
std::cout << "unknown type";
|
||||
}
|
||||
std::cout << " " << mData.mValue << std::endl;
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
|
@ -1,35 +1,55 @@
|
|||
set(LAUNCHER
|
||||
datafilespage.cpp
|
||||
graphicspage.cpp
|
||||
main.cpp
|
||||
maindialog.cpp
|
||||
playpage.cpp
|
||||
datafilespage.cpp
|
||||
utils/profilescombobox.cpp
|
||||
|
||||
settings/gamesettings.cpp
|
||||
settings/graphicssettings.cpp
|
||||
settings/launchersettings.cpp
|
||||
|
||||
utils/checkablemessagebox.cpp
|
||||
utils/textinputdialog.cpp
|
||||
|
||||
launcher.rc
|
||||
)
|
||||
|
||||
set(LAUNCHER_HEADER
|
||||
datafilespage.hpp
|
||||
graphicspage.hpp
|
||||
maindialog.hpp
|
||||
playpage.hpp
|
||||
datafilespage.hpp
|
||||
utils/profilescombobox.hpp
|
||||
|
||||
settings/gamesettings.hpp
|
||||
settings/graphicssettings.hpp
|
||||
settings/launchersettings.hpp
|
||||
settings/settingsbase.hpp
|
||||
|
||||
utils/checkablemessagebox.hpp
|
||||
utils/textinputdialog.hpp
|
||||
|
||||
)
|
||||
|
||||
# Headers that must be pre-processed
|
||||
set(LAUNCHER_HEADER_MOC
|
||||
datafilespage.hpp
|
||||
graphicspage.hpp
|
||||
maindialog.hpp
|
||||
playpage.hpp
|
||||
datafilespage.hpp
|
||||
utils/profilescombobox.hpp
|
||||
|
||||
utils/checkablemessagebox.hpp
|
||||
utils/textinputdialog.hpp
|
||||
)
|
||||
|
||||
source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER} ${LAUNCHER_HEADER_MOC})
|
||||
set(LAUNCHER_UI
|
||||
../../files/ui/datafilespage.ui
|
||||
../../files/ui/graphicspage.ui
|
||||
../../files/ui/mainwindow.ui
|
||||
../../files/ui/playpage.ui
|
||||
)
|
||||
|
||||
source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER})
|
||||
|
||||
find_package(Qt4 REQUIRED)
|
||||
set(QT_USE_QTGUI 1)
|
||||
|
@ -40,10 +60,12 @@ if(WIN32)
|
|||
set(QT_USE_QTMAIN TRUE)
|
||||
endif(WIN32)
|
||||
|
||||
QT4_ADD_RESOURCES(RCC_SRCS resources.qrc)
|
||||
QT4_ADD_RESOURCES(RCC_SRCS ${CMAKE_SOURCE_DIR}/files/launcher/launcher.qrc)
|
||||
QT4_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC})
|
||||
QT4_WRAP_UI(UI_HDRS ${LAUNCHER_UI})
|
||||
|
||||
include(${QT_USE_FILE})
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# Main executable
|
||||
IF(OGRE_STATIC)
|
||||
|
@ -58,8 +80,10 @@ ENDIF(OGRE_STATIC)
|
|||
add_executable(omwlauncher
|
||||
${GUI_TYPE}
|
||||
${LAUNCHER}
|
||||
${LAUNCHER_HEADER}
|
||||
${RCC_SRCS}
|
||||
${MOC_SRCS}
|
||||
${UI_HDRS}
|
||||
)
|
||||
|
||||
target_link_libraries(omwlauncher
|
||||
|
@ -74,18 +98,6 @@ if(DPKG_PROGRAM)
|
|||
INSTALL(TARGETS omwlauncher RUNTIME DESTINATION games COMPONENT omwlauncher)
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss
|
||||
"${APP_BUNDLE_DIR}/../launcher.qss")
|
||||
else()
|
||||
configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss
|
||||
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/resources/launcher.qss")
|
||||
|
||||
# Fallback in case getGlobalDataPath does not point to resources
|
||||
configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss
|
||||
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.qss")
|
||||
endif()
|
||||
|
||||
if (BUILD_WITH_CODE_COVERAGE)
|
||||
add_definitions (--coverage)
|
||||
target_link_libraries(omwlauncher gcov)
|
||||
|
|
|
@ -1,79 +1,122 @@
|
|||
#include <QtGui>
|
||||
|
||||
#include <components/esm/esmreader.hpp>
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/fileorderlist/datafileslist.hpp>
|
||||
#include <components/fileorderlist/utils/lineedit.hpp>
|
||||
#include <components/fileorderlist/utils/naturalsort.hpp>
|
||||
#include <components/fileorderlist/utils/filedialog.hpp>
|
||||
|
||||
////#include "model/datafilesmodel.hpp"
|
||||
////#include "model/esm/esmfile.hpp"
|
||||
|
||||
#include "utils/profilescombobox.hpp"
|
||||
////#include "utils/filedialog.hpp"
|
||||
////#include "utils/naturalsort.hpp"
|
||||
#include "utils/textinputdialog.hpp"
|
||||
|
||||
#include "datafilespage.hpp"
|
||||
|
||||
#include <boost/version.hpp>
|
||||
/**
|
||||
* Workaround for problems with whitespaces in paths in older versions of Boost library
|
||||
*/
|
||||
#if (BOOST_VERSION <= 104600)
|
||||
namespace boost
|
||||
#include <QtGui>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
|
||||
#include <components/fileorderlist/model/datafilesmodel.hpp>
|
||||
#include <components/fileorderlist/model/pluginsproxymodel.hpp>
|
||||
#include <components/fileorderlist/model/esm/esmfile.hpp>
|
||||
|
||||
#include <components/fileorderlist/utils/lineedit.hpp>
|
||||
#include <components/fileorderlist/utils/naturalsort.hpp>
|
||||
#include <components/fileorderlist/utils/profilescombobox.hpp>
|
||||
|
||||
#include "settings/gamesettings.hpp"
|
||||
#include "settings/launchersettings.hpp"
|
||||
|
||||
#include "utils/textinputdialog.hpp"
|
||||
|
||||
|
||||
//sort QModelIndexList ascending
|
||||
bool rowGreaterThan(const QModelIndex &index1, const QModelIndex &index2)
|
||||
{
|
||||
return index1.row() >= index2.row();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline boost::filesystem::path lexical_cast<boost::filesystem::path, std::string>(const std::string& arg)
|
||||
{
|
||||
return boost::filesystem::path(arg);
|
||||
}
|
||||
|
||||
} /* namespace boost */
|
||||
#endif /* (BOOST_VERSION <= 104600) */
|
||||
|
||||
using namespace ESM;
|
||||
using namespace std;
|
||||
|
||||
DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, mCfgMgr(cfg)
|
||||
//sort QModelIndexList descending
|
||||
bool rowSmallerThan(const QModelIndex &index1, const QModelIndex &index2)
|
||||
{
|
||||
mDataFilesList = new DataFilesList(mCfgMgr, this);
|
||||
return index1.row() <= index2.row();
|
||||
}
|
||||
|
||||
// Bottom part with profile options
|
||||
QLabel *profileLabel = new QLabel(tr("Current Profile: "), this);
|
||||
DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent)
|
||||
: mCfgMgr(cfg)
|
||||
, mGameSettings(gameSettings)
|
||||
, mLauncherSettings(launcherSettings)
|
||||
, QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
mProfilesComboBox = new ProfilesComboBox(this);
|
||||
mProfilesComboBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
mProfilesComboBox->setInsertPolicy(QComboBox::NoInsert);
|
||||
mProfilesComboBox->setDuplicatesEnabled(false);
|
||||
mProfilesComboBox->setEditEnabled(false);
|
||||
// Models
|
||||
mDataFilesModel = new DataFilesModel(this);
|
||||
|
||||
mProfileToolBar = new QToolBar(this);
|
||||
mProfileToolBar->setMovable(false);
|
||||
mProfileToolBar->setIconSize(QSize(16, 16));
|
||||
mMastersProxyModel = new QSortFilterProxyModel();
|
||||
mMastersProxyModel->setFilterRegExp(QString("^.*\\.esm"));
|
||||
mMastersProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
mMastersProxyModel->setSourceModel(mDataFilesModel);
|
||||
|
||||
mProfileToolBar->addWidget(profileLabel);
|
||||
mProfileToolBar->addWidget(mProfilesComboBox);
|
||||
mPluginsProxyModel = new PluginsProxyModel();
|
||||
mPluginsProxyModel->setFilterRegExp(QString("^.*\\.esp"));
|
||||
mPluginsProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
mPluginsProxyModel->setSourceModel(mDataFilesModel);
|
||||
|
||||
QVBoxLayout *pageLayout = new QVBoxLayout(this);
|
||||
mFilterProxyModel = new QSortFilterProxyModel();
|
||||
mFilterProxyModel->setDynamicSortFilter(true);
|
||||
mFilterProxyModel->setSourceModel(mPluginsProxyModel);
|
||||
|
||||
pageLayout->addWidget(mDataFilesList);
|
||||
pageLayout->addWidget(mProfileToolBar);
|
||||
QCheckBox checkBox;
|
||||
unsigned int height = checkBox.sizeHint().height() + 4;
|
||||
|
||||
mastersTable->setModel(mMastersProxyModel);
|
||||
mastersTable->setObjectName("MastersTable");
|
||||
mastersTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
mastersTable->setSortingEnabled(false);
|
||||
mastersTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
mastersTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
mastersTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
mastersTable->setAlternatingRowColors(true);
|
||||
mastersTable->horizontalHeader()->setStretchLastSection(true);
|
||||
mastersTable->horizontalHeader()->hide();
|
||||
|
||||
// Set the row height to the size of the checkboxes
|
||||
mastersTable->verticalHeader()->setDefaultSectionSize(height);
|
||||
mastersTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
||||
mastersTable->verticalHeader()->hide();
|
||||
|
||||
pluginsTable->setModel(mFilterProxyModel);
|
||||
pluginsTable->setObjectName("PluginsTable");
|
||||
pluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
pluginsTable->setSortingEnabled(false);
|
||||
pluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
pluginsTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
pluginsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
pluginsTable->setAlternatingRowColors(true);
|
||||
pluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
|
||||
pluginsTable->horizontalHeader()->setStretchLastSection(true);
|
||||
pluginsTable->horizontalHeader()->hide();
|
||||
|
||||
pluginsTable->verticalHeader()->setDefaultSectionSize(height);
|
||||
pluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
||||
|
||||
// Adjust the tableview widths inside the splitter
|
||||
QList<int> sizeList;
|
||||
sizeList << mLauncherSettings.value(QString("General/MastersTable/width"), QString("200")).toInt();
|
||||
sizeList << mLauncherSettings.value(QString("General/PluginTable/width"), QString("340")).toInt();
|
||||
|
||||
splitter->setSizes(sizeList);
|
||||
|
||||
// Create a dialog for the new profile name input
|
||||
mNewProfileDialog = new TextInputDialog(tr("New Profile"), tr("Profile name:"), this);
|
||||
|
||||
connect(profilesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentIndexChanged(int)));
|
||||
|
||||
connect(mNewProfileDialog->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(updateOkButton(QString)));
|
||||
|
||||
connect(pluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
|
||||
connect(mastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
|
||||
|
||||
connect(pluginsTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
|
||||
connect(mastersTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
|
||||
|
||||
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
||||
|
||||
connect(mProfilesComboBox, SIGNAL(profileRenamed(QString,QString)), this, SLOT(profileRenamed(QString,QString)));
|
||||
connect(mProfilesComboBox, SIGNAL(profileChanged(QString,QString)), this, SLOT(profileChanged(QString,QString)));
|
||||
connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
||||
|
||||
connect(splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(updateSplitter()));
|
||||
|
||||
createActions();
|
||||
setupConfig();
|
||||
setupDataFiles();
|
||||
}
|
||||
|
||||
void DataFilesPage::createActions()
|
||||
|
@ -83,7 +126,7 @@ void DataFilesPage::createActions()
|
|||
refreshAction->setShortcut(QKeySequence(tr("F5")));
|
||||
connect(refreshAction, SIGNAL(triggered()), this, SLOT(refresh()));
|
||||
|
||||
// Profile actions
|
||||
// We can't create actions inside the .ui file
|
||||
mNewProfileAction = new QAction(QIcon::fromTheme("document-new"), tr("&New Profile"), this);
|
||||
mNewProfileAction->setToolTip(tr("New Profile"));
|
||||
mNewProfileAction->setShortcut(QKeySequence(tr("Ctrl+N")));
|
||||
|
@ -91,355 +134,206 @@ void DataFilesPage::createActions()
|
|||
|
||||
mDeleteProfileAction = new QAction(QIcon::fromTheme("edit-delete"), tr("Delete Profile"), this);
|
||||
mDeleteProfileAction->setToolTip(tr("Delete Profile"));
|
||||
mDeleteProfileAction->setShortcut(QKeySequence(tr("Delete")));
|
||||
connect(mDeleteProfileAction, SIGNAL(triggered()), this, SLOT(deleteProfile()));
|
||||
|
||||
// Add the newly created actions to the toolbar
|
||||
mProfileToolBar->addSeparator();
|
||||
mProfileToolBar->addAction(mNewProfileAction);
|
||||
mProfileToolBar->addAction(mDeleteProfileAction);
|
||||
// Add the newly created actions to the toolbuttons
|
||||
newProfileButton->setDefaultAction(mNewProfileAction);
|
||||
deleteProfileButton->setDefaultAction(mDeleteProfileAction);
|
||||
|
||||
// Context menu actions
|
||||
mCheckAction = new QAction(tr("Check Selection"), this);
|
||||
connect(mCheckAction, SIGNAL(triggered()), this, SLOT(check()));
|
||||
|
||||
mUncheckAction = new QAction(tr("Uncheck Selection"), this);
|
||||
connect(mUncheckAction, SIGNAL(triggered()), this, SLOT(uncheck()));
|
||||
|
||||
mContextMenu = new QMenu(this);
|
||||
mContextMenu->addAction(mCheckAction);
|
||||
mContextMenu->addAction(mUncheckAction);
|
||||
}
|
||||
|
||||
void DataFilesPage::setupConfig()
|
||||
void DataFilesPage::setupDataFiles()
|
||||
{
|
||||
// Open our config file
|
||||
QString config = QString::fromStdString((mCfgMgr.getUserPath() / "launcher.cfg").string());
|
||||
mLauncherConfig = new QSettings(config, QSettings::IniFormat);
|
||||
// Set the encoding to the one found in openmw.cfg or the default
|
||||
mDataFilesModel->setEncoding(mGameSettings.value(QString("encoding"), QString("win1252")));
|
||||
|
||||
// Make sure we have no groups open
|
||||
while (!mLauncherConfig->group().isEmpty()) {
|
||||
mLauncherConfig->endGroup();
|
||||
QStringList paths = mGameSettings.getDataDirs();
|
||||
|
||||
foreach (const QString &path, paths) {
|
||||
mDataFilesModel->addFiles(path);
|
||||
}
|
||||
|
||||
mLauncherConfig->beginGroup("Profiles");
|
||||
QStringList profiles = mLauncherConfig->childGroups();
|
||||
QString dataLocal = mGameSettings.getDataLocal();
|
||||
if (!dataLocal.isEmpty())
|
||||
mDataFilesModel->addFiles(dataLocal);
|
||||
|
||||
// Add the profiles to the combobox
|
||||
foreach (const QString &profile, profiles) {
|
||||
// Sort by date accessed for now
|
||||
mDataFilesModel->sort(3);
|
||||
|
||||
if (profile.contains(QRegExp("[^a-zA-Z0-9_]")))
|
||||
continue; // Profile name contains garbage
|
||||
QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/"));
|
||||
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
||||
|
||||
if (!profiles.isEmpty())
|
||||
profilesComboBox->addItems(profiles);
|
||||
|
||||
qDebug() << "adding " << profile;
|
||||
mProfilesComboBox->addItem(profile);
|
||||
}
|
||||
// Add the current profile if empty
|
||||
if (profilesComboBox->findText(profile) == -1)
|
||||
profilesComboBox->addItem(profile);
|
||||
|
||||
// Add a default profile
|
||||
if (mProfilesComboBox->findText(QString("Default")) == -1) {
|
||||
mProfilesComboBox->addItem(QString("Default"));
|
||||
}
|
||||
|
||||
QString currentProfile = mLauncherConfig->value("CurrentProfile").toString();
|
||||
|
||||
if (currentProfile.isEmpty()) {
|
||||
// No current profile selected
|
||||
currentProfile = "Default";
|
||||
}
|
||||
|
||||
const int currentIndex = mProfilesComboBox->findText(currentProfile);
|
||||
if (currentIndex != -1) {
|
||||
// Profile is found
|
||||
mProfilesComboBox->setCurrentIndex(currentIndex);
|
||||
}
|
||||
|
||||
mLauncherConfig->endGroup();
|
||||
}
|
||||
|
||||
|
||||
void DataFilesPage::readConfig()
|
||||
{
|
||||
QString profile = mProfilesComboBox->currentText();
|
||||
|
||||
// Make sure we have no groups open
|
||||
while (!mLauncherConfig->group().isEmpty()) {
|
||||
mLauncherConfig->endGroup();
|
||||
}
|
||||
|
||||
mLauncherConfig->beginGroup("Profiles");
|
||||
mLauncherConfig->beginGroup(profile);
|
||||
|
||||
QStringList childKeys = mLauncherConfig->childKeys();
|
||||
QStringList plugins;
|
||||
|
||||
// Sort the child keys numerical instead of alphabetically
|
||||
// i.e. Plugin1, Plugin2 instead of Plugin1, Plugin10
|
||||
qSort(childKeys.begin(), childKeys.end(), naturalSortLessThanCI);
|
||||
|
||||
foreach (const QString &key, childKeys) {
|
||||
const QString keyValue = mLauncherConfig->value(key).toString();
|
||||
|
||||
mDataFilesList->setCheckState(keyValue, Qt::Checked);
|
||||
}
|
||||
|
||||
qDebug() << plugins;
|
||||
}
|
||||
|
||||
bool DataFilesPage::showDataFilesWarning()
|
||||
{
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle("Error detecting Morrowind installation");
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.setStandardButtons(QMessageBox::Cancel);
|
||||
msgBox.setText(tr("<br><b>Could not find the Data Files location</b><br><br> \
|
||||
The directory containing the data files was not found.<br><br> \
|
||||
Press \"Browse...\" to specify the location manually.<br>"));
|
||||
|
||||
QAbstractButton *dirSelectButton =
|
||||
msgBox.addButton(tr("B&rowse..."), QMessageBox::ActionRole);
|
||||
|
||||
msgBox.exec();
|
||||
|
||||
if (msgBox.clickedButton() == dirSelectButton) {
|
||||
|
||||
// Show a custom dir selection dialog which only accepts valid dirs
|
||||
QString selectedDir = FileDialog::getExistingDirectory(
|
||||
this, tr("Select Data Files Directory"),
|
||||
QDir::currentPath(),
|
||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
||||
// Add the user selected data directory
|
||||
if (!selectedDir.isEmpty()) {
|
||||
mDataDirs.push_back(Files::PathContainer::value_type(selectedDir.toStdString()));
|
||||
mCfgMgr.processPaths(mDataDirs);
|
||||
} else {
|
||||
// Cancel from within the dir selection dialog
|
||||
return false;
|
||||
}
|
||||
if (profilesComboBox->findText(QString("Default")) == -1)
|
||||
profilesComboBox->addItem(QString("Default"));
|
||||
|
||||
if (profile.isEmpty() || profile == QLatin1String("Default")) {
|
||||
profilesComboBox->setCurrentIndex(profilesComboBox->findText(QString("Default")));
|
||||
} else {
|
||||
// Cancel
|
||||
return false;
|
||||
profilesComboBox->setEditEnabled(true);
|
||||
profilesComboBox->setCurrentIndex(profilesComboBox->findText(profile));
|
||||
}
|
||||
|
||||
return true;
|
||||
// We do this here to prevent deletion of profiles when initializing the combobox
|
||||
connect(profilesComboBox, SIGNAL(profileRenamed(QString,QString)), this, SLOT(profileRenamed(QString,QString)));
|
||||
connect(profilesComboBox, SIGNAL(profileChanged(QString,QString)), this, SLOT(profileChanged(QString,QString)));
|
||||
|
||||
loadSettings();
|
||||
|
||||
}
|
||||
|
||||
bool DataFilesPage::setupDataFiles()
|
||||
void DataFilesPage::loadSettings()
|
||||
{
|
||||
// We use the Configuration Manager to retrieve the configuration values
|
||||
boost::program_options::variables_map variables;
|
||||
boost::program_options::options_description desc;
|
||||
|
||||
desc.add_options()
|
||||
("data", boost::program_options::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")->multitoken())
|
||||
("data-local", boost::program_options::value<std::string>()->default_value(""))
|
||||
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false))
|
||||
("encoding", boost::program_options::value<std::string>()->default_value("win1252"));
|
||||
|
||||
boost::program_options::notify(variables);
|
||||
|
||||
mCfgMgr.readConfiguration(variables, desc);
|
||||
|
||||
if (variables["data"].empty()) {
|
||||
if (!showDataFilesWarning())
|
||||
return false;
|
||||
} else {
|
||||
mDataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>());
|
||||
}
|
||||
|
||||
std::string local = variables["data-local"].as<std::string>();
|
||||
if (!local.empty()) {
|
||||
mDataLocal.push_back(Files::PathContainer::value_type(local));
|
||||
}
|
||||
|
||||
mCfgMgr.processPaths(mDataDirs);
|
||||
mCfgMgr.processPaths(mDataLocal);
|
||||
|
||||
// Second chance to display the warning, the data= entries are invalid
|
||||
while (mDataDirs.empty()) {
|
||||
if (!showDataFilesWarning())
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the charset for reading the esm/esp files
|
||||
QString encoding = QString::fromStdString(variables["encoding"].as<std::string>());
|
||||
|
||||
Files::PathContainer paths;
|
||||
paths.insert(paths.end(), mDataDirs.begin(), mDataDirs.end());
|
||||
paths.insert(paths.end(), mDataLocal.begin(), mDataLocal.end());
|
||||
mDataFilesList->setupDataFiles(paths, encoding);
|
||||
readConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
void DataFilesPage::writeConfig(QString profile)
|
||||
{
|
||||
QString pathStr = QString::fromStdString(mCfgMgr.getUserPath().string());
|
||||
QDir userPath(pathStr);
|
||||
|
||||
if (!userPath.exists()) {
|
||||
if (!userPath.mkpath(pathStr)) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle("Error creating OpenMW configuration directory");
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not create %0</b><br><br> \
|
||||
Please make sure you have the right permissions and try again.<br>").arg(pathStr));
|
||||
msgBox.exec();
|
||||
|
||||
qApp->quit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Open the OpenMW config as a QFile
|
||||
QFile file(pathStr.append("openmw.cfg"));
|
||||
|
||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
|
||||
// File cannot be opened or created
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle("Error writing OpenMW configuration file");
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not open or create %0</b><br><br> \
|
||||
Please make sure you have the right permissions and try again.<br>").arg(file.fileName()));
|
||||
msgBox.exec();
|
||||
|
||||
qApp->quit();
|
||||
return;
|
||||
}
|
||||
|
||||
QTextStream in(&file);
|
||||
QByteArray buffer;
|
||||
|
||||
// Remove all previous entries from config
|
||||
while (!in.atEnd()) {
|
||||
QString line = in.readLine();
|
||||
if (!line.startsWith("master") &&
|
||||
!line.startsWith("plugin") &&
|
||||
!line.startsWith("data") &&
|
||||
!line.startsWith("data-local"))
|
||||
{
|
||||
buffer += line += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
// Now we write back the other config entries
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle("Error writing OpenMW configuration file");
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not write to %0</b><br><br> \
|
||||
Please make sure you have the right permissions and try again.<br>").arg(file.fileName()));
|
||||
msgBox.exec();
|
||||
|
||||
qApp->quit();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!buffer.isEmpty()) {
|
||||
file.write(buffer);
|
||||
}
|
||||
|
||||
QTextStream gameConfig(&file);
|
||||
|
||||
// First write the list of data dirs
|
||||
mCfgMgr.processPaths(mDataDirs);
|
||||
mCfgMgr.processPaths(mDataLocal);
|
||||
|
||||
QString path;
|
||||
|
||||
// data= directories
|
||||
for (Files::PathContainer::iterator it = mDataDirs.begin(); it != mDataDirs.end(); ++it) {
|
||||
path = QString::fromStdString(it->string());
|
||||
path.remove(QChar('\"'));
|
||||
|
||||
// Make sure the string is quoted when it contains spaces
|
||||
if (path.contains(" ")) {
|
||||
gameConfig << "data=\"" << path << "\"" << endl;
|
||||
} else {
|
||||
gameConfig << "data=" << path << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// data-local directory
|
||||
if (!mDataLocal.empty()) {
|
||||
path = QString::fromStdString(mDataLocal.front().string());
|
||||
path.remove(QChar('\"'));
|
||||
|
||||
if (path.contains(" ")) {
|
||||
gameConfig << "data-local=\"" << path << "\"" << endl;
|
||||
} else {
|
||||
gameConfig << "data-local=" << path << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (profile.isEmpty())
|
||||
profile = mProfilesComboBox->currentText();
|
||||
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
||||
|
||||
if (profile.isEmpty())
|
||||
return;
|
||||
|
||||
// Make sure we have no groups open
|
||||
while (!mLauncherConfig->group().isEmpty()) {
|
||||
mLauncherConfig->endGroup();
|
||||
mDataFilesModel->uncheckAll();
|
||||
|
||||
QStringList masters = mLauncherSettings.values(QString("Profiles/") + profile + QString("/master"), Qt::MatchExactly);
|
||||
QStringList plugins = mLauncherSettings.values(QString("Profiles/") + profile + QString("/plugin"), Qt::MatchExactly);
|
||||
|
||||
foreach (const QString &master, masters) {
|
||||
QModelIndex index = mDataFilesModel->indexFromItem(mDataFilesModel->findItem(master));
|
||||
if (index.isValid())
|
||||
mDataFilesModel->setCheckState(index, Qt::Checked);
|
||||
}
|
||||
|
||||
mLauncherConfig->beginGroup("Profiles");
|
||||
mLauncherConfig->setValue("CurrentProfile", profile);
|
||||
|
||||
// Open the profile-name subgroup
|
||||
mLauncherConfig->beginGroup(profile);
|
||||
mLauncherConfig->remove(""); // Clear the subgroup
|
||||
|
||||
// Now write the masters to the configs
|
||||
const QStringList checkedFiles = mDataFilesList->checkedFiles();
|
||||
for(int i=0; i < checkedFiles.size(); i++)
|
||||
{
|
||||
if (checkedFiles.at(i).lastIndexOf("esm") != -1)
|
||||
{
|
||||
mLauncherConfig->setValue(QString("Master%0").arg(i), checkedFiles.at(i));
|
||||
gameConfig << "master=" << checkedFiles.at(i) << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
mLauncherConfig->setValue(QString("Plugin%1").arg(i), checkedFiles.at(i));
|
||||
gameConfig << "plugin=" << checkedFiles.at(i) << endl;
|
||||
}
|
||||
foreach (const QString &plugin, plugins) {
|
||||
QModelIndex index = mDataFilesModel->indexFromItem(mDataFilesModel->findItem(plugin));
|
||||
if (index.isValid())
|
||||
mDataFilesModel->setCheckState(index, Qt::Checked);
|
||||
}
|
||||
|
||||
file.close();
|
||||
mLauncherConfig->endGroup();
|
||||
mLauncherConfig->endGroup();
|
||||
mLauncherConfig->sync();
|
||||
}
|
||||
|
||||
void DataFilesPage::saveSettings()
|
||||
{
|
||||
if (mDataFilesModel->rowCount() < 1)
|
||||
return;
|
||||
|
||||
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
||||
|
||||
if (profile.isEmpty()) {
|
||||
profile = profilesComboBox->currentText();
|
||||
mLauncherSettings.setValue(QString("Profiles/currentprofile"), profile);
|
||||
}
|
||||
|
||||
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/master"));
|
||||
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/plugin"));
|
||||
|
||||
mGameSettings.remove(QString("master"));
|
||||
mGameSettings.remove(QString("plugin"));
|
||||
|
||||
QStringList items = mDataFilesModel->checkedItems();
|
||||
|
||||
foreach(const QString &item, items) {
|
||||
|
||||
if (item.endsWith(QString(".esm"), Qt::CaseInsensitive)) {
|
||||
mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/master"), item);
|
||||
mGameSettings.setMultiValue(QString("master"), item);
|
||||
|
||||
} else if (item.endsWith(QString(".esp"), Qt::CaseInsensitive)) {
|
||||
mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/plugin"), item);
|
||||
mGameSettings.setMultiValue(QString("plugin"), item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DataFilesPage::newProfile()
|
||||
{
|
||||
if (mNewProfileDialog->exec() == QDialog::Accepted) {
|
||||
|
||||
const QString text = mNewProfileDialog->lineEdit()->text();
|
||||
mProfilesComboBox->addItem(text);
|
||||
|
||||
// Copy the currently checked items to cfg
|
||||
writeConfig(text);
|
||||
mLauncherConfig->sync();
|
||||
|
||||
mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text));
|
||||
QString profile = mNewProfileDialog->lineEdit()->text();
|
||||
profilesComboBox->addItem(profile);
|
||||
profilesComboBox->setCurrentIndex(profilesComboBox->findText(profile));
|
||||
}
|
||||
}
|
||||
|
||||
void DataFilesPage::updateOkButton(const QString &text)
|
||||
{
|
||||
// We do this here because we need the profiles combobox text
|
||||
if (text.isEmpty()) {
|
||||
mNewProfileDialog->setOkButtonEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
(mProfilesComboBox->findText(text) == -1)
|
||||
(profilesComboBox->findText(text) == -1)
|
||||
? mNewProfileDialog->setOkButtonEnabled(true)
|
||||
: mNewProfileDialog->setOkButtonEnabled(false);
|
||||
}
|
||||
|
||||
void DataFilesPage::updateSplitter()
|
||||
{
|
||||
// Sigh, update the saved splitter size in settings only when moved
|
||||
// Since getting mSplitter->sizes() if page is hidden returns invalid values
|
||||
QList<int> sizes = splitter->sizes();
|
||||
|
||||
mLauncherSettings.setValue(QString("General/MastersTable/width"), QString::number(sizes.at(0)));
|
||||
mLauncherSettings.setValue(QString("General/PluginsTable/width"), QString::number(sizes.at(1)));
|
||||
}
|
||||
|
||||
void DataFilesPage::updateViews()
|
||||
{
|
||||
// Ensure the columns are hidden because sort() re-enables them
|
||||
mastersTable->setColumnHidden(1, true);
|
||||
mastersTable->setColumnHidden(2, true);
|
||||
mastersTable->setColumnHidden(3, true);
|
||||
mastersTable->setColumnHidden(4, true);
|
||||
mastersTable->setColumnHidden(5, true);
|
||||
mastersTable->setColumnHidden(6, true);
|
||||
mastersTable->setColumnHidden(7, true);
|
||||
mastersTable->setColumnHidden(8, true);
|
||||
|
||||
pluginsTable->setColumnHidden(1, true);
|
||||
pluginsTable->setColumnHidden(2, true);
|
||||
pluginsTable->setColumnHidden(3, true);
|
||||
pluginsTable->setColumnHidden(4, true);
|
||||
pluginsTable->setColumnHidden(5, true);
|
||||
pluginsTable->setColumnHidden(6, true);
|
||||
pluginsTable->setColumnHidden(7, true);
|
||||
pluginsTable->setColumnHidden(8, true);
|
||||
}
|
||||
|
||||
void DataFilesPage::setProfilesComboBoxIndex(int index)
|
||||
{
|
||||
profilesComboBox->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void DataFilesPage::slotCurrentIndexChanged(int index)
|
||||
{
|
||||
emit profileChanged(index);
|
||||
}
|
||||
|
||||
QAbstractItemModel* DataFilesPage::profilesComboBoxModel()
|
||||
{
|
||||
return profilesComboBox->model();
|
||||
}
|
||||
|
||||
int DataFilesPage::profilesComboBoxIndex()
|
||||
{
|
||||
return profilesComboBox->currentIndex();
|
||||
}
|
||||
|
||||
void DataFilesPage::deleteProfile()
|
||||
{
|
||||
QString profile = mProfilesComboBox->currentText();
|
||||
QString profile = profilesComboBox->currentText();
|
||||
|
||||
if (profile.isEmpty())
|
||||
return;
|
||||
|
@ -456,49 +350,151 @@ void DataFilesPage::deleteProfile()
|
|||
msgBox.exec();
|
||||
|
||||
if (msgBox.clickedButton() == deleteButton) {
|
||||
// Make sure we have no groups open
|
||||
while (!mLauncherConfig->group().isEmpty()) {
|
||||
mLauncherConfig->endGroup();
|
||||
}
|
||||
|
||||
mLauncherConfig->beginGroup("Profiles");
|
||||
|
||||
// Open the profile-name subgroup
|
||||
mLauncherConfig->beginGroup(profile);
|
||||
mLauncherConfig->remove(""); // Clear the subgroup
|
||||
mLauncherConfig->endGroup();
|
||||
mLauncherConfig->endGroup();
|
||||
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/master"));
|
||||
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/plugin"));
|
||||
|
||||
// Remove the profile from the combobox
|
||||
mProfilesComboBox->removeItem(mProfilesComboBox->findText(profile));
|
||||
profilesComboBox->removeItem(profilesComboBox->findText(profile));
|
||||
}
|
||||
}
|
||||
|
||||
void DataFilesPage::check()
|
||||
{
|
||||
if (pluginsTable->hasFocus())
|
||||
setPluginsCheckstates(Qt::Checked);
|
||||
|
||||
if (mastersTable->hasFocus())
|
||||
setMastersCheckstates(Qt::Checked);
|
||||
|
||||
}
|
||||
|
||||
void DataFilesPage::uncheck()
|
||||
{
|
||||
if (pluginsTable->hasFocus())
|
||||
setPluginsCheckstates(Qt::Unchecked);
|
||||
|
||||
if (mastersTable->hasFocus())
|
||||
setMastersCheckstates(Qt::Unchecked);
|
||||
}
|
||||
|
||||
void DataFilesPage::refresh()
|
||||
{
|
||||
// mDataFilesModel->sort(0);
|
||||
|
||||
// Refresh the plugins table
|
||||
pluginsTable->scrollToTop();
|
||||
}
|
||||
|
||||
void DataFilesPage::setMastersCheckstates(Qt::CheckState state)
|
||||
{
|
||||
if (!mastersTable->selectionModel()->hasSelection()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QModelIndexList indexes = mastersTable->selectionModel()->selectedIndexes();
|
||||
|
||||
foreach (const QModelIndex &index, indexes)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
QModelIndex sourceIndex = mMastersProxyModel->mapToSource(index);
|
||||
|
||||
if (!sourceIndex.isValid())
|
||||
return;
|
||||
|
||||
mDataFilesModel->setCheckState(sourceIndex, state);
|
||||
}
|
||||
}
|
||||
|
||||
void DataFilesPage::setPluginsCheckstates(Qt::CheckState state)
|
||||
{
|
||||
if (!pluginsTable->selectionModel()->hasSelection()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QModelIndexList indexes = pluginsTable->selectionModel()->selectedIndexes();
|
||||
|
||||
foreach (const QModelIndex &index, indexes)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(
|
||||
mFilterProxyModel->mapToSource(index));
|
||||
|
||||
if (!sourceIndex.isValid())
|
||||
return;
|
||||
|
||||
mDataFilesModel->setCheckState(sourceIndex, state);
|
||||
}
|
||||
}
|
||||
|
||||
void DataFilesPage::setCheckState(QModelIndex index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
QObject *object = QObject::sender();
|
||||
|
||||
// Not a signal-slot call
|
||||
if (!object)
|
||||
return;
|
||||
|
||||
|
||||
if (object->objectName() == QLatin1String("PluginsTable")) {
|
||||
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(
|
||||
mFilterProxyModel->mapToSource(index));
|
||||
|
||||
if (sourceIndex.isValid()) {
|
||||
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
||||
? mDataFilesModel->setCheckState(sourceIndex, Qt::Unchecked)
|
||||
: mDataFilesModel->setCheckState(sourceIndex, Qt::Checked);
|
||||
}
|
||||
}
|
||||
|
||||
if (object->objectName() == QLatin1String("MastersTable")) {
|
||||
QModelIndex sourceIndex = mMastersProxyModel->mapToSource(index);
|
||||
|
||||
if (sourceIndex.isValid()) {
|
||||
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
||||
? mDataFilesModel->setCheckState(sourceIndex, Qt::Unchecked)
|
||||
: mDataFilesModel->setCheckState(sourceIndex, Qt::Checked);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void DataFilesPage::filterChanged(const QString filter)
|
||||
{
|
||||
QRegExp regExp(filter, Qt::CaseInsensitive, QRegExp::FixedString);
|
||||
mFilterProxyModel->setFilterRegExp(regExp);
|
||||
}
|
||||
|
||||
void DataFilesPage::profileChanged(const QString &previous, const QString ¤t)
|
||||
{
|
||||
qDebug() << "Profile is changed from: " << previous << " to " << current;
|
||||
// Prevent the deletion of the default profile
|
||||
if (current == QLatin1String("Default")) {
|
||||
mDeleteProfileAction->setEnabled(false);
|
||||
mProfilesComboBox->setEditEnabled(false);
|
||||
profilesComboBox->setEditEnabled(false);
|
||||
} else {
|
||||
mDeleteProfileAction->setEnabled(true);
|
||||
mProfilesComboBox->setEditEnabled(true);
|
||||
profilesComboBox->setEditEnabled(true);
|
||||
}
|
||||
|
||||
if (!previous.isEmpty()) {
|
||||
writeConfig(previous);
|
||||
mLauncherConfig->sync();
|
||||
|
||||
if (mProfilesComboBox->currentIndex() == -1)
|
||||
return;
|
||||
|
||||
} else {
|
||||
if (previous.isEmpty())
|
||||
return;
|
||||
}
|
||||
|
||||
mDataFilesList->uncheckAll();
|
||||
readConfig();
|
||||
if (profilesComboBox->findText(previous) == -1)
|
||||
return; // Profile was deleted
|
||||
|
||||
// Store the previous profile
|
||||
mLauncherSettings.setValue(QString("Profiles/currentprofile"), previous);
|
||||
saveSettings();
|
||||
mLauncherSettings.setValue(QString("Profiles/currentprofile"), current);
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
void DataFilesPage::profileRenamed(const QString &previous, const QString ¤t)
|
||||
|
@ -507,27 +503,85 @@ void DataFilesPage::profileRenamed(const QString &previous, const QString &curre
|
|||
return;
|
||||
|
||||
// Save the new profile name
|
||||
writeConfig(current);
|
||||
mLauncherSettings.setValue(QString("Profiles/currentprofile"), current);
|
||||
saveSettings();
|
||||
|
||||
// Make sure we have no groups open
|
||||
while (!mLauncherConfig->group().isEmpty()) {
|
||||
mLauncherConfig->endGroup();
|
||||
}
|
||||
// Remove the old one
|
||||
mLauncherSettings.remove(QString("Profiles/") + previous + QString("/master"));
|
||||
mLauncherSettings.remove(QString("Profiles/") + previous + QString("/plugin"));
|
||||
|
||||
mLauncherConfig->beginGroup("Profiles");
|
||||
// Remove the profile from the combobox
|
||||
profilesComboBox->removeItem(profilesComboBox->findText(previous));
|
||||
|
||||
// Open the profile-name subgroup
|
||||
mLauncherConfig->beginGroup(previous);
|
||||
mLauncherConfig->remove(""); // Clear the subgroup
|
||||
mLauncherConfig->endGroup();
|
||||
mLauncherConfig->endGroup();
|
||||
mLauncherConfig->sync();
|
||||
loadSettings();
|
||||
|
||||
// Remove the profile from the combobox
|
||||
mProfilesComboBox->removeItem(mProfilesComboBox->findText(previous));
|
||||
|
||||
mDataFilesList->uncheckAll();
|
||||
////mMastersModel->uncheckAll();
|
||||
////mPluginsModel->uncheckAll();
|
||||
readConfig();
|
||||
}
|
||||
|
||||
void DataFilesPage::showContextMenu(const QPoint &point)
|
||||
{
|
||||
QObject *object = QObject::sender();
|
||||
|
||||
// Not a signal-slot call
|
||||
if (!object)
|
||||
return;
|
||||
|
||||
if (object->objectName() == QLatin1String("PluginsTable")) {
|
||||
if (!pluginsTable->selectionModel()->hasSelection())
|
||||
return;
|
||||
|
||||
QPoint globalPos = pluginsTable->mapToGlobal(point);
|
||||
QModelIndexList indexes = pluginsTable->selectionModel()->selectedIndexes();
|
||||
|
||||
// Show the check/uncheck actions depending on the state of the selected items
|
||||
mUncheckAction->setEnabled(false);
|
||||
mCheckAction->setEnabled(false);
|
||||
|
||||
foreach (const QModelIndex &index, indexes)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(
|
||||
mFilterProxyModel->mapToSource(index));
|
||||
|
||||
if (!sourceIndex.isValid())
|
||||
return;
|
||||
|
||||
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
||||
? mUncheckAction->setEnabled(true)
|
||||
: mCheckAction->setEnabled(true);
|
||||
}
|
||||
|
||||
// Show menu
|
||||
mContextMenu->exec(globalPos);
|
||||
}
|
||||
|
||||
if (object->objectName() == QLatin1String("MastersTable")) {
|
||||
if (!mastersTable->selectionModel()->hasSelection())
|
||||
return;
|
||||
|
||||
QPoint globalPos = mastersTable->mapToGlobal(point);
|
||||
QModelIndexList indexes = mastersTable->selectionModel()->selectedIndexes();
|
||||
|
||||
// Show the check/uncheck actions depending on the state of the selected items
|
||||
mUncheckAction->setEnabled(false);
|
||||
mCheckAction->setEnabled(false);
|
||||
|
||||
foreach (const QModelIndex &index, indexes)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
QModelIndex sourceIndex = mMastersProxyModel->mapToSource(index);
|
||||
|
||||
if (!sourceIndex.isValid())
|
||||
return;
|
||||
|
||||
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
||||
? mUncheckAction->setEnabled(true)
|
||||
: mCheckAction->setEnabled(true);
|
||||
}
|
||||
|
||||
mContextMenu->exec(globalPos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,57 +3,80 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QModelIndex>
|
||||
#include "utils/profilescombobox.hpp"
|
||||
#include <components/files/collections.hpp>
|
||||
|
||||
#include "ui_datafilespage.h"
|
||||
|
||||
class QTableView;
|
||||
class QSortFilterProxyModel;
|
||||
class QSettings;
|
||||
class QAbstractItemModel;
|
||||
class QAction;
|
||||
class QToolBar;
|
||||
class QMenu;
|
||||
class ProfilesComboBox;
|
||||
class DataFilesModel;
|
||||
|
||||
class DataFilesModel;
|
||||
class TextInputDialog;
|
||||
class DataFilesList;
|
||||
class GameSettings;
|
||||
class LauncherSettings;
|
||||
class PluginsProxyModel;
|
||||
|
||||
namespace Files { struct ConfigurationManager; }
|
||||
|
||||
class DataFilesPage : public QWidget
|
||||
class DataFilesPage : public QWidget, private Ui::DataFilesPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DataFilesPage(Files::ConfigurationManager& cfg, QWidget *parent = 0);
|
||||
DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent = 0);
|
||||
|
||||
ProfilesComboBox *mProfilesComboBox;
|
||||
QAbstractItemModel* profilesComboBoxModel();
|
||||
int profilesComboBoxIndex();
|
||||
|
||||
void writeConfig(QString profile = QString());
|
||||
bool showDataFilesWarning();
|
||||
bool setupDataFiles();
|
||||
void saveSettings();
|
||||
|
||||
signals:
|
||||
void profileChanged(int index);
|
||||
|
||||
public slots:
|
||||
void setCheckState(QModelIndex index);
|
||||
void setProfilesComboBoxIndex(int index);
|
||||
|
||||
void filterChanged(const QString filter);
|
||||
void showContextMenu(const QPoint &point);
|
||||
void profileChanged(const QString &previous, const QString ¤t);
|
||||
void profileRenamed(const QString &previous, const QString ¤t);
|
||||
void updateOkButton(const QString &text);
|
||||
void updateSplitter();
|
||||
void updateViews();
|
||||
|
||||
// Action slots
|
||||
void newProfile();
|
||||
void deleteProfile();
|
||||
// void moveUp();
|
||||
// void moveDown();
|
||||
// void moveTop();
|
||||
// void moveBottom();
|
||||
void check();
|
||||
void uncheck();
|
||||
void refresh();
|
||||
|
||||
private slots:
|
||||
void slotCurrentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
DataFilesList *mDataFilesList;
|
||||
DataFilesModel *mDataFilesModel;
|
||||
|
||||
QToolBar *mProfileToolBar;
|
||||
PluginsProxyModel *mPluginsProxyModel;
|
||||
QSortFilterProxyModel *mMastersProxyModel;
|
||||
|
||||
QSortFilterProxyModel *mFilterProxyModel;
|
||||
|
||||
// QTableView *mMastersTable;
|
||||
// QTableView *mPluginsTable;
|
||||
|
||||
|
||||
// QToolBar *mProfileToolBar;
|
||||
QMenu *mContextMenu;
|
||||
// QSplitter *mSplitter;
|
||||
|
||||
QAction *mNewProfileAction;
|
||||
QAction *mDeleteProfileAction;
|
||||
QAction *mCheckAction;
|
||||
QAction *mUncheckAction;
|
||||
|
||||
// QAction *mMoveUpAction;
|
||||
// QAction *mMoveDownAction;
|
||||
|
@ -61,20 +84,22 @@ private:
|
|||
// QAction *mMoveBottomAction;
|
||||
|
||||
Files::ConfigurationManager &mCfgMgr;
|
||||
Files::PathContainer mDataDirs;
|
||||
Files::PathContainer mDataLocal;
|
||||
|
||||
QSettings *mLauncherConfig;
|
||||
GameSettings &mGameSettings;
|
||||
LauncherSettings &mLauncherSettings;
|
||||
|
||||
TextInputDialog *mNewProfileDialog;
|
||||
|
||||
// const QStringList checkedPlugins();
|
||||
// const QStringList selectedMasters();
|
||||
void setMastersCheckstates(Qt::CheckState state);
|
||||
void setPluginsCheckstates(Qt::CheckState state);
|
||||
|
||||
void createActions();
|
||||
void setupDataFiles();
|
||||
void setupConfig();
|
||||
void readConfig();
|
||||
|
||||
void loadSettings();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
#include "graphicspage.hpp"
|
||||
|
||||
#include <QtGui>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <boost/math/common_factor.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/files/ogreplugin.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include <components/fileorderlist/utils/naturalsort.hpp>
|
||||
|
||||
#include "graphicspage.hpp"
|
||||
#include "settings/graphicssettings.hpp"
|
||||
|
||||
QString getAspect(int x, int y)
|
||||
{
|
||||
|
@ -24,52 +25,22 @@ QString getAspect(int x, int y)
|
|||
return QString(QString::number(xaspect) + ":" + QString::number(yaspect));
|
||||
}
|
||||
|
||||
GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, mCfgMgr(cfg)
|
||||
GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &graphicsSetting, QWidget *parent)
|
||||
: mCfgMgr(cfg)
|
||||
, mGraphicsSettings(graphicsSetting)
|
||||
, QWidget(parent)
|
||||
{
|
||||
QGroupBox *rendererGroup = new QGroupBox(tr("Renderer"), this);
|
||||
setupUi(this);
|
||||
|
||||
QLabel *rendererLabel = new QLabel(tr("Rendering Subsystem:"), rendererGroup);
|
||||
mRendererComboBox = new QComboBox(rendererGroup);
|
||||
// Set the maximum res we can set in windowed mode
|
||||
QRect res = QApplication::desktop()->screenGeometry();
|
||||
customWidthSpinBox->setMaximum(res.width());
|
||||
customHeightSpinBox->setMaximum(res.height());
|
||||
|
||||
// Layout for the combobox and label
|
||||
QGridLayout *renderSystemLayout = new QGridLayout();
|
||||
renderSystemLayout->addWidget(rendererLabel, 0, 0, 1, 1);
|
||||
renderSystemLayout->addWidget(mRendererComboBox, 0, 1, 1, 1);
|
||||
connect(rendererComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&)));
|
||||
connect(fullScreenCheckBox, SIGNAL(stateChanged(int)), this, SLOT(slotFullScreenChanged(int)));
|
||||
connect(standardRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool)));
|
||||
|
||||
// Display
|
||||
QGroupBox *displayGroup = new QGroupBox(tr("Display"), this);
|
||||
|
||||
mVSyncCheckBox = new QCheckBox(tr("Vertical Sync"), displayGroup);
|
||||
mFullScreenCheckBox = new QCheckBox(tr("Full Screen"), displayGroup);
|
||||
|
||||
QLabel *antiAliasingLabel = new QLabel(tr("Antialiasing:"), displayGroup);
|
||||
QLabel *resolutionLabel = new QLabel(tr("Resolution:"), displayGroup);
|
||||
|
||||
mResolutionComboBox = new QComboBox(displayGroup);
|
||||
mAntiAliasingComboBox = new QComboBox(displayGroup);
|
||||
|
||||
QVBoxLayout *rendererGroupLayout = new QVBoxLayout(rendererGroup);
|
||||
rendererGroupLayout->addLayout(renderSystemLayout);
|
||||
|
||||
QGridLayout *displayGroupLayout = new QGridLayout(displayGroup);
|
||||
displayGroupLayout->addWidget(mVSyncCheckBox, 0, 0, 1, 1);
|
||||
displayGroupLayout->addWidget(mFullScreenCheckBox, 1, 0, 1, 1);
|
||||
displayGroupLayout->addWidget(antiAliasingLabel, 2, 0, 1, 1);
|
||||
displayGroupLayout->addWidget(mAntiAliasingComboBox, 2, 1, 1, 1);
|
||||
displayGroupLayout->addWidget(resolutionLabel, 3, 0, 1, 1);
|
||||
displayGroupLayout->addWidget(mResolutionComboBox, 3, 1, 1, 1);
|
||||
|
||||
// Layout for the whole page
|
||||
QVBoxLayout *pageLayout = new QVBoxLayout(this);
|
||||
QSpacerItem *vSpacer1 = new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
|
||||
pageLayout->addWidget(rendererGroup);
|
||||
pageLayout->addWidget(displayGroup);
|
||||
pageLayout->addItem(vSpacer1);
|
||||
|
||||
connect(mRendererComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&)));
|
||||
}
|
||||
|
||||
bool GraphicsPage::setupOgre()
|
||||
|
@ -116,11 +87,11 @@ bool GraphicsPage::setupOgre()
|
|||
#endif
|
||||
}
|
||||
|
||||
boost::filesystem::path absPluginPath = boost::filesystem::absolute(boost::filesystem::path(pluginDir));
|
||||
|
||||
pluginDir = absPluginPath.string();
|
||||
QDir dir(QString::fromStdString(pluginDir));
|
||||
pluginDir = dir.absolutePath().toStdString();
|
||||
|
||||
Files::loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre);
|
||||
Files::loadOgrePlugin(pluginDir, "RenderSystem_GL3Plus", *mOgre);
|
||||
Files::loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mOgre);
|
||||
|
||||
#ifdef ENABLE_PLUGIN_GL
|
||||
|
@ -137,7 +108,7 @@ bool GraphicsPage::setupOgre()
|
|||
|
||||
for (Ogre::RenderSystemList::const_iterator r = renderers.begin(); r != renderers.end(); ++r) {
|
||||
mSelectedRenderSystem = *r;
|
||||
mRendererComboBox->addItem((*r)->getName().c_str());
|
||||
rendererComboBox->addItem((*r)->getName().c_str());
|
||||
}
|
||||
|
||||
QString openGLName = QString("OpenGL Rendering Subsystem");
|
||||
|
@ -153,71 +124,85 @@ bool GraphicsPage::setupOgre()
|
|||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not select a valid render system</b><br><br> \
|
||||
Please make sure the plugins.cfg file exists and contains a valid rendering plugin.<br>"));
|
||||
Please make sure the plugins.cfg file exists and contains a valid rendering plugin.<br>"));
|
||||
msgBox.exec();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now fill the GUI elements
|
||||
int index = mRendererComboBox->findText(QString::fromStdString(Settings::Manager::getString("render system", "Video")));
|
||||
|
||||
int index = rendererComboBox->findText(mGraphicsSettings.value(QString("Video/render system")));
|
||||
if ( index != -1) {
|
||||
mRendererComboBox->setCurrentIndex(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
rendererComboBox->setCurrentIndex(index);
|
||||
} else {
|
||||
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
|
||||
mRendererComboBox->setCurrentIndex(mRendererComboBox->findText(direct3DName));
|
||||
rendererComboBox->setCurrentIndex(rendererComboBox->findText(direct3DName));
|
||||
#else
|
||||
mRendererComboBox->setCurrentIndex(mRendererComboBox->findText(openGLName));
|
||||
rendererComboBox->setCurrentIndex(rendererComboBox->findText(openGLName));
|
||||
#endif
|
||||
}
|
||||
|
||||
mAntiAliasingComboBox->clear();
|
||||
mResolutionComboBox->clear();
|
||||
mAntiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
||||
mResolutionComboBox->addItems(getAvailableResolutions(mSelectedRenderSystem));
|
||||
antiAliasingComboBox->clear();
|
||||
resolutionComboBox->clear();
|
||||
antiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
||||
resolutionComboBox->addItems(getAvailableResolutions(mSelectedRenderSystem));
|
||||
|
||||
readConfig();
|
||||
// Load the rest of the values
|
||||
loadSettings();
|
||||
return true;
|
||||
}
|
||||
|
||||
void GraphicsPage::readConfig()
|
||||
void GraphicsPage::loadSettings()
|
||||
{
|
||||
if (Settings::Manager::getBool("vsync", "Video"))
|
||||
mVSyncCheckBox->setCheckState(Qt::Checked);
|
||||
if (mGraphicsSettings.value(QString("Video/vsync")) == QLatin1String("true"))
|
||||
vSyncCheckBox->setCheckState(Qt::Checked);
|
||||
|
||||
if (Settings::Manager::getBool("fullscreen", "Video"))
|
||||
mFullScreenCheckBox->setCheckState(Qt::Checked);
|
||||
if (mGraphicsSettings.value(QString("Video/fullscreen")) == QLatin1String("true"))
|
||||
fullScreenCheckBox->setCheckState(Qt::Checked);
|
||||
|
||||
int aaIndex = mAntiAliasingComboBox->findText(QString::fromStdString(Settings::Manager::getString("antialiasing", "Video")));
|
||||
int aaIndex = antiAliasingComboBox->findText(mGraphicsSettings.value(QString("Video/antialiasing")));
|
||||
if (aaIndex != -1)
|
||||
mAntiAliasingComboBox->setCurrentIndex(aaIndex);
|
||||
antiAliasingComboBox->setCurrentIndex(aaIndex);
|
||||
|
||||
QString resolution = QString::number(Settings::Manager::getInt("resolution x", "Video"));
|
||||
resolution.append(" x " + QString::number(Settings::Manager::getInt("resolution y", "Video")));
|
||||
QString width = mGraphicsSettings.value(QString("Video/resolution x"));
|
||||
QString height = mGraphicsSettings.value(QString("Video/resolution y"));
|
||||
QString resolution = width + QString(" x ") + height;
|
||||
|
||||
int resIndex = mResolutionComboBox->findText(resolution, Qt::MatchStartsWith);
|
||||
if (resIndex != -1)
|
||||
mResolutionComboBox->setCurrentIndex(resIndex);
|
||||
int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith);
|
||||
|
||||
if (resIndex != -1) {
|
||||
standardRadioButton->toggle();
|
||||
resolutionComboBox->setCurrentIndex(resIndex);
|
||||
} else {
|
||||
customRadioButton->toggle();
|
||||
customWidthSpinBox->setValue(width.toInt());
|
||||
customHeightSpinBox->setValue(height.toInt());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsPage::writeConfig()
|
||||
void GraphicsPage::saveSettings()
|
||||
{
|
||||
Settings::Manager::setBool("vsync", "Video", mVSyncCheckBox->checkState());
|
||||
Settings::Manager::setBool("fullscreen", "Video", mFullScreenCheckBox->checkState());
|
||||
Settings::Manager::setString("antialiasing", "Video", mAntiAliasingComboBox->currentText().toStdString());
|
||||
Settings::Manager::setString("render system", "Video", mRendererComboBox->currentText().toStdString());
|
||||
vSyncCheckBox->checkState() ? mGraphicsSettings.setValue(QString("Video/vsync"), QString("true"))
|
||||
: mGraphicsSettings.setValue(QString("Video/vsync"), QString("false"));
|
||||
|
||||
// Get the current resolution, but with the tabs replaced with a single space
|
||||
QString resolution = mResolutionComboBox->currentText().simplified();
|
||||
QStringList tokens = resolution.split(" ", QString::SkipEmptyParts);
|
||||
fullScreenCheckBox->checkState() ? mGraphicsSettings.setValue(QString("Video/fullscreen"), QString("true"))
|
||||
: mGraphicsSettings.setValue(QString("Video/fullscreen"), QString("false"));
|
||||
|
||||
int resX = tokens.at(0).toInt();
|
||||
int resY = tokens.at(2).toInt();
|
||||
Settings::Manager::setInt("resolution x", "Video", resX);
|
||||
Settings::Manager::setInt("resolution y", "Video", resY);
|
||||
mGraphicsSettings.setValue(QString("Video/antialiasing"), antiAliasingComboBox->currentText());
|
||||
mGraphicsSettings.setValue(QString("Video/render system"), rendererComboBox->currentText());
|
||||
|
||||
|
||||
if (standardRadioButton->isChecked()) {
|
||||
QRegExp resolutionRe(QString("(\\d+) x (\\d+).*"));
|
||||
|
||||
if (resolutionRe.exactMatch(resolutionComboBox->currentText().simplified())) {
|
||||
mGraphicsSettings.setValue(QString("Video/resolution x"), resolutionRe.cap(1));
|
||||
mGraphicsSettings.setValue(QString("Video/resolution y"), resolutionRe.cap(2));
|
||||
}
|
||||
} else {
|
||||
mGraphicsSettings.setValue(QString("Video/resolution x"), QString::number(customWidthSpinBox->value()));
|
||||
mGraphicsSettings.setValue(QString("Video/resolution y"), QString::number(customHeightSpinBox->value()));
|
||||
}
|
||||
}
|
||||
|
||||
QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSystem *renderer)
|
||||
|
@ -231,16 +216,14 @@ QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSy
|
|||
{
|
||||
Ogre::StringVector::iterator opt_it;
|
||||
uint idx = 0;
|
||||
for (opt_it = i->second.possibleValues.begin ();
|
||||
opt_it != i->second.possibleValues.end (); opt_it++, idx++)
|
||||
{
|
||||
|
||||
if (strcmp (key.toStdString().c_str(), i->first.c_str()) == 0)
|
||||
{
|
||||
for (opt_it = i->second.possibleValues.begin();
|
||||
opt_it != i->second.possibleValues.end(); opt_it++, idx++)
|
||||
{
|
||||
if (strcmp (key.toStdString().c_str(), i->first.c_str()) == 0) {
|
||||
result << ((key == "FSAA") ? QString("MSAA ") : QString("")) + QString::fromStdString((*opt_it).c_str()).simplified();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Sort ascending
|
||||
|
@ -257,7 +240,7 @@ QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSy
|
|||
|
||||
QStringList GraphicsPage::getAvailableResolutions(Ogre::RenderSystem *renderer)
|
||||
{
|
||||
QString key ("Video Mode");
|
||||
QString key("Video Mode");
|
||||
QStringList result;
|
||||
|
||||
uint row = 0;
|
||||
|
@ -274,24 +257,26 @@ QStringList GraphicsPage::getAvailableResolutions(Ogre::RenderSystem *renderer)
|
|||
for (opt_it = i->second.possibleValues.begin ();
|
||||
opt_it != i->second.possibleValues.end (); opt_it++, idx++)
|
||||
{
|
||||
QString qval = QString::fromStdString(*opt_it).simplified();
|
||||
// remove extra tokens after the resolution (for example bpp, can be there or not depending on rendersystem)
|
||||
QStringList tokens = qval.split(" ", QString::SkipEmptyParts);
|
||||
assert (tokens.size() >= 3);
|
||||
QString resolutionStr = tokens.at(0) + QString(" x ") + tokens.at(2);
|
||||
QRegExp resolutionRe(QString("(\\d+) x (\\d+)"));
|
||||
QString resolution = QString::fromStdString(*opt_it).simplified();
|
||||
|
||||
QString aspect = getAspect(tokens.at(0).toInt(),tokens.at(2).toInt());
|
||||
if (resolutionRe.exactMatch(resolution)) {
|
||||
|
||||
if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) {
|
||||
resolutionStr.append(tr("\t(Widescreen ") + aspect + ")");
|
||||
int width = resolutionRe.cap(1).toInt();
|
||||
int height = resolutionRe.cap(2).toInt();
|
||||
|
||||
} else if (aspect == QLatin1String("4:3")) {
|
||||
resolutionStr.append(tr("\t(Standard 4:3)"));
|
||||
QString aspect = getAspect(width, height);
|
||||
|
||||
if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) {
|
||||
resolution.append(tr("\t(Wide ") + aspect + ")");
|
||||
|
||||
} else if (aspect == QLatin1String("4:3")) {
|
||||
resolution.append(tr("\t(Standard 4:3)"));
|
||||
}
|
||||
// do not add duplicate resolutions
|
||||
if (!result.contains(resolution))
|
||||
result.append(resolution);
|
||||
}
|
||||
|
||||
// do not add duplicate resolutions
|
||||
if (!result.contains(resolutionStr))
|
||||
result << resolutionStr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,9 +290,36 @@ void GraphicsPage::rendererChanged(const QString &renderer)
|
|||
{
|
||||
mSelectedRenderSystem = mOgre->getRenderSystemByName(renderer.toStdString());
|
||||
|
||||
mAntiAliasingComboBox->clear();
|
||||
mResolutionComboBox->clear();
|
||||
antiAliasingComboBox->clear();
|
||||
resolutionComboBox->clear();
|
||||
|
||||
mAntiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
||||
mResolutionComboBox->addItems(getAvailableResolutions(mSelectedRenderSystem));
|
||||
antiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
||||
resolutionComboBox->addItems(getAvailableResolutions(mSelectedRenderSystem));
|
||||
}
|
||||
|
||||
void GraphicsPage::slotFullScreenChanged(int state)
|
||||
{
|
||||
if (state == Qt::Checked) {
|
||||
standardRadioButton->toggle();
|
||||
customRadioButton->setEnabled(false);
|
||||
customWidthSpinBox->setEnabled(false);
|
||||
customHeightSpinBox->setEnabled(false);
|
||||
} else {
|
||||
customRadioButton->setEnabled(true);
|
||||
customWidthSpinBox->setEnabled(true);
|
||||
customHeightSpinBox->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsPage::slotStandardToggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
resolutionComboBox->setEnabled(true);
|
||||
customWidthSpinBox->setEnabled(false);
|
||||
customHeightSpinBox->setEnabled(false);
|
||||
} else {
|
||||
resolutionComboBox->setEnabled(false);
|
||||
customWidthSpinBox->setEnabled(true);
|
||||
customHeightSpinBox->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
#include <OgreRoot.h>
|
||||
#include <OgreRenderSystem.h>
|
||||
#include <OgreConfigFile.h>
|
||||
#include <OgreConfigDialog.h>
|
||||
//#include <OgreConfigFile.h>
|
||||
//#include <OgreConfigDialog.h>
|
||||
|
||||
// Static plugin headers
|
||||
#ifdef ENABLE_PLUGIN_GL
|
||||
|
@ -16,26 +16,29 @@
|
|||
# include "OgreD3D9Plugin.h"
|
||||
#endif
|
||||
|
||||
class QComboBox;
|
||||
class QCheckBox;
|
||||
class QStackedWidget;
|
||||
class QSettings;
|
||||
#include "ui_graphicspage.h"
|
||||
|
||||
class GraphicsSettings;
|
||||
|
||||
namespace Files { struct ConfigurationManager; }
|
||||
|
||||
class GraphicsPage : public QWidget
|
||||
class GraphicsPage : public QWidget, private Ui::GraphicsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GraphicsPage(Files::ConfigurationManager &cfg, QWidget *parent = 0);
|
||||
GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &graphicsSettings, QWidget *parent = 0);
|
||||
|
||||
void saveSettings();
|
||||
bool setupOgre();
|
||||
void writeConfig();
|
||||
|
||||
public slots:
|
||||
void rendererChanged(const QString &renderer);
|
||||
|
||||
private slots:
|
||||
void slotFullScreenChanged(int state);
|
||||
void slotStandardToggled(bool checked);
|
||||
|
||||
private:
|
||||
Ogre::Root *mOgre;
|
||||
Ogre::RenderSystem *mSelectedRenderSystem;
|
||||
|
@ -48,22 +51,14 @@ private:
|
|||
Ogre::D3D9Plugin* mD3D9Plugin;
|
||||
#endif
|
||||
|
||||
QComboBox *mRendererComboBox;
|
||||
|
||||
QStackedWidget *mDisplayStackedWidget;
|
||||
|
||||
QComboBox *mAntiAliasingComboBox;
|
||||
QComboBox *mResolutionComboBox;
|
||||
QCheckBox *mVSyncCheckBox;
|
||||
QCheckBox *mFullScreenCheckBox;
|
||||
|
||||
Files::ConfigurationManager &mCfgMgr;
|
||||
GraphicsSettings &mGraphicsSettings;
|
||||
|
||||
QStringList getAvailableOptions(const QString &key, Ogre::RenderSystem *renderer);
|
||||
QStringList getAvailableResolutions(Ogre::RenderSystem *renderer);
|
||||
|
||||
void createPages();
|
||||
void readConfig();
|
||||
void loadSettings();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <QApplication>
|
||||
#include <QTextCodec>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
|
||||
#include "maindialog.hpp"
|
||||
|
||||
|
@ -30,14 +30,17 @@ int main(int argc, char *argv[])
|
|||
|
||||
QDir::setCurrent(dir.absolutePath());
|
||||
|
||||
// Support non-latin characters
|
||||
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
MainDialog mainWin;
|
||||
|
||||
if (mainWin.setup()) {
|
||||
|
||||
mainWin.show();
|
||||
return app.exec();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,52 +1,16 @@
|
|||
#include "maindialog.hpp"
|
||||
|
||||
#include <QtGui>
|
||||
|
||||
#include "maindialog.hpp"
|
||||
#include "utils/checkablemessagebox.hpp"
|
||||
|
||||
#include "playpage.hpp"
|
||||
#include "graphicspage.hpp"
|
||||
#include "datafilespage.hpp"
|
||||
|
||||
MainDialog::MainDialog()
|
||||
: mGameSettings(mCfgMgr)
|
||||
{
|
||||
QWidget *centralWidget = new QWidget(this);
|
||||
setCentralWidget(centralWidget);
|
||||
|
||||
mIconWidget = new QListWidget(centralWidget);
|
||||
mIconWidget->setObjectName("IconWidget");
|
||||
mIconWidget->setViewMode(QListView::IconMode);
|
||||
mIconWidget->setWrapping(false);
|
||||
mIconWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Just to be sure
|
||||
mIconWidget->setIconSize(QSize(48, 48));
|
||||
mIconWidget->setMovement(QListView::Static);
|
||||
|
||||
mIconWidget->setMinimumWidth(400);
|
||||
mIconWidget->setFixedHeight(80);
|
||||
mIconWidget->setSpacing(4);
|
||||
mIconWidget->setCurrentRow(0);
|
||||
mIconWidget->setFlow(QListView::LeftToRight);
|
||||
|
||||
QGroupBox *groupBox = new QGroupBox(centralWidget);
|
||||
QVBoxLayout *groupLayout = new QVBoxLayout(groupBox);
|
||||
|
||||
mPagesWidget = new QStackedWidget(groupBox);
|
||||
groupLayout->addWidget(mPagesWidget);
|
||||
|
||||
QPushButton *playButton = new QPushButton(tr("Play"));
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(centralWidget);
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Close);
|
||||
buttonBox->addButton(playButton, QDialogButtonBox::AcceptRole);
|
||||
|
||||
QVBoxLayout *dialogLayout = new QVBoxLayout(centralWidget);
|
||||
dialogLayout->addWidget(mIconWidget);
|
||||
dialogLayout->addWidget(groupBox);
|
||||
dialogLayout->addWidget(buttonBox);
|
||||
|
||||
setWindowTitle(tr("OpenMW Launcher"));
|
||||
setWindowIcon(QIcon(":/images/openmw.png"));
|
||||
// Remove what's this? button
|
||||
setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
setMinimumSize(QSize(575, 575));
|
||||
|
||||
// Install the stylesheet font
|
||||
QFile file;
|
||||
QFontDatabase fontDatabase;
|
||||
|
@ -56,64 +20,67 @@ MainDialog::MainDialog()
|
|||
// Check if the font is installed
|
||||
if (!fonts.contains("EB Garamond")) {
|
||||
|
||||
QString font = QString::fromStdString((mCfgMgr.getGlobalDataPath() / "resources/mygui/EBGaramond-Regular.ttf").string());
|
||||
file.setFileName(font);
|
||||
QString font = QString::fromStdString(mCfgMgr.getGlobalDataPath().string()) + QString("resources/mygui/EBGaramond-Regular.ttf");
|
||||
file.setFileName(font);
|
||||
|
||||
if (!file.exists()) {
|
||||
font = QString::fromStdString((mCfgMgr.getLocalPath() / "resources/mygui/EBGaramond-Regular.ttf").string());
|
||||
}
|
||||
if (!file.exists()) {
|
||||
font = QString::fromStdString(mCfgMgr.getLocalPath().string()) + QString("resources/mygui/EBGaramond-Regular.ttf");
|
||||
}
|
||||
|
||||
fontDatabase.addApplicationFont(font);
|
||||
fontDatabase.addApplicationFont(font);
|
||||
}
|
||||
|
||||
// Load the stylesheet
|
||||
QString config = QString::fromStdString((mCfgMgr.getGlobalDataPath() / "resources/launcher.qss").string());
|
||||
file.setFileName(config);
|
||||
setupUi(this);
|
||||
|
||||
if (!file.exists()) {
|
||||
file.setFileName(QString::fromStdString((mCfgMgr.getLocalPath() / "launcher.qss").string()));
|
||||
}
|
||||
iconWidget->setViewMode(QListView::IconMode);
|
||||
iconWidget->setWrapping(false);
|
||||
iconWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Just to be sure
|
||||
iconWidget->setIconSize(QSize(48, 48));
|
||||
iconWidget->setMovement(QListView::Static);
|
||||
|
||||
file.open(QFile::ReadOnly);
|
||||
QString styleSheet = QLatin1String(file.readAll());
|
||||
qApp->setStyleSheet(styleSheet);
|
||||
file.close();
|
||||
iconWidget->setSpacing(4);
|
||||
iconWidget->setCurrentRow(0);
|
||||
iconWidget->setFlow(QListView::LeftToRight);
|
||||
|
||||
QPushButton *playButton = new QPushButton(tr("Play"));
|
||||
buttonBox->addButton(playButton, QDialogButtonBox::AcceptRole);
|
||||
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(play()));
|
||||
|
||||
// Remove what's this? button
|
||||
setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
createIcons();
|
||||
createPages();
|
||||
}
|
||||
|
||||
void MainDialog::createIcons()
|
||||
{
|
||||
if (!QIcon::hasThemeIcon("document-new")) {
|
||||
if (!QIcon::hasThemeIcon("document-new"))
|
||||
QIcon::setThemeName("tango");
|
||||
}
|
||||
|
||||
// We create a fallback icon because the default fallback doesn't work
|
||||
QIcon graphicsIcon = QIcon(":/icons/tango/video-display.png");
|
||||
|
||||
QListWidgetItem *playButton = new QListWidgetItem(mIconWidget);
|
||||
QListWidgetItem *playButton = new QListWidgetItem(iconWidget);
|
||||
playButton->setIcon(QIcon(":/images/openmw.png"));
|
||||
playButton->setText(tr("Play"));
|
||||
playButton->setTextAlignment(Qt::AlignCenter);
|
||||
playButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
|
||||
QListWidgetItem *graphicsButton = new QListWidgetItem(mIconWidget);
|
||||
QListWidgetItem *graphicsButton = new QListWidgetItem(iconWidget);
|
||||
graphicsButton->setIcon(QIcon::fromTheme("video-display", graphicsIcon));
|
||||
graphicsButton->setText(tr("Graphics"));
|
||||
graphicsButton->setTextAlignment(Qt::AlignHCenter | Qt::AlignBottom | Qt::AlignAbsolute);
|
||||
graphicsButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
|
||||
QListWidgetItem *dataFilesButton = new QListWidgetItem(mIconWidget);
|
||||
QListWidgetItem *dataFilesButton = new QListWidgetItem(iconWidget);
|
||||
dataFilesButton->setIcon(QIcon(":/images/openmw-plugin.png"));
|
||||
dataFilesButton->setText(tr("Data Files"));
|
||||
dataFilesButton->setTextAlignment(Qt::AlignHCenter | Qt::AlignBottom);
|
||||
dataFilesButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
|
||||
connect(mIconWidget,
|
||||
connect(iconWidget,
|
||||
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
|
||||
|
||||
|
@ -122,77 +89,185 @@ void MainDialog::createIcons()
|
|||
void MainDialog::createPages()
|
||||
{
|
||||
mPlayPage = new PlayPage(this);
|
||||
mGraphicsPage = new GraphicsPage(mCfgMgr, this);
|
||||
mDataFilesPage = new DataFilesPage(mCfgMgr, this);
|
||||
mGraphicsPage = new GraphicsPage(mCfgMgr, mGraphicsSettings, this);
|
||||
mDataFilesPage = new DataFilesPage(mCfgMgr, mGameSettings, mLauncherSettings, this);
|
||||
|
||||
// Set the combobox of the play page to imitate the combobox on the datafilespage
|
||||
mPlayPage->mProfilesComboBox->setModel(mDataFilesPage->mProfilesComboBox->model());
|
||||
mPlayPage->mProfilesComboBox->setCurrentIndex(mDataFilesPage->mProfilesComboBox->currentIndex());
|
||||
mPlayPage->setProfilesComboBoxModel(mDataFilesPage->profilesComboBoxModel());
|
||||
mPlayPage->setProfilesComboBoxIndex(mDataFilesPage->profilesComboBoxIndex());
|
||||
|
||||
// Add the pages to the stacked widget
|
||||
mPagesWidget->addWidget(mPlayPage);
|
||||
mPagesWidget->addWidget(mGraphicsPage);
|
||||
mPagesWidget->addWidget(mDataFilesPage);
|
||||
pagesWidget->addWidget(mPlayPage);
|
||||
pagesWidget->addWidget(mGraphicsPage);
|
||||
pagesWidget->addWidget(mDataFilesPage);
|
||||
|
||||
// Select the first page
|
||||
mIconWidget->setCurrentItem(mIconWidget->item(0), QItemSelectionModel::Select);
|
||||
iconWidget->setCurrentItem(iconWidget->item(0), QItemSelectionModel::Select);
|
||||
|
||||
connect(mPlayPage->mPlayButton, SIGNAL(clicked()), this, SLOT(play()));
|
||||
connect(mPlayPage, SIGNAL(playButtonClicked()), this, SLOT(play()));
|
||||
|
||||
connect(mPlayPage->mProfilesComboBox,
|
||||
SIGNAL(currentIndexChanged(int)),
|
||||
mDataFilesPage->mProfilesComboBox, SLOT(setCurrentIndex(int)));
|
||||
|
||||
connect(mDataFilesPage->mProfilesComboBox,
|
||||
SIGNAL(currentIndexChanged(int)),
|
||||
mPlayPage->mProfilesComboBox, SLOT(setCurrentIndex(int)));
|
||||
connect(mPlayPage, SIGNAL(profileChanged(int)), mDataFilesPage, SLOT(setProfilesComboBoxIndex(int)));
|
||||
connect(mDataFilesPage, SIGNAL(profileChanged(int)), mPlayPage, SLOT(setProfilesComboBoxIndex(int)));
|
||||
|
||||
}
|
||||
|
||||
bool MainDialog::showFirstRunDialog()
|
||||
{
|
||||
CheckableMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle(tr("Morrowind installation detected"));
|
||||
|
||||
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion);
|
||||
int size = QApplication::style()->pixelMetric(QStyle::PM_MessageBoxIconSize);
|
||||
msgBox.setIconPixmap(icon.pixmap(size, size));
|
||||
|
||||
|
||||
QAbstractButton *importerButton =
|
||||
msgBox.addButton(tr("Import"), QDialogButtonBox::AcceptRole); // ActionRole doesn't work?!
|
||||
QAbstractButton *skipButton =
|
||||
msgBox.addButton(tr("Skip"), QDialogButtonBox::RejectRole);
|
||||
|
||||
Q_UNUSED(skipButton); // Surpress compiler unused warning
|
||||
|
||||
msgBox.setStandardButtons(QDialogButtonBox::NoButton);
|
||||
|
||||
msgBox.setText(tr("<br><b>An existing Morrowind installation was detected</b><br><br> \
|
||||
Would you like to import settings from Morrowind.ini?<br>"));
|
||||
|
||||
msgBox.setCheckBoxText(tr("Include selected masters and plugins (creates a new profile)"));
|
||||
msgBox.exec();
|
||||
|
||||
|
||||
if (msgBox.clickedButton() == importerButton) {
|
||||
|
||||
QStringList iniPaths;
|
||||
|
||||
foreach (const QString &path, mGameSettings.getDataDirs()) {
|
||||
QDir dir(path);
|
||||
dir.setPath(dir.canonicalPath()); // Resolve symlinks
|
||||
|
||||
if (!dir.cdUp())
|
||||
continue; // Cannot move from Data Files
|
||||
|
||||
if (dir.exists(QString("Morrowind.ini")))
|
||||
iniPaths.append(dir.absoluteFilePath(QString("Morrowind.ini")));
|
||||
}
|
||||
|
||||
if (iniPaths.isEmpty()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error reading Morrowind configuration file"));
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(QObject::tr("<br><b>Could not find Morrowind.ini</b><br><br> \
|
||||
The problem may be due to an incomplete installation of Morrowind.<br> \
|
||||
Reinstalling Morrowind may resolve the problem."));
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (iniPaths.count() > 1) {
|
||||
// Multiple Morrowind.ini files found
|
||||
bool ok;
|
||||
QString path = QInputDialog::getItem(this, tr("Multiple configurations found"),
|
||||
tr("<br><b>There are multiple Morrowind.ini files found.</b><br><br> \
|
||||
Please select the one you wish to import from:"), iniPaths, 0, false, &ok);
|
||||
if (ok && !path.isEmpty()) {
|
||||
iniPaths.clear();
|
||||
iniPaths.append(path);
|
||||
} else {
|
||||
// Cancel was clicked TODO: should we abort here?
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Create the file if it doesn't already exist, else the importer will fail
|
||||
QString path = QString::fromStdString(mCfgMgr.getUserPath().string()) + QString("openmw.cfg");
|
||||
QFile file(path);
|
||||
|
||||
if (!file.exists()) {
|
||||
if (!file.open(QIODevice::ReadWrite)) {
|
||||
// File cannot be created
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error writing OpenMW configuration file"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not open or create %0 for writing</b><br><br> \
|
||||
Please make sure you have the right permissions \
|
||||
and try again.<br>").arg(file.fileName()));
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
// Construct the arguments to run the importer
|
||||
QStringList arguments;
|
||||
|
||||
if (msgBox.isChecked())
|
||||
arguments.append(QString("-g"));
|
||||
|
||||
arguments.append(iniPaths.first());
|
||||
arguments.append(path);
|
||||
|
||||
if (!startProgram(QString("mwiniimport"), arguments, false))
|
||||
return false;
|
||||
|
||||
// Re-read the game settings
|
||||
mGameSettings.clear();
|
||||
|
||||
if (!setupGameSettings())
|
||||
return false;
|
||||
|
||||
// Add a new profile
|
||||
if (msgBox.isChecked()) {
|
||||
mLauncherSettings.setValue(QString("Profiles/CurrentProfile"), QString("Imported"));
|
||||
|
||||
mLauncherSettings.remove(QString("Profiles/Imported/master"));
|
||||
mLauncherSettings.remove(QString("Profiles/Imported/plugin"));
|
||||
|
||||
QStringList masters = mGameSettings.values(QString("master"));
|
||||
QStringList plugins = mGameSettings.values(QString("plugin"));
|
||||
|
||||
foreach (const QString &master, masters) {
|
||||
mLauncherSettings.setMultiValue(QString("Profiles/Imported/master"), master);
|
||||
}
|
||||
|
||||
foreach (const QString &plugin, plugins) {
|
||||
mLauncherSettings.setMultiValue(QString("Profiles/Imported/plugin"), plugin);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainDialog::setup()
|
||||
{
|
||||
// Create the settings manager and load default settings file
|
||||
const std::string localdefault = (mCfgMgr.getLocalPath() / "settings-default.cfg").string();
|
||||
const std::string globaldefault = (mCfgMgr.getGlobalPath() / "settings-default.cfg").string();
|
||||
|
||||
// prefer local
|
||||
if (boost::filesystem::exists(localdefault)) {
|
||||
mSettings.loadDefault(localdefault);
|
||||
} else if (boost::filesystem::exists(globaldefault)) {
|
||||
mSettings.loadDefault(globaldefault);
|
||||
} else {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle("Error reading OpenMW configuration file");
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not find %0</b><br><br> \
|
||||
The problem may be due to an incomplete installation of OpenMW.<br> \
|
||||
Reinstalling OpenMW may resolve the problem.").arg(QString::fromStdString(globaldefault)));
|
||||
msgBox.exec();
|
||||
if (!setupLauncherSettings())
|
||||
return false;
|
||||
|
||||
if (!setupGameSettings())
|
||||
return false;
|
||||
|
||||
if (!setupGraphicsSettings())
|
||||
return false;
|
||||
|
||||
// Check if we need to show the importer
|
||||
if (mLauncherSettings.value(QString("General/firstrun"), QString("true")) == QLatin1String("true"))
|
||||
{
|
||||
if (!showFirstRunDialog())
|
||||
return false;
|
||||
}
|
||||
|
||||
// load user settings if they exist, otherwise just load the default settings as user settings
|
||||
const std::string settingspath = (mCfgMgr.getUserPath() / "settings.cfg").string();
|
||||
// Now create the pages as they need the settings
|
||||
createPages();
|
||||
|
||||
if (boost::filesystem::exists(settingspath))
|
||||
mSettings.loadUser(settingspath);
|
||||
else if (boost::filesystem::exists(localdefault))
|
||||
mSettings.loadUser(localdefault);
|
||||
else if (boost::filesystem::exists(globaldefault))
|
||||
mSettings.loadUser(globaldefault);
|
||||
|
||||
// Setup the Graphics page
|
||||
if (!mGraphicsPage->setupOgre()) {
|
||||
// Call this so we can exit on Ogre errors before mainwindow is shown
|
||||
if (!mGraphicsPage->setupOgre())
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup the Data Files page
|
||||
if (!mDataFilesPage->setupDataFiles()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
loadSettings();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -201,89 +276,409 @@ void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
|||
if (!current)
|
||||
current = previous;
|
||||
|
||||
mPagesWidget->setCurrentIndex(mIconWidget->row(current));
|
||||
pagesWidget->setCurrentIndex(iconWidget->row(current));
|
||||
}
|
||||
|
||||
bool MainDialog::setupLauncherSettings()
|
||||
{
|
||||
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
||||
|
||||
QStringList paths;
|
||||
paths.append(QString("launcher.cfg"));
|
||||
paths.append(userPath + QString("launcher.cfg"));
|
||||
|
||||
foreach (const QString &path, paths) {
|
||||
qDebug() << "Loading config file:" << qPrintable(path);
|
||||
QFile file(path);
|
||||
if (file.exists()) {
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error opening OpenMW configuration file"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(QObject::tr("<br><b>Could not open %0 for reading</b><br><br> \
|
||||
Please make sure you have the right permissions \
|
||||
and try again.<br>").arg(file.fileName()));
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
QTextStream stream(&file);
|
||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
mLauncherSettings.readFile(stream);
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainDialog::setupGameSettings()
|
||||
{
|
||||
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
||||
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
|
||||
|
||||
QStringList paths;
|
||||
paths.append(userPath + QString("openmw.cfg"));
|
||||
paths.append(QString("openmw.cfg"));
|
||||
paths.append(globalPath + QString("openmw.cfg"));
|
||||
|
||||
foreach (const QString &path, paths) {
|
||||
qDebug() << "Loading config file:" << qPrintable(path);
|
||||
|
||||
QFile file(path);
|
||||
if (file.exists()) {
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error opening OpenMW configuration file"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(QObject::tr("<br><b>Could not open %0 for reading</b><br><br> \
|
||||
Please make sure you have the right permissions \
|
||||
and try again.<br>").arg(file.fileName()));
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
QTextStream stream(&file);
|
||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
mGameSettings.readFile(stream);
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
QStringList dataDirs;
|
||||
|
||||
// Check if the paths actually contain data files
|
||||
foreach (const QString path, mGameSettings.getDataDirs()) {
|
||||
QDir dir(path);
|
||||
QStringList filters;
|
||||
filters << "*.esp" << "*.esm";
|
||||
|
||||
if (!dir.entryList(filters).isEmpty())
|
||||
dataDirs.append(path);
|
||||
}
|
||||
|
||||
if (dataDirs.isEmpty())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error detecting Morrowind installation"));
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.setStandardButtons(QMessageBox::Cancel);
|
||||
msgBox.setText(QObject::tr("<br><b>Could not find the Data Files location</b><br><br> \
|
||||
The directory containing the data files was not found.<br><br> \
|
||||
Press \"Browse...\" to specify the location manually.<br>"));
|
||||
|
||||
QAbstractButton *dirSelectButton =
|
||||
msgBox.addButton(QObject::tr("B&rowse..."), QMessageBox::ActionRole);
|
||||
|
||||
msgBox.exec();
|
||||
|
||||
QString selectedFile;
|
||||
if (msgBox.clickedButton() == dirSelectButton) {
|
||||
selectedFile = QFileDialog::getOpenFileName(
|
||||
NULL,
|
||||
QObject::tr("Select master file"),
|
||||
QDir::currentPath(),
|
||||
QString(tr("Morrowind master file (*.esm)")));
|
||||
}
|
||||
|
||||
if (selectedFile.isEmpty())
|
||||
return false; // Cancel was clicked;
|
||||
|
||||
QFileInfo info(selectedFile);
|
||||
|
||||
// Add the new dir to the settings file and to the data dir container
|
||||
mGameSettings.setValue(QString("data"), info.absolutePath());
|
||||
mGameSettings.addDataDir(info.absolutePath());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainDialog::setupGraphicsSettings()
|
||||
{
|
||||
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
||||
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
|
||||
|
||||
QFile localDefault(QString("settings-default.cfg"));
|
||||
QFile globalDefault(globalPath + QString("settings-default.cfg"));
|
||||
|
||||
if (!localDefault.exists() && !globalDefault.exists()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error reading OpenMW configuration file"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(QObject::tr("<br><b>Could not find settings-default.cfg</b><br><br> \
|
||||
The problem may be due to an incomplete installation of OpenMW.<br> \
|
||||
Reinstalling OpenMW may resolve the problem."));
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QStringList paths;
|
||||
paths.append(globalPath + QString("settings-default.cfg"));
|
||||
paths.append(QString("settings-default.cfg"));
|
||||
paths.append(userPath + QString("settings.cfg"));
|
||||
|
||||
foreach (const QString &path, paths) {
|
||||
qDebug() << "Loading config file:" << qPrintable(path);
|
||||
QFile file(path);
|
||||
if (file.exists()) {
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error opening OpenMW configuration file"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(QObject::tr("<br><b>Could not open %0 for reading</b><br><br> \
|
||||
Please make sure you have the right permissions \
|
||||
and try again.<br>").arg(file.fileName()));
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
QTextStream stream(&file);
|
||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
mGraphicsSettings.readFile(stream);
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainDialog::loadSettings()
|
||||
{
|
||||
int width = mLauncherSettings.value(QString("General/MainWindow/width")).toInt();
|
||||
int height = mLauncherSettings.value(QString("General/MainWindow/height")).toInt();
|
||||
|
||||
int posX = mLauncherSettings.value(QString("General/MainWindow/posx")).toInt();
|
||||
int posY = mLauncherSettings.value(QString("General/MainWindow/posy")).toInt();
|
||||
|
||||
resize(width, height);
|
||||
move(posX, posY);
|
||||
}
|
||||
|
||||
void MainDialog::saveSettings()
|
||||
{
|
||||
QString width = QString::number(this->width());
|
||||
QString height = QString::number(this->height());
|
||||
|
||||
mLauncherSettings.setValue(QString("General/MainWindow/width"), width);
|
||||
mLauncherSettings.setValue(QString("General/MainWindow/height"), height);
|
||||
|
||||
QString posX = QString::number(this->pos().x());
|
||||
QString posY = QString::number(this->pos().y());
|
||||
|
||||
mLauncherSettings.setValue(QString("General/MainWindow/posx"), posX);
|
||||
mLauncherSettings.setValue(QString("General/MainWindow/posy"), posY);
|
||||
|
||||
mLauncherSettings.setValue(QString("General/firstrun"), QString("false"));
|
||||
|
||||
}
|
||||
|
||||
void MainDialog::writeSettings()
|
||||
{
|
||||
// Now write all config files
|
||||
saveSettings();
|
||||
mGraphicsPage->saveSettings();
|
||||
mDataFilesPage->saveSettings();
|
||||
|
||||
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
||||
QDir dir(userPath);
|
||||
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkpath(userPath)) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error creating OpenMW configuration directory"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not create %0</b><br><br> \
|
||||
Please make sure you have the right permissions \
|
||||
and try again.<br>").arg(userPath));
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Game settings
|
||||
QFile file(userPath + QString("openmw.cfg"));
|
||||
|
||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) {
|
||||
// File cannot be opened or created
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error writing OpenMW configuration file"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not open or create %0 for writing</b><br><br> \
|
||||
Please make sure you have the right permissions \
|
||||
and try again.<br>").arg(file.fileName()));
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
QTextStream stream(&file);
|
||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
mGameSettings.writeFile(stream);
|
||||
file.close();
|
||||
|
||||
// Graphics settings
|
||||
file.setFileName(userPath + QString("settings.cfg"));
|
||||
|
||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) {
|
||||
// File cannot be opened or created
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error writing OpenMW configuration file"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not open or create %0 for writing</b><br><br> \
|
||||
Please make sure you have the right permissions \
|
||||
and try again.<br>").arg(file.fileName()));
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
stream.setDevice(&file);
|
||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
mGraphicsSettings.writeFile(stream);
|
||||
file.close();
|
||||
|
||||
// Launcher settings
|
||||
file.setFileName(userPath + QString("launcher.cfg"));
|
||||
|
||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) {
|
||||
// File cannot be opened or created
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error writing Launcher configuration file"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not open or create %0 for writing</b><br><br> \
|
||||
Please make sure you have the right permissions \
|
||||
and try again.<br>").arg(file.fileName()));
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
stream.setDevice(&file);
|
||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
mLauncherSettings.writeFile(stream);
|
||||
file.close();
|
||||
}
|
||||
|
||||
void MainDialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
// Now write all config files
|
||||
mDataFilesPage->writeConfig();
|
||||
mGraphicsPage->writeConfig();
|
||||
|
||||
// Save user settings
|
||||
const std::string settingspath = (mCfgMgr.getUserPath() / "settings.cfg").string();
|
||||
mSettings.saveUser(settingspath);
|
||||
|
||||
saveSettings();
|
||||
writeSettings();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void MainDialog::play()
|
||||
{
|
||||
// First do a write of all the configs, just to be sure
|
||||
mDataFilesPage->writeConfig();
|
||||
mGraphicsPage->writeConfig();
|
||||
saveSettings();
|
||||
writeSettings();
|
||||
|
||||
// Save user settings
|
||||
const std::string settingspath = (mCfgMgr.getUserPath() / "settings.cfg").string();
|
||||
mSettings.saveUser(settingspath);
|
||||
// Launch the game detached
|
||||
startProgram(QString("openmw"), true);
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
bool MainDialog::startProgram(const QString &name, const QStringList &arguments, bool detached)
|
||||
{
|
||||
QString path = name;
|
||||
#ifdef Q_OS_WIN
|
||||
QString game = "./openmw.exe";
|
||||
QFile file(game);
|
||||
path.append(QString(".exe"));
|
||||
#elif defined(Q_OS_MAC)
|
||||
QDir dir(QCoreApplication::applicationDirPath());
|
||||
QString game = dir.absoluteFilePath("openmw");
|
||||
QFile file(game);
|
||||
game = "\"" + game + "\"";
|
||||
path = dir.absoluteFilePath(name);
|
||||
#else
|
||||
QString game = "./openmw";
|
||||
QFile file(game);
|
||||
path.prepend(QString("./"));
|
||||
#endif
|
||||
|
||||
QFile file(path);
|
||||
|
||||
QProcess process;
|
||||
QFileInfo info(file);
|
||||
|
||||
if (!file.exists()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle("Error starting OpenMW");
|
||||
msgBox.setWindowTitle(tr("Error starting executable"));
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not find OpenMW</b><br><br> \
|
||||
The OpenMW application is not found.<br> \
|
||||
Please make sure OpenMW is installed correctly and try again.<br>"));
|
||||
msgBox.setText(tr("<br><b>Could not find %1</b><br><br> \
|
||||
The application is not found.<br> \
|
||||
Please make sure OpenMW is installed correctly and try again.<br>").arg(info.fileName()));
|
||||
msgBox.exec();
|
||||
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!info.isExecutable()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle("Error starting OpenMW");
|
||||
msgBox.setWindowTitle(tr("Error starting executable"));
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not start OpenMW</b><br><br> \
|
||||
The OpenMW application is not executable.<br> \
|
||||
Please make sure you have the right permissions and try again.<br>"));
|
||||
msgBox.setText(tr("<br><b>Could not start %1</b><br><br> \
|
||||
The application is not executable.<br> \
|
||||
Please make sure you have the right permissions and try again.<br>").arg(info.fileName()));
|
||||
msgBox.exec();
|
||||
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Start the game
|
||||
if (!process.startDetached(game)) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle("Error starting OpenMW");
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not start OpenMW</b><br><br> \
|
||||
An error occurred while starting OpenMW.<br><br> \
|
||||
Press \"Show Details...\" for more information.<br>"));
|
||||
msgBox.setDetailedText(process.errorString());
|
||||
msgBox.exec();
|
||||
// Start the executable
|
||||
if (detached) {
|
||||
if (!process.startDetached(path, arguments)) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error starting executable"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not start %1</b><br><br> \
|
||||
An error occurred while starting %1.<br><br> \
|
||||
Press \"Show Details...\" for more information.<br>").arg(info.fileName()));
|
||||
msgBox.setDetailedText(process.errorString());
|
||||
msgBox.exec();
|
||||
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
qApp->quit();
|
||||
}
|
||||
}
|
||||
process.start(path, arguments);
|
||||
if (!process.waitForFinished()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error starting executable"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not start %1</b><br><br> \
|
||||
An error occurred while starting %1.<br><br> \
|
||||
Press \"Show Details...\" for more information.<br>").arg(info.fileName()));
|
||||
msgBox.setDetailedText(process.errorString());
|
||||
msgBox.exec();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (process.exitCode() != 0) {
|
||||
QString error(process.readAllStandardError());
|
||||
error.append(tr("\nArguments:\n"));
|
||||
error.append(arguments.join(" "));
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error running executable"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Executable %1 returned an error</b><br><br> \
|
||||
An error occurred while running %1.<br><br> \
|
||||
Press \"Show Details...\" for more information.<br>").arg(info.fileName()));
|
||||
msgBox.setDetailedText(error);
|
||||
msgBox.exec();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,12 @@
|
|||
#include <QMainWindow>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include "settings/gamesettings.hpp"
|
||||
#include "settings/graphicssettings.hpp"
|
||||
#include "settings/launchersettings.hpp"
|
||||
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
class QListWidget;
|
||||
class QListWidgetItem;
|
||||
|
@ -17,32 +22,46 @@ class PlayPage;
|
|||
class GraphicsPage;
|
||||
class DataFilesPage;
|
||||
|
||||
class MainDialog : public QMainWindow
|
||||
class MainDialog : public QMainWindow, private Ui::MainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainDialog();
|
||||
bool setup();
|
||||
bool showFirstRunDialog();
|
||||
|
||||
public slots:
|
||||
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
|
||||
void play();
|
||||
bool setup();
|
||||
|
||||
private:
|
||||
void createIcons();
|
||||
void createPages();
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
QListWidget *mIconWidget;
|
||||
QStackedWidget *mPagesWidget;
|
||||
bool setupLauncherSettings();
|
||||
bool setupGameSettings();
|
||||
bool setupGraphicsSettings();
|
||||
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
void writeSettings();
|
||||
|
||||
inline bool startProgram(const QString &name, bool detached = false) { return startProgram(name, QStringList(), detached); }
|
||||
bool startProgram(const QString &name, const QStringList &arguments, bool detached = false);
|
||||
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
PlayPage *mPlayPage;
|
||||
GraphicsPage *mGraphicsPage;
|
||||
DataFilesPage *mDataFilesPage;
|
||||
|
||||
Files::ConfigurationManager mCfgMgr;
|
||||
Settings::Manager mSettings;
|
||||
|
||||
GameSettings mGameSettings;
|
||||
GraphicsSettings mGraphicsSettings;
|
||||
LauncherSettings mLauncherSettings;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,43 +1,40 @@
|
|||
#include <QtGui>
|
||||
|
||||
#include "playpage.hpp"
|
||||
|
||||
#include <QtGui>
|
||||
|
||||
PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QWidget *playWidget = new QWidget(this);
|
||||
playWidget->setObjectName("PlayGroup");
|
||||
playWidget->setFixedSize(QSize(425, 375));
|
||||
|
||||
mPlayButton = new QPushButton(tr("Play"), playWidget);
|
||||
mPlayButton->setObjectName("PlayButton");
|
||||
mPlayButton->setMinimumSize(QSize(200, 50));
|
||||
|
||||
QLabel *profileLabel = new QLabel(tr("Current Profile:"), playWidget);
|
||||
profileLabel->setObjectName("ProfileLabel");
|
||||
setupUi(this);
|
||||
|
||||
// Hacks to get the stylesheet look properly on different platforms
|
||||
QPlastiqueStyle *style = new QPlastiqueStyle;
|
||||
mProfilesComboBox = new QComboBox(playWidget);
|
||||
mProfilesComboBox->setObjectName("ProfilesComboBox");
|
||||
mProfilesComboBox->setStyle(style);
|
||||
QFont font = QApplication::font();
|
||||
font.setPointSize(12); // Fixes problem with overlapping items
|
||||
|
||||
QGridLayout *playLayout = new QGridLayout(playWidget);
|
||||
profilesComboBox->setStyle(style);
|
||||
profilesComboBox->setFont(font);
|
||||
|
||||
QSpacerItem *hSpacer1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
QSpacerItem *hSpacer2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
connect(profilesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentIndexChanged(int)));
|
||||
connect(playButton, SIGNAL(clicked()), this, SLOT(slotPlayClicked()));
|
||||
|
||||
QSpacerItem *vSpacer1 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
QSpacerItem *vSpacer2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
}
|
||||
|
||||
playLayout->addWidget(mPlayButton, 1, 1, 1, 1);
|
||||
playLayout->addWidget(profileLabel, 2, 1, 1, 1);
|
||||
playLayout->addWidget(mProfilesComboBox, 3, 1, 1, 1);
|
||||
playLayout->addItem(hSpacer1, 2, 0, 1, 1);
|
||||
playLayout->addItem(hSpacer2, 2, 2, 1, 1);
|
||||
playLayout->addItem(vSpacer1, 0, 1, 1, 1);
|
||||
playLayout->addItem(vSpacer2, 4, 1, 1, 1);
|
||||
void PlayPage::setProfilesComboBoxModel(QAbstractItemModel *model)
|
||||
{
|
||||
profilesComboBox->setModel(model);
|
||||
}
|
||||
|
||||
QHBoxLayout *pageLayout = new QHBoxLayout(this);
|
||||
void PlayPage::setProfilesComboBoxIndex(int index)
|
||||
{
|
||||
profilesComboBox->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
pageLayout->addWidget(playWidget);
|
||||
void PlayPage::slotCurrentIndexChanged(int index)
|
||||
{
|
||||
emit profileChanged(index);
|
||||
}
|
||||
|
||||
}
|
||||
void PlayPage::slotPlayClicked()
|
||||
{
|
||||
emit playButtonClicked();
|
||||
}
|
||||
|
|
|
@ -3,19 +3,33 @@
|
|||
|
||||
#include <QWidget>
|
||||
|
||||
#include "ui_playpage.h"
|
||||
|
||||
class QComboBox;
|
||||
class QPushButton;
|
||||
class QAbstractItemModel;
|
||||
|
||||
class PlayPage : public QWidget
|
||||
class PlayPage : public QWidget, private Ui::PlayPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PlayPage(QWidget *parent = 0);
|
||||
void setProfilesComboBoxModel(QAbstractItemModel *model);
|
||||
|
||||
signals:
|
||||
void profileChanged(int index);
|
||||
void playButtonClicked();
|
||||
|
||||
public slots:
|
||||
void setProfilesComboBoxIndex(int index);
|
||||
|
||||
private slots:
|
||||
void slotCurrentIndexChanged(int index);
|
||||
void slotPlayClicked();
|
||||
|
||||
|
||||
QComboBox *mProfilesComboBox;
|
||||
QPushButton *mPlayButton;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="/images">
|
||||
<file alias="clear.png">resources/images/clear.png</file>
|
||||
<file alias="down.png">resources/images/down.png</file>
|
||||
<file alias="openmw.png">resources/images/openmw.png</file>
|
||||
<file alias="openmw-plugin.png">resources/images/openmw-plugin.png</file>
|
||||
<file alias="openmw-header.png">resources/images/openmw-header.png</file>
|
||||
<file alias="playpage-background.png">resources/images/playpage-background.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="icons/tango">
|
||||
<file alias="index.theme">resources/icons/tango/index.theme</file>
|
||||
<file alias="video-display.png">resources/icons/tango/video-display.png</file>
|
||||
<file alias="16x16/document-new.png">resources/icons/tango/document-new.png</file>
|
||||
<file alias="16x16/edit-copy.png">resources/icons/tango/edit-copy.png</file>
|
||||
<file alias="16x16/edit-delete.png">resources/icons/tango/edit-delete.png</file>
|
||||
<file alias="16x16/go-bottom.png">resources/icons/tango/go-bottom.png</file>
|
||||
<file alias="16x16/go-down.png">resources/icons/tango/go-down.png</file>
|
||||
<file alias="16x16/go-top.png">resources/icons/tango/go-top.png</file>
|
||||
<file alias="16x16/go-up.png">resources/icons/tango/go-up.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
177
apps/launcher/settings/gamesettings.cpp
Normal file
177
apps/launcher/settings/gamesettings.cpp
Normal file
|
@ -0,0 +1,177 @@
|
|||
#include "gamesettings.hpp"
|
||||
|
||||
#include <QTextStream>
|
||||
#include <QDir>
|
||||
#include <QString>
|
||||
#include <QRegExp>
|
||||
#include <QMap>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
/**
|
||||
* Workaround for problems with whitespaces in paths in older versions of Boost library
|
||||
*/
|
||||
#if (BOOST_VERSION <= 104600)
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<>
|
||||
inline boost::filesystem::path lexical_cast<boost::filesystem::path, std::string>(const std::string& arg)
|
||||
{
|
||||
return boost::filesystem::path(arg);
|
||||
}
|
||||
|
||||
} /* namespace boost */
|
||||
#endif /* (BOOST_VERSION <= 104600) */
|
||||
|
||||
|
||||
GameSettings::GameSettings(Files::ConfigurationManager &cfg)
|
||||
: mCfgMgr(cfg)
|
||||
{
|
||||
}
|
||||
|
||||
GameSettings::~GameSettings()
|
||||
{
|
||||
}
|
||||
|
||||
void GameSettings::validatePaths()
|
||||
{
|
||||
if (mSettings.isEmpty() || !mDataDirs.isEmpty())
|
||||
return; // Don't re-validate paths if they are already parsed
|
||||
|
||||
QStringList paths = mSettings.values(QString("data"));
|
||||
Files::PathContainer dataDirs;
|
||||
|
||||
foreach (const QString &path, paths) {
|
||||
dataDirs.push_back(Files::PathContainer::value_type(path.toStdString()));
|
||||
}
|
||||
|
||||
// Parse the data dirs to convert the tokenized paths
|
||||
mCfgMgr.processPaths(dataDirs);
|
||||
mDataDirs.clear();
|
||||
|
||||
for (Files::PathContainer::iterator it = dataDirs.begin(); it != dataDirs.end(); ++it) {
|
||||
QString path = QString::fromStdString(it->string());
|
||||
path.remove(QChar('\"'));
|
||||
|
||||
QDir dir(path);
|
||||
if (dir.exists())
|
||||
mDataDirs.append(path);
|
||||
}
|
||||
|
||||
// Do the same for data-local
|
||||
QString local = mSettings.value(QString("data-local"));
|
||||
|
||||
if (local.isEmpty())
|
||||
return;
|
||||
|
||||
dataDirs.clear();
|
||||
dataDirs.push_back(Files::PathContainer::value_type(local.toStdString()));
|
||||
|
||||
mCfgMgr.processPaths(dataDirs);
|
||||
|
||||
if (!dataDirs.empty()) {
|
||||
QString path = QString::fromStdString(dataDirs.front().string());
|
||||
path.remove(QChar('\"'));
|
||||
|
||||
QDir dir(path);
|
||||
if (dir.exists())
|
||||
mDataLocal = path;
|
||||
}
|
||||
}
|
||||
|
||||
QStringList GameSettings::values(const QString &key, const QStringList &defaultValues)
|
||||
{
|
||||
if (!mSettings.values(key).isEmpty())
|
||||
return mSettings.values(key);
|
||||
return defaultValues;
|
||||
}
|
||||
|
||||
bool GameSettings::readFile(QTextStream &stream)
|
||||
{
|
||||
QMap<QString, QString> cache;
|
||||
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
QString line = stream.readLine().simplified();
|
||||
|
||||
if (line.isEmpty() || line.startsWith("#"))
|
||||
continue;
|
||||
|
||||
if (keyRe.indexIn(line) != -1) {
|
||||
|
||||
QString key = keyRe.cap(1).simplified();
|
||||
QString value = keyRe.cap(2).simplified();
|
||||
|
||||
// Don't remove existing data entries
|
||||
if (key != QLatin1String("data"))
|
||||
mSettings.remove(key);
|
||||
|
||||
QStringList values = cache.values(key);
|
||||
values.append(mSettings.values(key));
|
||||
|
||||
if (!values.contains(value)) {
|
||||
cache.insertMulti(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mSettings.isEmpty()) {
|
||||
mSettings = cache; // This is the first time we read a file
|
||||
validatePaths();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Merge the changed keys with those which didn't
|
||||
mSettings.unite(cache);
|
||||
validatePaths();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameSettings::writeFile(QTextStream &stream)
|
||||
{
|
||||
// Iterate in reverse order to preserve insertion order
|
||||
QMapIterator<QString, QString> i(mSettings);
|
||||
i.toBack();
|
||||
|
||||
while (i.hasPrevious()) {
|
||||
i.previous();
|
||||
|
||||
if (i.key() == QLatin1String("master") || i.key() == QLatin1String("plugin"))
|
||||
continue;
|
||||
|
||||
// Quote paths with spaces
|
||||
if (i.key() == QLatin1String("data")
|
||||
|| i.key() == QLatin1String("data-local")
|
||||
|| i.key() == QLatin1String("resources"))
|
||||
{
|
||||
if (i.value().contains(QChar(' ')))
|
||||
{
|
||||
QString stripped = i.value();
|
||||
stripped.remove(QChar('\"')); // Remove quotes
|
||||
|
||||
stream << i.key() << "=\"" << stripped << "\"\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
stream << i.key() << "=" << i.value() << "\n";
|
||||
|
||||
}
|
||||
|
||||
QStringList masters = mSettings.values(QString("master"));
|
||||
for (int i = masters.count(); i--;) {
|
||||
stream << "master=" << masters.at(i) << "\n";
|
||||
}
|
||||
|
||||
QStringList plugins = mSettings.values(QString("plugin"));
|
||||
for (int i = plugins.count(); i--;) {
|
||||
stream << "plugin=" << plugins.at(i) << "\n";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
66
apps/launcher/settings/gamesettings.hpp
Normal file
66
apps/launcher/settings/gamesettings.hpp
Normal file
|
@ -0,0 +1,66 @@
|
|||
#ifndef GAMESETTINGS_HPP
|
||||
#define GAMESETTINGS_HPP
|
||||
|
||||
#include <QTextStream>
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
namespace Files { typedef std::vector<boost::filesystem::path> PathContainer;
|
||||
struct ConfigurationManager;}
|
||||
|
||||
class GameSettings
|
||||
{
|
||||
public:
|
||||
GameSettings(Files::ConfigurationManager &cfg);
|
||||
~GameSettings();
|
||||
|
||||
inline QString value(const QString &key, const QString &defaultValue = QString())
|
||||
{
|
||||
return mSettings.value(key).isEmpty() ? defaultValue : mSettings.value(key);
|
||||
}
|
||||
|
||||
|
||||
inline void setValue(const QString &key, const QString &value)
|
||||
{
|
||||
mSettings.insert(key, value);
|
||||
}
|
||||
|
||||
inline void setMultiValue(const QString &key, const QString &value)
|
||||
{
|
||||
QStringList values = mSettings.values(key);
|
||||
if (!values.contains(value))
|
||||
mSettings.insertMulti(key, value);
|
||||
}
|
||||
|
||||
inline void remove(const QString &key)
|
||||
{
|
||||
mSettings.remove(key);
|
||||
}
|
||||
|
||||
inline void clear()
|
||||
{
|
||||
mSettings.clear();
|
||||
}
|
||||
|
||||
inline QStringList getDataDirs() { return mDataDirs; }
|
||||
inline void addDataDir(const QString &dir) { if(!dir.isEmpty()) mDataDirs.append(dir); }
|
||||
inline QString getDataLocal() {return mDataLocal; }
|
||||
|
||||
QStringList values(const QString &key, const QStringList &defaultValues = QStringList());
|
||||
bool readFile(QTextStream &stream);
|
||||
bool writeFile(QTextStream &stream);
|
||||
|
||||
private:
|
||||
Files::ConfigurationManager &mCfgMgr;
|
||||
|
||||
void validatePaths();
|
||||
QMap<QString, QString> mSettings;
|
||||
|
||||
QStringList mDataDirs;
|
||||
QString mDataLocal;
|
||||
};
|
||||
|
||||
#endif // GAMESETTINGS_HPP
|
44
apps/launcher/settings/graphicssettings.cpp
Normal file
44
apps/launcher/settings/graphicssettings.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include "graphicssettings.hpp"
|
||||
|
||||
#include <QTextStream>
|
||||
#include <QString>
|
||||
#include <QRegExp>
|
||||
#include <QMap>
|
||||
|
||||
GraphicsSettings::GraphicsSettings()
|
||||
{
|
||||
}
|
||||
|
||||
GraphicsSettings::~GraphicsSettings()
|
||||
{
|
||||
}
|
||||
|
||||
bool GraphicsSettings::writeFile(QTextStream &stream)
|
||||
{
|
||||
QString sectionPrefix;
|
||||
QRegExp sectionRe("([^/]+)/(.+)$");
|
||||
QMap<QString, QString> settings = SettingsBase::getSettings();
|
||||
|
||||
QMapIterator<QString, QString> i(settings);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
|
||||
QString prefix;
|
||||
QString key;
|
||||
|
||||
if (sectionRe.exactMatch(i.key())) {
|
||||
prefix = sectionRe.cap(1);
|
||||
key = sectionRe.cap(2);
|
||||
}
|
||||
|
||||
if (sectionPrefix != prefix) {
|
||||
sectionPrefix = prefix;
|
||||
stream << "\n[" << prefix << "]\n";
|
||||
}
|
||||
|
||||
stream << key << " = " << i.value() << "\n";
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
16
apps/launcher/settings/graphicssettings.hpp
Normal file
16
apps/launcher/settings/graphicssettings.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef GRAPHICSSETTINGS_HPP
|
||||
#define GRAPHICSSETTINGS_HPP
|
||||
|
||||
#include "settingsbase.hpp"
|
||||
|
||||
class GraphicsSettings : public SettingsBase<QMap<QString, QString> >
|
||||
{
|
||||
public:
|
||||
GraphicsSettings();
|
||||
~GraphicsSettings();
|
||||
|
||||
bool writeFile(QTextStream &stream);
|
||||
|
||||
};
|
||||
|
||||
#endif // GRAPHICSSETTINGS_HPP
|
101
apps/launcher/settings/launchersettings.cpp
Normal file
101
apps/launcher/settings/launchersettings.cpp
Normal file
|
@ -0,0 +1,101 @@
|
|||
#include "launchersettings.hpp"
|
||||
|
||||
#include <QTextStream>
|
||||
#include <QString>
|
||||
#include <QRegExp>
|
||||
#include <QMap>
|
||||
|
||||
LauncherSettings::LauncherSettings()
|
||||
{
|
||||
}
|
||||
|
||||
LauncherSettings::~LauncherSettings()
|
||||
{
|
||||
}
|
||||
|
||||
QStringList LauncherSettings::values(const QString &key, Qt::MatchFlags flags)
|
||||
{
|
||||
QMap<QString, QString> settings = SettingsBase::getSettings();
|
||||
|
||||
if (flags == Qt::MatchExactly)
|
||||
return settings.values(key);
|
||||
|
||||
QStringList result;
|
||||
|
||||
if (flags == Qt::MatchStartsWith) {
|
||||
QStringList keys = settings.keys();
|
||||
|
||||
foreach (const QString ¤tKey, keys) {
|
||||
if (currentKey.startsWith(key))
|
||||
result.append(settings.value(currentKey));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QStringList LauncherSettings::subKeys(const QString &key)
|
||||
{
|
||||
QMap<QString, QString> settings = SettingsBase::getSettings();
|
||||
QStringList keys = settings.uniqueKeys();
|
||||
|
||||
QRegExp keyRe("(.+)/");
|
||||
|
||||
QStringList result;
|
||||
|
||||
foreach (const QString ¤tKey, keys) {
|
||||
|
||||
if (keyRe.indexIn(currentKey) != -1) {
|
||||
|
||||
QString prefixedKey = keyRe.cap(1);
|
||||
if(prefixedKey.startsWith(key)) {
|
||||
|
||||
QString subKey = prefixedKey.remove(key);
|
||||
if (!subKey.isEmpty())
|
||||
result.append(subKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.removeDuplicates();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool LauncherSettings::writeFile(QTextStream &stream)
|
||||
{
|
||||
QString sectionPrefix;
|
||||
QRegExp sectionRe("([^/]+)/(.+)$");
|
||||
QMap<QString, QString> settings = SettingsBase::getSettings();
|
||||
|
||||
QMapIterator<QString, QString> i(settings);
|
||||
i.toBack();
|
||||
|
||||
while (i.hasPrevious()) {
|
||||
i.previous();
|
||||
|
||||
QString prefix;
|
||||
QString key;
|
||||
|
||||
if (sectionRe.exactMatch(i.key())) {
|
||||
prefix = sectionRe.cap(1);
|
||||
key = sectionRe.cap(2);
|
||||
}
|
||||
|
||||
// Get rid of legacy settings
|
||||
if (key.contains(QChar('\\')))
|
||||
continue;
|
||||
|
||||
if (key == QLatin1String("CurrentProfile"))
|
||||
continue;
|
||||
|
||||
if (sectionPrefix != prefix) {
|
||||
sectionPrefix = prefix;
|
||||
stream << "\n[" << prefix << "]\n";
|
||||
}
|
||||
|
||||
stream << key << "=" << i.value() << "\n";
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
19
apps/launcher/settings/launchersettings.hpp
Normal file
19
apps/launcher/settings/launchersettings.hpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef LAUNCHERSETTINGS_HPP
|
||||
#define LAUNCHERSETTINGS_HPP
|
||||
|
||||
#include "settingsbase.hpp"
|
||||
|
||||
class LauncherSettings : public SettingsBase<QMap<QString, QString> >
|
||||
{
|
||||
public:
|
||||
LauncherSettings();
|
||||
~LauncherSettings();
|
||||
|
||||
QStringList subKeys(const QString &key);
|
||||
QStringList values(const QString &key, Qt::MatchFlags flags = Qt::MatchExactly);
|
||||
|
||||
bool writeFile(QTextStream &stream);
|
||||
|
||||
};
|
||||
|
||||
#endif // LAUNCHERSETTINGS_HPP
|
98
apps/launcher/settings/settingsbase.hpp
Normal file
98
apps/launcher/settings/settingsbase.hpp
Normal file
|
@ -0,0 +1,98 @@
|
|||
#ifndef SETTINGSBASE_HPP
|
||||
#define SETTINGSBASE_HPP
|
||||
|
||||
#include <QTextStream>
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
#include <QRegExp>
|
||||
#include <QMap>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
template <class Map>
|
||||
class SettingsBase
|
||||
{
|
||||
|
||||
public:
|
||||
SettingsBase() {}
|
||||
~SettingsBase() {}
|
||||
|
||||
inline QString value(const QString &key, const QString &defaultValue = QString())
|
||||
{
|
||||
return mSettings.value(key).isEmpty() ? defaultValue : mSettings.value(key);
|
||||
}
|
||||
|
||||
inline void setValue(const QString &key, const QString &value)
|
||||
{
|
||||
QStringList values = mSettings.values(key);
|
||||
if (!values.contains(value))
|
||||
mSettings.insert(key, value);
|
||||
}
|
||||
|
||||
inline void setMultiValue(const QString &key, const QString &value)
|
||||
{
|
||||
QStringList values = mSettings.values(key);
|
||||
if (!values.contains(value))
|
||||
mSettings.insertMulti(key, value);
|
||||
}
|
||||
|
||||
inline void remove(const QString &key)
|
||||
{
|
||||
mSettings.remove(key);
|
||||
}
|
||||
|
||||
Map getSettings() {return mSettings;}
|
||||
|
||||
bool readFile(QTextStream &stream)
|
||||
{
|
||||
mCache.clear();
|
||||
|
||||
QString sectionPrefix;
|
||||
QRegExp sectionRe("^\\[([^]]+)\\]");
|
||||
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
QString line = stream.readLine().simplified();
|
||||
|
||||
if (line.isEmpty() || line.startsWith("#"))
|
||||
continue;
|
||||
|
||||
if (sectionRe.exactMatch(line)) {
|
||||
sectionPrefix = sectionRe.cap(1);
|
||||
sectionPrefix.append("/");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (keyRe.indexIn(line) != -1) {
|
||||
|
||||
QString key = keyRe.cap(1).simplified();
|
||||
QString value = keyRe.cap(2).simplified();
|
||||
|
||||
if (!sectionPrefix.isEmpty())
|
||||
key.prepend(sectionPrefix);
|
||||
|
||||
mSettings.remove(key);
|
||||
|
||||
QStringList values = mCache.values(key);
|
||||
if (!values.contains(value)) {
|
||||
mCache.insertMulti(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mSettings.isEmpty()) {
|
||||
mSettings = mCache; // This is the first time we read a file
|
||||
return true;
|
||||
}
|
||||
|
||||
// Merge the changed keys with those which didn't
|
||||
mSettings.unite(mCache);
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
Map mSettings;
|
||||
Map mCache;
|
||||
};
|
||||
|
||||
#endif // SETTINGSBASE_HPP
|
269
apps/launcher/utils/checkablemessagebox.cpp
Normal file
269
apps/launcher/utils/checkablemessagebox.cpp
Normal file
|
@ -0,0 +1,269 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "checkablemessagebox.hpp"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QButtonGroup>
|
||||
#include <QCheckBox>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QHeaderView>
|
||||
#include <QLabel>
|
||||
#include <QSpacerItem>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
||||
/*!
|
||||
\class Utils::CheckableMessageBox
|
||||
|
||||
\brief A messagebox suitable for questions with a
|
||||
"Do not ask me again" checkbox.
|
||||
|
||||
Emulates the QMessageBox API with
|
||||
static conveniences. The message label can open external URLs.
|
||||
*/
|
||||
|
||||
class CheckableMessageBoxPrivate
|
||||
{
|
||||
public:
|
||||
CheckableMessageBoxPrivate(QDialog *q)
|
||||
: clickedButton(0)
|
||||
{
|
||||
QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
|
||||
pixmapLabel = new QLabel(q);
|
||||
sizePolicy.setHorizontalStretch(0);
|
||||
sizePolicy.setVerticalStretch(0);
|
||||
sizePolicy.setHeightForWidth(pixmapLabel->sizePolicy().hasHeightForWidth());
|
||||
pixmapLabel->setSizePolicy(sizePolicy);
|
||||
pixmapLabel->setVisible(false);
|
||||
|
||||
QSpacerItem *pixmapSpacer =
|
||||
new QSpacerItem(0, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||
|
||||
messageLabel = new QLabel(q);
|
||||
messageLabel->setMinimumSize(QSize(300, 0));
|
||||
messageLabel->setWordWrap(true);
|
||||
messageLabel->setOpenExternalLinks(true);
|
||||
messageLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse);
|
||||
|
||||
QSpacerItem *checkBoxRightSpacer =
|
||||
new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
QSpacerItem *buttonSpacer =
|
||||
new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
|
||||
checkBox = new QCheckBox(q);
|
||||
checkBox->setText(CheckableMessageBox::tr("Do not ask again"));
|
||||
|
||||
buttonBox = new QDialogButtonBox(q);
|
||||
buttonBox->setOrientation(Qt::Horizontal);
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||
|
||||
QVBoxLayout *verticalLayout = new QVBoxLayout();
|
||||
verticalLayout->addWidget(pixmapLabel);
|
||||
verticalLayout->addItem(pixmapSpacer);
|
||||
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->addLayout(verticalLayout);
|
||||
horizontalLayout_2->addWidget(messageLabel);
|
||||
|
||||
QHBoxLayout *horizontalLayout = new QHBoxLayout();
|
||||
horizontalLayout->addWidget(checkBox);
|
||||
horizontalLayout->addItem(checkBoxRightSpacer);
|
||||
|
||||
QVBoxLayout *verticalLayout_2 = new QVBoxLayout(q);
|
||||
verticalLayout_2->addLayout(horizontalLayout_2);
|
||||
verticalLayout_2->addLayout(horizontalLayout);
|
||||
verticalLayout_2->addItem(buttonSpacer);
|
||||
verticalLayout_2->addWidget(buttonBox);
|
||||
}
|
||||
|
||||
QLabel *pixmapLabel;
|
||||
QLabel *messageLabel;
|
||||
QCheckBox *checkBox;
|
||||
QDialogButtonBox *buttonBox;
|
||||
QAbstractButton *clickedButton;
|
||||
};
|
||||
|
||||
CheckableMessageBox::CheckableMessageBox(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
d(new CheckableMessageBoxPrivate(this))
|
||||
{
|
||||
setModal(true);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
connect(d->buttonBox, SIGNAL(accepted()), SLOT(accept()));
|
||||
connect(d->buttonBox, SIGNAL(rejected()), SLOT(reject()));
|
||||
connect(d->buttonBox, SIGNAL(clicked(QAbstractButton*)),
|
||||
SLOT(slotClicked(QAbstractButton*)));
|
||||
}
|
||||
|
||||
CheckableMessageBox::~CheckableMessageBox()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void CheckableMessageBox::slotClicked(QAbstractButton *b)
|
||||
{
|
||||
d->clickedButton = b;
|
||||
}
|
||||
|
||||
QAbstractButton *CheckableMessageBox::clickedButton() const
|
||||
{
|
||||
return d->clickedButton;
|
||||
}
|
||||
|
||||
QDialogButtonBox::StandardButton CheckableMessageBox::clickedStandardButton() const
|
||||
{
|
||||
if (d->clickedButton)
|
||||
return d->buttonBox->standardButton(d->clickedButton);
|
||||
return QDialogButtonBox::NoButton;
|
||||
}
|
||||
|
||||
QString CheckableMessageBox::text() const
|
||||
{
|
||||
return d->messageLabel->text();
|
||||
}
|
||||
|
||||
void CheckableMessageBox::setText(const QString &t)
|
||||
{
|
||||
d->messageLabel->setText(t);
|
||||
}
|
||||
|
||||
QPixmap CheckableMessageBox::iconPixmap() const
|
||||
{
|
||||
if (const QPixmap *p = d->pixmapLabel->pixmap())
|
||||
return QPixmap(*p);
|
||||
return QPixmap();
|
||||
}
|
||||
|
||||
void CheckableMessageBox::setIconPixmap(const QPixmap &p)
|
||||
{
|
||||
d->pixmapLabel->setPixmap(p);
|
||||
d->pixmapLabel->setVisible(!p.isNull());
|
||||
}
|
||||
|
||||
bool CheckableMessageBox::isChecked() const
|
||||
{
|
||||
return d->checkBox->isChecked();
|
||||
}
|
||||
|
||||
void CheckableMessageBox::setChecked(bool s)
|
||||
{
|
||||
d->checkBox->setChecked(s);
|
||||
}
|
||||
|
||||
QString CheckableMessageBox::checkBoxText() const
|
||||
{
|
||||
return d->checkBox->text();
|
||||
}
|
||||
|
||||
void CheckableMessageBox::setCheckBoxText(const QString &t)
|
||||
{
|
||||
d->checkBox->setText(t);
|
||||
}
|
||||
|
||||
bool CheckableMessageBox::isCheckBoxVisible() const
|
||||
{
|
||||
return d->checkBox->isVisible();
|
||||
}
|
||||
|
||||
void CheckableMessageBox::setCheckBoxVisible(bool v)
|
||||
{
|
||||
d->checkBox->setVisible(v);
|
||||
}
|
||||
|
||||
QDialogButtonBox::StandardButtons CheckableMessageBox::standardButtons() const
|
||||
{
|
||||
return d->buttonBox->standardButtons();
|
||||
}
|
||||
|
||||
void CheckableMessageBox::setStandardButtons(QDialogButtonBox::StandardButtons s)
|
||||
{
|
||||
d->buttonBox->setStandardButtons(s);
|
||||
}
|
||||
|
||||
QPushButton *CheckableMessageBox::button(QDialogButtonBox::StandardButton b) const
|
||||
{
|
||||
return d->buttonBox->button(b);
|
||||
}
|
||||
|
||||
QPushButton *CheckableMessageBox::addButton(const QString &text, QDialogButtonBox::ButtonRole role)
|
||||
{
|
||||
return d->buttonBox->addButton(text, role);
|
||||
}
|
||||
|
||||
QDialogButtonBox::StandardButton CheckableMessageBox::defaultButton() const
|
||||
{
|
||||
foreach (QAbstractButton *b, d->buttonBox->buttons())
|
||||
if (QPushButton *pb = qobject_cast<QPushButton *>(b))
|
||||
if (pb->isDefault())
|
||||
return d->buttonBox->standardButton(pb);
|
||||
return QDialogButtonBox::NoButton;
|
||||
}
|
||||
|
||||
void CheckableMessageBox::setDefaultButton(QDialogButtonBox::StandardButton s)
|
||||
{
|
||||
if (QPushButton *b = d->buttonBox->button(s)) {
|
||||
b->setDefault(true);
|
||||
b->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
QDialogButtonBox::StandardButton
|
||||
CheckableMessageBox::question(QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &question,
|
||||
const QString &checkBoxText,
|
||||
bool *checkBoxSetting,
|
||||
QDialogButtonBox::StandardButtons buttons,
|
||||
QDialogButtonBox::StandardButton defaultButton)
|
||||
{
|
||||
CheckableMessageBox mb(parent);
|
||||
mb.setWindowTitle(title);
|
||||
mb.setIconPixmap(QMessageBox::standardIcon(QMessageBox::Question));
|
||||
mb.setText(question);
|
||||
mb.setCheckBoxText(checkBoxText);
|
||||
mb.setChecked(*checkBoxSetting);
|
||||
mb.setStandardButtons(buttons);
|
||||
mb.setDefaultButton(defaultButton);
|
||||
mb.exec();
|
||||
*checkBoxSetting = mb.isChecked();
|
||||
return mb.clickedStandardButton();
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton CheckableMessageBox::dialogButtonBoxToMessageBoxButton(QDialogButtonBox::StandardButton db)
|
||||
{
|
||||
return static_cast<QMessageBox::StandardButton>(int(db));
|
||||
}
|
100
apps/launcher/utils/checkablemessagebox.hpp
Normal file
100
apps/launcher/utils/checkablemessagebox.hpp
Normal file
|
@ -0,0 +1,100 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CHECKABLEMESSAGEBOX_HPP
|
||||
#define CHECKABLEMESSAGEBOX_HPP
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QMessageBox>
|
||||
#include <QDialog>
|
||||
|
||||
class CheckableMessageBoxPrivate;
|
||||
|
||||
class CheckableMessageBox : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap)
|
||||
Q_PROPERTY(bool isChecked READ isChecked WRITE setChecked)
|
||||
Q_PROPERTY(QString checkBoxText READ checkBoxText WRITE setCheckBoxText)
|
||||
Q_PROPERTY(QDialogButtonBox::StandardButtons buttons READ standardButtons WRITE setStandardButtons)
|
||||
Q_PROPERTY(QDialogButtonBox::StandardButton defaultButton READ defaultButton WRITE setDefaultButton)
|
||||
|
||||
public:
|
||||
explicit CheckableMessageBox(QWidget *parent);
|
||||
virtual ~CheckableMessageBox();
|
||||
|
||||
static QDialogButtonBox::StandardButton
|
||||
question(QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &question,
|
||||
const QString &checkBoxText,
|
||||
bool *checkBoxSetting,
|
||||
QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Yes|QDialogButtonBox::No,
|
||||
QDialogButtonBox::StandardButton defaultButton = QDialogButtonBox::No);
|
||||
|
||||
QString text() const;
|
||||
void setText(const QString &);
|
||||
|
||||
bool isChecked() const;
|
||||
void setChecked(bool s);
|
||||
|
||||
QString checkBoxText() const;
|
||||
void setCheckBoxText(const QString &);
|
||||
|
||||
bool isCheckBoxVisible() const;
|
||||
void setCheckBoxVisible(bool);
|
||||
|
||||
QDialogButtonBox::StandardButtons standardButtons() const;
|
||||
void setStandardButtons(QDialogButtonBox::StandardButtons s);
|
||||
QPushButton *button(QDialogButtonBox::StandardButton b) const;
|
||||
QPushButton *addButton(const QString &text, QDialogButtonBox::ButtonRole role);
|
||||
|
||||
QDialogButtonBox::StandardButton defaultButton() const;
|
||||
void setDefaultButton(QDialogButtonBox::StandardButton s);
|
||||
|
||||
// See static QMessageBox::standardPixmap()
|
||||
QPixmap iconPixmap() const;
|
||||
void setIconPixmap (const QPixmap &p);
|
||||
|
||||
// Query the result
|
||||
QAbstractButton *clickedButton() const;
|
||||
QDialogButtonBox::StandardButton clickedStandardButton() const;
|
||||
|
||||
// Conversion convenience
|
||||
static QMessageBox::StandardButton dialogButtonBoxToMessageBoxButton(QDialogButtonBox::StandardButton);
|
||||
|
||||
private slots:
|
||||
void slotClicked(QAbstractButton *b);
|
||||
|
||||
private:
|
||||
CheckableMessageBoxPrivate *d;
|
||||
};
|
||||
|
||||
#endif // CHECKABLEMESSAGEBOX_HPP
|
|
@ -1,52 +0,0 @@
|
|||
#include <QRegExpValidator>
|
||||
#include <QLineEdit>
|
||||
#include <QString>
|
||||
|
||||
#include "profilescombobox.hpp"
|
||||
|
||||
ProfilesComboBox::ProfilesComboBox(QWidget *parent) :
|
||||
QComboBox(parent)
|
||||
{
|
||||
mValidator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore
|
||||
|
||||
setEditable(true);
|
||||
setValidator(mValidator);
|
||||
setCompleter(0);
|
||||
|
||||
connect(this, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(slotIndexChanged(int)));
|
||||
connect(lineEdit(), SIGNAL(returnPressed()), this,
|
||||
SLOT(slotReturnPressed()));
|
||||
}
|
||||
|
||||
void ProfilesComboBox::setEditEnabled(bool editable)
|
||||
{
|
||||
if (!editable)
|
||||
return setEditable(false);
|
||||
|
||||
// Reset the completer and validator
|
||||
setEditable(true);
|
||||
setValidator(mValidator);
|
||||
setCompleter(0);
|
||||
}
|
||||
|
||||
void ProfilesComboBox::slotReturnPressed()
|
||||
{
|
||||
QString current = currentText();
|
||||
QString previous = itemText(currentIndex());
|
||||
|
||||
if (findText(current) != -1)
|
||||
return;
|
||||
|
||||
setItemText(currentIndex(), current);
|
||||
emit(profileRenamed(previous, current));
|
||||
}
|
||||
|
||||
void ProfilesComboBox::slotIndexChanged(int index)
|
||||
{
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
emit(profileChanged(mOldProfile, currentText()));
|
||||
mOldProfile = itemText(index);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
#include <QDialogButtonBox>
|
||||
#include <QApplication>
|
||||
#include <QPushButton>
|
||||
#include <QDebug>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QValidator>
|
||||
|
@ -17,9 +17,19 @@ TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWid
|
|||
mButtonBox->addButton(QDialogButtonBox::Ok);
|
||||
mButtonBox->addButton(QDialogButtonBox::Cancel);
|
||||
|
||||
setMaximumHeight(height());
|
||||
setOkButtonEnabled(false);
|
||||
setModal(true);
|
||||
// Line edit
|
||||
QValidator *validator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore
|
||||
mLineEdit = new LineEdit(this);
|
||||
mLineEdit->setValidator(validator);
|
||||
mLineEdit->setCompleter(0);
|
||||
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setText(text);
|
||||
|
||||
QVBoxLayout *dialogLayout = new QVBoxLayout(this);
|
||||
dialogLayout->addWidget(label);
|
||||
dialogLayout->addWidget(mLineEdit);
|
||||
dialogLayout->addWidget(mButtonBox);
|
||||
|
||||
// Messageboxes on mac have no title
|
||||
#ifndef Q_OS_MAC
|
||||
|
@ -28,22 +38,13 @@ TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWid
|
|||
Q_UNUSED(title);
|
||||
#endif
|
||||
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setText(text);
|
||||
|
||||
// Line edit
|
||||
QValidator *validator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore
|
||||
mLineEdit = new LineEdit(this);
|
||||
mLineEdit->setValidator(validator);
|
||||
mLineEdit->setCompleter(0);
|
||||
|
||||
QVBoxLayout *dialogLayout = new QVBoxLayout(this);
|
||||
dialogLayout->addWidget(label);
|
||||
dialogLayout->addWidget(mLineEdit);
|
||||
dialogLayout->addWidget(mButtonBox);
|
||||
setMaximumHeight(height());
|
||||
setOkButtonEnabled(false);
|
||||
setModal(true);
|
||||
|
||||
connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
||||
}
|
||||
|
||||
int TextInputDialog::exec()
|
||||
|
@ -55,7 +56,17 @@ int TextInputDialog::exec()
|
|||
|
||||
void TextInputDialog::setOkButtonEnabled(bool enabled)
|
||||
{
|
||||
|
||||
QPushButton *okButton = mButtonBox->button(QDialogButtonBox::Ok);
|
||||
okButton->setEnabled(enabled);
|
||||
|
||||
QPalette *palette = new QPalette();
|
||||
palette->setColor(QPalette::Text,Qt::red);
|
||||
|
||||
if (enabled) {
|
||||
mLineEdit->setPalette(QApplication::palette());
|
||||
} else {
|
||||
// Existing profile name, make the text red
|
||||
mLineEdit->setPalette(*palette);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ opencs_units_noqt (model/tools
|
|||
|
||||
|
||||
opencs_units (view/doc
|
||||
viewmanager view operations operation subview startup opendialog
|
||||
viewmanager view operations operation subview startup filedialog
|
||||
)
|
||||
|
||||
|
||||
|
@ -75,6 +75,10 @@ set (OPENCS_US
|
|||
)
|
||||
|
||||
set (OPENCS_RES ../../files/opencs/resources.qrc
|
||||
../../files/launcher/launcher.qrc
|
||||
)
|
||||
|
||||
set (OPENCS_UI ../../files/ui/datafilespage.ui
|
||||
)
|
||||
|
||||
source_group (opencs FILES ${OPENCS_SRC} ${OPENCS_HDR})
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
|
||||
#include "editor.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
|
||||
#include "model/doc/document.hpp"
|
||||
#include "model/world/data.hpp"
|
||||
|
||||
CS::Editor::Editor() : mViewManager (mDocumentManager), mNewDocumentIndex (0)
|
||||
CS::Editor::Editor() : mViewManager (mDocumentManager)
|
||||
{
|
||||
connect (&mViewManager, SIGNAL (newDocumentRequest ()), this, SLOT (createDocument ()));
|
||||
connect (&mViewManager, SIGNAL (loadDocumentRequest ()), this, SLOT (loadDocument ()));
|
||||
|
@ -16,42 +14,99 @@ CS::Editor::Editor() : mViewManager (mDocumentManager), mNewDocumentIndex (0)
|
|||
connect (&mStartup, SIGNAL (createDocument()), this, SLOT (createDocument ()));
|
||||
connect (&mStartup, SIGNAL (loadDocument()), this, SLOT (loadDocument ()));
|
||||
|
||||
connect (&mOpenDialog, SIGNAL(accepted()), this, SLOT(openFiles()));
|
||||
connect (&mFileDialog, SIGNAL(openFiles()), this, SLOT(openFiles()));
|
||||
connect (&mFileDialog, SIGNAL(createNewFile()), this, SLOT(createNewFile()));
|
||||
|
||||
setupDataFiles();
|
||||
}
|
||||
|
||||
void CS::Editor::setupDataFiles()
|
||||
{
|
||||
boost::program_options::variables_map variables;
|
||||
boost::program_options::options_description desc;
|
||||
|
||||
desc.add_options()
|
||||
("data", boost::program_options::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")->multitoken())
|
||||
("data-local", boost::program_options::value<std::string>()->default_value(""))
|
||||
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false))
|
||||
("encoding", boost::program_options::value<std::string>()->default_value("win1252"));
|
||||
|
||||
boost::program_options::notify(variables);
|
||||
|
||||
mCfgMgr.readConfiguration(variables, desc);
|
||||
|
||||
Files::PathContainer mDataDirs, mDataLocal;
|
||||
if (!variables["data"].empty()) {
|
||||
mDataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>());
|
||||
}
|
||||
|
||||
std::string local = variables["data-local"].as<std::string>();
|
||||
if (!local.empty()) {
|
||||
mDataLocal.push_back(Files::PathContainer::value_type(local));
|
||||
}
|
||||
|
||||
mCfgMgr.processPaths(mDataDirs);
|
||||
mCfgMgr.processPaths(mDataLocal);
|
||||
|
||||
// Set the charset for reading the esm/esp files
|
||||
QString encoding = QString::fromStdString(variables["encoding"].as<std::string>());
|
||||
mFileDialog.setEncoding(encoding);
|
||||
|
||||
Files::PathContainer dataDirs;
|
||||
dataDirs.insert(dataDirs.end(), mDataDirs.begin(), mDataDirs.end());
|
||||
dataDirs.insert(dataDirs.end(), mDataLocal.begin(), mDataLocal.end());
|
||||
|
||||
for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter)
|
||||
{
|
||||
QString path = QString::fromStdString(iter->string());
|
||||
mFileDialog.addFiles(path);
|
||||
}
|
||||
}
|
||||
|
||||
void CS::Editor::createDocument()
|
||||
{
|
||||
mStartup.hide();
|
||||
|
||||
/// \todo open the ESX picker instead
|
||||
|
||||
std::ostringstream stream;
|
||||
|
||||
stream << "NewDocument" << (++mNewDocumentIndex);
|
||||
|
||||
std::vector<boost::filesystem::path> files;
|
||||
files.push_back (stream.str());
|
||||
|
||||
CSMDoc::Document *document = mDocumentManager.addDocument (files, true);
|
||||
|
||||
mViewManager.addView (document);
|
||||
mFileDialog.newFile();
|
||||
}
|
||||
|
||||
void CS::Editor::loadDocument()
|
||||
{
|
||||
mStartup.hide();
|
||||
mOpenDialog.show();
|
||||
mOpenDialog.raise();
|
||||
mOpenDialog.activateWindow();
|
||||
|
||||
mFileDialog.openFile();
|
||||
}
|
||||
|
||||
void CS::Editor::openFiles()
|
||||
{
|
||||
std::vector<boost::filesystem::path> paths;
|
||||
mOpenDialog.getFileList(paths);
|
||||
CSMDoc::Document *document = mDocumentManager.addDocument(paths, false);
|
||||
std::vector<boost::filesystem::path> files;
|
||||
QStringList paths = mFileDialog.checkedItemsPaths();
|
||||
|
||||
foreach (const QString &path, paths) {
|
||||
files.push_back(path.toStdString());
|
||||
}
|
||||
|
||||
CSMDoc::Document *document = mDocumentManager.addDocument(files, false);
|
||||
|
||||
mViewManager.addView (document);
|
||||
mFileDialog.hide();
|
||||
}
|
||||
|
||||
void CS::Editor::createNewFile()
|
||||
{
|
||||
std::vector<boost::filesystem::path> files;
|
||||
QStringList paths = mFileDialog.checkedItemsPaths();
|
||||
|
||||
foreach (const QString &path, paths) {
|
||||
files.push_back(path.toStdString());
|
||||
}
|
||||
|
||||
files.push_back(mFileDialog.fileName().toStdString());
|
||||
|
||||
CSMDoc::Document *document = mDocumentManager.addDocument (files, true);
|
||||
|
||||
mViewManager.addView (document);
|
||||
mFileDialog.hide();
|
||||
}
|
||||
|
||||
int CS::Editor::run()
|
||||
|
|
|
@ -3,11 +3,13 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
|
||||
#include "model/doc/documentmanager.hpp"
|
||||
|
||||
#include "view/doc/viewmanager.hpp"
|
||||
#include "view/doc/startup.hpp"
|
||||
#include "view/doc/opendialog.hpp"
|
||||
#include "view/doc/filedialog.hpp"
|
||||
|
||||
namespace CS
|
||||
{
|
||||
|
@ -15,12 +17,14 @@ namespace CS
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
int mNewDocumentIndex; ///< \todo remove when the proper new document dialogue is implemented.
|
||||
|
||||
CSMDoc::DocumentManager mDocumentManager;
|
||||
CSVDoc::ViewManager mViewManager;
|
||||
CSVDoc::StartupDialogue mStartup;
|
||||
OpenDialog mOpenDialog;
|
||||
FileDialog mFileDialog;
|
||||
|
||||
Files::ConfigurationManager mCfgMgr;
|
||||
|
||||
void setupDataFiles();
|
||||
|
||||
// not implemented
|
||||
Editor (const Editor&);
|
||||
|
@ -39,7 +43,8 @@ namespace CS
|
|||
|
||||
void loadDocument();
|
||||
void openFiles();
|
||||
void createNewFile();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -18,9 +18,6 @@ void CSMDoc::Document::load (const std::vector<boost::filesystem::path>::const_i
|
|||
|
||||
if (lastAsModified)
|
||||
getData().loadFile (*end2, false);
|
||||
|
||||
addOptionalGmsts();
|
||||
addOptionalGlobals();
|
||||
}
|
||||
|
||||
void CSMDoc::Document::addOptionalGmsts()
|
||||
|
@ -116,8 +113,7 @@ void CSMDoc::Document::addOptionalGmsts()
|
|||
{
|
||||
ESM::GameSetting gmst;
|
||||
gmst.mId = sFloats[i];
|
||||
gmst.mF = 0;
|
||||
gmst.mType = ESM::VT_Float;
|
||||
gmst.mValue.setType (ESM::VT_Float);
|
||||
addOptionalGmst (gmst);
|
||||
}
|
||||
|
||||
|
@ -125,8 +121,7 @@ void CSMDoc::Document::addOptionalGmsts()
|
|||
{
|
||||
ESM::GameSetting gmst;
|
||||
gmst.mId = sIntegers[i];
|
||||
gmst.mI = 0;
|
||||
gmst.mType = ESM::VT_Long;
|
||||
gmst.mValue.setType (ESM::VT_Int);
|
||||
addOptionalGmst (gmst);
|
||||
}
|
||||
|
||||
|
@ -134,8 +129,8 @@ void CSMDoc::Document::addOptionalGmsts()
|
|||
{
|
||||
ESM::GameSetting gmst;
|
||||
gmst.mId = sStrings[i];
|
||||
gmst.mStr = "<no text>";
|
||||
gmst.mType = ESM::VT_String;
|
||||
gmst.mValue.setType (ESM::VT_String);
|
||||
gmst.mValue.setString ("<no text>");
|
||||
addOptionalGmst (gmst);
|
||||
}
|
||||
}
|
||||
|
@ -154,8 +149,7 @@ void CSMDoc::Document::addOptionalGlobals()
|
|||
{
|
||||
ESM::Global global;
|
||||
global.mId = sGlobals[i];
|
||||
global.mType = ESM::VT_Int;
|
||||
global.mValue = 0;
|
||||
global.mValue.setType (ESM::VT_Long);
|
||||
addOptionalGlobal (global);
|
||||
}
|
||||
}
|
||||
|
@ -192,11 +186,18 @@ void CSMDoc::Document::createBase()
|
|||
for (int i=0; sGlobals[i]; ++i)
|
||||
{
|
||||
ESM::Global record;
|
||||
|
||||
record.mId = sGlobals[i];
|
||||
record.mValue = i==0 ? 1 : 0;
|
||||
record.mType = ESM::VT_Float;
|
||||
|
||||
record.mValue.setType (i==2 ? ESM::VT_Float : ESM::VT_Int);
|
||||
|
||||
if (i==0)
|
||||
record.mValue.setInteger (1);
|
||||
|
||||
getData().getGlobals().add (record);
|
||||
}
|
||||
|
||||
/// \todo add GMSTs
|
||||
}
|
||||
|
||||
CSMDoc::Document::Document (const std::vector<boost::filesystem::path>& files, bool new_)
|
||||
|
@ -211,7 +212,9 @@ CSMDoc::Document::Document (const std::vector<boost::filesystem::path>& files, b
|
|||
|
||||
mName = files.back().filename().string();
|
||||
|
||||
if (files.size()>1 || !new_)
|
||||
if (new_ && files.size()==1)
|
||||
createBase();
|
||||
else if (files.size()>1)
|
||||
{
|
||||
std::vector<boost::filesystem::path>::const_iterator end = files.end();
|
||||
|
||||
|
@ -221,8 +224,8 @@ CSMDoc::Document::Document (const std::vector<boost::filesystem::path>& files, b
|
|||
load (files.begin(), end, !new_);
|
||||
}
|
||||
|
||||
if (new_ && files.size()==1)
|
||||
createBase();
|
||||
addOptionalGmsts();
|
||||
addOptionalGlobals();
|
||||
|
||||
connect (&mUndoStack, SIGNAL (cleanChanged (bool)), this, SLOT (modificationStateChanged (bool)));
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ namespace CSMWorld
|
|||
Display_Integer,
|
||||
Display_Float,
|
||||
Display_Var,
|
||||
Display_VarType
|
||||
Display_GmstVarType,
|
||||
Display_GlobalVarType
|
||||
};
|
||||
|
||||
std::string mTitle;
|
||||
|
|
|
@ -12,13 +12,13 @@ namespace CSMWorld
|
|||
|
||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||
{
|
||||
return record.get().mValue;
|
||||
return record.get().mValue.getFloat();
|
||||
}
|
||||
|
||||
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
||||
{
|
||||
ESXRecordT record2 = record.get();
|
||||
record2.mValue = data.toFloat();
|
||||
record2.mValue.setFloat (data.toFloat());
|
||||
record.setModified (record2);
|
||||
}
|
||||
|
||||
|
@ -96,17 +96,17 @@ namespace CSMWorld
|
|||
template<typename ESXRecordT>
|
||||
struct VarTypeColumn : public Column<ESXRecordT>
|
||||
{
|
||||
VarTypeColumn() : Column<ESXRecordT> ("Type", ColumnBase::Display_VarType) {}
|
||||
VarTypeColumn (ColumnBase::Display display) : Column<ESXRecordT> ("Type", display) {}
|
||||
|
||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||
{
|
||||
return static_cast<int> (record.get().mType);
|
||||
return static_cast<int> (record.get().mValue.getType());
|
||||
}
|
||||
|
||||
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
||||
{
|
||||
ESXRecordT record2 = record.get();
|
||||
record2.mType = static_cast<ESM::VarType> (data.toInt());
|
||||
record2.mValue.setType (static_cast<ESM::VarType> (data.toInt()));
|
||||
record.setModified (record2);
|
||||
}
|
||||
|
||||
|
@ -123,11 +123,21 @@ namespace CSMWorld
|
|||
|
||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||
{
|
||||
switch (record.get().mType)
|
||||
switch (record.get().mValue.getType())
|
||||
{
|
||||
case ESM::VT_String: return record.get().mStr.c_str(); break;
|
||||
case ESM::VT_Int: return record.get().mI; break;
|
||||
case ESM::VT_Float: return record.get().mF; break;
|
||||
case ESM::VT_String:
|
||||
|
||||
return record.get().mValue.getString().c_str(); break;
|
||||
|
||||
case ESM::VT_Int:
|
||||
case ESM::VT_Short:
|
||||
case ESM::VT_Long:
|
||||
|
||||
return record.get().mValue.getInteger(); break;
|
||||
|
||||
case ESM::VT_Float:
|
||||
|
||||
return record.get().mValue.getFloat(); break;
|
||||
|
||||
default: return QVariant();
|
||||
}
|
||||
|
@ -137,11 +147,24 @@ namespace CSMWorld
|
|||
{
|
||||
ESXRecordT record2 = record.get();
|
||||
|
||||
switch (record2.mType)
|
||||
switch (record2.mValue.getType())
|
||||
{
|
||||
case ESM::VT_String: record2.mStr = data.toString().toUtf8().constData(); break;
|
||||
case ESM::VT_Int: record2.mI = data.toInt(); break;
|
||||
case ESM::VT_Float: record2.mF = data.toFloat(); break;
|
||||
case ESM::VT_String:
|
||||
|
||||
record2.mValue.setString (data.toString().toUtf8().constData());
|
||||
break;
|
||||
|
||||
case ESM::VT_Int:
|
||||
case ESM::VT_Short:
|
||||
case ESM::VT_Long:
|
||||
|
||||
record2.mValue.setInteger (data.toInt());
|
||||
break;
|
||||
|
||||
case ESM::VT_Float:
|
||||
|
||||
record2.mValue.setFloat (data.toFloat());
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <QAbstractTableModel>
|
||||
|
||||
#include <components/esm/esmreader.hpp>
|
||||
#include <components/esm/defs.hpp>
|
||||
#include <components/esm/loadglob.hpp>
|
||||
|
||||
#include "idtable.hpp"
|
||||
|
@ -26,12 +27,13 @@ CSMWorld::Data::Data()
|
|||
mGlobals.addColumn (new StringIdColumn<ESM::Global>);
|
||||
mGlobals.addColumn (new RecordStateColumn<ESM::Global>);
|
||||
mGlobals.addColumn (new FixedRecordTypeColumn<ESM::Global> (UniversalId::Type_Global));
|
||||
mGlobals.addColumn (new FloatValueColumn<ESM::Global>);
|
||||
mGlobals.addColumn (new VarTypeColumn<ESM::Global> (ColumnBase::Display_GlobalVarType));
|
||||
mGlobals.addColumn (new VarValueColumn<ESM::Global>);
|
||||
|
||||
mGmsts.addColumn (new StringIdColumn<ESM::GameSetting>);
|
||||
mGmsts.addColumn (new RecordStateColumn<ESM::GameSetting>);
|
||||
mGmsts.addColumn (new FixedRecordTypeColumn<ESM::GameSetting> (UniversalId::Type_Gmst));
|
||||
mGmsts.addColumn (new VarTypeColumn<ESM::GameSetting>);
|
||||
mGmsts.addColumn (new VarTypeColumn<ESM::GameSetting> (ColumnBase::Display_GmstVarType));
|
||||
mGmsts.addColumn (new VarValueColumn<ESM::GameSetting>);
|
||||
|
||||
addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
|
||||
|
|
272
apps/opencs/view/doc/filedialog.cpp
Normal file
272
apps/opencs/view/doc/filedialog.cpp
Normal file
|
@ -0,0 +1,272 @@
|
|||
#include "filedialog.hpp"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QRegExpValidator>
|
||||
#include <QRegExp>
|
||||
#include <QSpacerItem>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
|
||||
#include <components/fileorderlist/model/datafilesmodel.hpp>
|
||||
#include <components/fileorderlist/model/pluginsproxymodel.hpp>
|
||||
#include <components/fileorderlist/model/esm/esmfile.hpp>
|
||||
|
||||
#include <components/fileorderlist/utils/lineedit.hpp>
|
||||
|
||||
FileDialog::FileDialog(QWidget *parent) :
|
||||
QDialog(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
// Models
|
||||
mDataFilesModel = new DataFilesModel(this);
|
||||
|
||||
mMastersProxyModel = new QSortFilterProxyModel();
|
||||
mMastersProxyModel->setFilterRegExp(QString("^.*\\.esm"));
|
||||
mMastersProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
mMastersProxyModel->setSourceModel(mDataFilesModel);
|
||||
|
||||
mPluginsProxyModel = new PluginsProxyModel();
|
||||
mPluginsProxyModel->setFilterRegExp(QString("^.*\\.esp"));
|
||||
mPluginsProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
mPluginsProxyModel->setSourceModel(mDataFilesModel);
|
||||
|
||||
mFilterProxyModel = new QSortFilterProxyModel();
|
||||
mFilterProxyModel->setDynamicSortFilter(true);
|
||||
mFilterProxyModel->setSourceModel(mPluginsProxyModel);
|
||||
|
||||
QCheckBox checkBox;
|
||||
unsigned int height = checkBox.sizeHint().height() + 4;
|
||||
|
||||
mastersTable->setModel(mMastersProxyModel);
|
||||
mastersTable->setObjectName("MastersTable");
|
||||
mastersTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
mastersTable->setSortingEnabled(false);
|
||||
mastersTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
mastersTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
mastersTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
mastersTable->setAlternatingRowColors(true);
|
||||
mastersTable->horizontalHeader()->setStretchLastSection(true);
|
||||
|
||||
// Set the row height to the size of the checkboxes
|
||||
mastersTable->verticalHeader()->setDefaultSectionSize(height);
|
||||
mastersTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
||||
mastersTable->verticalHeader()->hide();
|
||||
|
||||
pluginsTable->setModel(mFilterProxyModel);
|
||||
pluginsTable->setObjectName("PluginsTable");
|
||||
pluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
pluginsTable->setSortingEnabled(false);
|
||||
pluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
pluginsTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
pluginsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
pluginsTable->setAlternatingRowColors(true);
|
||||
pluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
|
||||
pluginsTable->horizontalHeader()->setStretchLastSection(true);
|
||||
|
||||
pluginsTable->verticalHeader()->setDefaultSectionSize(height);
|
||||
pluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
||||
|
||||
// Hide the profile elements
|
||||
profileLabel->hide();
|
||||
profilesComboBox->hide();
|
||||
newProfileButton->hide();
|
||||
deleteProfileButton->hide();
|
||||
|
||||
// Add some extra widgets
|
||||
QHBoxLayout *nameLayout = new QHBoxLayout();
|
||||
QSpacerItem *spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
|
||||
mNameLabel = new QLabel(tr("File Name:"), this);
|
||||
|
||||
QRegExpValidator *validator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9\\s]*$"));
|
||||
mNameLineEdit = new LineEdit(this);
|
||||
mNameLineEdit->setValidator(validator);
|
||||
|
||||
nameLayout->addSpacerItem(spacer);
|
||||
nameLayout->addWidget(mNameLabel);
|
||||
nameLayout->addWidget(mNameLineEdit);
|
||||
|
||||
mButtonBox = new QDialogButtonBox(this);
|
||||
|
||||
mCreateButton = new QPushButton(tr("Create"), this);
|
||||
mCreateButton->setEnabled(false);
|
||||
|
||||
verticalLayout->addLayout(nameLayout);
|
||||
verticalLayout->addWidget(mButtonBox);
|
||||
|
||||
// Set sizes
|
||||
QList<int> sizeList;
|
||||
sizeList << 175;
|
||||
sizeList << 200;
|
||||
|
||||
splitter->setSizes(sizeList);
|
||||
|
||||
resize(600, 400);
|
||||
|
||||
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
||||
connect(mDataFilesModel, SIGNAL(checkedItemsChanged(QStringList)), this, SLOT(updateOpenButton(QStringList)));
|
||||
connect(mNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateCreateButton(QString)));
|
||||
|
||||
connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
||||
|
||||
connect(pluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
|
||||
connect(mastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
|
||||
|
||||
connect(mCreateButton, SIGNAL(clicked()), this, SLOT(createButtonClicked()));
|
||||
|
||||
connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
}
|
||||
|
||||
void FileDialog::updateViews()
|
||||
{
|
||||
// Ensure the columns are hidden because sort() re-enables them
|
||||
mastersTable->setColumnHidden(1, true);
|
||||
mastersTable->setColumnHidden(3, true);
|
||||
mastersTable->setColumnHidden(4, true);
|
||||
mastersTable->setColumnHidden(5, true);
|
||||
mastersTable->setColumnHidden(6, true);
|
||||
mastersTable->setColumnHidden(7, true);
|
||||
mastersTable->setColumnHidden(8, true);
|
||||
mastersTable->resizeColumnsToContents();
|
||||
|
||||
pluginsTable->setColumnHidden(1, true);
|
||||
pluginsTable->setColumnHidden(3, true);
|
||||
pluginsTable->setColumnHidden(4, true);
|
||||
pluginsTable->setColumnHidden(5, true);
|
||||
pluginsTable->setColumnHidden(6, true);
|
||||
pluginsTable->setColumnHidden(7, true);
|
||||
pluginsTable->setColumnHidden(8, true);
|
||||
pluginsTable->resizeColumnsToContents();
|
||||
|
||||
}
|
||||
|
||||
void FileDialog::updateOpenButton(const QStringList &items)
|
||||
{
|
||||
QPushButton *openButton = mButtonBox->button(QDialogButtonBox::Open);
|
||||
|
||||
if (!openButton)
|
||||
return;
|
||||
|
||||
openButton->setEnabled(!items.isEmpty());
|
||||
}
|
||||
|
||||
void FileDialog::updateCreateButton(const QString &name)
|
||||
{
|
||||
if (!mCreateButton->isVisible())
|
||||
return;
|
||||
|
||||
mCreateButton->setEnabled(!name.isEmpty());
|
||||
}
|
||||
|
||||
void FileDialog::filterChanged(const QString &filter)
|
||||
{
|
||||
QRegExp filterRe(filter, Qt::CaseInsensitive, QRegExp::FixedString);
|
||||
mFilterProxyModel->setFilterRegExp(filterRe);
|
||||
}
|
||||
|
||||
void FileDialog::addFiles(const QString &path)
|
||||
{
|
||||
mDataFilesModel->addFiles(path);
|
||||
mDataFilesModel->sort(3); // Sort by date accessed
|
||||
}
|
||||
|
||||
void FileDialog::setEncoding(const QString &encoding)
|
||||
{
|
||||
mDataFilesModel->setEncoding(encoding);
|
||||
}
|
||||
|
||||
void FileDialog::setCheckState(QModelIndex index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
QObject *object = QObject::sender();
|
||||
|
||||
// Not a signal-slot call
|
||||
if (!object)
|
||||
return;
|
||||
|
||||
|
||||
if (object->objectName() == QLatin1String("PluginsTable")) {
|
||||
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(
|
||||
mFilterProxyModel->mapToSource(index));
|
||||
|
||||
if (sourceIndex.isValid()) {
|
||||
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
||||
? mDataFilesModel->setCheckState(sourceIndex, Qt::Unchecked)
|
||||
: mDataFilesModel->setCheckState(sourceIndex, Qt::Checked);
|
||||
}
|
||||
}
|
||||
|
||||
if (object->objectName() == QLatin1String("MastersTable")) {
|
||||
QModelIndex sourceIndex = mMastersProxyModel->mapToSource(index);
|
||||
|
||||
if (sourceIndex.isValid()) {
|
||||
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
||||
? mDataFilesModel->setCheckState(sourceIndex, Qt::Unchecked)
|
||||
: mDataFilesModel->setCheckState(sourceIndex, Qt::Checked);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList FileDialog::checkedItemsPaths()
|
||||
{
|
||||
return mDataFilesModel->checkedItemsPaths();
|
||||
}
|
||||
|
||||
QString FileDialog::fileName()
|
||||
{
|
||||
return mNameLineEdit->text();
|
||||
}
|
||||
|
||||
void FileDialog::openFile()
|
||||
{
|
||||
setWindowTitle(tr("Open"));
|
||||
|
||||
mNameLabel->hide();
|
||||
mNameLineEdit->hide();
|
||||
mCreateButton->hide();
|
||||
|
||||
mButtonBox->removeButton(mCreateButton);
|
||||
mButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Open);
|
||||
QPushButton *openButton = mButtonBox->button(QDialogButtonBox::Open);
|
||||
openButton->setEnabled(false);
|
||||
|
||||
show();
|
||||
raise();
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
void FileDialog::newFile()
|
||||
{
|
||||
setWindowTitle(tr("New"));
|
||||
|
||||
mNameLabel->show();
|
||||
mNameLineEdit->clear();
|
||||
mNameLineEdit->show();
|
||||
mCreateButton->show();
|
||||
|
||||
mButtonBox->setStandardButtons(QDialogButtonBox::Cancel);
|
||||
mButtonBox->addButton(mCreateButton, QDialogButtonBox::ActionRole);
|
||||
|
||||
show();
|
||||
raise();
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
void FileDialog::accept()
|
||||
{
|
||||
emit openFiles();
|
||||
}
|
||||
|
||||
void FileDialog::createButtonClicked()
|
||||
{
|
||||
emit createNewFile();
|
||||
}
|
66
apps/opencs/view/doc/filedialog.hpp
Normal file
66
apps/opencs/view/doc/filedialog.hpp
Normal file
|
@ -0,0 +1,66 @@
|
|||
#ifndef FILEDIALOG_HPP
|
||||
#define FILEDIALOG_HPP
|
||||
|
||||
#include <QDialog>
|
||||
#include <QModelIndex>
|
||||
|
||||
#include "ui_datafilespage.h"
|
||||
|
||||
class QDialogButtonBox;
|
||||
class QSortFilterProxyModel;
|
||||
class QAbstractItemModel;
|
||||
class QPushButton;
|
||||
class QStringList;
|
||||
class QString;
|
||||
class QMenu;
|
||||
|
||||
class DataFilesModel;
|
||||
class PluginsProxyModel;
|
||||
|
||||
class FileDialog : public QDialog, private Ui::DataFilesPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FileDialog(QWidget *parent = 0);
|
||||
void addFiles(const QString &path);
|
||||
void setEncoding(const QString &encoding);
|
||||
|
||||
void openFile();
|
||||
void newFile();
|
||||
void accepted();
|
||||
|
||||
QStringList checkedItemsPaths();
|
||||
QString fileName();
|
||||
|
||||
signals:
|
||||
void openFiles();
|
||||
void createNewFile();
|
||||
|
||||
public slots:
|
||||
void accept();
|
||||
|
||||
private slots:
|
||||
void updateViews();
|
||||
void updateOpenButton(const QStringList &items);
|
||||
void updateCreateButton(const QString &name);
|
||||
void setCheckState(QModelIndex index);
|
||||
|
||||
void filterChanged(const QString &filter);
|
||||
|
||||
void createButtonClicked();
|
||||
|
||||
private:
|
||||
QLabel *mNameLabel;
|
||||
LineEdit *mNameLineEdit;
|
||||
|
||||
QPushButton *mCreateButton;
|
||||
QDialogButtonBox *mButtonBox;
|
||||
|
||||
DataFilesModel *mDataFilesModel;
|
||||
|
||||
PluginsProxyModel *mPluginsProxyModel;
|
||||
QSortFilterProxyModel *mMastersProxyModel;
|
||||
QSortFilterProxyModel *mFilterProxyModel;
|
||||
};
|
||||
|
||||
#endif // FILEDIALOG_HPP
|
|
@ -38,8 +38,12 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
|
|||
{
|
||||
mDelegateFactories = new CSVWorld::CommandDelegateFactoryCollection;
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_VarType,
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_GmstVarType,
|
||||
new CSVWorld::VarTypeDelegateFactory (ESM::VT_None, ESM::VT_String, ESM::VT_Int, ESM::VT_Float));
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_GlobalVarType,
|
||||
new CSVWorld::VarTypeDelegateFactory (ESM::VT_Short, ESM::VT_Long, ESM::VT_Float));
|
||||
|
||||
}
|
||||
|
||||
CSVDoc::ViewManager::~ViewManager()
|
||||
|
|
|
@ -85,7 +85,7 @@ void CSVWorld::VarTypeDelegateFactory::add (ESM::VarType type)
|
|||
{
|
||||
{ ESM::VT_None, "empty" },
|
||||
{ ESM::VT_Short, "short" },
|
||||
{ ESM::VT_Int, "long" },
|
||||
{ ESM::VT_Int, "integer" },
|
||||
{ ESM::VT_Long, "long" },
|
||||
{ ESM::VT_Float, "float" },
|
||||
{ ESM::VT_String, "string" },
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef CSV_WORLD_VARTYPEDELEGATE_H
|
||||
#define CSV_WORLD_VARTYPEDELEGATE_H
|
||||
|
||||
#include <components/esm/variant.hpp>
|
||||
|
||||
#include "enumdelegate.hpp"
|
||||
|
||||
namespace CSVWorld
|
||||
|
|
|
@ -16,7 +16,7 @@ source_group(game FILES ${GAME} ${GAME_HEADER})
|
|||
add_openmw_dir (mwrender
|
||||
renderingmanager debugging sky player animation npcanimation creatureanimation activatoranimation
|
||||
actors objects renderinginterface localmap occlusionquery terrain terrainmaterial water shadows
|
||||
compositors characterpreview externalrendering globalmap videoplayer
|
||||
compositors characterpreview externalrendering globalmap videoplayer ripplesimulation refraction
|
||||
)
|
||||
|
||||
add_openmw_dir (mwinput
|
||||
|
@ -30,7 +30,7 @@ add_openmw_dir (mwgui
|
|||
formatting inventorywindow container hud countdialog tradewindow settingswindow
|
||||
confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu
|
||||
itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog spellcreationdialog
|
||||
enchantingdialog trainingwindow travelwindow imagebutton exposedwindow cursor
|
||||
enchantingdialog trainingwindow travelwindow imagebutton exposedwindow cursor spellicons
|
||||
)
|
||||
|
||||
add_openmw_dir (mwdialogue
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
#include <components/bsa/bsa_archive.hpp>
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/translation/translation.hpp>
|
||||
#include <components/nif/nif_file.hpp>
|
||||
#include <components/nif/niffile.hpp>
|
||||
#include <components/nifoverrides/nifoverrides.hpp>
|
||||
|
||||
#include <components/nifbullet/bullet_nif_loader.hpp>
|
||||
#include <components/nifogre/ogre_nif_loader.hpp>
|
||||
#include <components/nifbullet/bulletnifloader.hpp>
|
||||
#include <components/nifogre/ogrenifloader.hpp>
|
||||
|
||||
#include "mwinput/inputmanagerimp.hpp"
|
||||
|
||||
|
@ -62,6 +62,13 @@ void OMW::Engine::setAnimationVerbose(bool animverbose)
|
|||
{
|
||||
}
|
||||
|
||||
bool OMW::Engine::frameStarted (const Ogre::FrameEvent& evt)
|
||||
{
|
||||
if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
MWBase::Environment::get().getWorld()->frameStarted(evt.timeSinceLastFrame);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
||||
{
|
||||
try
|
||||
|
@ -316,7 +323,6 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
|||
|
||||
addResourcesDirectory(mResDir / "mygui");
|
||||
addResourcesDirectory(mResDir / "water");
|
||||
addResourcesDirectory(mResDir / "gbuffer");
|
||||
addResourcesDirectory(mResDir / "shadows");
|
||||
addZipResource(mResDir / "mygui" / "Obliviontt.zip");
|
||||
|
||||
|
@ -444,7 +450,7 @@ void OMW::Engine::go()
|
|||
// Save user settings
|
||||
settings.saveUser(settingspath);
|
||||
|
||||
std::cout << "Quitting peacefully.\n";
|
||||
std::cout << "Quitting peacefully." << std::endl;
|
||||
}
|
||||
|
||||
void OMW::Engine::activate()
|
||||
|
|
|
@ -105,6 +105,7 @@ namespace OMW
|
|||
void executeLocalScripts();
|
||||
|
||||
virtual bool frameRenderingQueued (const Ogre::FrameEvent& evt);
|
||||
virtual bool frameStarted (const Ogre::FrameEvent& evt);
|
||||
|
||||
/// Load settings from various files, returns the path to the user settings file
|
||||
std::string loadSettings (Settings::Manager & settings);
|
||||
|
|
|
@ -237,6 +237,8 @@ namespace MWBase
|
|||
virtual void startEnchanting(MWWorld::Ptr actor) = 0;
|
||||
virtual void startTraining(MWWorld::Ptr actor) = 0;
|
||||
|
||||
virtual void changePointer (const std::string& name) = 0;
|
||||
|
||||
virtual const Translation::Storage& getTranslationDataStorage() const = 0;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -296,6 +296,7 @@ namespace MWBase
|
|||
virtual bool toggleVanityMode(bool enable, bool force) = 0;
|
||||
virtual void allowVanityMode(bool allow) = 0;
|
||||
virtual void togglePlayerLooking(bool enable) = 0;
|
||||
virtual void changeVanityModeScale(float factor) = 0;
|
||||
|
||||
virtual void renderPlayer() = 0;
|
||||
|
||||
|
@ -314,6 +315,7 @@ namespace MWBase
|
|||
/// \todo this does not belong here
|
||||
virtual void playVideo(const std::string& name, bool allowSkipping) = 0;
|
||||
virtual void stopVideo() = 0;
|
||||
virtual void frameStarted (float dt) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ namespace MWClass
|
|||
const MWWorld::Ptr& actor) const
|
||||
{
|
||||
if (MWWorld::Class::get (ptr).getCreatureStats (ptr).isDead())
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr));
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr, true));
|
||||
else
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr));
|
||||
}
|
||||
|
|
|
@ -220,7 +220,9 @@ namespace MWClass
|
|||
const MWWorld::Ptr& actor) const
|
||||
{
|
||||
if (MWWorld::Class::get (ptr).getCreatureStats (ptr).isDead())
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr));
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr, true));
|
||||
else if (MWWorld::Class::get(actor).getStance(actor, MWWorld::Class::Sneak))
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr)); // stealing
|
||||
else
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr));
|
||||
}
|
||||
|
@ -365,11 +367,10 @@ namespace MWClass
|
|||
fSwimRunAthleticsMult->getFloat();
|
||||
moveSpeed = swimSpeed;
|
||||
}
|
||||
else if(Npc::getStance(ptr, Run, false))
|
||||
else if(Npc::getStance(ptr, Run, false) && !Npc::getStance(ptr, Sneak, false))
|
||||
moveSpeed = runSpeed;
|
||||
else
|
||||
moveSpeed = walkSpeed;
|
||||
|
||||
if(getMovementSettings(ptr).mLeftRight != 0 && getMovementSettings(ptr).mForwardBackward == 0)
|
||||
moveSpeed *= 0.75f;
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include "../mwrender/objects.hpp"
|
||||
#include "../mwrender/renderinginterface.hpp"
|
||||
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
|
@ -138,6 +140,23 @@ namespace MWClass
|
|||
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
|
||||
|
||||
info.effects = MWGui::Widgets::MWEffectList::effectListFromESM(&ref->mBase->mEffects);
|
||||
|
||||
// hide effects the player doesnt know about
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer();
|
||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats (player);
|
||||
int alchemySkill = npcStats.getSkill (ESM::Skill::Alchemy).getBase();
|
||||
int i=0;
|
||||
for (MWGui::Widgets::SpellEffectList::iterator it = info.effects.begin(); it != info.effects.end(); ++it)
|
||||
{
|
||||
/// \todo this code is duplicated from mwclass/ingredient, put it in a helper function
|
||||
it->mKnown = ( (i == 0 && alchemySkill >= 15)
|
||||
|| (i == 1 && alchemySkill >= 30)
|
||||
|| (i == 2 && alchemySkill >= 45)
|
||||
|| (i == 3 && alchemySkill >= 60));
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
info.isPotion = true;
|
||||
|
||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||
|
|
|
@ -31,14 +31,13 @@ namespace
|
|||
template<typename T>
|
||||
bool selectCompareImp (const ESM::DialInfo::SelectStruct& select, T value1)
|
||||
{
|
||||
if (select.mType==ESM::VT_Short || select.mType==ESM::VT_Int ||
|
||||
select.mType==ESM::VT_Long)
|
||||
if (select.mValue.getType()==ESM::VT_Int)
|
||||
{
|
||||
return selectCompareImp (select.mSelectRule[4], value1, select.mI);
|
||||
return selectCompareImp (select.mSelectRule[4], value1, select.mValue.getInteger());
|
||||
}
|
||||
else if (select.mType==ESM::VT_Float)
|
||||
else if (select.mValue.getType()==ESM::VT_Float)
|
||||
{
|
||||
return selectCompareImp (select.mSelectRule[4], value1, select.mF);
|
||||
return selectCompareImp (select.mSelectRule[4], value1, select.mValue.getFloat());
|
||||
}
|
||||
else
|
||||
throw std::runtime_error (
|
||||
|
|
|
@ -237,7 +237,7 @@ namespace MWGui
|
|||
Widgets::SpellEffectList _list = Widgets::MWEffectList::effectListFromESM(&list);
|
||||
effectsWidget->setEffectList(_list);
|
||||
|
||||
std::vector<MyGUI::WidgetPtr> effectItems;
|
||||
std::vector<MyGUI::Widget*> effectItems;
|
||||
effectsWidget->createEffectWidgets(effectItems, mEffectsBox, coord, false, 0);
|
||||
effectsWidget->setCoord(coord);
|
||||
}
|
||||
|
|
|
@ -40,11 +40,11 @@ BirthDialog::BirthDialog(MWBase::WindowManager& parWindowManager)
|
|||
mBirthList->eventListMouseItemActivate += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
|
||||
mBirthList->eventListChangePosition += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
|
||||
|
||||
MyGUI::ButtonPtr backButton;
|
||||
MyGUI::Button* backButton;
|
||||
getWidget(backButton, "BackButton");
|
||||
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onBackClicked);
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onOkClicked);
|
||||
|
@ -55,7 +55,7 @@ BirthDialog::BirthDialog(MWBase::WindowManager& parWindowManager)
|
|||
|
||||
void BirthDialog::setNextButtonShow(bool shown)
|
||||
{
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
|
||||
if (shown)
|
||||
|
@ -82,7 +82,7 @@ void BirthDialog::setBirthId(const std::string &birthId)
|
|||
if (boost::iequals(*mBirthList->getItemDataAt<std::string>(i), birthId))
|
||||
{
|
||||
mBirthList->setIndexSelected(i);
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
break;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ void BirthDialog::onSelectBirth(MyGUI::ListBox* _sender, size_t _index)
|
|||
if (_index == MyGUI::ITEM_NONE)
|
||||
return;
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
|
||||
const std::string *birthId = mBirthList->getItemDataAt<std::string>(_index);
|
||||
|
@ -159,7 +159,7 @@ void BirthDialog::updateBirths()
|
|||
|
||||
void BirthDialog::updateSpells()
|
||||
{
|
||||
for (std::vector<MyGUI::WidgetPtr>::iterator it = mSpellItems.begin(); it != mSpellItems.end(); ++it)
|
||||
for (std::vector<MyGUI::Widget*>::iterator it = mSpellItems.begin(); it != mSpellItems.end(); ++it)
|
||||
{
|
||||
MyGUI::Gui::getInstance().destroyWidget(*it);
|
||||
}
|
||||
|
|
|
@ -46,9 +46,9 @@ namespace MWGui
|
|||
void updateSpells();
|
||||
|
||||
MyGUI::ListBox* mBirthList;
|
||||
MyGUI::WidgetPtr mSpellArea;
|
||||
MyGUI::Widget* mSpellArea;
|
||||
MyGUI::ImageBox* mBirthImage;
|
||||
std::vector<MyGUI::WidgetPtr> mSpellItems;
|
||||
std::vector<MyGUI::Widget*> mSpellItems;
|
||||
|
||||
std::string mCurrentBirthId;
|
||||
};
|
||||
|
|
|
@ -31,11 +31,11 @@ GenerateClassResultDialog::GenerateClassResultDialog(MWBase::WindowManager& parW
|
|||
getWidget(mClassImage, "ClassImage");
|
||||
getWidget(mClassName, "ClassName");
|
||||
|
||||
MyGUI::ButtonPtr backButton;
|
||||
MyGUI::Button* backButton;
|
||||
getWidget(backButton, "BackButton");
|
||||
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onBackClicked);
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked);
|
||||
|
@ -97,11 +97,11 @@ PickClassDialog::PickClassDialog(MWBase::WindowManager& parWindowManager)
|
|||
|
||||
getWidget(mClassImage, "ClassImage");
|
||||
|
||||
MyGUI::ButtonPtr backButton;
|
||||
MyGUI::Button* backButton;
|
||||
getWidget(backButton, "BackButton");
|
||||
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PickClassDialog::onBackClicked);
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PickClassDialog::onOkClicked);
|
||||
|
||||
|
@ -111,7 +111,7 @@ PickClassDialog::PickClassDialog(MWBase::WindowManager& parWindowManager)
|
|||
|
||||
void PickClassDialog::setNextButtonShow(bool shown)
|
||||
{
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
|
||||
if (shown)
|
||||
|
@ -138,7 +138,7 @@ void PickClassDialog::setClassId(const std::string &classId)
|
|||
if (boost::iequals(*mClassList->getItemDataAt<std::string>(i), classId))
|
||||
{
|
||||
mClassList->setIndexSelected(i);
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
break;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ void PickClassDialog::onSelectClass(MyGUI::ListBox* _sender, size_t _index)
|
|||
if (_index == MyGUI::ITEM_NONE)
|
||||
return;
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
|
||||
const std::string *classId = mClassList->getItemDataAt<std::string>(_index);
|
||||
|
@ -256,7 +256,7 @@ void InfoBoxDialog::fitToText(MyGUI::TextBox* widget)
|
|||
widget->setSize(size);
|
||||
}
|
||||
|
||||
void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin)
|
||||
void InfoBoxDialog::layoutVertically(MyGUI::Widget* widget, int margin)
|
||||
{
|
||||
size_t count = widget->getChildCount();
|
||||
int pos = 0;
|
||||
|
@ -264,7 +264,7 @@ void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin)
|
|||
int width = 0;
|
||||
for (unsigned i = 0; i < count; ++i)
|
||||
{
|
||||
MyGUI::WidgetPtr child = widget->getChildAt(i);
|
||||
MyGUI::Widget* child = widget->getChildAt(i);
|
||||
if (!child->getVisible())
|
||||
continue;
|
||||
|
||||
|
@ -302,7 +302,7 @@ std::string InfoBoxDialog::getText() const
|
|||
|
||||
void InfoBoxDialog::setButtons(ButtonList &buttons)
|
||||
{
|
||||
for (std::vector<MyGUI::ButtonPtr>::iterator it = this->mButtons.begin(); it != this->mButtons.end(); ++it)
|
||||
for (std::vector<MyGUI::Button*>::iterator it = this->mButtons.begin(); it != this->mButtons.end(); ++it)
|
||||
{
|
||||
MyGUI::Gui::getInstance().destroyWidget(*it);
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ void InfoBoxDialog::setButtons(ButtonList &buttons)
|
|||
mCurrentButton = -1;
|
||||
|
||||
// TODO: The buttons should be generated from a template in the layout file, ie. cloning an existing widget
|
||||
MyGUI::ButtonPtr button;
|
||||
MyGUI::Button* button;
|
||||
MyGUI::IntCoord coord = MyGUI::IntCoord(0, 0, mButtonBar->getWidth(), 10);
|
||||
ButtonList::const_iterator end = buttons.end();
|
||||
for (ButtonList::const_iterator it = buttons.begin(); it != end; ++it)
|
||||
|
@ -342,11 +342,11 @@ int InfoBoxDialog::getChosenButton() const
|
|||
return mCurrentButton;
|
||||
}
|
||||
|
||||
void InfoBoxDialog::onButtonClicked(MyGUI::WidgetPtr _sender)
|
||||
void InfoBoxDialog::onButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
std::vector<MyGUI::ButtonPtr>::const_iterator end = mButtons.end();
|
||||
std::vector<MyGUI::Button*>::const_iterator end = mButtons.end();
|
||||
int i = 0;
|
||||
for (std::vector<MyGUI::ButtonPtr>::const_iterator it = mButtons.begin(); it != end; ++it)
|
||||
for (std::vector<MyGUI::Button*>::const_iterator it = mButtons.begin(); it != end; ++it)
|
||||
{
|
||||
if (*it == _sender)
|
||||
{
|
||||
|
@ -376,10 +376,10 @@ ClassChoiceDialog::ClassChoiceDialog(MWBase::WindowManager& parWindowManager)
|
|||
|
||||
CreateClassDialog::CreateClassDialog(MWBase::WindowManager& parWindowManager)
|
||||
: WindowModal("openmw_chargen_create_class.layout", parWindowManager)
|
||||
, mSpecDialog(nullptr)
|
||||
, mAttribDialog(nullptr)
|
||||
, mSkillDialog(nullptr)
|
||||
, mDescDialog(nullptr)
|
||||
, mSpecDialog(NULL)
|
||||
, mAttribDialog(NULL)
|
||||
, mSkillDialog(NULL)
|
||||
, mDescDialog(NULL)
|
||||
{
|
||||
// Centre dialog
|
||||
center();
|
||||
|
@ -420,15 +420,15 @@ CreateClassDialog::CreateClassDialog(MWBase::WindowManager& parWindowManager)
|
|||
// Make sure the edit box has focus
|
||||
MyGUI::InputManager::getInstance().setKeyFocusWidget(mEditName);
|
||||
|
||||
MyGUI::ButtonPtr descriptionButton;
|
||||
MyGUI::Button* descriptionButton;
|
||||
getWidget(descriptionButton, "DescriptionButton");
|
||||
descriptionButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionClicked);
|
||||
|
||||
MyGUI::ButtonPtr backButton;
|
||||
MyGUI::Button* backButton;
|
||||
getWidget(backButton, "BackButton");
|
||||
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onBackClicked);
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onOkClicked);
|
||||
|
||||
|
@ -518,7 +518,7 @@ std::vector<ESM::Skill::SkillEnum> CreateClassDialog::getMinorSkills() const
|
|||
|
||||
void CreateClassDialog::setNextButtonShow(bool shown)
|
||||
{
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
|
||||
if (shown)
|
||||
|
@ -544,7 +544,7 @@ void CreateClassDialog::onDialogCancel()
|
|||
mDescDialog = 0;
|
||||
}
|
||||
|
||||
void CreateClassDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender)
|
||||
void CreateClassDialog::onSpecializationClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
delete mSpecDialog;
|
||||
mSpecDialog = new SelectSpecializationDialog(mWindowManager);
|
||||
|
@ -694,7 +694,7 @@ SelectSpecializationDialog::SelectSpecializationDialog(MWBase::WindowManager& pa
|
|||
ToolTips::createSpecializationToolTip(mSpecialization1, magic, ESM::Class::Magic);
|
||||
ToolTips::createSpecializationToolTip(mSpecialization2, stealth, ESM::Class::Stealth);
|
||||
|
||||
MyGUI::ButtonPtr cancelButton;
|
||||
MyGUI::Button* cancelButton;
|
||||
getWidget(cancelButton, "CancelButton");
|
||||
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
|
||||
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked);
|
||||
|
@ -706,7 +706,7 @@ SelectSpecializationDialog::~SelectSpecializationDialog()
|
|||
|
||||
// widget controls
|
||||
|
||||
void SelectSpecializationDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender)
|
||||
void SelectSpecializationDialog::onSpecializationClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
if (_sender == mSpecialization0)
|
||||
mSpecializationId = ESM::Class::Combat;
|
||||
|
@ -747,7 +747,7 @@ SelectAttributeDialog::SelectAttributeDialog(MWBase::WindowManager& parWindowMan
|
|||
ToolTips::createAttributeToolTip(attribute, attribute->getAttributeId());
|
||||
}
|
||||
|
||||
MyGUI::ButtonPtr cancelButton;
|
||||
MyGUI::Button* cancelButton;
|
||||
getWidget(cancelButton, "CancelButton");
|
||||
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
|
||||
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked);
|
||||
|
@ -840,7 +840,7 @@ SelectSkillDialog::SelectSkillDialog(MWBase::WindowManager& parWindowManager)
|
|||
}
|
||||
}
|
||||
|
||||
MyGUI::ButtonPtr cancelButton;
|
||||
MyGUI::Button* cancelButton;
|
||||
getWidget(cancelButton, "CancelButton");
|
||||
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
|
||||
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked);
|
||||
|
@ -873,7 +873,7 @@ DescriptionDialog::DescriptionDialog(MWBase::WindowManager& parWindowManager)
|
|||
|
||||
getWidget(mTextEdit, "TextEdit");
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked);
|
||||
okButton->setCaption(mWindowManager.getGameSettingString("sInputMenu1", ""));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef MWGUI_CLASS_H
|
||||
#define MWGUI_CLASS_H
|
||||
|
||||
#include <MyGUI.h>
|
||||
|
||||
#include "widgets.hpp"
|
||||
#include "window_base.hpp"
|
||||
|
||||
|
@ -35,17 +35,17 @@ namespace MWGui
|
|||
EventHandle_Int eventButtonSelected;
|
||||
|
||||
protected:
|
||||
void onButtonClicked(MyGUI::WidgetPtr _sender);
|
||||
void onButtonClicked(MyGUI::Widget* _sender);
|
||||
|
||||
private:
|
||||
|
||||
void fitToText(MyGUI::TextBox* widget);
|
||||
void layoutVertically(MyGUI::WidgetPtr widget, int margin);
|
||||
void layoutVertically(MyGUI::Widget* widget, int margin);
|
||||
int mCurrentButton;
|
||||
MyGUI::WidgetPtr mTextBox;
|
||||
MyGUI::Widget* mTextBox;
|
||||
MyGUI::TextBox* mText;
|
||||
MyGUI::WidgetPtr mButtonBar;
|
||||
std::vector<MyGUI::ButtonPtr> mButtons;
|
||||
MyGUI::Widget* mButtonBar;
|
||||
std::vector<MyGUI::Button*> mButtons;
|
||||
};
|
||||
|
||||
// Lets the player choose between 3 ways of creating a class
|
||||
|
@ -235,7 +235,7 @@ namespace MWGui
|
|||
void onOkClicked(MyGUI::Widget* _sender);
|
||||
|
||||
private:
|
||||
MyGUI::EditPtr mTextEdit;
|
||||
MyGUI::EditBox* mTextEdit;
|
||||
};
|
||||
|
||||
class CreateClassDialog : public WindowModal
|
||||
|
@ -265,7 +265,7 @@ namespace MWGui
|
|||
void onOkClicked(MyGUI::Widget* _sender);
|
||||
void onBackClicked(MyGUI::Widget* _sender);
|
||||
|
||||
void onSpecializationClicked(MyGUI::WidgetPtr _sender);
|
||||
void onSpecializationClicked(MyGUI::Widget* _sender);
|
||||
void onSpecializationSelected();
|
||||
void onAttributeClicked(Widgets::MWAttributePtr _sender);
|
||||
void onAttributeSelected();
|
||||
|
@ -280,7 +280,7 @@ namespace MWGui
|
|||
void update();
|
||||
|
||||
private:
|
||||
MyGUI::EditPtr mEditName;
|
||||
MyGUI::EditBox* mEditName;
|
||||
MyGUI::TextBox* mSpecializationName;
|
||||
Widgets::MWAttributePtr mFavoriteAttribute0, mFavoriteAttribute1;
|
||||
Widgets::MWSkillPtr mMajorSkill[5];
|
||||
|
|
|
@ -216,7 +216,7 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
|
||||
void Console::keyPress(MyGUI::WidgetPtr _sender,
|
||||
void Console::keyPress(MyGUI::Widget* _sender,
|
||||
MyGUI::KeyCode key,
|
||||
MyGUI::Char _char)
|
||||
{
|
||||
|
@ -266,7 +266,7 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
|
||||
void Console::acceptCommand(MyGUI::EditPtr _sender)
|
||||
void Console::acceptCommand(MyGUI::EditBox* _sender)
|
||||
{
|
||||
const std::string &cm = command->getCaption();
|
||||
if(cm.empty()) return;
|
||||
|
|
|
@ -55,8 +55,8 @@ namespace MWGui
|
|||
|
||||
|
||||
public:
|
||||
MyGUI::EditPtr command;
|
||||
MyGUI::EditPtr history;
|
||||
MyGUI::EditBox* command;
|
||||
MyGUI::EditBox* history;
|
||||
|
||||
typedef std::list<std::string> StringList;
|
||||
|
||||
|
@ -95,11 +95,11 @@ namespace MWGui
|
|||
|
||||
private:
|
||||
|
||||
void keyPress(MyGUI::WidgetPtr _sender,
|
||||
void keyPress(MyGUI::Widget* _sender,
|
||||
MyGUI::KeyCode key,
|
||||
MyGUI::Char _char);
|
||||
|
||||
void acceptCommand(MyGUI::EditPtr _sender);
|
||||
void acceptCommand(MyGUI::EditBox* _sender);
|
||||
|
||||
std::string complete( std::string input, std::vector<std::string> &matches );
|
||||
};
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "../mwworld/manualref.hpp"
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
|
||||
|
@ -70,9 +71,11 @@ namespace
|
|||
}
|
||||
|
||||
|
||||
ContainerBase::ContainerBase(DragAndDrop* dragAndDrop) :
|
||||
mDragAndDrop(dragAndDrop),
|
||||
mFilter(ContainerBase::Filter_All)
|
||||
ContainerBase::ContainerBase(DragAndDrop* dragAndDrop)
|
||||
: mDragAndDrop(dragAndDrop)
|
||||
, mFilter(ContainerBase::Filter_All)
|
||||
, mDisplayEquippedItems(true)
|
||||
, mHighlightEquippedItems(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -313,7 +316,6 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
|
|||
{
|
||||
object.getRefData().setCount(origCount - mDragAndDrop->mDraggedCount);
|
||||
}
|
||||
std::cout << "container weight " << curWeight << "/" << capacity << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -430,7 +432,7 @@ void ContainerBase::drawItems()
|
|||
equippedItems.erase(found);
|
||||
}
|
||||
// and add the items that are left (= have the correct category)
|
||||
if (!ignoreEquippedItems())
|
||||
if (mDisplayEquippedItems && mHighlightEquippedItems)
|
||||
{
|
||||
for (std::vector<MWWorld::Ptr>::const_iterator it=equippedItems.begin();
|
||||
it != equippedItems.end(); ++it)
|
||||
|
@ -445,7 +447,8 @@ void ContainerBase::drawItems()
|
|||
std::vector<MWWorld::Ptr> regularItems;
|
||||
for (MWWorld::ContainerStoreIterator iter (containerStore.begin(categories)); iter!=containerStore.end(); ++iter)
|
||||
{
|
||||
if (std::find(equippedItems.begin(), equippedItems.end(), *iter) == equippedItems.end()
|
||||
if ( (std::find(equippedItems.begin(), equippedItems.end(), *iter) == equippedItems.end()
|
||||
|| (!mHighlightEquippedItems && mDisplayEquippedItems))
|
||||
&& std::find(ignoreItems.begin(), ignoreItems.end(), *iter) == ignoreItems.end()
|
||||
&& std::find(mBoughtItems.begin(), mBoughtItems.end(), *iter) == mBoughtItems.end())
|
||||
regularItems.push_back(*iter);
|
||||
|
@ -587,6 +590,27 @@ void ContainerBase::returnBoughtItems(MWWorld::ContainerStore& store)
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<MWWorld::Ptr> ContainerBase::getEquippedItems()
|
||||
{
|
||||
if (mPtr.getTypeName() != typeid(ESM::NPC).name())
|
||||
return std::vector<MWWorld::Ptr>();
|
||||
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
|
||||
|
||||
std::vector<MWWorld::Ptr> items;
|
||||
|
||||
for (int slot=0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
||||
{
|
||||
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
|
||||
if (it != invStore.end())
|
||||
{
|
||||
items.push_back(*it);
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
MWWorld::ContainerStore& ContainerBase::getContainerStore()
|
||||
{
|
||||
MWWorld::ContainerStore& store = MWWorld::Class::get(mPtr).getContainerStore(mPtr);
|
||||
|
@ -599,6 +623,7 @@ ContainerWindow::ContainerWindow(MWBase::WindowManager& parWindowManager,DragAnd
|
|||
: ContainerBase(dragAndDrop)
|
||||
, WindowBase("openmw_container_window.layout", parWindowManager)
|
||||
{
|
||||
getWidget(mDisposeCorpseButton, "DisposeCorpseButton");
|
||||
getWidget(mTakeButton, "TakeButton");
|
||||
getWidget(mCloseButton, "CloseButton");
|
||||
|
||||
|
@ -608,6 +633,7 @@ ContainerWindow::ContainerWindow(MWBase::WindowManager& parWindowManager,DragAnd
|
|||
getWidget(itemView, "ItemView");
|
||||
setWidgets(containerWidget, itemView);
|
||||
|
||||
mDisposeCorpseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onDisposeCorpseButtonClicked);
|
||||
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onCloseButtonClicked);
|
||||
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onTakeAllButtonClicked);
|
||||
|
||||
|
@ -625,8 +651,18 @@ void ContainerWindow::onWindowResize(MyGUI::Window* window)
|
|||
drawItems();
|
||||
}
|
||||
|
||||
void ContainerWindow::open(MWWorld::Ptr container)
|
||||
void ContainerWindow::open(MWWorld::Ptr container, bool loot)
|
||||
{
|
||||
mDisplayEquippedItems = true;
|
||||
mHighlightEquippedItems = false;
|
||||
if (container.getTypeName() == typeid(ESM::NPC).name() && !loot)
|
||||
{
|
||||
// we are stealing stuff
|
||||
mDisplayEquippedItems = false;
|
||||
}
|
||||
|
||||
mDisposeCorpseButton->setVisible(loot);
|
||||
|
||||
openContainer(container);
|
||||
setTitle(MWWorld::Class::get(container).getName(container));
|
||||
drawItems();
|
||||
|
@ -671,6 +707,22 @@ void ContainerWindow::onTakeAllButtonClicked(MyGUI::Widget* _sender)
|
|||
}
|
||||
}
|
||||
|
||||
void ContainerWindow::onDisposeCorpseButtonClicked(MyGUI::Widget *sender)
|
||||
{
|
||||
if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop)
|
||||
{
|
||||
onTakeAllButtonClicked(mTakeButton);
|
||||
|
||||
/// \todo I don't think this is the correct flag to check
|
||||
if (MWWorld::Class::get(mPtr).isEssential(mPtr))
|
||||
mWindowManager.messageBox("#{sDisposeCorpseFail}");
|
||||
else
|
||||
MWBase::Environment::get().getWorld()->deleteObject(mPtr);
|
||||
|
||||
mPtr = MWWorld::Ptr();
|
||||
}
|
||||
}
|
||||
|
||||
void ContainerWindow::onReferenceUnavailable()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);
|
||||
|
|
|
@ -82,6 +82,9 @@ namespace MWGui
|
|||
void drawItems();
|
||||
|
||||
protected:
|
||||
bool mDisplayEquippedItems;
|
||||
bool mHighlightEquippedItems;
|
||||
|
||||
MyGUI::ScrollView* mItemView;
|
||||
MyGUI::Widget* mContainerWidget;
|
||||
|
||||
|
@ -111,14 +114,13 @@ namespace MWGui
|
|||
|
||||
virtual bool isTradeWindow() { return false; }
|
||||
virtual bool isInventory() { return false; }
|
||||
virtual std::vector<MWWorld::Ptr> getEquippedItems() { return std::vector<MWWorld::Ptr>(); }
|
||||
virtual std::vector<MWWorld::Ptr> getEquippedItems();
|
||||
virtual void _unequipItem(MWWorld::Ptr item) { ; }
|
||||
|
||||
virtual bool isTrading() { return false; }
|
||||
|
||||
virtual void onSelectedItemImpl(MWWorld::Ptr item) { ; }
|
||||
|
||||
virtual bool ignoreEquippedItems() { return false; }
|
||||
virtual std::vector<MWWorld::Ptr> itemsToIgnore() { return std::vector<MWWorld::Ptr>(); }
|
||||
|
||||
virtual void notifyContentChanged() { ; }
|
||||
|
@ -131,15 +133,17 @@ namespace MWGui
|
|||
|
||||
virtual ~ContainerWindow();
|
||||
|
||||
void open(MWWorld::Ptr container);
|
||||
void open(MWWorld::Ptr container, bool loot=false);
|
||||
|
||||
protected:
|
||||
MyGUI::Button* mDisposeCorpseButton;
|
||||
MyGUI::Button* mTakeButton;
|
||||
MyGUI::Button* mCloseButton;
|
||||
|
||||
void onWindowResize(MyGUI::Window* window);
|
||||
void onCloseButtonClicked(MyGUI::Widget* _sender);
|
||||
void onTakeAllButtonClicked(MyGUI::Widget* _sender);
|
||||
void onDisposeCorpseButtonClicked(MyGUI::Widget* sender);
|
||||
|
||||
virtual void onReferenceUnavailable();
|
||||
};
|
||||
|
|
|
@ -13,8 +13,9 @@ namespace MWGui
|
|||
{
|
||||
|
||||
|
||||
ResourceImageSetPointerFix::ResourceImageSetPointerFix() :
|
||||
mImageSet(nullptr)
|
||||
ResourceImageSetPointerFix::ResourceImageSetPointerFix()
|
||||
: mImageSet(NULL)
|
||||
, mRotation(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -50,7 +51,7 @@ namespace MWGui
|
|||
|
||||
void ResourceImageSetPointerFix::setImage(MyGUI::ImageBox* _image)
|
||||
{
|
||||
if (mImageSet != nullptr)
|
||||
if (mImageSet != NULL)
|
||||
_image->setItemResourceInfo(mImageSet->getIndexInfo(0, 0));
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ DialogueWindow::DialogueWindow(MWBase::WindowManager& parWindowManager)
|
|||
getWidget(mTopicsList, "TopicsList");
|
||||
mTopicsList->eventItemSelected += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic);
|
||||
|
||||
MyGUI::ButtonPtr byeButton;
|
||||
MyGUI::Button* byeButton;
|
||||
getWidget(byeButton, "ByeButton");
|
||||
byeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onByeClicked);
|
||||
|
||||
|
@ -164,7 +164,7 @@ DialogueWindow::DialogueWindow(MWBase::WindowManager& parWindowManager)
|
|||
void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
MyGUI::ISubWidgetText* t = mHistory->getClient()->getSubWidgetText();
|
||||
if(t == nullptr)
|
||||
if(t == NULL)
|
||||
return;
|
||||
|
||||
const MyGUI::IntPoint& lastPressed = MyGUI::InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
|
||||
|
@ -381,7 +381,7 @@ std::string DialogueWindow::parseText(const std::string& text)
|
|||
std::vector<MWDialogue::HyperTextToken> hypertext = MWDialogue::ParseHyperText(text);
|
||||
|
||||
size_t historySize = 0;
|
||||
if(mHistory->getClient()->getSubWidgetText() != nullptr)
|
||||
if(mHistory->getClient()->getSubWidgetText() != NULL)
|
||||
{
|
||||
historySize = mHistory->getOnlyText().size();
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace MWGui
|
|||
DialogueHistory* mHistory;
|
||||
Widgets::MWList* mTopicsList;
|
||||
MyGUI::ProgressPtr mDispositionBar;
|
||||
MyGUI::EditPtr mDispositionText;
|
||||
MyGUI::EditBox* mDispositionText;
|
||||
|
||||
PersuasionDialog mPersuasionDialog;
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include "exposedwindow.hpp"
|
||||
|
||||
#include "MyGUI_Window.h"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
MyGUI::VectorWidgetPtr ExposedWindow::getSkinWidgetsByName (const std::string &name)
|
||||
|
@ -16,7 +14,7 @@ namespace MWGui
|
|||
if (widgets.empty())
|
||||
{
|
||||
MYGUI_ASSERT( ! _throw, "widget name '" << _name << "' not found in skin of layout '" << getName() << "'");
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef MWGUI_EXPOSEDWINDOW_H
|
||||
#define MWGUI_EXPOSEDWINDOW_H
|
||||
|
||||
#include "MyGUI_Window.h"
|
||||
#include <MyGUI_Window.h>
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
#include <cmath>
|
||||
|
||||
#include <MyGUI.h>
|
||||
#include <MyGUI_Widget.h>
|
||||
#include <MyGUI_RenderManager.h>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
|
@ -19,6 +20,7 @@
|
|||
#include "inventorywindow.hpp"
|
||||
#include "container.hpp"
|
||||
#include "console.hpp"
|
||||
#include "spellicons.hpp"
|
||||
|
||||
using namespace MWGui;
|
||||
|
||||
|
@ -32,7 +34,6 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
|||
, mWeapStatus(NULL)
|
||||
, mSpellStatus(NULL)
|
||||
, mEffectBox(NULL)
|
||||
, mEffect1(NULL)
|
||||
, mMinimap(NULL)
|
||||
, mCompass(NULL)
|
||||
, mCrosshair(NULL)
|
||||
|
@ -86,9 +87,7 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
|||
mSpellBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked);
|
||||
|
||||
getWidget(mEffectBox, "EffectBox");
|
||||
getWidget(mEffect1, "Effect1");
|
||||
mEffectBoxBaseRight = viewSize.width - mEffectBox->getRight();
|
||||
mEffectBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked);
|
||||
|
||||
getWidget(mMinimapBox, "MiniMapBox");
|
||||
mMinimapBoxBaseRight = viewSize.width - mMinimapBox->getRight();
|
||||
|
@ -107,13 +106,18 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
|||
getWidget(mTriangleCounter, "TriangleCounter");
|
||||
getWidget(mBatchCounter, "BatchCounter");
|
||||
|
||||
setEffect("icons\\s\\tx_s_chameleon.dds");
|
||||
|
||||
LocalMapBase::init(mMinimap, mCompass, this);
|
||||
|
||||
mMainWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWorldClicked);
|
||||
mMainWidget->eventMouseMove += MyGUI::newDelegate(this, &HUD::onWorldMouseOver);
|
||||
mMainWidget->eventMouseLostFocus += MyGUI::newDelegate(this, &HUD::onWorldMouseLostFocus);
|
||||
|
||||
mSpellIcons = new SpellIcons();
|
||||
}
|
||||
|
||||
HUD::~HUD()
|
||||
{
|
||||
delete mSpellIcons;
|
||||
}
|
||||
|
||||
void HUD::setFpsLevel(int level)
|
||||
|
@ -156,11 +160,6 @@ void HUD::setBatchCount(unsigned int count)
|
|||
mBatchCounter->setCaption(boost::lexical_cast<std::string>(count));
|
||||
}
|
||||
|
||||
void HUD::setEffect(const char *img)
|
||||
{
|
||||
mEffect1->setImageTexture(img);
|
||||
}
|
||||
|
||||
void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<float>& value)
|
||||
{
|
||||
static const char *ids[] =
|
||||
|
@ -222,7 +221,7 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender)
|
|||
else
|
||||
world->dropObjectOnGround(world->getPlayer().getPlayer(), object);
|
||||
|
||||
MyGUI::PointerManager::getInstance().setPointer("arrow");
|
||||
MWBase::Environment::get().getWindowManager()->changePointer("arrow");
|
||||
|
||||
std::string sound = MWWorld::Class::get(object).getDownSoundId(object);
|
||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||
|
@ -273,21 +272,21 @@ void HUD::onWorldMouseOver(MyGUI::Widget* _sender, int x, int y)
|
|||
bool canDrop = world->canPlaceObject(mouseX, mouseY);
|
||||
|
||||
if (!canDrop)
|
||||
MyGUI::PointerManager::getInstance().setPointer("drop_ground");
|
||||
MWBase::Environment::get().getWindowManager()->changePointer("drop_ground");
|
||||
else
|
||||
MyGUI::PointerManager::getInstance().setPointer("arrow");
|
||||
MWBase::Environment::get().getWindowManager()->changePointer("arrow");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MyGUI::PointerManager::getInstance().setPointer("arrow");
|
||||
MWBase::Environment::get().getWindowManager()->changePointer("arrow");
|
||||
mWorldMouseOver = true;
|
||||
}
|
||||
}
|
||||
|
||||
void HUD::onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new)
|
||||
{
|
||||
MyGUI::PointerManager::getInstance().setPointer("arrow");
|
||||
MWBase::Environment::get().getWindowManager()->changePointer("arrow");
|
||||
mWorldMouseOver = false;
|
||||
}
|
||||
|
||||
|
@ -542,3 +541,8 @@ void HUD::updatePositions()
|
|||
mMapVisible = mMinimapBox->getVisible ();
|
||||
mEffectBox->setPosition((viewSize.width - mEffectBoxBaseRight) - mEffectBox->getWidth() + effectsDx, mEffectBox->getTop());
|
||||
}
|
||||
|
||||
void HUD::update()
|
||||
{
|
||||
mSpellIcons->updateWidgets(mEffectBox, true);
|
||||
}
|
||||
|
|
|
@ -8,12 +8,13 @@
|
|||
namespace MWGui
|
||||
{
|
||||
class DragAndDrop;
|
||||
class SpellIcons;
|
||||
|
||||
class HUD : public OEngine::GUI::Layout, public LocalMapBase
|
||||
{
|
||||
public:
|
||||
HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop);
|
||||
void setEffect(const char *img);
|
||||
virtual ~HUD();
|
||||
void setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value);
|
||||
void setFPS(float fps);
|
||||
void setTriangleCount(unsigned int count);
|
||||
|
@ -43,6 +44,10 @@ namespace MWGui
|
|||
|
||||
bool getWorldMouseOver() { return mWorldMouseOver; }
|
||||
|
||||
MyGUI::Widget* getEffectBox() { return mEffectBox; }
|
||||
|
||||
void update();
|
||||
|
||||
private:
|
||||
MyGUI::ProgressPtr mHealth, mMagicka, mStamina;
|
||||
MyGUI::Widget* mHealthFrame;
|
||||
|
@ -51,7 +56,6 @@ namespace MWGui
|
|||
MyGUI::ProgressPtr mWeapStatus, mSpellStatus;
|
||||
MyGUI::Widget *mEffectBox, *mMinimapBox;
|
||||
MyGUI::Button* mMinimapButton;
|
||||
MyGUI::ImageBox* mEffect1;
|
||||
MyGUI::ScrollView* mMinimap;
|
||||
MyGUI::ImageBox* mCompass;
|
||||
MyGUI::ImageBox* mCrosshair;
|
||||
|
@ -60,7 +64,7 @@ namespace MWGui
|
|||
|
||||
MyGUI::Widget* mDummy;
|
||||
|
||||
MyGUI::WidgetPtr mFpsBox;
|
||||
MyGUI::Widget* mFpsBox;
|
||||
MyGUI::TextBox* mFpsCounter;
|
||||
MyGUI::TextBox* mTriangleCounter;
|
||||
MyGUI::TextBox* mBatchCounter;
|
||||
|
@ -85,6 +89,8 @@ namespace MWGui
|
|||
|
||||
bool mWorldMouseOver;
|
||||
|
||||
SpellIcons* mSpellIcons;
|
||||
|
||||
void onWorldClicked(MyGUI::Widget* _sender);
|
||||
void onWorldMouseOver(MyGUI::Widget* _sender, int x, int y);
|
||||
void onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef MWGUI_IMAGEBUTTON_H
|
||||
#define MWGUI_IMAGEBUTTON_H
|
||||
|
||||
#include "MyGUI_ImageBox.h"
|
||||
#include <MyGUI_ImageBox.h>
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
|
|
@ -160,11 +160,8 @@ namespace MWGui
|
|||
// the "Take" button should not be visible.
|
||||
// NOTE: the take button is "reset" when the window opens, so we can safely do the following
|
||||
// without screwing up future book windows
|
||||
if (mDragAndDrop->mDraggedFrom == this)
|
||||
{
|
||||
mWindowManager.getBookWindow()->setTakeButtonShow(false);
|
||||
mWindowManager.getScrollWindow()->setTakeButtonShow(false);
|
||||
}
|
||||
mWindowManager.getBookWindow()->setTakeButtonShow(false);
|
||||
mWindowManager.getScrollWindow()->setTakeButtonShow(false);
|
||||
|
||||
mDragAndDrop->mIsOnDragAndDrop = false;
|
||||
MyGUI::Gui::getInstance().destroyWidget(mDragAndDrop->mDraggedWidget);
|
||||
|
@ -214,24 +211,6 @@ namespace MWGui
|
|||
return MWWorld::Ptr();
|
||||
}
|
||||
|
||||
std::vector<MWWorld::Ptr> InventoryWindow::getEquippedItems()
|
||||
{
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
|
||||
|
||||
std::vector<MWWorld::Ptr> items;
|
||||
|
||||
for (int slot=0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
||||
{
|
||||
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
|
||||
if (it != invStore.end())
|
||||
{
|
||||
items.push_back(*it);
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
void InventoryWindow::_unequipItem(MWWorld::Ptr item)
|
||||
{
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
|
||||
|
|
|
@ -64,7 +64,6 @@ namespace MWGui
|
|||
|
||||
virtual bool isTrading() { return mTrading; }
|
||||
virtual bool isInventory() { return true; }
|
||||
virtual std::vector<MWWorld::Ptr> getEquippedItems();
|
||||
virtual void _unequipItem(MWWorld::Ptr item);
|
||||
|
||||
virtual void onReferenceUnavailable() { ; }
|
||||
|
|
|
@ -29,8 +29,8 @@ namespace MWGui
|
|||
void notifyNextPage(MyGUI::Widget* _sender);
|
||||
void notifyPrevPage(MyGUI::Widget* _sender);
|
||||
|
||||
MyGUI::EditPtr mLeftTextWidget;
|
||||
MyGUI::EditPtr mRightTextWidget;
|
||||
MyGUI::EditBox* mLeftTextWidget;
|
||||
MyGUI::EditBox* mRightTextWidget;
|
||||
MWGui::ImageButton* mPrevBtn;
|
||||
MWGui::ImageButton* mNextBtn;
|
||||
std::vector<std::string> mLeftPages;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#include "list.hpp"
|
||||
|
||||
#include <MyGUI.h>
|
||||
#include <MyGUI_ScrollView.h>
|
||||
#include <MyGUI_Gui.h>
|
||||
#include <MyGUI_Button.h>
|
||||
#include <MyGUI_ImageBox.h>
|
||||
|
||||
using namespace MWGui;
|
||||
using namespace MWGui::Widgets;
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#ifndef MWGUI_LIST_HPP
|
||||
#define MWGUI_LIST_HPP
|
||||
|
||||
#include <MyGUI.h>
|
||||
#include <MyGUI_Widget.h>
|
||||
|
||||
namespace MyGUI
|
||||
{
|
||||
class ScrollView;
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
|
|
@ -19,6 +19,8 @@ namespace MWGui
|
|||
|
||||
void onResChange(int w, int h);
|
||||
|
||||
void updateWindow(Ogre::RenderWindow* rw) { mWindow = rw; }
|
||||
|
||||
private:
|
||||
bool mFirstLoad;
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
|
|||
std::vector<std::string>::const_iterator it;
|
||||
for(it = buttons.begin(); it != buttons.end(); ++it)
|
||||
{
|
||||
MyGUI::ButtonPtr button = mButtonsWidget->createWidget<MyGUI::Button>(
|
||||
MyGUI::Button* button = mButtonsWidget->createWidget<MyGUI::Button>(
|
||||
MyGUI::WidgetStyle::Child,
|
||||
std::string("MW_Button"),
|
||||
dummyCoord,
|
||||
|
@ -301,7 +301,7 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
|
|||
MyGUI::IntSize buttonSize(0, buttonHeight);
|
||||
int left = (mainWidgetSize.width - buttonsWidth)/2 + buttonPadding;
|
||||
|
||||
std::vector<MyGUI::ButtonPtr>::const_iterator button;
|
||||
std::vector<MyGUI::Button*>::const_iterator button;
|
||||
for(button = mButtons.begin(); button != mButtons.end(); ++button)
|
||||
{
|
||||
buttonCord.left = left;
|
||||
|
@ -349,7 +349,7 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
|
|||
|
||||
int top = textButtonPadding + buttonTopPadding + textSize.height;
|
||||
|
||||
std::vector<MyGUI::ButtonPtr>::const_iterator button;
|
||||
std::vector<MyGUI::Button*>::const_iterator button;
|
||||
for(button = mButtons.begin(); button != mButtons.end(); ++button)
|
||||
{
|
||||
buttonSize.width = (*button)->getTextSize().width + buttonPadding*2;
|
||||
|
@ -371,7 +371,7 @@ void InteractiveMessageBox::enterPressed()
|
|||
{
|
||||
|
||||
std::string ok = Misc::StringUtils::lowerCase(MyGUI::LanguageManager::getInstance().replaceTags("#{sOK}"));
|
||||
std::vector<MyGUI::ButtonPtr>::const_iterator button;
|
||||
std::vector<MyGUI::Button*>::const_iterator button;
|
||||
for(button = mButtons.begin(); button != mButtons.end(); ++button)
|
||||
{
|
||||
if(Misc::StringUtils::lowerCase((*button)->getCaption()) == ok)
|
||||
|
@ -393,7 +393,7 @@ void InteractiveMessageBox::buttonActivated (MyGUI::Widget* pressed)
|
|||
{
|
||||
mMarkedToDelete = true;
|
||||
int index = 0;
|
||||
std::vector<MyGUI::ButtonPtr>::const_iterator button;
|
||||
std::vector<MyGUI::Button*>::const_iterator button;
|
||||
for(button = mButtons.begin(); button != mButtons.end(); ++button)
|
||||
{
|
||||
if(*button == pressed)
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define MWGUI_MESSAGE_BOX_H
|
||||
|
||||
#include <openengine/gui/layout.hpp>
|
||||
#include <MyGUI.h>
|
||||
|
||||
#include "window_base.hpp"
|
||||
|
||||
|
@ -10,6 +9,13 @@
|
|||
|
||||
#undef MessageBox
|
||||
|
||||
namespace MyGUI
|
||||
{
|
||||
class Widget;
|
||||
class Button;
|
||||
class EditBox;
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
class InteractiveMessageBox;
|
||||
|
@ -61,7 +67,7 @@ namespace MWGui
|
|||
MessageBoxManager& mMessageBoxManager;
|
||||
int mHeight;
|
||||
const std::string& mMessage;
|
||||
MyGUI::EditPtr mMessageWidget;
|
||||
MyGUI::EditBox* mMessageWidget;
|
||||
int mFixedWidth;
|
||||
int mBottomPadding;
|
||||
int mNextBoxPadding;
|
||||
|
@ -81,9 +87,9 @@ namespace MWGui
|
|||
void buttonActivated (MyGUI::Widget* _widget);
|
||||
|
||||
MessageBoxManager& mMessageBoxManager;
|
||||
MyGUI::EditPtr mMessageWidget;
|
||||
MyGUI::WidgetPtr mButtonsWidget;
|
||||
std::vector<MyGUI::ButtonPtr> mButtons;
|
||||
MyGUI::EditBox* mMessageWidget;
|
||||
MyGUI::Widget* mButtonsWidget;
|
||||
std::vector<MyGUI::Button*> mButtons;
|
||||
|
||||
int mTextButtonPadding;
|
||||
int mButtonPressed;
|
||||
|
|
|
@ -41,7 +41,7 @@ RaceDialog::RaceDialog(MWBase::WindowManager& parWindowManager)
|
|||
mHeadRotate->eventScrollChangePosition += MyGUI::newDelegate(this, &RaceDialog::onHeadRotate);
|
||||
|
||||
// Set up next/previous buttons
|
||||
MyGUI::ButtonPtr prevButton, nextButton;
|
||||
MyGUI::Button *prevButton, *nextButton;
|
||||
|
||||
setText("GenderChoiceT", mWindowManager.getGameSettingString("sRaceMenu2", "Change Sex"));
|
||||
getWidget(prevButton, "PrevGenderButton");
|
||||
|
@ -73,11 +73,11 @@ RaceDialog::RaceDialog(MWBase::WindowManager& parWindowManager)
|
|||
setText("SpellPowerT", mWindowManager.getGameSettingString("sRaceMenu7", "Specials"));
|
||||
getWidget(mSpellPowerList, "SpellPowerList");
|
||||
|
||||
MyGUI::ButtonPtr backButton;
|
||||
MyGUI::Button* backButton;
|
||||
getWidget(backButton, "BackButton");
|
||||
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onBackClicked);
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onOkClicked);
|
||||
|
@ -89,7 +89,7 @@ RaceDialog::RaceDialog(MWBase::WindowManager& parWindowManager)
|
|||
|
||||
void RaceDialog::setNextButtonShow(bool shown)
|
||||
{
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
|
||||
if (shown)
|
||||
|
@ -134,7 +134,7 @@ void RaceDialog::setRaceId(const std::string &raceId)
|
|||
if (boost::iequals(*mRaceList->getItemDataAt<std::string>(i), raceId))
|
||||
{
|
||||
mRaceList->setIndexSelected(i);
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
break;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index)
|
|||
if (_index == MyGUI::ITEM_NONE)
|
||||
return;
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
const std::string *raceId = mRaceList->getItemDataAt<std::string>(_index);
|
||||
if (boost::iequals(mCurrentRaceId, *raceId))
|
||||
|
@ -331,7 +331,7 @@ void RaceDialog::updateRaces()
|
|||
|
||||
void RaceDialog::updateSkills()
|
||||
{
|
||||
for (std::vector<MyGUI::WidgetPtr>::iterator it = mSkillItems.begin(); it != mSkillItems.end(); ++it)
|
||||
for (std::vector<MyGUI::Widget*>::iterator it = mSkillItems.begin(); it != mSkillItems.end(); ++it)
|
||||
{
|
||||
MyGUI::Gui::getInstance().destroyWidget(*it);
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ void RaceDialog::updateSkills()
|
|||
|
||||
void RaceDialog::updateSpellPowers()
|
||||
{
|
||||
for (std::vector<MyGUI::WidgetPtr>::iterator it = mSpellPowerItems.begin(); it != mSpellPowerItems.end(); ++it)
|
||||
for (std::vector<MyGUI::Widget*>::iterator it = mSpellPowerItems.begin(); it != mSpellPowerItems.end(); ++it)
|
||||
{
|
||||
MyGUI::Gui::getInstance().destroyWidget(*it);
|
||||
}
|
||||
|
|
|
@ -85,11 +85,11 @@ namespace MWGui
|
|||
MyGUI::ListBox* mRaceList;
|
||||
MyGUI::ScrollBar* mHeadRotate;
|
||||
|
||||
MyGUI::WidgetPtr mSkillList;
|
||||
std::vector<MyGUI::WidgetPtr> mSkillItems;
|
||||
MyGUI::Widget* mSkillList;
|
||||
std::vector<MyGUI::Widget*> mSkillItems;
|
||||
|
||||
MyGUI::WidgetPtr mSpellPowerList;
|
||||
std::vector<MyGUI::WidgetPtr> mSpellPowerItems;
|
||||
MyGUI::Widget* mSpellPowerList;
|
||||
std::vector<MyGUI::Widget*> mSpellPowerItems;
|
||||
|
||||
int mGenderIndex, mFaceIndex, mHairIndex;
|
||||
int mFaceCount, mHairCount;
|
||||
|
|
|
@ -86,11 +86,11 @@ ReviewDialog::ReviewDialog(MWBase::WindowManager& parWindowManager)
|
|||
mSkillWidgetMap.insert(std::make_pair(i, static_cast<MyGUI::TextBox*> (0)));
|
||||
}
|
||||
|
||||
MyGUI::ButtonPtr backButton;
|
||||
MyGUI::Button* backButton;
|
||||
getWidget(backButton, "BackButton");
|
||||
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBackClicked);
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onOkClicked);
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId
|
|||
|
||||
void ReviewDialog::updateSkillArea()
|
||||
{
|
||||
for (std::vector<MyGUI::WidgetPtr>::iterator it = mSkillWidgets.begin(); it != mSkillWidgets.end(); ++it)
|
||||
for (std::vector<MyGUI::Widget*>::iterator it = mSkillWidgets.begin(); it != mSkillWidgets.end(); ++it)
|
||||
{
|
||||
MyGUI::Gui::getInstance().destroyWidget(*it);
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace MWGui
|
|||
std::map<int, MyGUI::TextBox*> mSkillWidgetMap;
|
||||
std::string mName, mRaceId, mBirthSignId;
|
||||
ESM::Class mKlass;
|
||||
std::vector<MyGUI::WidgetPtr> mSkillWidgets; //< Skills and other information
|
||||
std::vector<MyGUI::Widget*> mSkillWidgets; //< Skills and other information
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <OgreRoot.h>
|
||||
#include <OgreRenderSystem.h>
|
||||
#include <OgrePlugin.h>
|
||||
#include <OgreString.h>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
@ -77,6 +78,17 @@ namespace
|
|||
{
|
||||
return (Ogre::Root::getSingleton ().getRenderSystem ()->getName ().find("OpenGL") != std::string::npos) ? "glsl" : "hlsl";
|
||||
}
|
||||
|
||||
bool cgAvailable ()
|
||||
{
|
||||
Ogre::Root::PluginInstanceList list = Ogre::Root::getSingleton ().getInstalledPlugins ();
|
||||
for (Ogre::Root::PluginInstanceList::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||
{
|
||||
if ((*it)->getName() == "Cg Program Manager")
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
|
@ -109,6 +121,7 @@ namespace MWGui
|
|||
getWidget(mReflectActorsButton, "ReflectActorsButton");
|
||||
getWidget(mReflectTerrainButton, "ReflectTerrainButton");
|
||||
getWidget(mShadersButton, "ShadersButton");
|
||||
getWidget(mShaderModeButton, "ShaderModeButton");
|
||||
getWidget(mShadowsEnabledButton, "ShadowsEnabledButton");
|
||||
getWidget(mShadowsLargeDistance, "ShadowsLargeDistance");
|
||||
getWidget(mShadowsTextureSize, "ShadowsTextureSize");
|
||||
|
@ -116,22 +129,22 @@ namespace MWGui
|
|||
getWidget(mStaticsShadows, "StaticsShadows");
|
||||
getWidget(mMiscShadows, "MiscShadows");
|
||||
getWidget(mShadowsDebug, "ShadowsDebug");
|
||||
getWidget(mUnderwaterButton, "UnderwaterButton");
|
||||
getWidget(mControlsBox, "ControlsBox");
|
||||
getWidget(mResetControlsButton, "ResetControlsButton");
|
||||
getWidget(mInvertYButton, "InvertYButton");
|
||||
getWidget(mUISensitivitySlider, "UISensitivitySlider");
|
||||
getWidget(mCameraSensitivitySlider, "CameraSensitivitySlider");
|
||||
getWidget(mGammaSlider, "GammaSlider");
|
||||
getWidget(mRefractionButton, "RefractionButton");
|
||||
|
||||
mSubtitlesButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mCrosshairButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mInvertYButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
|
||||
mUnderwaterButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mShadersButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onShadersToggled);
|
||||
mShaderModeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onShaderModeToggled);
|
||||
mFullscreenButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mWaterShaderButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mRefractionButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mReflectObjectsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mReflectTerrainButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mReflectActorsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
|
@ -144,7 +157,6 @@ namespace MWGui
|
|||
mViewDistanceSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
mResolutionList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onResolutionSelected);
|
||||
mAnisotropySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
mGammaSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
|
||||
mShadowsEnabledButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mShadowsLargeDistance->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
|
@ -202,14 +214,6 @@ namespace MWGui
|
|||
getWidget(fovText, "FovText");
|
||||
fovText->setCaption("Field of View (" + boost::lexical_cast<std::string>(int(Settings::Manager::getFloat("field of view", "General"))) + ")");
|
||||
|
||||
float gammaVal = (Settings::Manager::getFloat("gamma", "Video")-0.1f)/(3.f-0.1f);
|
||||
mGammaSlider->setScrollPosition(gammaVal * (mGammaSlider->getScrollRange()-1));
|
||||
MyGUI::TextBox* gammaText;
|
||||
getWidget(gammaText, "GammaText");
|
||||
std::stringstream gamma;
|
||||
gamma << std::setprecision (2) << Settings::Manager::getFloat("gamma", "Video");
|
||||
gammaText->setCaption("Gamma (" + gamma.str() + ")");
|
||||
|
||||
float anisotropyVal = Settings::Manager::getInt("anisotropy", "General") / 16.0;
|
||||
mAnisotropySlider->setScrollPosition(anisotropyVal * (mAnisotropySlider->getScrollRange()-1));
|
||||
std::string tf = Settings::Manager::getString("texture filtering", "General");
|
||||
|
@ -230,10 +234,12 @@ namespace MWGui
|
|||
mReflectObjectsButton->setCaptionWithReplacing(Settings::Manager::getBool("reflect statics", "Water") ? "#{sOn}" : "#{sOff}");
|
||||
mReflectActorsButton->setCaptionWithReplacing(Settings::Manager::getBool("reflect actors", "Water") ? "#{sOn}" : "#{sOff}");
|
||||
mReflectTerrainButton->setCaptionWithReplacing(Settings::Manager::getBool("reflect terrain", "Water") ? "#{sOn}" : "#{sOff}");
|
||||
mUnderwaterButton->setCaptionWithReplacing(Settings::Manager::getBool("underwater effect", "Water") ? "#{sOn}" : "#{sOff}");
|
||||
|
||||
mShadowsTextureSize->setCaption (Settings::Manager::getString ("texture size", "Shadows"));
|
||||
mShadowsLargeDistance->setCaptionWithReplacing(Settings::Manager::getBool("split", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
//mShadowsLargeDistance->setCaptionWithReplacing(Settings::Manager::getBool("split", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
mShadowsLargeDistance->setCaptionWithReplacing("#{sOff}");
|
||||
mShadowsLargeDistance->setEnabled (false);
|
||||
|
||||
mShadowsEnabledButton->setCaptionWithReplacing(Settings::Manager::getBool("enabled", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
mActorShadows->setCaptionWithReplacing(Settings::Manager::getBool("actor shadows", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
mStaticsShadows->setCaptionWithReplacing(Settings::Manager::getBool("statics shadows", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
|
@ -250,26 +256,14 @@ namespace MWGui
|
|||
|
||||
mInvertYButton->setCaptionWithReplacing(Settings::Manager::getBool("invert y axis", "Input") ? "#{sOn}" : "#{sOff}");
|
||||
|
||||
std::string shaders;
|
||||
mShadersButton->setCaptionWithReplacing (Settings::Manager::getBool("shaders", "Objects") ? "#{sOn}" : "#{sOff}");
|
||||
mShaderModeButton->setCaption (Settings::Manager::getString("shader mode", "General"));
|
||||
|
||||
mRefractionButton->setCaptionWithReplacing (Settings::Manager::getBool("refraction", "Water") ? "#{sOn}" : "#{sOff}");
|
||||
|
||||
if (!Settings::Manager::getBool("shaders", "Objects"))
|
||||
shaders = "off";
|
||||
else
|
||||
{
|
||||
shaders = Settings::Manager::getString("shader mode", "General");
|
||||
}
|
||||
mShadersButton->setCaption (shaders);
|
||||
|
||||
if (!MWRender::RenderingManager::waterShaderSupported())
|
||||
{
|
||||
mWaterShaderButton->setEnabled(false);
|
||||
mReflectObjectsButton->setEnabled(false);
|
||||
mReflectActorsButton->setEnabled(false);
|
||||
mReflectTerrainButton->setEnabled(false);
|
||||
}
|
||||
|
||||
if (shaders == "off")
|
||||
{
|
||||
mUnderwaterButton->setEnabled (false);
|
||||
mRefractionButton->setEnabled(false);
|
||||
mShadowsEnabledButton->setEnabled(false);
|
||||
}
|
||||
|
||||
|
@ -385,12 +379,12 @@ namespace MWGui
|
|||
}
|
||||
else
|
||||
{
|
||||
if (_sender == mVSyncButton)
|
||||
Settings::Manager::setBool("vsync", "Video", newState);
|
||||
if (_sender == mWaterShaderButton)
|
||||
Settings::Manager::setBool("shader", "Water", newState);
|
||||
else if (_sender == mUnderwaterButton)
|
||||
{
|
||||
Settings::Manager::setBool("underwater effect", "Water", newState);
|
||||
}
|
||||
else if (_sender == mRefractionButton)
|
||||
Settings::Manager::setBool("refraction", "Water", newState);
|
||||
else if (_sender == mReflectObjectsButton)
|
||||
{
|
||||
Settings::Manager::setBool("reflect misc", "Water", newState);
|
||||
|
@ -424,33 +418,44 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
|
||||
void SettingsWindow::onShadersToggled(MyGUI::Widget* _sender)
|
||||
void SettingsWindow::onShaderModeToggled(MyGUI::Widget* _sender)
|
||||
{
|
||||
std::string val = static_cast<MyGUI::Button*>(_sender)->getCaption();
|
||||
if (val == "off")
|
||||
if (val == "cg")
|
||||
{
|
||||
val = hlslGlsl();
|
||||
}
|
||||
else if (val == hlslGlsl())
|
||||
else if (cgAvailable ())
|
||||
val = "cg";
|
||||
else
|
||||
val = "off";
|
||||
|
||||
static_cast<MyGUI::Button*>(_sender)->setCaption(val);
|
||||
|
||||
if (val == "off")
|
||||
Settings::Manager::setString("shader mode", "General", val);
|
||||
|
||||
apply();
|
||||
}
|
||||
|
||||
void SettingsWindow::onShadersToggled(MyGUI::Widget* _sender)
|
||||
{
|
||||
std::string on = mWindowManager.getGameSettingString("sOn", "On");
|
||||
std::string off = mWindowManager.getGameSettingString("sOff", "On");
|
||||
|
||||
std::string val = static_cast<MyGUI::Button*>(_sender)->getCaption();
|
||||
if (val == off)
|
||||
val = on;
|
||||
else
|
||||
val = off;
|
||||
static_cast<MyGUI::Button*>(_sender)->setCaptionWithReplacing (val);
|
||||
|
||||
if (val == off)
|
||||
{
|
||||
Settings::Manager::setBool("shaders", "Objects", false);
|
||||
|
||||
// water shader not supported with object shaders off
|
||||
mWaterShaderButton->setCaptionWithReplacing("#{sOff}");
|
||||
mUnderwaterButton->setCaptionWithReplacing("#{sOff}");
|
||||
mWaterShaderButton->setEnabled(false);
|
||||
mReflectObjectsButton->setEnabled(false);
|
||||
mReflectActorsButton->setEnabled(false);
|
||||
mReflectTerrainButton->setEnabled(false);
|
||||
mUnderwaterButton->setEnabled(false);
|
||||
Settings::Manager::setBool("shader", "Water", false);
|
||||
// refraction needs shaders to display underwater fog
|
||||
mRefractionButton->setCaptionWithReplacing("#{sOff}");
|
||||
mRefractionButton->setEnabled(false);
|
||||
|
||||
Settings::Manager::setBool("refraction", "Water", false);
|
||||
Settings::Manager::setBool("underwater effect", "Water", false);
|
||||
|
||||
// shadows not supported
|
||||
|
@ -461,17 +466,13 @@ namespace MWGui
|
|||
else
|
||||
{
|
||||
Settings::Manager::setBool("shaders", "Objects", true);
|
||||
Settings::Manager::setString("shader mode", "General", val);
|
||||
|
||||
// re-enable
|
||||
if (MWRender::RenderingManager::waterShaderSupported())
|
||||
{
|
||||
mWaterShaderButton->setEnabled(true);
|
||||
mReflectObjectsButton->setEnabled(true);
|
||||
mReflectActorsButton->setEnabled(true);
|
||||
mReflectTerrainButton->setEnabled(true);
|
||||
}
|
||||
mUnderwaterButton->setEnabled(true);
|
||||
mReflectObjectsButton->setEnabled(true);
|
||||
mReflectActorsButton->setEnabled(true);
|
||||
mReflectTerrainButton->setEnabled(true);
|
||||
mRefractionButton->setEnabled(true);
|
||||
|
||||
mShadowsEnabledButton->setEnabled(true);
|
||||
}
|
||||
|
||||
|
@ -521,15 +522,6 @@ namespace MWGui
|
|||
fovText->setCaption("Field of View (" + boost::lexical_cast<std::string>(int((1-val) * sFovMin + val * sFovMax)) + ")");
|
||||
Settings::Manager::setFloat("field of view", "General", (1-val) * sFovMin + val * sFovMax);
|
||||
}
|
||||
else if (scroller == mGammaSlider)
|
||||
{
|
||||
Settings::Manager::setFloat("gamma", "Video", (1-val) * 0.1f + val * 3.f);
|
||||
MyGUI::TextBox* gammaText;
|
||||
getWidget(gammaText, "GammaText");
|
||||
std::stringstream gamma;
|
||||
gamma << std::setprecision (2) << Settings::Manager::getFloat("gamma", "Video");
|
||||
gammaText->setCaption("Gamma (" + gamma.str() + ")");
|
||||
}
|
||||
else if (scroller == mAnisotropySlider)
|
||||
{
|
||||
mAnisotropyLabel->setCaption("Anisotropy (" + boost::lexical_cast<std::string>(int(val*16)) + ")");
|
||||
|
|
|
@ -40,7 +40,6 @@ namespace MWGui
|
|||
MyGUI::Button* mFPSButton;
|
||||
MyGUI::ScrollBar* mViewDistanceSlider;
|
||||
MyGUI::ScrollBar* mFOVSlider;
|
||||
MyGUI::ScrollBar* mGammaSlider;
|
||||
MyGUI::ScrollBar* mAnisotropySlider;
|
||||
MyGUI::Button* mTextureFilteringButton;
|
||||
MyGUI::TextBox* mAnisotropyLabel;
|
||||
|
@ -50,7 +49,8 @@ namespace MWGui
|
|||
MyGUI::Button* mReflectActorsButton;
|
||||
MyGUI::Button* mReflectTerrainButton;
|
||||
MyGUI::Button* mShadersButton;
|
||||
MyGUI::Button* mUnderwaterButton;
|
||||
MyGUI::Button* mShaderModeButton;
|
||||
MyGUI::Button* mRefractionButton;
|
||||
|
||||
MyGUI::Button* mShadowsEnabledButton;
|
||||
MyGUI::Button* mShadowsLargeDistance;
|
||||
|
@ -84,6 +84,7 @@ namespace MWGui
|
|||
void onResolutionCancel();
|
||||
|
||||
void onShadersToggled(MyGUI::Widget* _sender);
|
||||
void onShaderModeToggled(MyGUI::Widget* _sender);
|
||||
void onShadowTextureSize(MyGUI::Widget* _sender);
|
||||
|
||||
void onRebindAction(MyGUI::Widget* _sender);
|
||||
|
|
|
@ -94,9 +94,6 @@ namespace MWGui
|
|||
mPtr = actor;
|
||||
clearSpells();
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
|
||||
MWMechanics::Spells& playerSpells = MWWorld::Class::get (player).getCreatureStats (player).getSpells();
|
||||
MWMechanics::Spells& merchantSpells = MWWorld::Class::get (actor).getCreatureStats (actor).getSpells();
|
||||
|
||||
for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter)
|
||||
|
@ -107,8 +104,8 @@ namespace MWGui
|
|||
if (spell->mData.mType!=ESM::Spell::ST_Spell)
|
||||
continue; // don't try to sell diseases, curses or powers
|
||||
|
||||
if (std::find (playerSpells.begin(), playerSpells.end(), *iter)!=playerSpells.end())
|
||||
continue; // we have that spell already
|
||||
if (playerHasSpell(iter->first))
|
||||
continue;
|
||||
|
||||
addSpell (iter->first);
|
||||
}
|
||||
|
@ -118,6 +115,18 @@ namespace MWGui
|
|||
mSpellsView->setCanvasSize (MyGUI::IntSize(mSpellsView->getWidth(), std::max(mSpellsView->getHeight(), mCurrentY)));
|
||||
}
|
||||
|
||||
bool SpellBuyingWindow::playerHasSpell(const std::string &id)
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWMechanics::Spells& playerSpells = MWWorld::Class::get (player).getCreatureStats (player).getSpells();
|
||||
for (MWMechanics::Spells::TIterator it = playerSpells.begin(); it != playerSpells.end(); ++it)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(id, it->first))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SpellBuyingWindow::onSpellButtonClick(MyGUI::Widget* _sender)
|
||||
{
|
||||
int price = *_sender->getUserData<int>();
|
||||
|
|
|
@ -47,6 +47,8 @@ namespace MWGui
|
|||
void updateLabels();
|
||||
|
||||
virtual void onReferenceUnavailable();
|
||||
|
||||
bool playerHasSpell (const std::string& id);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
293
apps/openmw/mwgui/spellicons.cpp
Normal file
293
apps/openmw/mwgui/spellicons.cpp
Normal file
|
@ -0,0 +1,293 @@
|
|||
#include "spellicons.hpp"
|
||||
|
||||
#include <MyGUI_Widget.h>
|
||||
#include <MyGUI_Gui.h>
|
||||
#include <MyGUI_ImageBox.h>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
|
||||
#include "../mwmechanics/activespells.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "tooltips.hpp"
|
||||
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
void SpellIcons::updateWidgets(MyGUI::Widget *parent, bool adjustSize)
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
const MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
||||
|
||||
std::map <int, std::vector<MagicEffectInfo> > effects;
|
||||
|
||||
// add permanent item enchantments
|
||||
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
||||
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
||||
{
|
||||
MWWorld::ContainerStoreIterator it = store.getSlot(slot);
|
||||
if (it == store.end())
|
||||
continue;
|
||||
std::string enchantment = MWWorld::Class::get(*it).getEnchantment(*it);
|
||||
if (enchantment.empty())
|
||||
continue;
|
||||
const ESM::Enchantment* enchant = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(enchantment);
|
||||
if (enchant->mData.mType != ESM::Enchantment::ConstantEffect)
|
||||
continue;
|
||||
|
||||
const ESM::EffectList& list = enchant->mEffects;
|
||||
for (std::vector<ESM::ENAMstruct>::const_iterator effectIt = list.mList.begin();
|
||||
effectIt != list.mList.end(); ++effectIt)
|
||||
{
|
||||
const ESM::MagicEffect* magicEffect =
|
||||
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::MagicEffect>().find(effectIt->mEffectID);
|
||||
|
||||
MagicEffectInfo effectInfo;
|
||||
effectInfo.mSource = MWWorld::Class::get(*it).getName(*it);
|
||||
effectInfo.mKey = MWMechanics::EffectKey (effectIt->mEffectID);
|
||||
if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill)
|
||||
effectInfo.mKey.mArg = effectIt->mSkill;
|
||||
else if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
|
||||
effectInfo.mKey.mArg = effectIt->mAttribute;
|
||||
// just using the min magnitude here, permanent enchantments with a random magnitude just wouldn't make any sense
|
||||
effectInfo.mMagnitude = effectIt->mMagnMin;
|
||||
effectInfo.mPermanent = true;
|
||||
effects[effectIt->mEffectID].push_back (effectInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// add permanent spells
|
||||
const MWMechanics::Spells& spells = stats.getSpells();
|
||||
for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it)
|
||||
{
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(it->first);
|
||||
|
||||
// these are the spell types that are permanently in effect
|
||||
if (!(spell->mData.mType == ESM::Spell::ST_Ability)
|
||||
&& !(spell->mData.mType == ESM::Spell::ST_Disease)
|
||||
&& !(spell->mData.mType == ESM::Spell::ST_Curse)
|
||||
&& !(spell->mData.mType == ESM::Spell::ST_Blight))
|
||||
continue;
|
||||
const ESM::EffectList& list = spell->mEffects;
|
||||
for (std::vector<ESM::ENAMstruct>::const_iterator effectIt = list.mList.begin();
|
||||
effectIt != list.mList.end(); ++effectIt)
|
||||
{
|
||||
const ESM::MagicEffect* magicEffect =
|
||||
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::MagicEffect>().find(effectIt->mEffectID);
|
||||
MagicEffectInfo effectInfo;
|
||||
effectInfo.mSource = getSpellDisplayName (it->first);
|
||||
effectInfo.mKey = MWMechanics::EffectKey (effectIt->mEffectID);
|
||||
if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill)
|
||||
effectInfo.mKey.mArg = effectIt->mSkill;
|
||||
else if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
|
||||
effectInfo.mKey.mArg = effectIt->mAttribute;
|
||||
// just using the min magnitude here, permanent spells with a random magnitude just wouldn't make any sense
|
||||
effectInfo.mMagnitude = effectIt->mMagnMin;
|
||||
effectInfo.mPermanent = true;
|
||||
|
||||
effects[effectIt->mEffectID].push_back (effectInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// add lasting effect spells/potions etc
|
||||
const MWMechanics::ActiveSpells::TContainer& activeSpells = stats.getActiveSpells().getActiveSpells();
|
||||
for (MWMechanics::ActiveSpells::TContainer::const_iterator it = activeSpells.begin();
|
||||
it != activeSpells.end(); ++it)
|
||||
{
|
||||
const ESM::EffectList& list = getSpellEffectList(it->first);
|
||||
|
||||
float timeScale = MWBase::Environment::get().getWorld()->getTimeScaleFactor();
|
||||
|
||||
for (std::vector<ESM::ENAMstruct>::const_iterator effectIt = list.mList.begin();
|
||||
effectIt != list.mList.end(); ++effectIt)
|
||||
{
|
||||
const ESM::MagicEffect* magicEffect =
|
||||
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::MagicEffect>().find(effectIt->mEffectID);
|
||||
|
||||
MagicEffectInfo effectInfo;
|
||||
effectInfo.mSource = getSpellDisplayName (it->first);
|
||||
effectInfo.mKey = MWMechanics::EffectKey (effectIt->mEffectID);
|
||||
if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill)
|
||||
effectInfo.mKey.mArg = effectIt->mSkill;
|
||||
else if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
|
||||
effectInfo.mKey.mArg = effectIt->mAttribute;
|
||||
effectInfo.mMagnitude = effectIt->mMagnMin + (effectIt->mMagnMax-effectIt->mMagnMin) * it->second.second;
|
||||
effectInfo.mRemainingTime = effectIt->mDuration +
|
||||
(it->second.first - MWBase::Environment::get().getWorld()->getTimeStamp())*3600/timeScale;
|
||||
|
||||
// ingredients need special casing for their magnitude / duration
|
||||
/// \todo duplicated from ActiveSpells, helper function?
|
||||
if (MWBase::Environment::get().getWorld()->getStore().get<ESM::Ingredient>().search (it->first))
|
||||
{
|
||||
effectInfo.mRemainingTime = effectIt->mDuration * it->second.second +
|
||||
(it->second.first - MWBase::Environment::get().getWorld()->getTimeStamp())*3600/timeScale;
|
||||
|
||||
effectInfo.mMagnitude = static_cast<int> (0.05*it->second.second / (0.1 * magicEffect->mData.mBaseCost));
|
||||
}
|
||||
|
||||
|
||||
effects[effectIt->mEffectID].push_back (effectInfo);
|
||||
}
|
||||
}
|
||||
|
||||
parent->setVisible(effects.size() != 0);
|
||||
|
||||
int w=2;
|
||||
if (adjustSize)
|
||||
{
|
||||
int s = effects.size() * 16+4;
|
||||
int diff = parent->getWidth() - s;
|
||||
parent->setSize(s, parent->getHeight());
|
||||
parent->setPosition(parent->getLeft()+diff, parent->getTop());
|
||||
}
|
||||
|
||||
|
||||
for (std::map <int, std::vector<MagicEffectInfo> >::const_iterator it = effects.begin(); it != effects.end(); ++it)
|
||||
{
|
||||
MyGUI::ImageBox* image;
|
||||
if (mWidgetMap.find(it->first) == mWidgetMap.end())
|
||||
image = parent->createWidget<MyGUI::ImageBox>
|
||||
("ImageBox", MyGUI::IntCoord(w,2,16,16), MyGUI::Align::Default);
|
||||
else
|
||||
image = mWidgetMap[it->first];
|
||||
mWidgetMap[it->first] = image;
|
||||
image->setPosition(w,2);
|
||||
image->setVisible(true);
|
||||
|
||||
const ESM::MagicEffect* effect =
|
||||
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::MagicEffect>().find(it->first);
|
||||
|
||||
std::string icon = effect->mIcon;
|
||||
icon[icon.size()-3] = 'd';
|
||||
icon[icon.size()-2] = 'd';
|
||||
icon[icon.size()-1] = 's';
|
||||
icon = "icons\\" + icon;
|
||||
|
||||
image->setImageTexture(icon);
|
||||
w += 16;
|
||||
|
||||
float remainingDuration = 0;
|
||||
|
||||
std::string sourcesDescription;
|
||||
|
||||
const float fadeTime = 5.f;
|
||||
|
||||
for (std::vector<MagicEffectInfo>::const_iterator effectIt = it->second.begin();
|
||||
effectIt != it->second.end(); ++effectIt)
|
||||
{
|
||||
if (effectIt != it->second.begin())
|
||||
sourcesDescription += "\n";
|
||||
|
||||
// if at least one of the effect sources is permanent, the effect will never wear off
|
||||
if (effectIt->mPermanent)
|
||||
remainingDuration = fadeTime;
|
||||
else
|
||||
remainingDuration = std::max(remainingDuration, effectIt->mRemainingTime);
|
||||
|
||||
sourcesDescription += effectIt->mSource;
|
||||
|
||||
if (effect->mData.mFlags & ESM::MagicEffect::TargetSkill)
|
||||
sourcesDescription += " (" +
|
||||
MWBase::Environment::get().getWindowManager()->getGameSettingString(
|
||||
ESM::Skill::sSkillNameIds[effectIt->mKey.mArg], "") + ")";
|
||||
if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
|
||||
sourcesDescription += " (" +
|
||||
MWBase::Environment::get().getWindowManager()->getGameSettingString(
|
||||
ESM::Attribute::sGmstAttributeIds[effectIt->mKey.mArg], "") + ")";
|
||||
|
||||
if (!(effect->mData.mFlags & ESM::MagicEffect::NoMagnitude))
|
||||
{
|
||||
std::string pt = MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", "");
|
||||
std::string pts = MWBase::Environment::get().getWindowManager()->getGameSettingString("spoints", "");
|
||||
|
||||
sourcesDescription += ": " + boost::lexical_cast<std::string>(effectIt->mMagnitude);
|
||||
sourcesDescription += " " + ((effectIt->mMagnitude > 1) ? pts : pt);
|
||||
}
|
||||
}
|
||||
|
||||
std::string name = ESM::MagicEffect::effectIdToString (it->first);
|
||||
|
||||
ToolTipInfo tooltipInfo;
|
||||
tooltipInfo.caption = "#{" + name + "}";
|
||||
tooltipInfo.icon = effect->mIcon;
|
||||
tooltipInfo.text = sourcesDescription;
|
||||
tooltipInfo.imageSize = 16;
|
||||
tooltipInfo.wordWrap = false;
|
||||
|
||||
image->setUserData(tooltipInfo);
|
||||
image->setUserString("ToolTipType", "ToolTipInfo");
|
||||
|
||||
// Fade out during the last 5 seconds
|
||||
image->setAlpha(std::min(remainingDuration/fadeTime, 1.f));
|
||||
}
|
||||
|
||||
// hide inactive effects
|
||||
for (std::map<int, MyGUI::ImageBox*>::iterator it = mWidgetMap.begin(); it != mWidgetMap.end(); ++it)
|
||||
{
|
||||
if (effects.find(it->first) == effects.end())
|
||||
it->second->setVisible(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::string SpellIcons::getSpellDisplayName (const std::string& id)
|
||||
{
|
||||
if (const ESM::Spell *spell =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search (id))
|
||||
return spell->mName;
|
||||
|
||||
if (const ESM::Potion *potion =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Potion>().search (id))
|
||||
return potion->mName;
|
||||
|
||||
if (const ESM::Ingredient *ingredient =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Ingredient>().search (id))
|
||||
return ingredient->mName;
|
||||
|
||||
throw std::runtime_error ("ID " + id + " has no display name");
|
||||
}
|
||||
|
||||
ESM::EffectList SpellIcons::getSpellEffectList (const std::string& id)
|
||||
{
|
||||
if (const ESM::Spell *spell =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search (id))
|
||||
return spell->mEffects;
|
||||
|
||||
if (const ESM::Potion *potion =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Potion>().search (id))
|
||||
return potion->mEffects;
|
||||
|
||||
if (const ESM::Ingredient *ingredient =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Ingredient>().search (id))
|
||||
{
|
||||
const ESM::MagicEffect *magicEffect =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find (
|
||||
ingredient->mData.mEffectID[0]);
|
||||
|
||||
ESM::ENAMstruct effect;
|
||||
effect.mEffectID = ingredient->mData.mEffectID[0];
|
||||
effect.mSkill = ingredient->mData.mSkills[0];
|
||||
effect.mAttribute = ingredient->mData.mAttributes[0];
|
||||
effect.mRange = 0;
|
||||
effect.mArea = 0;
|
||||
effect.mDuration = magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration ? 0 : 1;
|
||||
effect.mMagnMin = 1;
|
||||
effect.mMagnMax = 1;
|
||||
ESM::EffectList result;
|
||||
result.mList.push_back (effect);
|
||||
return result;
|
||||
}
|
||||
throw std::runtime_error("ID " + id + " does not have effects");
|
||||
}
|
||||
|
||||
}
|
47
apps/openmw/mwgui/spellicons.hpp
Normal file
47
apps/openmw/mwgui/spellicons.hpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#ifndef MWGUI_SPELLICONS_H
|
||||
#define MWGUI_SPELLICONS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../mwmechanics/magiceffects.hpp"
|
||||
|
||||
namespace MyGUI
|
||||
{
|
||||
class Widget;
|
||||
class ImageBox;
|
||||
}
|
||||
namespace ESM
|
||||
{
|
||||
struct ENAMstruct;
|
||||
struct EffectList;
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
// information about a single magic effect source as required for display in the tooltip
|
||||
struct MagicEffectInfo
|
||||
{
|
||||
MagicEffectInfo() : mPermanent(false) {}
|
||||
std::string mSource; // display name for effect source (e.g. potion name)
|
||||
MWMechanics::EffectKey mKey;
|
||||
int mMagnitude;
|
||||
float mRemainingTime;
|
||||
bool mPermanent; // the effect is permanent
|
||||
};
|
||||
|
||||
class SpellIcons
|
||||
{
|
||||
public:
|
||||
void updateWidgets(MyGUI::Widget* parent, bool adjustSize);
|
||||
|
||||
private:
|
||||
std::string getSpellDisplayName (const std::string& id);
|
||||
ESM::EffectList getSpellEffectList (const std::string& id);
|
||||
|
||||
std::map<int, MyGUI::ImageBox*> mWidgetMap;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -19,6 +19,7 @@
|
|||
#include "../mwmechanics/creaturestats.hpp"
|
||||
#include "../mwmechanics/spellsuccess.hpp"
|
||||
|
||||
#include "spellicons.hpp"
|
||||
#include "inventorywindow.hpp"
|
||||
#include "confirmationdialog.hpp"
|
||||
|
||||
|
@ -51,6 +52,8 @@ namespace MWGui
|
|||
, mHeight(0)
|
||||
, mWidth(0)
|
||||
{
|
||||
mSpellIcons = new SpellIcons();
|
||||
|
||||
getWidget(mSpellView, "SpellView");
|
||||
getWidget(mEffectBox, "EffectsBox");
|
||||
|
||||
|
@ -61,6 +64,11 @@ namespace MWGui
|
|||
mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord += MyGUI::newDelegate(this, &SpellWindow::onWindowResize);
|
||||
}
|
||||
|
||||
SpellWindow::~SpellWindow()
|
||||
{
|
||||
delete mSpellIcons;
|
||||
}
|
||||
|
||||
void SpellWindow::onPinToggled()
|
||||
{
|
||||
mWindowManager.setSpellVisibility(!mPinned);
|
||||
|
@ -73,6 +81,8 @@ namespace MWGui
|
|||
|
||||
void SpellWindow::updateSpells()
|
||||
{
|
||||
mSpellIcons->updateWidgets(mEffectBox, false);
|
||||
|
||||
const int spellHeight = 18;
|
||||
|
||||
mHeight = 0;
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
|
||||
namespace MWGui
|
||||
{
|
||||
class SpellIcons;
|
||||
|
||||
class SpellWindow : public WindowPinnableBase
|
||||
{
|
||||
public:
|
||||
SpellWindow(MWBase::WindowManager& parWindowManager);
|
||||
virtual ~SpellWindow();
|
||||
|
||||
void updateSpells();
|
||||
|
||||
|
@ -33,6 +36,8 @@ namespace MWGui
|
|||
|
||||
virtual void onPinToggled();
|
||||
virtual void open();
|
||||
|
||||
SpellIcons* mSpellIcons;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ StatsWindow::StatsWindow (MWBase::WindowManager& parWindowManager)
|
|||
for (int i = 0; i < ESM::Skill::Length; ++i)
|
||||
{
|
||||
mSkillValues.insert(std::pair<int, MWMechanics::Stat<float> >(i, MWMechanics::Stat<float>()));
|
||||
mSkillWidgetMap.insert(std::pair<int, MyGUI::TextBox*>(i, (MyGUI::TextBox*)nullptr));
|
||||
mSkillWidgetMap.insert(std::pair<int, MyGUI::TextBox*>(i, (MyGUI::TextBox*)NULL));
|
||||
}
|
||||
|
||||
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);
|
||||
|
@ -419,7 +419,7 @@ void StatsWindow::updateSkillArea()
|
|||
{
|
||||
mChanged = false;
|
||||
|
||||
for (std::vector<MyGUI::WidgetPtr>::iterator it = mSkillWidgets.begin(); it != mSkillWidgets.end(); ++it)
|
||||
for (std::vector<MyGUI::Widget*>::iterator it = mSkillWidgets.begin(); it != mSkillWidgets.end(); ++it)
|
||||
{
|
||||
MyGUI::Gui::getInstance().destroyWidget(*it);
|
||||
}
|
||||
|
|
|
@ -67,11 +67,11 @@ namespace MWGui
|
|||
SkillList mMajorSkills, mMinorSkills, mMiscSkills;
|
||||
std::map<int, MWMechanics::Stat<float> > mSkillValues;
|
||||
std::map<int, MyGUI::TextBox*> mSkillWidgetMap;
|
||||
std::map<std::string, MyGUI::WidgetPtr> mFactionWidgetMap;
|
||||
std::map<std::string, MyGUI::Widget*> mFactionWidgetMap;
|
||||
FactionList mFactions; ///< Stores a list of factions and the current rank
|
||||
std::string mBirthSignId;
|
||||
int mReputation, mBounty;
|
||||
std::vector<MyGUI::WidgetPtr> mSkillWidgets; //< Skills and other information
|
||||
std::vector<MyGUI::Widget*> mSkillWidgets; //< Skills and other information
|
||||
std::set<std::string> mExpelled;
|
||||
|
||||
bool mChanged;
|
||||
|
|
|
@ -13,7 +13,7 @@ TextInputDialog::TextInputDialog(MWBase::WindowManager& parWindowManager)
|
|||
getWidget(mTextEdit, "TextEdit");
|
||||
mTextEdit->eventEditSelectAccept += newDelegate(this, &TextInputDialog::onTextAccepted);
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TextInputDialog::onOkClicked);
|
||||
|
||||
|
@ -23,7 +23,7 @@ TextInputDialog::TextInputDialog(MWBase::WindowManager& parWindowManager)
|
|||
|
||||
void TextInputDialog::setNextButtonShow(bool shown)
|
||||
{
|
||||
MyGUI::ButtonPtr okButton;
|
||||
MyGUI::Button* okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
|
||||
if (shown)
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace MWGui
|
|||
void onTextAccepted(MyGUI::Edit* _sender);
|
||||
|
||||
private:
|
||||
MyGUI::EditPtr mTextEdit;
|
||||
MyGUI::EditBox* mTextEdit;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -127,9 +127,7 @@ void ToolTips::onFrame(float frameDuration)
|
|||
|
||||
Widget* focus = InputManager::getInstance().getMouseFocusWidget();
|
||||
if (focus == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IntSize tooltipSize;
|
||||
|
||||
|
@ -168,6 +166,10 @@ void ToolTips::onFrame(float frameDuration)
|
|||
mFocusObject = *focus->getUserData<MWWorld::Ptr>();
|
||||
tooltipSize = getToolTipViaPtr(false);
|
||||
}
|
||||
else if (type == "ToolTipInfo")
|
||||
{
|
||||
tooltipSize = createToolTip(*focus->getUserData<MWGui::ToolTipInfo>());
|
||||
}
|
||||
else if (type == "AvatarItemSelection")
|
||||
{
|
||||
MyGUI::IntCoord avatarPos = mWindowManager->getInventoryWindow ()->getAvatarScreenCoord ();
|
||||
|
@ -363,7 +365,7 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
|
|||
|
||||
std::string caption = info.caption;
|
||||
std::string image = info.icon;
|
||||
int imageSize = (image != "") ? 32 : 0;
|
||||
int imageSize = (image != "") ? info.imageSize : 0;
|
||||
std::string text = info.text;
|
||||
|
||||
// remove the first newline (easier this way)
|
||||
|
@ -403,7 +405,7 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
|
|||
|
||||
EditBox* captionWidget = mDynamicToolTipBox->createWidget<EditBox>("NormalText", IntCoord(0, 0, 300, 300), Align::Left | Align::Top, "ToolTipCaption");
|
||||
captionWidget->setProperty("Static", "true");
|
||||
captionWidget->setCaption(caption);
|
||||
captionWidget->setCaptionWithReplacing(caption);
|
||||
IntSize captionSize = captionWidget->getTextSize();
|
||||
|
||||
int captionHeight = std::max(caption != "" ? captionSize.height : 0, imageSize);
|
||||
|
@ -411,7 +413,7 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
|
|||
EditBox* textWidget = mDynamicToolTipBox->createWidget<EditBox>("SandText", IntCoord(0, captionHeight+imageCaptionVPadding, 300, 300-captionHeight-imageCaptionVPadding), Align::Stretch, "ToolTipText");
|
||||
textWidget->setProperty("Static", "true");
|
||||
textWidget->setProperty("MultiLine", "true");
|
||||
textWidget->setProperty("WordWrap", "true");
|
||||
textWidget->setProperty("WordWrap", info.wordWrap ? "true" : "false");
|
||||
textWidget->setCaptionWithReplacing(text);
|
||||
textWidget->setTextAlign(Align::HCenter | Align::Top);
|
||||
IntSize textSize = textWidget->getTextSize();
|
||||
|
@ -439,7 +441,7 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
|
|||
effectsWidget->setWindowManager(mWindowManager);
|
||||
effectsWidget->setEffectList(info.effects);
|
||||
|
||||
std::vector<MyGUI::WidgetPtr> effectItems;
|
||||
std::vector<MyGUI::Widget*> effectItems;
|
||||
effectsWidget->createEffectWidgets(effectItems, effectArea, coord, true, info.isPotion ? Widgets::MWEffectList::EF_NoTarget : 0);
|
||||
totalSize.height += coord.top-6;
|
||||
totalSize.width = std::max(totalSize.width, coord.width);
|
||||
|
@ -459,7 +461,7 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
|
|||
enchantWidget->setWindowManager(mWindowManager);
|
||||
enchantWidget->setEffectList(Widgets::MWEffectList::effectListFromESM(&enchant->mEffects));
|
||||
|
||||
std::vector<MyGUI::WidgetPtr> enchantEffectItems;
|
||||
std::vector<MyGUI::Widget*> enchantEffectItems;
|
||||
int flag = (enchant->mData.mType == ESM::Enchantment::ConstantEffect) ? Widgets::MWEffectList::EF_Constant : 0;
|
||||
enchantWidget->createEffectWidgets(enchantEffectItems, enchantArea, coord, true, flag);
|
||||
totalSize.height += coord.top-6;
|
||||
|
|
|
@ -15,11 +15,14 @@ namespace MWGui
|
|||
public:
|
||||
ToolTipInfo()
|
||||
: isPotion(false)
|
||||
, imageSize(32)
|
||||
, wordWrap(true)
|
||||
{}
|
||||
|
||||
std::string caption;
|
||||
std::string text;
|
||||
std::string icon;
|
||||
int imageSize;
|
||||
|
||||
// enchantment (for cloth, armor, weapons)
|
||||
std::string enchant;
|
||||
|
@ -28,6 +31,7 @@ namespace MWGui
|
|||
Widgets::SpellEffectList effects;
|
||||
|
||||
bool isPotion; // potions do not show target in the tooltip
|
||||
bool wordWrap;
|
||||
};
|
||||
|
||||
class ToolTips : public OEngine::GUI::Layout
|
||||
|
|
|
@ -31,6 +31,9 @@ namespace MWGui
|
|||
, mBalanceButtonsState(BBS_None)
|
||||
, mBalanceChangePause(0.0)
|
||||
{
|
||||
// items the NPC is wearing should not be for trade
|
||||
mDisplayEquippedItems = true;
|
||||
|
||||
MyGUI::ScrollView* itemView;
|
||||
MyGUI::Widget* containerWidget;
|
||||
getWidget(containerWidget, "Items");
|
||||
|
@ -64,6 +67,7 @@ namespace MWGui
|
|||
|
||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onCancelButtonClicked);
|
||||
mOfferButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onOfferButtonClicked);
|
||||
mMaxSaleButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onMaxSaleButtonClicked);
|
||||
mIncreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onIncreaseButtonPressed);
|
||||
mIncreaseButton->eventMouseButtonReleased += MyGUI::newDelegate(this, &TradeWindow::onBalanceButtonReleased);
|
||||
mDecreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonPressed);
|
||||
|
@ -191,21 +195,7 @@ namespace MWGui
|
|||
}
|
||||
|
||||
// check if the merchant can afford this
|
||||
int merchantgold;
|
||||
if (mPtr.getTypeName() == typeid(ESM::NPC).name())
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>();
|
||||
if (ref->mBase->mNpdt52.mGold == -10)
|
||||
merchantgold = ref->mBase->mNpdt12.mGold;
|
||||
else
|
||||
merchantgold = ref->mBase->mNpdt52.mGold;
|
||||
}
|
||||
else // ESM::Creature
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>();
|
||||
merchantgold = ref->mBase->mData.mGold;
|
||||
}
|
||||
if (mCurrentBalance > 0 && merchantgold < mCurrentBalance)
|
||||
if (mCurrentBalance > 0 && getMerchantGold() < mCurrentBalance)
|
||||
{
|
||||
// user notification
|
||||
MWBase::Environment::get().getWindowManager()->
|
||||
|
@ -293,6 +283,12 @@ namespace MWGui
|
|||
mWindowManager.removeGuiMode(GM_Barter);
|
||||
}
|
||||
|
||||
void TradeWindow::onMaxSaleButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
mCurrentBalance = getMerchantGold();
|
||||
updateLabels();
|
||||
}
|
||||
|
||||
void TradeWindow::onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
||||
{
|
||||
mBalanceButtonsState = BBS_Increase;
|
||||
|
@ -341,46 +337,7 @@ namespace MWGui
|
|||
mTotalBalance->setCaption(boost::lexical_cast<std::string>(-mCurrentBalance));
|
||||
}
|
||||
|
||||
int merchantgold;
|
||||
if (mPtr.getTypeName() == typeid(ESM::NPC).name())
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>();
|
||||
if (ref->mBase->mNpdt52.mGold == -10)
|
||||
merchantgold = ref->mBase->mNpdt12.mGold;
|
||||
else
|
||||
merchantgold = ref->mBase->mNpdt52.mGold;
|
||||
}
|
||||
else // ESM::Creature
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>();
|
||||
merchantgold = ref->mBase->mData.mGold;
|
||||
}
|
||||
|
||||
mMerchantGold->setCaptionWithReplacing("#{sSellerGold} " + boost::lexical_cast<std::string>(merchantgold));
|
||||
}
|
||||
|
||||
std::vector<MWWorld::Ptr> TradeWindow::getEquippedItems()
|
||||
{
|
||||
std::vector<MWWorld::Ptr> items;
|
||||
|
||||
if (mPtr.getTypeName() == typeid(ESM::Creature).name())
|
||||
{
|
||||
// creatures don't have equipment slots.
|
||||
return items;
|
||||
}
|
||||
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
|
||||
|
||||
for (int slot=0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
||||
{
|
||||
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
|
||||
if (it != invStore.end())
|
||||
{
|
||||
items.push_back(*it);
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
mMerchantGold->setCaptionWithReplacing("#{sSellerGold} " + boost::lexical_cast<std::string>(getMerchantGold()));
|
||||
}
|
||||
|
||||
bool TradeWindow::npcAcceptsItem(MWWorld::Ptr item)
|
||||
|
@ -468,4 +425,25 @@ namespace MWGui
|
|||
mWindowManager.removeGuiMode(GM_Barter);
|
||||
mWindowManager.removeGuiMode(GM_Dialogue);
|
||||
}
|
||||
|
||||
int TradeWindow::getMerchantGold()
|
||||
{
|
||||
int merchantGold;
|
||||
|
||||
if (mPtr.getTypeName() == typeid(ESM::NPC).name())
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>();
|
||||
if (ref->mBase->mNpdt52.mGold == -10)
|
||||
merchantGold = ref->mBase->mNpdt12.mGold;
|
||||
else
|
||||
merchantGold = ref->mBase->mNpdt52.mGold;
|
||||
}
|
||||
else // ESM::Creature
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>();
|
||||
merchantGold = ref->mBase->mData.mGold;
|
||||
}
|
||||
|
||||
return merchantGold;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ namespace MWGui
|
|||
void onFilterChanged(MyGUI::Widget* _sender);
|
||||
void onOfferButtonClicked(MyGUI::Widget* _sender);
|
||||
void onCancelButtonClicked(MyGUI::Widget* _sender);
|
||||
void onMaxSaleButtonClicked(MyGUI::Widget* _sender);
|
||||
void onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
||||
void onDecreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
||||
void onBalanceButtonReleased(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
||||
|
@ -81,10 +82,6 @@ namespace MWGui
|
|||
void onIncreaseButtonTriggered();
|
||||
void onDecreaseButtonTriggered();
|
||||
|
||||
// don't show items that the NPC has equipped in his trade-window.
|
||||
virtual bool ignoreEquippedItems() { return true; }
|
||||
virtual std::vector<MWWorld::Ptr> getEquippedItems();
|
||||
|
||||
virtual bool isTrading() { return true; }
|
||||
virtual bool isTradeWindow() { return true; }
|
||||
|
||||
|
@ -93,6 +90,9 @@ namespace MWGui
|
|||
void updateLabels();
|
||||
|
||||
virtual void onReferenceUnavailable();
|
||||
|
||||
private:
|
||||
int getMerchantGold();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <MyGUI_ProgressBar.h>
|
||||
#include <MyGUI_ImageBox.h>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
@ -31,10 +34,10 @@ void MWGui::Widgets::fixTexturePath(std::string &path)
|
|||
/* MWSkill */
|
||||
|
||||
MWSkill::MWSkill()
|
||||
: mManager(nullptr)
|
||||
: mManager(NULL)
|
||||
, mSkillId(ESM::Skill::Length)
|
||||
, mSkillNameWidget(nullptr)
|
||||
, mSkillValueWidget(nullptr)
|
||||
, mSkillNameWidget(NULL)
|
||||
, mSkillValueWidget(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -103,7 +106,7 @@ void MWSkill::initialiseOverride()
|
|||
assignWidget(mSkillNameWidget, "StatName");
|
||||
assignWidget(mSkillValueWidget, "StatValue");
|
||||
|
||||
MyGUI::ButtonPtr button;
|
||||
MyGUI::Button* button;
|
||||
assignWidget(button, "StatNameButton");
|
||||
if (button)
|
||||
{
|
||||
|
@ -123,10 +126,10 @@ void MWSkill::initialiseOverride()
|
|||
/* MWAttribute */
|
||||
|
||||
MWAttribute::MWAttribute()
|
||||
: mManager(nullptr)
|
||||
: mManager(NULL)
|
||||
, mId(-1)
|
||||
, mAttributeNameWidget(nullptr)
|
||||
, mAttributeValueWidget(nullptr)
|
||||
, mAttributeNameWidget(NULL)
|
||||
, mAttributeValueWidget(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -195,7 +198,7 @@ void MWAttribute::initialiseOverride()
|
|||
assignWidget(mAttributeNameWidget, "StatName");
|
||||
assignWidget(mAttributeValueWidget, "StatValue");
|
||||
|
||||
MyGUI::ButtonPtr button;
|
||||
MyGUI::Button* button;
|
||||
assignWidget(button, "StatNameButton");
|
||||
if (button)
|
||||
{
|
||||
|
@ -215,8 +218,8 @@ void MWAttribute::initialiseOverride()
|
|||
/* MWSpell */
|
||||
|
||||
MWSpell::MWSpell()
|
||||
: mWindowManager(nullptr)
|
||||
, mSpellNameWidget(nullptr)
|
||||
: mWindowManager(NULL)
|
||||
, mSpellNameWidget(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -226,7 +229,7 @@ void MWSpell::setSpellId(const std::string &spellId)
|
|||
updateWidgets();
|
||||
}
|
||||
|
||||
void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags)
|
||||
void MWSpell::createEffectWidgets(std::vector<MyGUI::Widget*> &effects, MyGUI::Widget* creator, MyGUI::IntCoord &coord, int flags)
|
||||
{
|
||||
const MWWorld::ESMStore &store =
|
||||
MWBase::Environment::get().getWorld()->getStore();
|
||||
|
@ -234,7 +237,7 @@ void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI:
|
|||
const ESM::Spell *spell = store.get<ESM::Spell>().search(mId);
|
||||
MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found");
|
||||
|
||||
MWSpellEffectPtr effect = nullptr;
|
||||
MWSpellEffectPtr effect = NULL;
|
||||
std::vector<ESM::ENAMstruct>::const_iterator end = spell->mEffects.mList.end();
|
||||
for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->mEffects.mList.begin(); it != end; ++it)
|
||||
{
|
||||
|
@ -286,7 +289,7 @@ MWSpell::~MWSpell()
|
|||
/* MWEffectList */
|
||||
|
||||
MWEffectList::MWEffectList()
|
||||
: mWindowManager(nullptr)
|
||||
: mWindowManager(NULL)
|
||||
, mEffectList(0)
|
||||
{
|
||||
}
|
||||
|
@ -297,11 +300,11 @@ void MWEffectList::setEffectList(const SpellEffectList& list)
|
|||
updateWidgets();
|
||||
}
|
||||
|
||||
void MWEffectList::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, bool center, int flags)
|
||||
void MWEffectList::createEffectWidgets(std::vector<MyGUI::Widget*> &effects, MyGUI::Widget* creator, MyGUI::IntCoord &coord, bool center, int flags)
|
||||
{
|
||||
// We don't know the width of all the elements beforehand, so we do it in
|
||||
// 2 steps: first, create all widgets and check their width....
|
||||
MWSpellEffectPtr effect = nullptr;
|
||||
MWSpellEffectPtr effect = NULL;
|
||||
int maxwidth = coord.width;
|
||||
|
||||
for (SpellEffectList::iterator it=mEffectList.begin();
|
||||
|
@ -320,7 +323,7 @@ void MWEffectList::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, M
|
|||
}
|
||||
|
||||
// ... then adjust the size for all widgets
|
||||
for (std::vector<MyGUI::WidgetPtr>::iterator it = effects.begin(); it != effects.end(); ++it)
|
||||
for (std::vector<MyGUI::Widget*>::iterator it = effects.begin(); it != effects.end(); ++it)
|
||||
{
|
||||
effect = static_cast<MWSpellEffectPtr>(*it);
|
||||
bool needcenter = center && (maxwidth > effect->getRequestedWidth());
|
||||
|
@ -375,9 +378,9 @@ SpellEffectList MWEffectList::effectListFromESM(const ESM::EffectList* effects)
|
|||
/* MWSpellEffect */
|
||||
|
||||
MWSpellEffect::MWSpellEffect()
|
||||
: mWindowManager(nullptr)
|
||||
, mImageWidget(nullptr)
|
||||
, mTextWidget(nullptr)
|
||||
: mWindowManager(NULL)
|
||||
, mImageWidget(NULL)
|
||||
, mTextWidget(NULL)
|
||||
, mRequestedWidth(0)
|
||||
{
|
||||
}
|
||||
|
@ -421,17 +424,7 @@ void MWSpellEffect::updateWidgets()
|
|||
}
|
||||
if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
|
||||
{
|
||||
static const char *attributes[8] = {
|
||||
"sAttributeStrength",
|
||||
"sAttributeIntelligence",
|
||||
"sAttributeWillpower",
|
||||
"sAttributeAgility",
|
||||
"sAttributeSpeed",
|
||||
"sAttributeEndurance",
|
||||
"sAttributePersonality",
|
||||
"sAttributeLuck"
|
||||
};
|
||||
spellLine += " " + mWindowManager->getGameSettingString(attributes[mEffectParams.mAttribute], "");
|
||||
spellLine += " " + mWindowManager->getGameSettingString(ESM::Attribute::sGmstAttributeIds[mEffectParams.mAttribute], "");
|
||||
}
|
||||
|
||||
if ((mEffectParams.mMagnMin >= 0 || mEffectParams.mMagnMax >= 0) && !(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude))
|
||||
|
@ -495,9 +488,9 @@ void MWSpellEffect::initialiseOverride()
|
|||
MWDynamicStat::MWDynamicStat()
|
||||
: mValue(0)
|
||||
, mMax(1)
|
||||
, mTextWidget(nullptr)
|
||||
, mBarWidget(nullptr)
|
||||
, mBarTextWidget(nullptr)
|
||||
, mTextWidget(NULL)
|
||||
, mBarWidget(NULL)
|
||||
, mBarTextWidget(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,17 @@
|
|||
#define MWGUI_WIDGETS_H
|
||||
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
|
||||
#include <MyGUI.h>
|
||||
|
||||
#include "../mwmechanics/stat.hpp"
|
||||
|
||||
#include <MyGUI_Widget.h>
|
||||
#include <MyGUI_TextBox.h>
|
||||
#include <MyGUI_Button.h>
|
||||
|
||||
namespace MyGUI
|
||||
{
|
||||
class ImageBox;
|
||||
}
|
||||
|
||||
namespace MWBase
|
||||
{
|
||||
class WindowManager;
|
||||
|
@ -118,7 +124,8 @@ namespace MWGui
|
|||
MWBase::WindowManager *mManager;
|
||||
ESM::Skill::SkillEnum mSkillId;
|
||||
SkillValue mValue;
|
||||
MyGUI::WidgetPtr mSkillNameWidget, mSkillValueWidget;
|
||||
MyGUI::Widget* mSkillNameWidget;
|
||||
MyGUI::Widget* mSkillValueWidget;
|
||||
};
|
||||
typedef MWSkill* MWSkillPtr;
|
||||
|
||||
|
@ -160,7 +167,8 @@ namespace MWGui
|
|||
MWBase::WindowManager *mManager;
|
||||
int mId;
|
||||
AttributeValue mValue;
|
||||
MyGUI::WidgetPtr mAttributeNameWidget, mAttributeValueWidget;
|
||||
MyGUI::Widget* mAttributeNameWidget;
|
||||
MyGUI::Widget* mAttributeValueWidget;
|
||||
};
|
||||
typedef MWAttribute* MWAttributePtr;
|
||||
|
||||
|
@ -186,7 +194,7 @@ namespace MWGui
|
|||
* @param spell category, if this is 0, this means the spell effects are permanent and won't display e.g. duration
|
||||
* @param various flags, see MWEffectList::EffectFlags
|
||||
*/
|
||||
void createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags);
|
||||
void createEffectWidgets(std::vector<MyGUI::Widget*> &effects, MyGUI::Widget* creator, MyGUI::IntCoord &coord, int flags);
|
||||
|
||||
const std::string &getSpellId() const { return mId; }
|
||||
|
||||
|
@ -230,7 +238,7 @@ namespace MWGui
|
|||
* @param center the effect widgets horizontally
|
||||
* @param various flags, see MWEffectList::EffectFlags
|
||||
*/
|
||||
void createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, bool center, int flags);
|
||||
void createEffectWidgets(std::vector<MyGUI::Widget*> &effects, MyGUI::Widget* creator, MyGUI::IntCoord &coord, bool center, int flags);
|
||||
|
||||
protected:
|
||||
virtual ~MWEffectList();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "MyGUI_UString.h"
|
||||
#include <MyGUI_UString.h>
|
||||
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
#include <openengine/gui/manager.hpp>
|
||||
|
@ -54,14 +54,16 @@
|
|||
#include "imagebutton.hpp"
|
||||
#include "exposedwindow.hpp"
|
||||
#include "cursor.hpp"
|
||||
#include "spellicons.hpp"
|
||||
|
||||
using namespace MWGui;
|
||||
|
||||
WindowManager::WindowManager(
|
||||
const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre,
|
||||
const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *ogre,
|
||||
const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts,
|
||||
Translation::Storage& translationDataStorage)
|
||||
: mGuiManager(NULL)
|
||||
, mRendering(ogre)
|
||||
, mHud(NULL)
|
||||
, mMap(NULL)
|
||||
, mMenu(NULL)
|
||||
|
@ -112,7 +114,7 @@ WindowManager::WindowManager(
|
|||
, mTranslationDataStorage (translationDataStorage)
|
||||
{
|
||||
// Set up the GUI system
|
||||
mGuiManager = new OEngine::GUI::MyGUIManager(mOgre->getWindow(), mOgre->getScene(), false, logpath);
|
||||
mGuiManager = new OEngine::GUI::MyGUIManager(mRendering->getWindow(), mRendering->getScene(), false, logpath);
|
||||
mGui = mGuiManager->getGui();
|
||||
|
||||
//Register own widgets with MyGUI
|
||||
|
@ -177,15 +179,14 @@ WindowManager::WindowManager(
|
|||
mEnchantingDialog = new EnchantingDialog(*this);
|
||||
mTrainingWindow = new TrainingWindow(*this);
|
||||
|
||||
mLoadingScreen = new LoadingScreen(mOgre->getScene (), mOgre->getWindow (), *this);
|
||||
mLoadingScreen = new LoadingScreen(mRendering->getScene (), mRendering->getWindow (), *this);
|
||||
mLoadingScreen->onResChange (w,h);
|
||||
|
||||
mInputBlocker = mGui->createWidget<MyGUI::Widget>("",0,0,w,h,MyGUI::Align::Default,"Windows","");
|
||||
|
||||
mCursor = new Cursor();
|
||||
|
||||
// The HUD is always on
|
||||
mHud->setVisible(true);
|
||||
mHud->setVisible(mHudEnabled);
|
||||
|
||||
mCharGen = new CharacterCreation(this);
|
||||
|
||||
|
@ -270,6 +271,8 @@ void WindowManager::update()
|
|||
mHud->setTriangleCount(mTriangleCount);
|
||||
mHud->setBatchCount(mBatchCount);
|
||||
|
||||
mHud->update();
|
||||
|
||||
mCursor->update();
|
||||
}
|
||||
|
||||
|
@ -299,7 +302,7 @@ void WindowManager::updateVisible()
|
|||
mEnchantingDialog->setVisible(false);
|
||||
mTrainingWindow->setVisible(false);
|
||||
|
||||
mHud->setVisible(true);
|
||||
mHud->setVisible(mHudEnabled);
|
||||
|
||||
// Mouse is visible whenever we're not in game mode
|
||||
mCursor->setVisible(isGuiMode());
|
||||
|
@ -584,7 +587,7 @@ void WindowManager::messageBox (const std::string& message, const std::vector<st
|
|||
else
|
||||
mMessageBoxManager->createMessageBox(message);
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
mMessageBoxManager->createInteractiveMessageBox(message, buttons);
|
||||
|
@ -607,8 +610,9 @@ std::string WindowManager::getGameSettingString(const std::string &id, const std
|
|||
const ESM::GameSetting *setting =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().search(id);
|
||||
|
||||
if (setting && setting->mType == ESM::VT_String)
|
||||
return setting->getString();
|
||||
if (setting && setting->mValue.getType()==ESM::VT_String)
|
||||
return setting->mValue.getString();
|
||||
|
||||
return default_;
|
||||
}
|
||||
|
||||
|
@ -789,8 +793,8 @@ void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _r
|
|||
const ESM::GameSetting *setting =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(tag);
|
||||
|
||||
if (setting && setting->mType == ESM::VT_String)
|
||||
_result = setting->getString();
|
||||
if (setting && setting->mValue.getType()==ESM::VT_String)
|
||||
_result = setting->mValue.getString();
|
||||
else
|
||||
_result = tag;
|
||||
}
|
||||
|
@ -802,6 +806,7 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector
|
|||
mToolTips->setDelay(Settings::Manager::getFloat("tooltip delay", "GUI"));
|
||||
|
||||
bool changeRes = false;
|
||||
bool windowRecreated = false;
|
||||
for (Settings::CategorySettingVector::const_iterator it = changed.begin();
|
||||
it != changed.end(); ++it)
|
||||
{
|
||||
|
@ -811,6 +816,8 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector
|
|||
{
|
||||
changeRes = true;
|
||||
}
|
||||
else if (it->first == "Video" && it->second == "vsync")
|
||||
windowRecreated = true;
|
||||
else if (it->first == "HUD" && it->second == "crosshair")
|
||||
mCrosshairEnabled = Settings::Manager::getBool ("crosshair", "HUD");
|
||||
else if (it->first == "GUI" && it->second == "subtitles")
|
||||
|
@ -834,6 +841,11 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector
|
|||
mDragAndDrop->mDragAndDropWidget->setSize(MyGUI::IntSize(x, y));
|
||||
mInputBlocker->setSize(MyGUI::IntSize(x,y));
|
||||
}
|
||||
if (windowRecreated)
|
||||
{
|
||||
mGuiManager->updateWindow (mRendering->getWindow ());
|
||||
mLoadingScreen->updateWindow (mRendering->getWindow ());
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManager::pushGuiMode(GuiMode mode)
|
||||
|
@ -1050,7 +1062,6 @@ void WindowManager::notifyInputActionBound ()
|
|||
allowMouse();
|
||||
}
|
||||
|
||||
|
||||
void WindowManager::showCrosshair (bool show)
|
||||
{
|
||||
mHud->setCrosshairVisible (show && mCrosshairEnabled);
|
||||
|
@ -1116,3 +1127,8 @@ const Translation::Storage& WindowManager::getTranslationDataStorage() const
|
|||
{
|
||||
return mTranslationDataStorage;
|
||||
}
|
||||
|
||||
void WindowManager::changePointer(const std::string &name)
|
||||
{
|
||||
mCursor->onCursorChange(name);
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ namespace MWGui
|
|||
class EnchantingDialog;
|
||||
class TrainingWindow;
|
||||
class Cursor;
|
||||
class SpellIcons;
|
||||
|
||||
class WindowManager : public MWBase::WindowManager
|
||||
{
|
||||
|
@ -227,10 +228,13 @@ namespace MWGui
|
|||
virtual void startEnchanting(MWWorld::Ptr actor);
|
||||
virtual void startTraining(MWWorld::Ptr actor);
|
||||
|
||||
virtual void changePointer (const std::string& name);
|
||||
|
||||
virtual const Translation::Storage& getTranslationDataStorage() const;
|
||||
|
||||
private:
|
||||
OEngine::GUI::MyGUIManager *mGuiManager;
|
||||
OEngine::Render::OgreRenderer *mRendering;
|
||||
HUD *mHud;
|
||||
MapWindow *mMap;
|
||||
MainMenu *mMenu;
|
||||
|
|
|
@ -42,9 +42,11 @@ namespace MWInput
|
|||
, mMouseX(ogre.getWindow()->getWidth ()/2.f)
|
||||
, mMouseY(ogre.getWindow()->getHeight ()/2.f)
|
||||
, mMouseWheel(0)
|
||||
, mUserFile(userFile)
|
||||
, mDragDrop(false)
|
||||
, mGuiCursorEnabled(false)
|
||||
, mDebug(debug)
|
||||
, mUserFile(userFile)
|
||||
, mUserFileExists(userFileExists)
|
||||
, mInvertY (Settings::Manager::getBool("invert y axis", "Input"))
|
||||
, mCameraSensitivity (Settings::Manager::getFloat("camera sensitivity", "Input"))
|
||||
, mUISensitivity (Settings::Manager::getFloat("ui sensitivity", "Input"))
|
||||
|
@ -54,7 +56,7 @@ namespace MWInput
|
|||
, mTimeIdle(0.f)
|
||||
, mOverencumberedMessageDelay(0.f)
|
||||
{
|
||||
Ogre::RenderWindow* window = ogre.getWindow ();
|
||||
Ogre::RenderWindow* window = mOgre.getWindow ();
|
||||
size_t windowHnd;
|
||||
|
||||
resetIdleTime();
|
||||
|
@ -69,7 +71,7 @@ namespace MWInput
|
|||
|
||||
// Set non-exclusive mouse and keyboard input if the user requested
|
||||
// it.
|
||||
if (debug)
|
||||
if (mDebug)
|
||||
{
|
||||
#if defined OIS_WIN32_PLATFORM
|
||||
pl.insert(std::make_pair(std::string("w32_mouse"),
|
||||
|
@ -116,7 +118,7 @@ namespace MWInput
|
|||
|
||||
MyGUI::InputManager::getInstance().injectMouseMove(mMouseX, mMouseY, mMouse->getMouseState ().Z.abs);
|
||||
|
||||
std::string file = userFileExists ? userFile : "";
|
||||
std::string file = mUserFileExists ? mUserFile : "";
|
||||
mInputCtrl = new ICS::InputControlSystem(file, true, this, NULL, A_Last);
|
||||
|
||||
loadKeyDefaults();
|
||||
|
@ -191,9 +193,6 @@ namespace MWInput
|
|||
case A_AutoMove:
|
||||
toggleAutoMove ();
|
||||
break;
|
||||
case A_ToggleSneak:
|
||||
/// \todo implement
|
||||
break;
|
||||
case A_ToggleWalk:
|
||||
toggleWalking ();
|
||||
break;
|
||||
|
@ -242,7 +241,7 @@ namespace MWInput
|
|||
case A_ToggleHUD:
|
||||
mWindows.toggleHud();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -306,13 +305,13 @@ namespace MWInput
|
|||
else
|
||||
mPlayer.setForwardBackward (0);
|
||||
|
||||
mPlayer.setSneak(actionIsActive(A_Sneak));
|
||||
|
||||
if (actionIsActive(A_Jump) && mControlSwitch["playerjumping"])
|
||||
{
|
||||
mPlayer.setUpDown (1);
|
||||
triedToMove = true;
|
||||
}
|
||||
else if (actionIsActive(A_Crouch))
|
||||
mPlayer.setUpDown (-1);
|
||||
else
|
||||
mPlayer.setUpDown (0);
|
||||
|
||||
|
@ -362,7 +361,7 @@ namespace MWInput
|
|||
actionIsActive(A_MoveLeft) ||
|
||||
actionIsActive(A_MoveRight) ||
|
||||
actionIsActive(A_Jump) ||
|
||||
actionIsActive(A_Crouch) ||
|
||||
actionIsActive(A_Sneak) ||
|
||||
actionIsActive(A_TogglePOV))
|
||||
{
|
||||
resetIdleTime();
|
||||
|
@ -549,6 +548,9 @@ namespace MWInput
|
|||
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
world->rotateObject(world->getPlayer().getPlayer(), -y, 0.f, x, true);
|
||||
|
||||
if (arg.state.Z.rel)
|
||||
MWBase::Environment::get().getWorld()->changeVanityModeScale(arg.state.Z.rel);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -747,7 +749,7 @@ namespace MWInput
|
|||
defaultKeyBindings[A_QuickKeysMenu] = OIS::KC_F1;
|
||||
defaultKeyBindings[A_Console] = OIS::KC_F2;
|
||||
defaultKeyBindings[A_Run] = OIS::KC_LSHIFT;
|
||||
defaultKeyBindings[A_Crouch] = OIS::KC_LCONTROL;
|
||||
defaultKeyBindings[A_Sneak] = OIS::KC_LCONTROL;
|
||||
defaultKeyBindings[A_AutoMove] = OIS::KC_Q;
|
||||
defaultKeyBindings[A_Jump] = OIS::KC_E;
|
||||
defaultKeyBindings[A_Journal] = OIS::KC_J;
|
||||
|
@ -814,7 +816,7 @@ namespace MWInput
|
|||
descriptions[A_ToggleSpell] = "sReady_Magic";
|
||||
descriptions[A_Console] = "sConsoleTitle";
|
||||
descriptions[A_Run] = "sRun";
|
||||
descriptions[A_Crouch] = "sCrouch_Sneak";
|
||||
descriptions[A_Sneak] = "sCrouch_Sneak";
|
||||
descriptions[A_AutoMove] = "sAuto_Run";
|
||||
descriptions[A_Jump] = "sJump";
|
||||
descriptions[A_Journal] = "sJournal";
|
||||
|
@ -863,7 +865,7 @@ namespace MWInput
|
|||
ret.push_back(A_MoveRight);
|
||||
ret.push_back(A_TogglePOV);
|
||||
ret.push_back(A_Run);
|
||||
ret.push_back(A_Crouch);
|
||||
ret.push_back(A_Sneak);
|
||||
ret.push_back(A_Activate);
|
||||
ret.push_back(A_ToggleWeapon);
|
||||
ret.push_back(A_ToggleSpell);
|
||||
|
|
|
@ -150,6 +150,8 @@ namespace MWInput
|
|||
float mMouseX;
|
||||
float mMouseY;
|
||||
int mMouseWheel;
|
||||
bool mDebug;
|
||||
bool mUserFileExists;
|
||||
|
||||
std::map<std::string, bool> mControlSwitch;
|
||||
|
||||
|
@ -214,9 +216,9 @@ namespace MWInput
|
|||
A_CycleSpellRight,
|
||||
A_CycleWeaponLeft,//Cycling through weapons
|
||||
A_CycleWeaponRight,
|
||||
A_ToggleSneak, //Toggles Sneak, add Push-Sneak later
|
||||
A_ToggleSneak, //Toggles Sneak
|
||||
A_ToggleWalk, //Toggle Walking/Running
|
||||
A_Crouch,
|
||||
A_Sneak,
|
||||
|
||||
A_QuickSave,
|
||||
A_QuickLoad,
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace MWMechanics
|
|||
|
||||
for (TIterator iter (begin()); iter!=end(); ++iter)
|
||||
{
|
||||
std::pair<ESM::EffectList, bool> effects = getEffectList (iter->first);
|
||||
std::pair<ESM::EffectList, std::pair<bool, bool> > effects = getEffectList (iter->first);
|
||||
|
||||
const MWWorld::TimeStamp& start = iter->second.first;
|
||||
float magnitude = iter->second.second;
|
||||
|
@ -74,7 +74,7 @@ namespace MWMechanics
|
|||
{
|
||||
int duration = iter->mDuration;
|
||||
|
||||
if (effects.second)
|
||||
if (effects.second.first)
|
||||
duration *= magnitude;
|
||||
|
||||
MWWorld::TimeStamp end = start;
|
||||
|
@ -85,7 +85,7 @@ namespace MWMechanics
|
|||
{
|
||||
EffectParam param;
|
||||
|
||||
if (effects.second)
|
||||
if (effects.second.first)
|
||||
{
|
||||
const ESM::MagicEffect *magicEffect =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find (
|
||||
|
@ -113,15 +113,15 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
std::pair<ESM::EffectList, bool> ActiveSpells::getEffectList (const std::string& id) const
|
||||
std::pair<ESM::EffectList, std::pair<bool, bool> > ActiveSpells::getEffectList (const std::string& id) const
|
||||
{
|
||||
if (const ESM::Spell *spell =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search (id))
|
||||
return std::make_pair (spell->mEffects, false);
|
||||
return std::make_pair (spell->mEffects, std::make_pair(false, false));
|
||||
|
||||
if (const ESM::Potion *potion =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Potion>().search (id))
|
||||
return std::make_pair (potion->mEffects, false);
|
||||
return std::make_pair (potion->mEffects, std::make_pair(false, true));
|
||||
|
||||
if (const ESM::Ingredient *ingredient =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Ingredient>().search (id))
|
||||
|
@ -140,11 +140,12 @@ namespace MWMechanics
|
|||
effect.mMagnMin = 1;
|
||||
effect.mMagnMax = 1;
|
||||
|
||||
std::pair<ESM::EffectList, bool> result;
|
||||
|
||||
std::pair<ESM::EffectList, std::pair<bool, bool> > result;
|
||||
result.second.second = true;
|
||||
result.second.first = true;
|
||||
|
||||
result.first.mList.push_back (effect);
|
||||
result.second = true;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -157,7 +158,8 @@ namespace MWMechanics
|
|||
|
||||
bool ActiveSpells::addSpell (const std::string& id, const MWWorld::Ptr& actor)
|
||||
{
|
||||
std::pair<ESM::EffectList, bool> effects = getEffectList (id);
|
||||
std::pair<ESM::EffectList, std::pair<bool, bool> > effects = getEffectList (id);
|
||||
bool stacks = effects.second.second;
|
||||
|
||||
bool found = false;
|
||||
|
||||
|
@ -178,7 +180,7 @@ namespace MWMechanics
|
|||
|
||||
float random = static_cast<float> (std::rand()) / RAND_MAX;
|
||||
|
||||
if (effects.second)
|
||||
if (effects.second.first)
|
||||
{
|
||||
// ingredient -> special treatment required.
|
||||
const CreatureStats& creatureStats = MWWorld::Class::get (actor).getCreatureStats (actor);
|
||||
|
@ -194,7 +196,7 @@ namespace MWMechanics
|
|||
random *= 0.25 * x;
|
||||
}
|
||||
|
||||
if (iter==mSpells.end())
|
||||
if (iter==mSpells.end() || stacks)
|
||||
mSpells.insert (std::make_pair (id,
|
||||
std::make_pair (MWBase::Environment::get().getWorld()->getTimeStamp(), random)));
|
||||
else
|
||||
|
@ -236,7 +238,7 @@ namespace MWMechanics
|
|||
|
||||
double ActiveSpells::timeToExpire (const TIterator& iterator) const
|
||||
{
|
||||
std::pair<ESM::EffectList, bool> effects = getEffectList (iterator->first);
|
||||
std::pair<ESM::EffectList, std::pair<bool, bool> > effects = getEffectList (iterator->first);
|
||||
|
||||
int duration = 0;
|
||||
|
||||
|
@ -247,7 +249,7 @@ namespace MWMechanics
|
|||
duration = iter->mDuration;
|
||||
}
|
||||
|
||||
if (effects.second)
|
||||
if (effects.second.first)
|
||||
duration *= iterator->second.second;
|
||||
|
||||
double scaledDuration = duration *
|
||||
|
@ -274,4 +276,9 @@ namespace MWMechanics
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const ActiveSpells::TContainer& ActiveSpells::getActiveSpells() const
|
||||
{
|
||||
return mSpells;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace MWMechanics
|
|||
{
|
||||
public:
|
||||
|
||||
typedef std::map<std::string, std::pair<MWWorld::TimeStamp, float> > TContainer;
|
||||
typedef std::multimap<std::string, std::pair<MWWorld::TimeStamp, float> > TContainer;
|
||||
typedef TContainer::const_iterator TIterator;
|
||||
|
||||
private:
|
||||
|
@ -44,7 +44,8 @@ namespace MWMechanics
|
|||
|
||||
void rebuildEffects() const;
|
||||
|
||||
std::pair<ESM::EffectList, bool> getEffectList (const std::string& id) const;
|
||||
std::pair<ESM::EffectList, std::pair<bool, bool> > getEffectList (const std::string& id) const;
|
||||
///< @return (EffectList, (isIngredient, stacks))
|
||||
|
||||
public:
|
||||
|
||||
|
@ -63,6 +64,8 @@ namespace MWMechanics
|
|||
|
||||
const MagicEffects& getMagicEffects() const;
|
||||
|
||||
const TContainer& getActiveSpells() const;
|
||||
|
||||
TIterator begin() const;
|
||||
|
||||
TIterator end() const;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue