From dd8964da99a2d2ace31fb0ed4f68b689d495c8b2 Mon Sep 17 00:00:00 2001 From: Bodillium Date: Wed, 22 Oct 2014 21:54:37 +1100 Subject: [PATCH 001/119] Begin reworking files and directories section First attempt at LaTeX and Git! --- manual/opencs/files_and_directories.tex | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/manual/opencs/files_and_directories.tex b/manual/opencs/files_and_directories.tex index fc9ae878ae..39d918b46a 100644 --- a/manual/opencs/files_and_directories.tex +++ b/manual/opencs/files_and_directories.tex @@ -1,22 +1,23 @@ \section{Files and Directories} \subsection{Introduction} -This section of the manual covers usage of files and directories by the OpenCS. Files and directories are file system concepts, -and you are probably already familiar with it. We won't try to explain this concepts, we will just focus on \OCS. +This section of the manual describes the directories and file types used by OpenCS. A file is a resource for storing data, identified by its +filename extension (e.g. .exe, .jpg, .txt), whereas a directory is a folder or file system structure in which these files are stored. You +are most likely already familiar with these concepts. \subsection{Used terms} %TODO \subsection{Basics} \paragraph{Directories} -OpenMW and \OCS{} uses multiple directories on file systems. First of, there is a \textbf{user directory} that holds configuration -files and few different folders. The location of the user directory is hard coded for each supported operating system. +OpenMW and \OCS{} store their files in multiple directories. Firstly, there is the \textbf{user directory} that holds configuration +files and several other folders. The location of the user directory is hard coded for each supported operating system. %TODO list paths. -In addition to this single hard coded directory, both \OMW{} and \OCS{} need a~place to seek for actual data files of the game: -textures, models, sounds and files that store records of objects in game; dialogues and so one -- so called content files. We support -multiple such paths (we call it \textbf{data paths}) as specified in the configuration. Usually one data path points to the directory -where original \MW{} is either installed or unpacked. You are free to specify as many data paths as you would like, -however, there is one special data path that, as described later, is used to store newly created content files. +In addition to the user directory, both \OMW{} and \OCS{} need a place to store the game’s actual data files: for example, the +textures, models, sounds and records of in-game objects. We support multiple paths to these files (termed \textbf{data paths}), +as specified in the configuration. Usually, one data path points to the directory where \MW{} is installed, however, you are +free to specify as many data paths as you would like. In addition, one particular data path, as described below, is used to store +newly created content files. \paragraph{Content files} \BS{} \MW{} engine is using two types of files: ESM (master) and ESP (plugin). The distinction between those From f70ddb5e980b543e146d4d95662a0d09f0bff400 Mon Sep 17 00:00:00 2001 From: Bodillium Date: Thu, 23 Oct 2014 15:46:43 +1100 Subject: [PATCH 002/119] Finish reworking files and directories section --- manual/opencs/files_and_directories.tex | 135 ++++++++++++------------ 1 file changed, 65 insertions(+), 70 deletions(-) diff --git a/manual/opencs/files_and_directories.tex b/manual/opencs/files_and_directories.tex index 39d918b46a..21774093e1 100644 --- a/manual/opencs/files_and_directories.tex +++ b/manual/opencs/files_and_directories.tex @@ -13,109 +13,104 @@ OpenMW and \OCS{} store their files in multiple directories. Firstly, there is t files and several other folders. The location of the user directory is hard coded for each supported operating system. %TODO list paths. -In addition to the user directory, both \OMW{} and \OCS{} need a place to store the game’s actual data files: for example, the -textures, models, sounds and records of in-game objects. We support multiple paths to these files (termed \textbf{data paths}), -as specified in the configuration. Usually, one data path points to the directory where \MW{} is installed, however, you are -free to specify as many data paths as you would like. In addition, one particular data path, as described below, is used to store +In addition to the user directory, both \OMW{} and \OCS{} need a place to store the game’s actual data files: for example, the +textures, models, sounds and records of in-game objects. We support multiple paths to these files (termed \textbf{data paths}), +as specified in the configuration. Usually, one data path points to the directory where \MW{} is installed, however, you are +free to specify as many data paths as you would like. In addition, one particular data path, as described below, is used to store newly created content files. \paragraph{Content files} -\BS{} \MW{} engine is using two types of files: ESM (master) and ESP (plugin). The distinction between those -is not clear, and often confusing. You would expect the ESM (master) file is used to specify one master, that is modified by the ESPs plugins, -and indeed: this is the basic idea. However, original expansions also were made as ESM files, even though they essentially could be -described as a really large plugins, and therefore rather use ESP files. There were technical reasons behind this decision -- somewhat valid -in the case of original engine, but clearly it's better to create a system that can be used is more sensible way. \OMW{} achieves -this with our own content file types. +\BS{} \MW{} engine uses two file types: ESM (master) and ESP (plugin). The distinction between the two is often confusing. +You would expect that the ESM (master) file is used to specify a single master which is modified by the ESP files (plugins), and indeed: +this is the basic idea. However, the original expansions are also ESM files, even though they can be described as a really large plugins. +There were technical reasons behind this decision -- somewhat valid in the case of original engine, but a more logical file system is +much preferable. \OMW{} achieves this through the creation of our own types of content file. -We support both ESM and ESP files, but in order to make use of new features of OpenMW one should consider using new file types designed -with our engine in mind: game files and addon files together called ``content files``. +We support both ESM and ESP files, but, in order to make use of \OMW{}'s new features, one should consider using new file types designed +with our engine in mind: game files and addon files, collectively termed \textbf{content files}. \subparagraph{OpenMW content files} -Game and Addon files are concept somewhat similar to the old ESM/ESP, only in the way it should be from the very beginning. Nothing easier -to describe. If you want to make new game using \OMW{} as engine (so called ``total conversion'') you should create a game file. -If you want to create a addon for existing game file -- simply create addon file. Nothing else matters: The only distinction you should -consider is if your project is about changing other game, or creating a new one. Simple as that. +The distinction between game and addon files is similar to that between ESM and ESP, however their relationship to each other is +strictly defined -– the former are always master files, and the latter are always plugins. If you want to make a new game using the \OMW{} +engine (i.e. a ``total conversion''), you should create a game file. If you want to create an addon for an existing game file, simply +create an addon file. Nothing else matters: the only distinction you should consider is whether your project involves changing another game, +or creating a new one. Simple as that. -Other simple thing about content files are extensions. We are using .omwaddon for addon files and .omwgame for game files. +Furthermore, our content files’ extensions are .omwaddon for addon files and .omwgame for game files. %TODO describe what content files contains. and what not. \subparagraph{\MW{} content files} -Using our content files is recommended solution for projects that are intended to used with \OMW{} engine. However some players -wish to use original \MW{} engine, even with it large flaws and lacking features\footnote{If this is actually wrong, we are very -successful project. Yay!}. Also, since 2002 thousands of ESP/ESM files were created, some with really outstanding content. -Because of this \OCS{} simply has no other choice but support ESP/ESM files. However, if you decided to choose ESP/ESM file instead -using our own content file types you are most likely aim at the original engine compatibility. This subject is covered in the very -last section of this manual. %not finished TODO add the said section. Most likely when more features are present. +Using our content files is the recommended solution for projects that employ the \OMW{} engine. However, some players will wish to use +the original \MW{} engine, despite its large flaws and lacking features\footnote{If this is wrong, we are a very successful project. Yay!}. +In addition, since 2002 thousands of ESP/ESM files have been created, some with truly outstanding content. Because of this, \OCS{} is +committed to supporting ESP/ESM files. If you do decide to use ESP/ESM files rather than our own content files, you are most likely aiming +for original engine compatibility. This subject is covered in the very last section of the manual. +%not finished TODO add the said section. Most likely when more features are present. -The actual creation of new files is described in the next chapter. Here we are gonna focus only on details that you need to know -in order to create your first \OCS{} file while full understanding your needs. For now let's jut remember that content files -are created inside the user directory, in the the \textbf{data} subfolder (that is the one special data directory mentioned earlier). +The actual creation of new files is described in the next chapter. Here we are going to focus only on the essential information needed +to create your first \OCS{} file. For now, let's jut remember that content files are stored in the user directory, in the \textbf{data} subfolder (the particular data directory mentioned above). \subparagraph{Dependencies} -Since addon is supposed to change the game it is logical that it also depends on the said game. It simply can not work otherwise. -Just think about it: your modification is changing prize of the iron sword. But what if there is no iron sword in game? That is right: -we get nonsense. What you want to do is to tie your addon to the files you are changing. Those can be either game files (expansion island -for a game) or other addon files (house on the said island). It is a good idea to be dependent only on files that are really changed -in your addon obviously, but sadly there is no other way to achieve this than knowing what you want to do. Again, please remember that -this section of the manual does not cover creating the content files -- it is only theoretical introduction to the subject. For now just -keep in mind that dependencies exist, and is up to you what to decide if your content file should depend on other content file. +Since addons aim to modify an existing game, it is logical that they also depend on the said game: otherwise they will not function. +For example, your modification changes the price of iron swords. But what if there are no iron swords in the game? That is right: +it is nonsense. Therefore, it is necessary to make your addon a dependency of other content files. These can be either game files +(e.g. an entirely new island), or other addon files (e.g. a house on the island). It is a good idea for addons to depend only on the +content files they modify, but this is up to the end user to determine. -Game files are not intend to have any dependencies for a very simple reasons: player is using only one game file (excluding original -and dirty {ESP/ESM} system) at the time and therefore no game file can depend on other game file, and since game file makes the base -for addon files -- it can not depend on addon files. +Game files do not depend on any other content files, as they act as master files. A player can only use one game file at a time +(although this does not apply to the original and dirty ESP/ESM system). %\subparagraph{Loading order} %TODO \paragraph{Project files} -Project files act as containers for data not used by the \OMW{} game engine itself, but still useful for OpenCS. The shining example -of this data category are without doubt record filters (described in the later section of the manual you are reading currently). -As a mod author you probably do not need and/or want to distribute project files at all, they are meant to be used only by you. +Project files contain data not used by the \OMW{} game engine but which are still needed by OpenCS. Good examples of this data type +are the record filters (described below). As a mod author, you probably do not need and/or want to distribute project files at all, +as they are meant to be used only by you. -As you would imagine, project file makes sense only in combination with actual content files. In fact, each time you start to work -on new content file and project file was not found, it will be created. -Project files extension is, to not surprise ``.project''. The whole name of the project file is the whole name of the content file -with appended extensions. For instance swords.omwaddon file is associated with swords.omwaddon.project file. +Since project files govern how content files are used in OpenCS, they are always used in conjunction with your specific project. +In fact, each time work commences on a new content file without a corresponding project file, a new project file will be created. + +Project file extension is ``.project''. The name of the project file is the whole name of the content file with appended extensions. +For instance, a content file named swords.omwaddon is associated with the project file swords.omwaddon.project. %TODO where are they stored. -Project files are stored inside the user directory, in the \textbf{projects} subfolder. This is the path location for both freshly -created project files, and a place where \OCS{} looks for already existing files. +Project files are stored inside the user directory, in the \textbf{projects} subfolder. This is both the location of newly created +project files, and the place where \OCS{} looks for already existing files. -\paragraph{Resources files} +\paragraph{Resource files} %textures, sounds, whatever -Unless we are talking about the fully text based game, like Zork or Rogue, you are expecting that a video game is using some media files: -models with textures, pictures acting as icons, sounds and everything else. Since content files, no matter if it is ESP, ESM or new \OMW{} -file type do not contain any of those, it is clear that they have to be deliver with a different file. It is also clear that this, -let's call it ``resources file``, have to be supported by the engine. Without code handling those files, it is nothing more than -a mathematical abstraction -- something, that lacks meaning for human beings\footnote{Unless we call programmers a human beings.}. -Therefore this section must cover ways to add resources files to your content file, and point out what is supported. We are going -to do just that. Later, you will learn how to make use of those files in your content. +The vast majority of modern video games use what we shall term \textbf{resource files}: models, textures, icons, sounds and so on. +ESPs, ESMs and \OMW{} content files do not contain these files, merely instructions on how they are used. It follows that the \OMW{} +engine must be capable of supporting these resource files in order for them to function. Therefore this section cover ways to add +resource files to your content file, and outlines which formats are supported. Later, you will learn how to make use of these files +in your content. \subparagraph{Audio} -OpenMW is using {FFmpeg} for audio playback, and so we support every audio type that is supported by this library. This makes a huge list. -Below is only small portion of supported file types. +OpenMW utilises {FFmpeg} for audio playback, so we support every audio type supported by this library. This is a huge list. +Below is only a small sample of supported file types. \begin{description} - \item mp3 ({MPEG}-1 {Part 3 Layer 3}) popular audio file format and \textit{de facto} standard for storing audio. Used by the \MW{} game. - \item ogg open source, multimedia container file using high quality vorbis audio codec. Recommended. + \item mp3 ({MPEG}-1 {Part 3 Layer 3}) A popular audio file format and the \textit{de facto} standard for storing audio. Used by + the \MW{} game. + \item ogg Open source, multimedia container file which uses the high quality vorbis audio codec. Recommended. \end{description} \subparagraph{Video} -As in the case of audio files, we are using {FFmepg} to decode video files. The list of supported files is long, we will cover -only the most significant. +As in the case of audio files, we use {FFmpeg} to decode video files. The list of supported files is long -– only the most +significant will be covered. \begin{description} - \item bik videos used by original \MW{} game. - \item mp4 multimedia container which use more advanced codecs ({MPEG-4 Parts 2,3,10}) with a better audio and video compression rate, - but also requiring more {CPU} intensive decoding -- this makes it probably less suited for storing sounds in computer games, but good for videos. - \item webm is a new, shiny and open source video format with excellent compression. It needs quite a lot of processing power to be decoded, + \item bik Format used by the original \MW{} game. + \item mp4 Multimedia container which use more advanced codecs ({MPEG-4 Parts 2,3,10}) with a better audio and video compression rate, + but which require more {CPU} intensive decoding -- this probably makes it less suited for storing sounds in computer games, but good for videos. + \item webm A new, shiny and open source video format with excellent compression. It needs quite a lot of processing power to be decoded, but since game logic is not running during cut scenes we can recommend it for use with \OMW. - \item ogv alternative, open source container using theora codec for video and vorbis for audio. + \item ogv An alternative, open source container using theora codec for video and vorbis for audio. \end{description} \subparagraph{Textures and images} -Original \MW{} game uses {DDS} and {TGA} files for all kind of two dimensional images and textures alike. In addition, engine supported BMP -files for some reason ({BMP} is a terrible format for a video game). We also support extended set of image files -- including {JPEG} and {PNG}. -JPEG and PNG files can be useful in some cases, for instance JPEG file is a valid option for skybox texture and PNG can useful for masks. -However please, keep in mind that JPEG can grow into large sizes quickly and are not the best option with {DirectX} rendering backend. You probabbly still want -to use {DDS} files for textures. - +\MW{} uses {DDS} and {TGA} files for all kinds of two dimensional images and textures. In addition, the original engine supported BMP +files (although {BMP} is a terrible format for a video game). We also support an extended set of image files -- including {JPEG} and {PNG}. +JPEG and PNG files can be useful in some cases. For instance, a JPEG file is a valid option for a skybox texture and PNG can useful for masks. +However, keep in mind that a JPEG can grow large quickly and so are not the best option with a {DirectX} rendering backend. DDS files +are therefore recommended for textures. %\subparagraph{Meshes} %TODO once we will support something more than just nifs \ No newline at end of file From 20aa89e785a5e61f80057584b3aebddcee11f187 Mon Sep 17 00:00:00 2001 From: Bodillium Date: Thu, 23 Oct 2014 23:32:24 +1100 Subject: [PATCH 003/119] Minor tweaks to files and directories --- manual/opencs/files_and_directories.tex | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/manual/opencs/files_and_directories.tex b/manual/opencs/files_and_directories.tex index 21774093e1..1b07fe267a 100644 --- a/manual/opencs/files_and_directories.tex +++ b/manual/opencs/files_and_directories.tex @@ -22,8 +22,8 @@ newly created content files. \paragraph{Content files} \BS{} \MW{} engine uses two file types: ESM (master) and ESP (plugin). The distinction between the two is often confusing. You would expect that the ESM (master) file is used to specify a single master which is modified by the ESP files (plugins), and indeed: -this is the basic idea. However, the original expansions are also ESM files, even though they can be described as a really large plugins. -There were technical reasons behind this decision -- somewhat valid in the case of original engine, but a more logical file system is +this is the basic idea. However, the original expansions are also ESM files, even though they can be described as very large plugins. +There were technical reasons behind this decision -- somewhat valid in the case of the original engine, but a more logical file system is much preferable. \OMW{} achieves this through the creation of our own types of content file. We support both ESM and ESP files, but, in order to make use of \OMW{}'s new features, one should consider using new file types designed @@ -48,7 +48,8 @@ for original engine compatibility. This subject is covered in the very last sect %not finished TODO add the said section. Most likely when more features are present. The actual creation of new files is described in the next chapter. Here we are going to focus only on the essential information needed -to create your first \OCS{} file. For now, let's jut remember that content files are stored in the user directory, in the \textbf{data} subfolder (the particular data directory mentioned above). +to create your first \OCS{} file. For now, let's jut remember that content files are stored in the user directory, in the \textbf{data} +subfolder (the particular data directory mentioned above). \subparagraph{Dependencies} Since addons aim to modify an existing game, it is logical that they also depend on the said game: otherwise they will not function. @@ -67,9 +68,9 @@ are the record filters (described below). As a mod author, you probably do not n as they are meant to be used only by you. Since project files govern how content files are used in OpenCS, they are always used in conjunction with your specific project. -In fact, each time work commences on a new content file without a corresponding project file, a new project file will be created. +In fact, each time work commences on a content file that does not have a corresponding project file, a new project file will be created. -Project file extension is ``.project''. The name of the project file is the whole name of the content file with appended extensions. +The project file extension is ``.project''. The name of the project file is the whole name of the content file with appended extensions. For instance, a content file named swords.omwaddon is associated with the project file swords.omwaddon.project. %TODO where are they stored. @@ -80,7 +81,7 @@ project files, and the place where \OCS{} looks for already existing files. %textures, sounds, whatever The vast majority of modern video games use what we shall term \textbf{resource files}: models, textures, icons, sounds and so on. ESPs, ESMs and \OMW{} content files do not contain these files, merely instructions on how they are used. It follows that the \OMW{} -engine must be capable of supporting these resource files in order for them to function. Therefore this section cover ways to add +engine must be capable of supporting these resource files in order for them to function. Therefore this section covers ways to add resource files to your content file, and outlines which formats are supported. Later, you will learn how to make use of these files in your content. @@ -101,7 +102,8 @@ significant will be covered. \begin{description} \item bik Format used by the original \MW{} game. \item mp4 Multimedia container which use more advanced codecs ({MPEG-4 Parts 2,3,10}) with a better audio and video compression rate, - but which require more {CPU} intensive decoding -- this probably makes it less suited for storing sounds in computer games, but good for videos. + but which require more {CPU} intensive decoding -- this probably makes it less suited for storing sounds in computer games, but + good for videos. \item webm A new, shiny and open source video format with excellent compression. It needs quite a lot of processing power to be decoded, but since game logic is not running during cut scenes we can recommend it for use with \OMW. \item ogv An alternative, open source container using theora codec for video and vorbis for audio. From 31db37afd460201d83767b7a4f0cd4933a7b96c1 Mon Sep 17 00:00:00 2001 From: k1ll Date: Wed, 19 Jun 2013 20:22:07 +0200 Subject: [PATCH 004/119] FindMygui mingw --- cmake/FindMyGUI.cmake | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/cmake/FindMyGUI.cmake b/cmake/FindMyGUI.cmake index 40fa2373f0..2829a74d35 100644 --- a/cmake/FindMyGUI.cmake +++ b/cmake/FindMyGUI.cmake @@ -19,7 +19,46 @@ include(PreprocessorUtils) # ENDIF (MYGUI_LIBRARIES AND MYGUI_INCLUDE_DIRS) IF (WIN32) #Windows + MESSAGE(STATUS "Looking for MyGUI") + + IF(MINGW) + + FIND_PATH ( MYGUI_INCLUDE_DIRS MyGUI.h PATH_SUFFIXES MYGUI) + FIND_PATH ( MYGUI_PLATFORM_INCLUDE_DIRS MyGUI_OgrePlatform.h PATH_SUFFIXES MYGUI) + FIND_LIBRARY ( MYGUI_LIBRARIES_REL NAMES + libMyGUIEngine${CMAKE_SHARED_LIBRARY_SUFFIX} + libMyGUI.OgrePlatform${CMAKE_STATIC_LIBRARY_SUFFIX} + HINTS + ${MYGUI_LIB_DIR} + PATH_SUFFIXES "" release relwithdebinfo minsizerel ) + + FIND_LIBRARY ( MYGUI_LIBRARIES_DBG NAMES + libMyGUIEngine_d${CMAKE_SHARED_LIBRARY_SUFFIX} + libMyGUI.OgrePlatform_d${CMAKE_STATIC_LIBRARY_SUFFIX} + HINTS + ${MYGUI_LIB_DIR} + PATH_SUFFIXES "" debug ) + + FIND_LIBRARY ( MYGUI_PLATFORM_LIBRARIES_REL NAMES + libMyGUI.OgrePlatform${CMAKE_STATIC_LIBRARY_SUFFIX} + HINTS + ${MYGUI_LIB_DIR} + PATH_SUFFIXES "" release relwithdebinfo minsizerel ) + + FIND_LIBRARY ( MYGUI_PLATFORM_LIBRARIES_DBG NAMES + MyGUI.OgrePlatform_d${CMAKE_STATIC_LIBRARY_SUFFIX} + HINTS + ${MYGUI_LIB_DIR} + PATH_SUFFIXES "" debug ) + + make_library_set ( MYGUI_LIBRARIES ) + make_library_set ( MYGUI_PLATFORM_LIBRARIES ) + + MESSAGE ("${MYGUI_LIBRARIES}") + MESSAGE ("${MYGUI_PLATFORM_LIBRARIES}") + ENDIF(MINGW) + SET(MYGUISDK $ENV{MYGUI_HOME}) IF (MYGUISDK) findpkg_begin ( "MYGUI" ) From 00b7712a5910932f5bb8e333e6a28883f506092a Mon Sep 17 00:00:00 2001 From: k1ll Date: Sat, 22 Jun 2013 11:33:22 +0200 Subject: [PATCH 005/119] Fix shlwapi include case and add the lib for linking when building for windows --- components/CMakeLists.txt | 4 ++++ components/files/windowspath.cpp | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 38fcd88e3e..5bd18d119e 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -170,6 +170,10 @@ if (GIT_CHECKOUT) add_dependencies (components git-version) endif (GIT_CHECKOUT) +if (WIN32) +target_link_libraries(components shlwapi) +endif() + # Fix for not visible pthreads functions for linker with glibc 2.15 if (UNIX AND NOT APPLE) target_link_libraries(components ${CMAKE_THREAD_LIBS_INIT}) diff --git a/components/files/windowspath.cpp b/components/files/windowspath.cpp index 0df782702d..ece4049a87 100644 --- a/components/files/windowspath.cpp +++ b/components/files/windowspath.cpp @@ -6,9 +6,7 @@ #include #include -#include - -#pragma comment(lib, "Shlwapi.lib") +#include #include namespace bconv = boost::locale::conv; From a230050ec8d4d094a5905b0280173fc3e780a09a Mon Sep 17 00:00:00 2001 From: k1ll Date: Sat, 22 Jun 2013 11:37:17 +0200 Subject: [PATCH 006/119] Boost tr1 unordered map does not work with mingw --- apps/openmw/mwworld/worldimp.cpp | 2 +- components/files/configurationmanager.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 013386f8f9..744057e437 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1,6 +1,6 @@ #include "worldimp.hpp" -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include #elif defined HAVE_UNORDERED_MAP #include diff --git a/components/files/configurationmanager.hpp b/components/files/configurationmanager.hpp index b0b7fea9a9..24b08c5236 100644 --- a/components/files/configurationmanager.hpp +++ b/components/files/configurationmanager.hpp @@ -1,7 +1,7 @@ #ifndef COMPONENTS_FILES_CONFIGURATIONMANAGER_HPP #define COMPONENTS_FILES_CONFIGURATIONMANAGER_HPP -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include #elif defined HAVE_UNORDERED_MAP #include From de247ec94b26f08b15fff61a3fed070a7e06109c Mon Sep 17 00:00:00 2001 From: k1ll Date: Sat, 22 Jun 2013 11:48:52 +0200 Subject: [PATCH 007/119] Fix ifdef --- extern/sdl4ogre/sdlwindowhelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/sdl4ogre/sdlwindowhelper.cpp b/extern/sdl4ogre/sdlwindowhelper.cpp index 637fae0efe..6690e3caba 100644 --- a/extern/sdl4ogre/sdlwindowhelper.cpp +++ b/extern/sdl4ogre/sdlwindowhelper.cpp @@ -30,7 +30,7 @@ SDLWindowHelper::SDLWindowHelper (SDL_Window* window, int w, int h, switch (wmInfo.subsystem) { -#ifdef WIN32 +#ifdef _WIN32 case SDL_SYSWM_WINDOWS: // Windows code winHandle = Ogre::StringConverter::toString((uintptr_t)wmInfo.info.win.window); From c61919501dfb4416797c398a957bcf5259748ed5 Mon Sep 17 00:00:00 2001 From: k1ll Date: Sat, 22 Jun 2013 11:56:18 +0200 Subject: [PATCH 008/119] Fix unnecessary include, ssize_t define and use pretty function instead of funcsig for mingw --- extern/ogre-ffmpeg-videoplayer/audiodecoder.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extern/ogre-ffmpeg-videoplayer/audiodecoder.hpp b/extern/ogre-ffmpeg-videoplayer/audiodecoder.hpp index b05b16d428..fe36ec39f1 100644 --- a/extern/ogre-ffmpeg-videoplayer/audiodecoder.hpp +++ b/extern/ogre-ffmpeg-videoplayer/audiodecoder.hpp @@ -21,8 +21,8 @@ extern "C" #endif } -#ifdef _WIN32 -#include +#if defined(_WIN32) && !defined(__MINGW32__) +#include typedef SSIZE_T ssize_t; #endif From b194af4ab27d35a167c69c9b8f6a6f481017b237 Mon Sep 17 00:00:00 2001 From: k1ll Date: Sat, 6 Jul 2013 13:32:59 +0200 Subject: [PATCH 009/119] Add static qt to components --- components/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 5bd18d119e..e6158c0a25 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -170,6 +170,10 @@ if (GIT_CHECKOUT) add_dependencies (components git-version) endif (GIT_CHECKOUT) +if(MINGW) +target_link_libraries(components ${QT_LIBRARIES}) +endif() + if (WIN32) target_link_libraries(components shlwapi) endif() From 8e094d6fa5ed03434c1fd7e86a1018dc8a895137 Mon Sep 17 00:00:00 2001 From: k1ll Date: Sat, 6 Jul 2013 17:18:11 +0200 Subject: [PATCH 010/119] Add static bullet to components --- components/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index e6158c0a25..01de1c28e1 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -127,6 +127,9 @@ set (ESM_UI ${CMAKE_SOURCE_DIR}/files/ui/contentselector.ui ) find_package(Qt4 COMPONENTS QtCore QtGui) +if(MINGW) +find_package(Bullet REQUIRED COMPONENTS Collision) +endif() if(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY) add_component_qt_dir (contentselector @@ -171,7 +174,7 @@ if (GIT_CHECKOUT) endif (GIT_CHECKOUT) if(MINGW) -target_link_libraries(components ${QT_LIBRARIES}) +target_link_libraries(components ${QT_LIBRARIES} ${BULLET_LIBRARIES}) endif() if (WIN32) From fe03727ae5fa6e598b151122ad5f3878e52b2e3c Mon Sep 17 00:00:00 2001 From: k1ll Date: Tue, 6 Aug 2013 18:55:17 +0200 Subject: [PATCH 011/119] Don't force linking static boost libraries when building with mingw --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07fffd5776..2c83e26627 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,9 +134,11 @@ endif() # Platform specific if (WIN32) + if(NOT MINGW) set(Boost_USE_STATIC_LIBS ON) set(PLATFORM_INCLUDE_DIR "platform") add_definitions(-DBOOST_ALL_NO_LIB) + endif(NOT MINGW) # Suppress WinMain(), provided by SDL add_definitions(-DSDL_MAIN_HANDLED) From 96d9afec384d16de4876c3e3b74a190afee28732 Mon Sep 17 00:00:00 2001 From: k1ll Date: Fri, 23 May 2014 23:26:05 +0200 Subject: [PATCH 012/119] More header case fixes --- apps/openmw/main.cpp | 2 +- extern/oics/tinyxml.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 070136dfd7..2d2c9af0c9 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -15,7 +15,7 @@ #if defined(_WIN32) // For OutputDebugString #define WIN32_LEAN_AND_MEAN -#include +#include // makes __argc and __argv available on windows #include #endif diff --git a/extern/oics/tinyxml.cpp b/extern/oics/tinyxml.cpp index 21b2d9c9a3..5d8eb475a0 100644 --- a/extern/oics/tinyxml.cpp +++ b/extern/oics/tinyxml.cpp @@ -32,7 +32,7 @@ distribution. #include "tinyxml.h" #ifdef _WIN32 -#include // import MultiByteToWideChar +#include // import MultiByteToWideChar #endif From 901ee5b756ab1d156e055ccf1f5d0624d240c53b Mon Sep 17 00:00:00 2001 From: k1ll Date: Fri, 23 May 2014 23:35:28 +0200 Subject: [PATCH 013/119] Add flag for mingw-w64 unicode support --- apps/mwiniimporter/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/mwiniimporter/CMakeLists.txt b/apps/mwiniimporter/CMakeLists.txt index 790d47dc47..753c86fef6 100644 --- a/apps/mwiniimporter/CMakeLists.txt +++ b/apps/mwiniimporter/CMakeLists.txt @@ -18,6 +18,10 @@ target_link_libraries(openmw-iniimporter components ) +if (MINGW) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -municode") +endif() + if (BUILD_WITH_CODE_COVERAGE) add_definitions (--coverage) target_link_libraries(openmw-iniimporter gcov) From ca53457a1c572851491fe8d6e1238ee5bd608ae5 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 6 May 2015 01:46:34 +0200 Subject: [PATCH 014/119] Correct the map icons used for detect spells (Fixes #2519) --- apps/openmw/mwgui/mapwindow.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 02e8ffdfed..269b43a71f 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -468,21 +468,17 @@ namespace MWGui return; std::string markerTexture; - MyGUI::Colour markerColour; if (type == MWBase::World::Detect_Creature) { - markerTexture = "textures\\menu_map_dcreature.dds"; - markerColour = MyGUI::Colour(1,0,0,1); + markerTexture = "textures\\detect_animal_icon.dds"; } if (type == MWBase::World::Detect_Key) { - markerTexture = "textures\\menu_map_dkey.dds"; - markerColour = MyGUI::Colour(0,1,0,1); + markerTexture = "textures\\detect_key_icon.dds"; } if (type == MWBase::World::Detect_Enchantment) { - markerTexture = "textures\\menu_map_dmagic.dds"; - markerColour = MyGUI::Colour(0,0,1,1); + markerTexture = "textures\\detect_enchantment_icon.dds"; } int counter = 0; @@ -499,7 +495,7 @@ namespace MWGui widgetCoord, MyGUI::Align::Default); markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setImageTexture(markerTexture); - markerWidget->setColour(markerColour); + markerWidget->setImageCoord(MyGUI::IntCoord(0,0,8,8)); markerWidget->setNeedMouseFocus(false); mMagicMarkerWidgets.push_back(markerWidget); } From 033719ccd70db35d3d67d4d707bb2de3c4c184b4 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 6 May 2015 02:11:35 +0200 Subject: [PATCH 015/119] Correct the icon used for custom map markers --- apps/openmw/mwgui/mapwindow.cpp | 12 ++++++------ files/mygui/openmw_resources.xml | 9 +++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 269b43a71f..9adfeffe88 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -300,17 +300,17 @@ namespace MWGui MarkerUserData markerPos; MyGUI::IntPoint widgetPos = getMarkerPosition(marker.mWorldX, marker.mWorldY, markerPos); - MyGUI::IntCoord widgetCoord(widgetPos.left - 4, - widgetPos.top - 4, - 8, 8); - MarkerWidget* markerWidget = mLocalMap->createWidget("MarkerButton", + MyGUI::IntCoord widgetCoord(widgetPos.left - 8, + widgetPos.top - 8, + 16, 16); + MarkerWidget* markerWidget = mLocalMap->createWidget("CustomMarkerButton", widgetCoord, MyGUI::Align::Default); markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setUserString("ToolTipType", "Layout"); markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); markerWidget->setUserString("Caption_TextOneLine", MyGUI::TextIterator::toTagsString(marker.mNote)); - markerWidget->setNormalColour(MyGUI::Colour(1.0f, 0.3f, 0.3f)); - markerWidget->setHoverColour(MyGUI::Colour(1.0f, 0.5f, 0.5f)); + markerWidget->setNormalColour(MyGUI::Colour(0.6f, 0.6f, 0.6f)); + markerWidget->setHoverColour(MyGUI::Colour(1.0f, 1.0f, 1.0f)); markerWidget->setUserData(marker); markerWidget->setNeedMouseFocus(true); customMarkerCreated(markerWidget); diff --git a/files/mygui/openmw_resources.xml b/files/mygui/openmw_resources.xml index 423281a621..305cb0c0da 100644 --- a/files/mygui/openmw_resources.xml +++ b/files/mygui/openmw_resources.xml @@ -31,6 +31,15 @@ + + + + + + + + + From b312f50b1f609355011fc89763df6aeeec0ab8cf Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 6 May 2015 02:12:55 +0200 Subject: [PATCH 016/119] Fix regression with detect spells detecting deleted objects (Fixes #2518) --- apps/openmw/mwworld/worldimp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 013386f8f9..0f81106248 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2956,7 +2956,7 @@ namespace MWWorld Ogre::Vector3(mDetector.getRefData().getPosition().pos)) >= mSquaredDist) return true; - if (!ptr.getRefData().isEnabled()) + if (!ptr.getRefData().isEnabled() || ptr.getRefData().isDeleted()) return true; // Consider references inside containers as well (except if we are looking for a Creature, they cannot be in containers) From eef8f717973d69f1242db16db4517156d37f1d77 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 7 May 2015 16:46:59 +0200 Subject: [PATCH 017/119] Add a comment --- apps/openmw/mwworld/cellstore.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index d7036d6b19..672b6046b6 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -120,6 +120,7 @@ namespace MWWorld /// Call functor (ref) for each reference. functor must return a bool. Returning /// false will abort the iteration. + /// \attention This function also lists deleted (count 0) objects! /// \return Iteration completed? /// /// \note Creatures and NPCs are handled last. From 3b8b217888469c839c53ca4945deaeb88ac4d6bf Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 8 May 2015 02:22:39 +0200 Subject: [PATCH 018/119] Fix no punishment for stealing when taking an item with the inventory opened --- apps/openmw/mwgui/inventorywindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 80b246e840..9aa8a8ea1d 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -594,6 +594,8 @@ namespace MWGui MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWBase::Environment::get().getWorld()->breakInvisibility(player); + MWBase::Environment::get().getMechanicsManager()->itemTaken(player, object, MWWorld::Ptr(), count); + // add to player inventory // can't use ActionTake here because we need an MWWorld::Ptr to the newly inserted object MWWorld::Ptr newObject = *player.getClass().getContainerStore (player).add (object, object.getRefData().getCount(), player); @@ -612,8 +614,6 @@ namespace MWGui throw std::runtime_error("Added item not found"); mDragAndDrop->startDrag(i, mSortModel, mTradeModel, mItemView, count); - MWBase::Environment::get().getMechanicsManager()->itemTaken(player, newObject, MWWorld::Ptr(), count); - MWBase::Environment::get().getWindowManager()->updateSpellWindow(); } From ac88326909d80223815a84743578a0c2adcbb583 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 8 May 2015 23:57:23 +0200 Subject: [PATCH 019/119] Exit out of choice when no responses are found (Fixes #2525) --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index b928738ddd..0b9fd65d20 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -485,6 +485,12 @@ namespace MWDialogue executeScript (info->mResultScript); } + else + { + mChoice = -1; + mIsInChoice = false; + MWBase::Environment::get().getWindowManager()->getDialogueWindow()->clearChoices(); + } } } From 9d86e5b02803550d7406a6cff53d6e12534d3a16 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 10 May 2015 13:04:50 +0200 Subject: [PATCH 020/119] GetSpellEffects returns true for active abilities (Fixes #2530) --- apps/openmw/mwmechanics/spells.cpp | 14 ++++++++++++++ apps/openmw/mwmechanics/spells.hpp | 3 +++ apps/openmw/mwscript/miscextensions.cpp | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index 04225b43eb..b1829964be 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -143,6 +143,20 @@ namespace MWMechanics return mSelectedSpell; } + bool Spells::isSpellActive(const std::string &id) const + { + TContainer::const_iterator found = mSpells.find(id); + if (found != mSpells.end()) + { + const ESM::Spell *spell = + MWBase::Environment::get().getWorld()->getStore().get().find (id); + + return (spell->mData.mType==ESM::Spell::ST_Ability || spell->mData.mType==ESM::Spell::ST_Blight || + spell->mData.mType==ESM::Spell::ST_Disease || spell->mData.mType==ESM::Spell::ST_Curse); + } + return false; + } + bool Spells::hasCommonDisease() const { for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) diff --git a/apps/openmw/mwmechanics/spells.hpp b/apps/openmw/mwmechanics/spells.hpp index 064b2c1e5d..6b41499395 100644 --- a/apps/openmw/mwmechanics/spells.hpp +++ b/apps/openmw/mwmechanics/spells.hpp @@ -98,6 +98,9 @@ namespace MWMechanics const std::string getSelectedSpell() const; ///< May return an empty string. + bool isSpellActive(const std::string& id) const; + ///< Are we under the effects of the given spell ID? + bool hasCommonDisease() const; bool hasBlightDisease() const; diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 29f586a653..38106340ae 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -595,7 +595,8 @@ namespace MWScript std::string id = runtime.getStringLiteral(runtime[0].mInteger); runtime.pop(); - runtime.push(ptr.getClass().getCreatureStats(ptr).getActiveSpells().isSpellActive(id)); + const MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr); + runtime.push(stats.getActiveSpells().isSpellActive(id) || stats.getSpells().isSpellActive(id)); } }; From c819180aa1299422f42f94b82cc58d48f6c76a6c Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 10 May 2015 13:09:22 +0200 Subject: [PATCH 021/119] Minor cleanup --- apps/openmw/mwgui/spellbuyingwindow.cpp | 8 +------- apps/openmw/mwscript/statsextensions.cpp | 10 ++-------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index 57b02940e1..76a1d51e5b 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -127,13 +127,7 @@ namespace MWGui bool SpellBuyingWindow::playerHasSpell(const std::string &id) { MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); - MWMechanics::Spells& playerSpells = player.getClass().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; + return player.getClass().getCreatureStats(player).getSpells().hasSpell(id); } void SpellBuyingWindow::onSpellButtonClick(MyGUI::Widget* _sender) diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index d825b085e7..80f46e4573 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -515,14 +515,8 @@ namespace MWScript Interpreter::Type_Integer value = 0; - for (MWMechanics::Spells::TIterator iter ( - ptr.getClass().getCreatureStats (ptr).getSpells().begin()); - iter!=ptr.getClass().getCreatureStats (ptr).getSpells().end(); ++iter) - if (iter->first==id) - { - value = 1; - break; - } + if (ptr.getClass().getCreatureStats(ptr).getSpells().hasSpell(id)) + value = 1; runtime.push (value); } From 97c35da441f1de47aeb523cb3f1594b6195caf91 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 10 May 2015 15:34:07 +0200 Subject: [PATCH 022/119] Change exterior water level to z=-1 (Fixes #1405) --- apps/openmw/mwworld/scene.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 8d689240b6..f5a9b8960d 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -256,12 +256,13 @@ namespace MWWorld insertCell (*cell, true, loadingListener); mRendering.cellAdded (cell); - bool waterEnabled = cell->getCell()->hasWater(); + bool waterEnabled = cell->getCell()->hasWater() || cell->isExterior(); mRendering.setWaterEnabled(waterEnabled); + float waterLevel = cell->isExterior() ? -1.f : cell->getWaterLevel(); if (waterEnabled) { - mPhysics->enableWater(cell->getWaterLevel()); - mRendering.setWaterHeight(cell->getWaterLevel()); + mPhysics->enableWater(waterLevel); + mRendering.setWaterHeight(waterLevel); } else mPhysics->disableWater(); From 58a2ad663cee7de5e9f419af80485c97ca890c63 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 11 May 2015 16:24:52 +0200 Subject: [PATCH 023/119] Fix regression of sleep interruption chance --- apps/openmw/mwgui/waitdialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/waitdialog.cpp b/apps/openmw/mwgui/waitdialog.cpp index f74b068912..94905dd9e8 100644 --- a/apps/openmw/mwgui/waitdialog.cpp +++ b/apps/openmw/mwgui/waitdialog.cpp @@ -155,8 +155,9 @@ namespace MWGui if (!region->mSleepList.empty()) { // figure out if player will be woken while sleeping + int x = OEngine::Misc::Rng::rollDice(hoursToWait); float fSleepRandMod = world->getStore().get().find("fSleepRandMod")->getFloat(); - if (OEngine::Misc::Rng::rollProbability() > fSleepRandMod) + if (x > fSleepRandMod * hoursToWait) { float fSleepRestMod = world->getStore().get().find("fSleepRestMod")->getFloat(); mInterruptAt = hoursToWait - int(fSleepRestMod * hoursToWait); From 5abeab21edb1854955bb0865b3cf6d22b2d48a38 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 11 May 2015 16:55:09 +0200 Subject: [PATCH 024/119] Various integer/floating point roll adjustments based on wiki --- apps/openmw/mwclass/creature.cpp | 2 +- apps/openmw/mwclass/npc.cpp | 2 +- apps/openmw/mwgui/pickpocketitemmodel.cpp | 2 +- apps/openmw/mwmechanics/combat.cpp | 2 +- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 8404b95234..192bdf2ce8 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -251,7 +251,7 @@ namespace MWClass float hitchance = MWMechanics::getHitChance(ptr, victim, ref->mBase->mData.mCombat); - if(OEngine::Misc::Rng::rollProbability() >= hitchance/100.0f) + if(OEngine::Misc::Rng::roll0to99() >= hitchance) { victim.getClass().onHit(victim, 0.0f, false, MWWorld::Ptr(), ptr, false); MWMechanics::reduceWeaponCondition(0.f, false, weapon, ptr); diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 1d58dc87e3..3ca57aca88 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -515,7 +515,7 @@ namespace MWClass float hitchance = MWMechanics::getHitChance(ptr, victim, ptr.getClass().getSkill(ptr, weapskill)); - if (OEngine::Misc::Rng::rollProbability() >= hitchance / 100.0f) + if (OEngine::Misc::Rng::roll0to99() >= hitchance) { othercls.onHit(victim, 0.0f, false, weapon, ptr, false); MWMechanics::reduceWeaponCondition(0.f, false, weapon, ptr); diff --git a/apps/openmw/mwgui/pickpocketitemmodel.cpp b/apps/openmw/mwgui/pickpocketitemmodel.cpp index bc7c5528e8..b8ac20f99d 100644 --- a/apps/openmw/mwgui/pickpocketitemmodel.cpp +++ b/apps/openmw/mwgui/pickpocketitemmodel.cpp @@ -20,7 +20,7 @@ namespace MWGui { for (size_t i = 0; igetItemCount(); ++i) { - if (chance <= OEngine::Misc::Rng::roll0to99()) + if (OEngine::Misc::Rng::roll0to99() > chance) mHiddenItems.push_back(mSourceModel->getItem(i)); } } diff --git a/apps/openmw/mwmechanics/combat.cpp b/apps/openmw/mwmechanics/combat.cpp index c5fc34507b..045f0108ca 100644 --- a/apps/openmw/mwmechanics/combat.cpp +++ b/apps/openmw/mwmechanics/combat.cpp @@ -187,7 +187,7 @@ namespace MWMechanics int skillValue = attacker.getClass().getSkill(attacker, weapon.getClass().getEquipmentSkill(weapon)); - if (OEngine::Misc::Rng::rollProbability() >= getHitChance(attacker, victim, skillValue) / 100.0f) + if (OEngine::Misc::Rng::roll0to99() >= getHitChance(attacker, victim, skillValue)) { victim.getClass().onHit(victim, 0.0f, false, projectile, attacker, false); MWMechanics::reduceWeaponCondition(0.f, false, weapon, attacker); diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index da8d49db0f..c829154e27 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -737,7 +737,7 @@ namespace MWMechanics float x = 0; float y = 0; - float roll = OEngine::Misc::Rng::rollClosedProbability() * 100; + int roll = OEngine::Misc::Rng::roll0to99(); if (type == PT_Admire) { From 5cf50227b4e0a1318606df0c5e56c7f41a5dd9fd Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 13 May 2015 19:53:50 +0200 Subject: [PATCH 025/119] updated changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15464b1d72..3219edd9ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Bug #923: Editor: Operations-Multithreading is broken Bug #1317: Erene Llenim in Seyda Neen does not walk around + Bug #1405: Water rendering glitch near Seyda Neen lighthouse Bug #1621: "Error Detecting Morrowind Installation" in the default directory Bug #2216: Creating a clone of the player stops you moving. Bug #2387: Casting bound weapon spell doesn't switch to "ready weapon" mode @@ -23,6 +24,10 @@ Bug #2475: cumulative stacks of 100 point fortify skill speechcraft boosts do not apply correctly Bug #2498: Editor: crash when issuing undo command after the table subview is closed Bug #2500: Editor: object table - can't undo delete record + Bug #2518: OpenMW detect spell returns false positives + Bug #2521: NPCs don't react to stealing when inventory menu is open. + Bug #2525: Can't click on red dialogue choice [rise of house telvanni][60fffec] + Bug #2530: GetSpellEffects not working as in vanilla Feature #139: Editor: Global Search & Replace Feature #1219: Editor: Add dialogue mode only columns Feature #2024: Hotkey for hand to hand (i.e. unequip any weapon) @@ -34,6 +39,7 @@ Feature #2505: Editor: optionally show a line number column in the script editor Feature #2512: Editor: Offer use of monospace fonts in the script editor as an option Feature #2514: Editor: focus on ID input field on clone/add + Feature #2519: it is not possible to change icons that appear on the map after casting the Detect spells Task #2460: OS X: Use Application Support directory as user data path Task #2516: Editor: Change References / Referenceables terminology From c9d519f36c62611a768936018fe185a011a4d6a0 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 14 May 2015 14:48:29 +0200 Subject: [PATCH 026/119] focus search input field when opening search subview (Fixes #2534) --- apps/opencs/view/tools/searchbox.cpp | 7 +++++++ apps/opencs/view/tools/searchbox.hpp | 2 ++ apps/opencs/view/tools/searchsubview.cpp | 8 +++++++- apps/opencs/view/tools/searchsubview.hpp | 4 ++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/tools/searchbox.cpp b/apps/opencs/view/tools/searchbox.cpp index ca55207875..1307c1aab1 100644 --- a/apps/opencs/view/tools/searchbox.cpp +++ b/apps/opencs/view/tools/searchbox.cpp @@ -153,6 +153,11 @@ void CSVTools::SearchBox::setEditLock (bool locked) mReplace.setEnabled (!locked); } +void CSVTools::SearchBox::focus() +{ + mInput.currentWidget()->setFocus(); +} + void CSVTools::SearchBox::modeSelected (int index) { switch (index) @@ -172,6 +177,8 @@ void CSVTools::SearchBox::modeSelected (int index) break; } + mInput.currentWidget()->setFocus(); + updateSearchButton(); } diff --git a/apps/opencs/view/tools/searchbox.hpp b/apps/opencs/view/tools/searchbox.hpp index 433c096936..fe56966d11 100644 --- a/apps/opencs/view/tools/searchbox.hpp +++ b/apps/opencs/view/tools/searchbox.hpp @@ -49,6 +49,8 @@ namespace CSVTools void setEditLock (bool locked); + void focus(); + private slots: void modeSelected (int index); diff --git a/apps/opencs/view/tools/searchsubview.cpp b/apps/opencs/view/tools/searchsubview.cpp index 32c26ee969..dc670af40a 100644 --- a/apps/opencs/view/tools/searchsubview.cpp +++ b/apps/opencs/view/tools/searchsubview.cpp @@ -60,6 +60,12 @@ void CSVTools::SearchSubView::replace (bool selection) } } +void CSVTools::SearchSubView::showEvent (QShowEvent *event) +{ + CSVDoc::SubView::showEvent (event); + mSearchBox.focus(); +} + CSVTools::SearchSubView::SearchSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) : CSVDoc::SubView (id), mDocument (document), mLocked (false) { @@ -83,7 +89,7 @@ CSVTools::SearchSubView::SearchSubView (const CSMWorld::UniversalId& id, CSMDoc: SIGNAL (focusId (const CSMWorld::UniversalId&, const std::string&))); connect (mTable, SIGNAL (replaceRequest()), this, SLOT (replaceRequest())); - + connect (&document, SIGNAL (stateChanged (int, CSMDoc::Document *)), this, SLOT (stateChanged (int, CSMDoc::Document *))); diff --git a/apps/opencs/view/tools/searchsubview.hpp b/apps/opencs/view/tools/searchsubview.hpp index 6dedd6ef2b..2e96b98b50 100644 --- a/apps/opencs/view/tools/searchsubview.hpp +++ b/apps/opencs/view/tools/searchsubview.hpp @@ -32,6 +32,10 @@ namespace CSVTools private: void replace (bool selection); + + protected: + + void showEvent (QShowEvent *event); public: From f92d801fafa64ea3cabd78886a3d6dae2760b5af Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 15 May 2015 12:32:29 +1000 Subject: [PATCH 027/119] Jump to the added/cloned record (or undeleted record in case of undo). Should resolve Feature #2541. Controlled by radio buttons on user preferences settings. --- apps/opencs/model/settings/usersettings.cpp | 8 +++ apps/opencs/view/world/table.cpp | 54 +++++++++++++++++++-- apps/opencs/view/world/table.hpp | 4 ++ 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 9e00b7d1aa..41ce593b75 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -206,6 +206,14 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() shiftCtrlDoubleClick->setDeclaredValues (values); shiftCtrlDoubleClick->setDefaultValue (editRecordAndClose); shiftCtrlDoubleClick->setToolTip ("Action on shift control double click in table:

" + toolTip); + + QString defaultValue = "Jump and Select"; + QStringList jumpValues = QStringList() << defaultValue << "Jump Only" << "No Jump"; + + Setting *jumpToAdded = createSetting (Type_RadioButton, "jump-to-added", + "Jump to the added or cloned record."); + jumpToAdded->setDefaultValue (defaultValue); + jumpToAdded->setDeclaredValues (jumpValues); } declareSection ("search", "Search & Replace"); diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 5a650f98a1..44150bbc6a 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -21,6 +21,7 @@ #include "../../model/world/tablemimedata.hpp" #include "../../model/world/tablemimedata.hpp" #include "../../model/world/commanddispatcher.hpp" +#include "../../model/settings/usersettings.hpp" #include "recordstatusdelegate.hpp" #include "util.hpp" @@ -255,6 +256,24 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, : mCreateAction (0), mCloneAction(0), mRecordStatusDisplay (0), DragRecordTable(document) { + CSMSettings::UserSettings &settings = CSMSettings::UserSettings::instance(); + QString jumpSetting = settings.settingValue ("table-input/jump-to-added"); + if (jumpSetting.isEmpty() || jumpSetting == "Jump and Select") // default + { + mJumpToAddedRecord = true; + mUnselectAfterJump = false; + } + else if(jumpSetting == "Jump Only") + { + mJumpToAddedRecord = true; + mUnselectAfterJump = true; + } + else + { + mJumpToAddedRecord = false; + mUnselectAfterJump = false; + } + mModel = &dynamic_cast (*mDocument.getData().getTableModel (id)); mProxyModel = new CSMWorld::IdTableProxyModel (this); @@ -346,7 +365,7 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, addAction (mExtendedRevertAction); connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)), - this, SLOT (tableSizeUpdate())); + this, SLOT (rowsInsertedEvent(const QModelIndex&, int, int))); /// \note This signal could instead be connected to a slot that filters out changes not affecting /// the records status column (for permanence reasons) @@ -517,9 +536,27 @@ void CSVWorld::Table::previewRecord() } } -void CSVWorld::Table::updateUserSetting - (const QString &name, const QStringList &list) +void CSVWorld::Table::updateUserSetting (const QString &name, const QStringList &list) { + if (name=="table-input/jump-to-added") + { + if(list.isEmpty() || list.at(0) == "Jump and Select") // default + { + mJumpToAddedRecord = true; + mUnselectAfterJump = false; + } + else if(list.at(0) == "Jump Only") + { + mJumpToAddedRecord = true; + mUnselectAfterJump = true; + } + else // No Jump + { + mJumpToAddedRecord = false; + mUnselectAfterJump = false; + } + } + if (name=="records/type-format" || name=="records/status-format") { int columns = mModel->columnCount(); @@ -700,3 +737,14 @@ std::vector< CSMWorld::UniversalId > CSVWorld::Table::getDraggedRecords() const return idToDrag; } +void CSVWorld::Table::rowsInsertedEvent(const QModelIndex& parent, int start, int end) +{ + tableSizeUpdate(); + if(mJumpToAddedRecord) + { + selectRow(end); + + if(mUnselectAfterJump) + clearSelection(); + } +} diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index 75161b8b65..becb21f65d 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -67,6 +67,8 @@ namespace CSVWorld CSMWorld::CommandDispatcher *mDispatcher; CSMWorld::UniversalId mEditCellId; std::map mDoubleClickActions; + bool mJumpToAddedRecord; + bool mUnselectAfterJump; private: @@ -139,6 +141,8 @@ namespace CSVWorld void recordFilterChanged (boost::shared_ptr filter); void updateUserSetting (const QString &name, const QStringList &list); + + void rowsInsertedEvent(const QModelIndex& parent, int start, int end); }; } From 28617c8beb8cf3353033b2d946d6f2bd93c3a561 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 15 May 2015 12:33:31 +1000 Subject: [PATCH 028/119] Update table size status for removed rows. --- apps/opencs/view/world/table.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 44150bbc6a..86daf8af7b 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -364,6 +364,9 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, connect (mExtendedRevertAction, SIGNAL (triggered()), mDispatcher, SLOT (executeExtendedRevert())); addAction (mExtendedRevertAction); + connect (mProxyModel, SIGNAL (rowsRemoved (const QModelIndex&, int, int)), + this, SLOT (tableSizeUpdate())); + connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)), this, SLOT (rowsInsertedEvent(const QModelIndex&, int, int))); From 27000fb36b8a2ffdfb4d57087b5751cb1e7526b0 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 15 May 2015 14:09:35 +0200 Subject: [PATCH 029/119] don't reject single precision float values in value filters (Fixes #2533) --- apps/opencs/model/filter/valuenode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/filter/valuenode.cpp b/apps/opencs/model/filter/valuenode.cpp index 72cf5896bf..6fdae3e1ba 100644 --- a/apps/opencs/model/filter/valuenode.cpp +++ b/apps/opencs/model/filter/valuenode.cpp @@ -27,7 +27,7 @@ bool CSMFilter::ValueNode::test (const CSMWorld::IdTableBase& table, int row, QVariant data = table.data (index); if (data.type()!=QVariant::Double && data.type()!=QVariant::Bool && data.type()!=QVariant::Int && - data.type()!=QVariant::UInt) + data.type()!=QVariant::UInt && data.type()!=static_cast (QMetaType::Float)) return false; double value = data.toDouble(); From 60a835c16d0ae58e1fed8fe933dad752c4e03a5d Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 16 May 2015 10:18:11 +0200 Subject: [PATCH 030/119] stop script editor from eating undo/redo shortcuts (Fixes #2506) --- apps/opencs/view/world/scriptedit.cpp | 13 +++++++++++++ apps/opencs/view/world/scriptedit.hpp | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index b4f4234f19..2e05fa110e 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -25,6 +25,19 @@ CSVWorld::ScriptEdit::ChangeLock::~ChangeLock() --mEdit.mChangeLocked; } +bool CSVWorld::ScriptEdit::event (QEvent *event) +{ + // ignore undo and redo shortcuts + if (event->type()==QEvent::ShortcutOverride) + { + QKeyEvent *keyEvent = static_cast (event); + + if (keyEvent->matches (QKeySequence::Undo) || keyEvent->matches (QKeySequence::Redo)) + return true; + } + + return QPlainTextEdit::event (event); +} CSVWorld::ScriptEdit::ScriptEdit (const CSMDoc::Document& document, ScriptHighlighter::Mode mode, QWidget* parent) diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp index a19cee486b..fb577e60e4 100644 --- a/apps/opencs/view/world/scriptedit.hpp +++ b/apps/opencs/view/world/scriptedit.hpp @@ -53,6 +53,10 @@ namespace CSVWorld QFont mDefaultFont; QFont mMonoFont; + protected: + + bool event (QEvent *event); + public: ScriptEdit (const CSMDoc::Document& document, ScriptHighlighter::Mode mode, From 7d321e0fb7faba64cbb5f11dea2ea8dbf70bdb27 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 16 May 2015 13:18:04 +0300 Subject: [PATCH 031/119] Fix #2557 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don’t show main dialog right away if wizard is selected. --- apps/launcher/main.cpp | 6 ++++-- apps/launcher/maindialog.cpp | 10 +++++----- apps/launcher/maindialog.hpp | 8 +++++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/launcher/main.cpp b/apps/launcher/main.cpp index 11ea568692..ba06861107 100644 --- a/apps/launcher/main.cpp +++ b/apps/launcher/main.cpp @@ -59,14 +59,16 @@ int main(int argc, char *argv[]) Launcher::MainDialog mainWin; - if (!mainWin.showFirstRunDialog()) + Launcher::FirstRunDialogResult result = mainWin.showFirstRunDialog(); + if (result == Launcher::FirstRunDialogResultFailure) return 0; // if (!mainWin.setup()) { // return 0; // } - mainWin.show(); + if (result == Launcher::FirstRunDialogResultContinue) + mainWin.show(); int returnValue = app.exec(); SDL_Quit(); diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index 00e6a9aa29..fd36993bfb 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -148,10 +148,10 @@ void Launcher::MainDialog::createPages() } -bool Launcher::MainDialog::showFirstRunDialog() +Launcher::FirstRunDialogResult Launcher::MainDialog::showFirstRunDialog() { if (!setupLauncherSettings()) - return false; + return FirstRunDialogResultFailure; if (mLauncherSettings.value(QString("General/firstrun"), QString("true")) == QLatin1String("true")) { @@ -176,14 +176,14 @@ bool Launcher::MainDialog::showFirstRunDialog() if (msgBox.clickedButton() == wizardButton) { if (!mWizardInvoker->startProcess(QLatin1String("openmw-wizard"), false)) { - return false; + return FirstRunDialogResultFailure; } else { - return true; + return FirstRunDialogResultWizard; } } } - return setup(); + return setup() ? FirstRunDialogResultContinue : FirstRunDialogResultFailure; } bool Launcher::MainDialog::setup() diff --git a/apps/launcher/maindialog.hpp b/apps/launcher/maindialog.hpp index 0708f70026..4c21dbaf4f 100644 --- a/apps/launcher/maindialog.hpp +++ b/apps/launcher/maindialog.hpp @@ -31,6 +31,12 @@ namespace Launcher class UnshieldThread; class SettingsPage; + typedef enum { + FirstRunDialogResultFailure, + FirstRunDialogResultContinue, + FirstRunDialogResultWizard + } FirstRunDialogResult; + #ifndef WIN32 bool expansions(Launcher::UnshieldThread& cd); #endif @@ -44,7 +50,7 @@ namespace Launcher ~MainDialog(); bool setup(); - bool showFirstRunDialog(); + FirstRunDialogResult showFirstRunDialog(); bool reloadSettings(); bool writeSettings(); From 1b41f6c4c54bbb8f46393bb8f57fcdf00ef820f5 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 16 May 2015 12:29:26 +0200 Subject: [PATCH 032/119] Sleep interruption fix --- apps/openmw/mwgui/waitdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/waitdialog.cpp b/apps/openmw/mwgui/waitdialog.cpp index 94905dd9e8..28e3be5911 100644 --- a/apps/openmw/mwgui/waitdialog.cpp +++ b/apps/openmw/mwgui/waitdialog.cpp @@ -157,7 +157,7 @@ namespace MWGui // figure out if player will be woken while sleeping int x = OEngine::Misc::Rng::rollDice(hoursToWait); float fSleepRandMod = world->getStore().get().find("fSleepRandMod")->getFloat(); - if (x > fSleepRandMod * hoursToWait) + if (x < fSleepRandMod * hoursToWait) { float fSleepRestMod = world->getStore().get().find("fSleepRestMod")->getFloat(); mInterruptAt = hoursToWait - int(fSleepRestMod * hoursToWait); From 34f106749a3b302f00f9c0172e1a5911dca4c6df Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 17 May 2015 10:38:15 +0200 Subject: [PATCH 033/119] removed a redundant typedef --- apps/launcher/maindialog.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/launcher/maindialog.hpp b/apps/launcher/maindialog.hpp index 4c21dbaf4f..c903099901 100644 --- a/apps/launcher/maindialog.hpp +++ b/apps/launcher/maindialog.hpp @@ -31,11 +31,12 @@ namespace Launcher class UnshieldThread; class SettingsPage; - typedef enum { + enum FirstRunDialogResult + { FirstRunDialogResultFailure, FirstRunDialogResultContinue, FirstRunDialogResultWizard - } FirstRunDialogResult; + }; #ifndef WIN32 bool expansions(Launcher::UnshieldThread& cd); From b9856162b33ff4f0d1a1d46d68b64373496b29ba Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 17 May 2015 10:38:54 +0200 Subject: [PATCH 034/119] updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3219edd9ac..466c2ef253 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ Bug #2521: NPCs don't react to stealing when inventory menu is open. Bug #2525: Can't click on red dialogue choice [rise of house telvanni][60fffec] Bug #2530: GetSpellEffects not working as in vanilla + Bug #2557: Crash on first launch after choosing "Run installation wizard" Feature #139: Editor: Global Search & Replace Feature #1219: Editor: Add dialogue mode only columns Feature #2024: Hotkey for hand to hand (i.e. unequip any weapon) From e9ca02216201fdb64e1dcd59a6a385d8a4c067d5 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 17 May 2015 20:45:13 +1000 Subject: [PATCH 035/119] Add an optional horizontal scrollbar to the main view window. Should resolve Feature #2549. - TableSubviews and DialogueSubviews now provide size hints - Option to stop the growth of the window at the screen boundary for multi-monitor setup with different resolution. - Three options: Grow Only: No change to current, except the use of size hints Scrollbar Only: Simple addition of a scrollbar, the view window does not grow Grow then Scroll: Window grows as per current behaviour. The scrollbar appears once it cannot grow any further. --- apps/opencs/model/settings/usersettings.cpp | 14 ++ apps/opencs/view/doc/subview.cpp | 16 +++ apps/opencs/view/doc/subview.hpp | 13 ++ apps/opencs/view/doc/view.cpp | 145 +++++++++++++++++++- apps/opencs/view/doc/view.hpp | 5 + apps/opencs/view/world/dialoguesubview.cpp | 12 +- apps/opencs/view/world/tablesubview.cpp | 12 +- 7 files changed, 213 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 41ce593b75..bd31b6e384 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -143,6 +143,20 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() minWidth->setDefaultValue (325); minWidth->setRange (50, 10000); minWidth->setToolTip ("Minimum width of subviews."); + + QString defaultScroll = "Scrollbar Only"; + QStringList scrollValues = QStringList() << defaultScroll << "Grow Only" << "Grow then Scroll"; + + Setting *mainwinScroll = createSetting (Type_RadioButton, "mainwindow-scrollbar", + "Add a horizontal scrollbar to the main view window."); + mainwinScroll->setDefaultValue (defaultScroll); + mainwinScroll->setDeclaredValues (scrollValues); + + Setting *grow = createSetting (Type_CheckBox, "grow-limit", "Grow Limit Screen"); + grow->setDefaultValue ("false"); + grow->setToolTip ("When \"Grow then Scroll\" option is selected, the window size grows to" + " the width of the virtual desktop. \nIf this option is selected the the window growth" + "is limited to the current screen."); } declareSection ("records", "Records"); diff --git a/apps/opencs/view/doc/subview.cpp b/apps/opencs/view/doc/subview.cpp index df1e7ee492..09128d9191 100644 --- a/apps/opencs/view/doc/subview.cpp +++ b/apps/opencs/view/doc/subview.cpp @@ -43,3 +43,19 @@ void CSVDoc::SubView::closeRequest() { emit closeRequest (this); } + +CSVDoc::SizeHintWidget::SizeHintWidget(QWidget *parent) : QWidget(parent) +{} + +CSVDoc::SizeHintWidget::~SizeHintWidget() +{} + +QSize CSVDoc::SizeHintWidget::sizeHint() const +{ + return mSize; +} + +void CSVDoc::SizeHintWidget::setSizeHint(const QSize &size) +{ + mSize = size; +} diff --git a/apps/opencs/view/doc/subview.hpp b/apps/opencs/view/doc/subview.hpp index a8aa3cda1e..f327107c21 100644 --- a/apps/opencs/view/doc/subview.hpp +++ b/apps/opencs/view/doc/subview.hpp @@ -8,6 +8,7 @@ #include "subviewfactory.hpp" #include +#include class QUndoStack; @@ -70,6 +71,18 @@ namespace CSVDoc void closeRequest(); }; + + class SizeHintWidget : public QWidget + { + QSize mSize; + + public: + SizeHintWidget(QWidget *parent = 0); + ~SizeHintWidget(); + + virtual QSize sizeHint() const; + void setSizeHint(const QSize &size); + }; } #endif diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 5636fff943..16b96ed4d3 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -9,6 +9,10 @@ #include #include #include +#include +#include +#include +#include #include "../../model/doc/document.hpp" #include "../../model/settings/usersettings.hpp" @@ -16,6 +20,7 @@ #include "../../model/world/idtable.hpp" #include "../world/subviews.hpp" +#include "../world/tablesubview.hpp" #include "../tools/subviews.hpp" @@ -334,8 +339,15 @@ void CSVDoc::View::updateTitle() void CSVDoc::View::updateSubViewIndicies(SubView *view) { if(view && mSubViews.contains(view)) + { mSubViews.removeOne(view); + // adjust (reduce) the scroll area (even floating), except when it is "Scrollbar Only" + CSMSettings::UserSettings &settings = CSMSettings::UserSettings::instance(); + if(settings.settingValue ("window/mainwindow-scrollbar") == "Grow then Scroll") + updateScrollbar(); + } + CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); bool hideTitle = userSettings.setting ("window/hide-subview", QString ("false"))=="true" && @@ -381,7 +393,7 @@ void CSVDoc::View::updateActions() CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews) : mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1), - mViewTotal (totalViews) + mViewTotal (totalViews), mScroll(0), mScrollbarOnly(false) { int width = CSMSettings::UserSettings::instance().settingValue ("window/default-width").toInt(); @@ -400,7 +412,18 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to mSubViewWindow.setDockOptions (QMainWindow::AllowNestedDocks); - setCentralWidget (&mSubViewWindow); + CSMSettings::UserSettings &settings = CSMSettings::UserSettings::instance(); + if(settings.settingValue ("window/mainwindow-scrollbar") == "Grow Only") + { + setCentralWidget (&mSubViewWindow); + } + else + { + mScroll = new QScrollArea(this); + mScroll->setWidgetResizable(true); + mScroll->setWidget(&mSubViewWindow); + setCentralWidget(mScroll); + } mOperations = new Operations; addDockWidget (Qt::BottomDockWidgetArea, mOperations); @@ -527,6 +550,59 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin view->setStatusBar (mShowStatusBar->isChecked()); + // Work out how to deal with additional subviews + // + // Policy for "Grow then Scroll": + // + // - Increase the horizontal width of the mainwindow until it becomes greater than or equal + // to the screen (monitor) width. + // - Move the mainwindow position sideways if necessary to fit within the screen. + // - Any more additions increases the size of the mSubViewWindow (horizontal scrollbar + // should become visible) + // - Move the scroll bar to the newly added subview + // + CSMSettings::UserSettings &settings = CSMSettings::UserSettings::instance(); + QString mainwinScroll = settings.settingValue ("window/mainwindow-scrollbar"); + if (mainwinScroll.isEmpty() || mainwinScroll == "Scrollbar Only") + mScrollbarOnly = true; + else if(mainwinScroll == "Grow Only") + mScrollbarOnly = false; + else + mScrollbarOnly = false; + + QDesktopWidget *dw = QApplication::desktop(); + QRect rect; + if(settings.settingValue ("window/grow-limit") == "true") + rect = dw->screenGeometry(this); + else + rect = dw->screenGeometry(dw->screen(dw->screenNumber(this))); + + if (!mScrollbarOnly && mScroll && mSubViews.size() > 1) + { + int newWidth = width()+minWidth; + int frameWidth = frameGeometry().width() - width(); + if (newWidth+frameWidth <= rect.width()) + { + resize(newWidth, height()); + // WARNING: below code assumes that new subviews are added to the right + if (x() > rect.width()-(newWidth+frameWidth)) + move(rect.width()-(newWidth+frameWidth), y()); // shift left to stay within the screen + } + else + { + // full width + resize(rect.width()-frameWidth, height()); + mSubViewWindow.setMinimumWidth(mSubViewWindow.width()+minWidth); + move(0, y()); + } + + // Make the new subview visible, setFocus() or raise() don't seem to work + // On Ubuntu the scrollbar does not go right to the end, even if using + // mScroll->horizontalScrollBar()->setValue(mScroll->horizontalScrollBar()->maximum()); + if (mSubViewWindow.width() > rect.width()) + mScroll->horizontalScrollBar()->setValue(mSubViewWindow.width()); + } + mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view); updateSubViewIndicies(); @@ -774,6 +850,48 @@ void CSVDoc::View::updateUserSetting (const QString &name, const QStringList &li { subView->updateUserSetting (name, list); } + + if (name=="window/mainwindow-scrollbar") + { + if(list.at(0) != "Grow Only") + { + if (mScroll) + { + if (list.at(0).isEmpty() || list.at(0) == "Scrollbar Only") + { + mScrollbarOnly = true; + mSubViewWindow.setMinimumWidth(0); + } + else + { + if(!mScrollbarOnly) + return; + + mScrollbarOnly = false; + updateScrollbar(); + } + } + else + { + mScroll = new QScrollArea(this); + mScroll->setWidgetResizable(true); + mScroll->setWidget(&mSubViewWindow); + setCentralWidget(mScroll); + } + } + else + { + if (mScroll) + { + mScroll->takeWidget(); + setCentralWidget (&mSubViewWindow); + mScroll->deleteLater(); + mScroll = 0; + } + else + return; + } + } } void CSVDoc::View::toggleShowStatusBar (bool show) @@ -815,3 +933,26 @@ void CSVDoc::View::closeRequest (SubView *subView) else if (mViewManager.closeRequest (this)) mViewManager.removeDocAndView (mDocument); } + +void CSVDoc::View::updateScrollbar() +{ + QRect rect; + QWidget *topLevel = QApplication::topLevelAt(pos()); + if (topLevel) + rect = topLevel->rect(); + else + rect = this->rect(); + + int newWidth = 0; + for (int i = 0; i < mSubViews.size(); ++i) + { + newWidth += mSubViews[i]->width(); + } + + int frameWidth = frameGeometry().width() - width(); + + if ((newWidth+frameWidth) >= rect.width()) + mSubViewWindow.setMinimumWidth(newWidth); + else + mSubViewWindow.setMinimumWidth(0); +} diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index 32d7159c28..1d44cb7f5a 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -10,6 +10,7 @@ class QAction; class QDockWidget; +class QScrollArea; namespace CSMDoc { @@ -47,6 +48,8 @@ namespace CSVDoc SubViewFactoryManager mSubViewFactory; QMainWindow mSubViewWindow; GlobalDebugProfileMenu *mGlobalDebugProfileMenu; + QScrollArea *mScroll; + bool mScrollbarOnly; // not implemented @@ -87,6 +90,8 @@ namespace CSVDoc /// User preference function void resizeViewHeight (int height); + void updateScrollbar(); + public: View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews); diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 0d0e82dbf3..ccab576fa0 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include "../../model/world/nestedtableproxymodel.hpp" #include "../../model/world/columnbase.hpp" @@ -581,7 +583,15 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM changeCurrentId(id.getId()); - QWidget *mainWidget = new QWidget(this); + //QWidget *mainWidget = new QWidget(this); + CSVDoc::SizeHintWidget *mainWidget = new CSVDoc::SizeHintWidget; + + const QRect rect = QApplication::desktop()->screenGeometry(this); + int frameHeight = 40; // set a reasonable default + QWidget *topLevel = QApplication::topLevelAt(pos()); + if (topLevel) + frameHeight = topLevel->frameGeometry().height() - topLevel->height(); + mainWidget->setSizeHint(QSize(400, rect.height()-frameHeight)); // FIXME: 400 QHBoxLayout *buttonsLayout = new QHBoxLayout; QToolButton* prevButton = new QToolButton(mainWidget); diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index 729b6b8d77..dde04fb3f7 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "../../model/doc/document.hpp" #include "../../model/world/tablemimedata.hpp" @@ -30,11 +33,18 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D layout->insertWidget (0, mFilterBox); - QWidget *widget = new QWidget; + CSVDoc::SizeHintWidget *widget = new CSVDoc::SizeHintWidget; widget->setLayout (layout); setWidget (widget); + // prefer height of the screen and full width of the table + const QRect rect = QApplication::desktop()->screenGeometry(this); + int frameHeight = 40; // set a reasonable default + QWidget *topLevel = QApplication::topLevelAt(pos()); + if (topLevel) + frameHeight = topLevel->frameGeometry().height() - topLevel->height(); + widget->setSizeHint(QSize(mTable->horizontalHeader()->length(), rect.height()-frameHeight)); connect (mTable, SIGNAL (editRequest (const CSMWorld::UniversalId&, const std::string&)), this, SLOT (editRequest (const CSMWorld::UniversalId&, const std::string&))); From 93c3bb37167a2887f2c5d07c2265a1bf63fb650b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 17 May 2015 14:27:17 +0200 Subject: [PATCH 036/119] fixed subview-closing related crash (Fixes #2564) --- apps/opencs/view/doc/view.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 5636fff943..e10f85c64a 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -811,7 +811,10 @@ void CSVDoc::View::closeRequest (SubView *subView) if (mSubViews.size()>1 || mViewTotal<=1 || userSettings.setting ("window/hide-subview", QString ("false"))!="true") + { subView->deleteLater(); + mSubViews.removeOne (subView); + } else if (mViewManager.closeRequest (this)) mViewManager.removeDocAndView (mDocument); } From 7b207a795468c7f9603655722f33a54a2476de52 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 17 May 2015 14:31:53 +0200 Subject: [PATCH 037/119] added shortcut for closing subviews (Fixes #2558) --- apps/opencs/view/doc/subview.cpp | 18 ++++++++++++++++++ apps/opencs/view/doc/subview.hpp | 2 ++ 2 files changed, 20 insertions(+) diff --git a/apps/opencs/view/doc/subview.cpp b/apps/opencs/view/doc/subview.cpp index df1e7ee492..f4f0c6afe8 100644 --- a/apps/opencs/view/doc/subview.cpp +++ b/apps/opencs/view/doc/subview.cpp @@ -2,6 +2,24 @@ #include "view.hpp" +#include +#include +#include + +bool CSVDoc::SubView::event (QEvent *event) +{ + if (event->type()==QEvent::ShortcutOverride) + { + QKeyEvent *keyEvent = static_cast (event); + + if (keyEvent->key()==Qt::Key_W && keyEvent->modifiers()==(Qt::ShiftModifier | Qt::ControlModifier)) + emit closeRequest(); + return true; + } + + return QDockWidget::event (event); +} + CSVDoc::SubView::SubView (const CSMWorld::UniversalId& id) : mUniversalId (id) { diff --git a/apps/opencs/view/doc/subview.hpp b/apps/opencs/view/doc/subview.hpp index a8aa3cda1e..b323f9ed92 100644 --- a/apps/opencs/view/doc/subview.hpp +++ b/apps/opencs/view/doc/subview.hpp @@ -34,6 +34,8 @@ namespace CSVDoc void setUniversalId(const CSMWorld::UniversalId& id); + bool event (QEvent *event); + public: SubView (const CSMWorld::UniversalId& id); From 8bcfac1ea3779ad3ac18b2dfedecb291f5c98418 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 17 May 2015 16:25:13 +0200 Subject: [PATCH 038/119] Fix adjustPosition not always working correctly (Fixes #2563) moveObject was returning an incorrect Ptr for cell movements. --- apps/openmw/mwbase/world.hpp | 4 +- .../mwscript/transformationextensions.cpp | 7 ++-- apps/openmw/mwworld/worldimp.cpp | 37 +++++++++---------- apps/openmw/mwworld/worldimp.hpp | 4 +- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 9e6c6d9bf3..c110e94d61 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -286,8 +286,8 @@ namespace MWBase virtual MWWorld::Ptr moveObject (const MWWorld::Ptr& ptr, float x, float y, float z) = 0; ///< @return an updated Ptr in case the Ptr's cell changes - virtual void - moveObject(const MWWorld::Ptr &ptr, MWWorld::CellStore* newCell, float x, float y, float z) = 0; + virtual MWWorld::Ptr moveObject(const MWWorld::Ptr &ptr, MWWorld::CellStore* newCell, float x, float y, float z) = 0; + ///< @return an updated Ptr virtual void scaleObject (const MWWorld::Ptr& ptr, float scale) = 0; diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index f87983ce88..414ef7fb7d 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -370,18 +370,17 @@ namespace MWScript // another morrowind oddity: player will be moved to the exterior cell at this location, // non-player actors will move within the cell they are in. - MWWorld::Ptr updated; if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr()) { MWWorld::CellStore* cell = MWBase::Environment::get().getWorld()->getExterior(cx,cy); MWBase::Environment::get().getWorld()->moveObject(ptr,cell,x,y,z); - updated = MWWorld::Ptr(ptr.getBase(), cell); + ptr = MWWorld::Ptr(ptr.getBase(), cell); } else { - updated = MWBase::Environment::get().getWorld()->moveObject(ptr, x, y, z); + ptr = MWBase::Environment::get().getWorld()->moveObject(ptr, x, y, z); } - dynamic_cast(runtime.getContext()).updatePtr(updated); + dynamic_cast(runtime.getContext()).updatePtr(ptr); float ax = Ogre::Radian(ptr.getRefData().getPosition().rot[0]).valueDegrees(); float ay = Ogre::Radian(ptr.getRefData().getPosition().rot[1]).valueDegrees(); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 0f81106248..bb0402c4e5 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1108,7 +1108,7 @@ namespace MWWorld } } - void World::moveObject(const Ptr &ptr, CellStore* newCell, float x, float y, float z) + MWWorld::Ptr World::moveObject(const Ptr &ptr, CellStore* newCell, float x, float y, float z) { ESM::Position pos = ptr.getRefData().getPosition(); @@ -1123,6 +1123,7 @@ namespace MWWorld CellStore *currCell = ptr.isInCell() ? ptr.getCell() : NULL; // currCell == NULL should only happen for player, during initial startup bool isPlayer = ptr == mPlayer->getPlayer(); bool haveToMove = isPlayer || (currCell && mWorldScene->isCellActive(*currCell)); + MWWorld::Ptr newPtr = ptr; if (currCell != newCell) { @@ -1140,6 +1141,7 @@ namespace MWWorld mWorldScene->changeToExteriorCell(pos, false); } addContainerScripts (getPlayerPtr(), newCell); + newPtr = getPlayerPtr(); } else { @@ -1147,7 +1149,7 @@ namespace MWWorld bool newCellActive = mWorldScene->isCellActive(*newCell); if (!currCellActive && newCellActive) { - MWWorld::Ptr newPtr = ptr.getClass().copyToCell(ptr, *newCell, pos); + newPtr = ptr.getClass().copyToCell(ptr, *newCell, pos); mWorldScene->addObjectToScene(newPtr); std::string script = newPtr.getClass().getScript(newPtr); @@ -1163,23 +1165,21 @@ namespace MWWorld removeContainerScripts (ptr); haveToMove = false; - MWWorld::Ptr newPtr = ptr.getClass() - .copyToCell(ptr, *newCell); + newPtr = ptr.getClass().copyToCell(ptr, *newCell); newPtr.getRefData().setBaseNode(0); } else if (!currCellActive && !newCellActive) - ptr.getClass().copyToCell(ptr, *newCell); + newPtr = ptr.getClass().copyToCell(ptr, *newCell); else // both cells active { - MWWorld::Ptr copy = - ptr.getClass().copyToCell(ptr, *newCell, pos); + newPtr = ptr.getClass().copyToCell(ptr, *newCell, pos); - mRendering->updateObjectCell(ptr, copy); + mRendering->updateObjectCell(ptr, newPtr); ptr.getRefData().setBaseNode(NULL); - MWBase::Environment::get().getSoundManager()->updatePtr (ptr, copy); + MWBase::Environment::get().getSoundManager()->updatePtr (ptr, newPtr); MWBase::MechanicsManager *mechMgr = MWBase::Environment::get().getMechanicsManager(); - mechMgr->updateCell(ptr, copy); + mechMgr->updateCell(ptr, newPtr); std::string script = ptr.getClass().getScript(ptr); @@ -1187,22 +1187,23 @@ namespace MWWorld { mLocalScripts.remove(ptr); removeContainerScripts (ptr); - mLocalScripts.add(script, copy); - addContainerScripts (copy, newCell); + mLocalScripts.add(script, newPtr); + addContainerScripts (newPtr, newCell); } } ptr.getRefData().setCount(0); } } - if (haveToMove && ptr.getRefData().getBaseNode()) + if (haveToMove && newPtr.getRefData().getBaseNode()) { - mRendering->moveObject(ptr, vec); - mPhysics->moveObject (ptr); + mRendering->moveObject(newPtr, vec); + mPhysics->moveObject (newPtr); } if (isPlayer) { mWorldScene->playerMoved (vec); } + return newPtr; } MWWorld::Ptr World::moveObjectImp(const Ptr& ptr, float x, float y, float z) @@ -1216,11 +1217,7 @@ namespace MWWorld cell = getExterior(cellX, cellY); } - moveObject(ptr, cell, x, y, z); - - MWWorld::Ptr updated = ptr; - updated.mCell = cell; - return updated; + return moveObject(ptr, cell, x, y, z); } MWWorld::Ptr World::moveObject (const Ptr& ptr, float x, float y, float z) diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 63d6506de0..bf25c20bbd 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -348,7 +348,9 @@ namespace MWWorld virtual MWWorld::Ptr moveObject (const Ptr& ptr, float x, float y, float z); ///< @return an updated Ptr in case the Ptr's cell changes - virtual void moveObject (const Ptr& ptr, CellStore* newCell, float x, float y, float z); + + virtual MWWorld::Ptr moveObject (const Ptr& ptr, CellStore* newCell, float x, float y, float z); + ///< @return an updated Ptr virtual void scaleObject (const Ptr& ptr, float scale); From cfcfb173205bb1148b7b40f20b3eb75eb6791295 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 18 May 2015 07:12:02 +1000 Subject: [PATCH 039/119] Updates to optional horizontal scrollbar. - move SizeHintWidget out to separate files - remove redundant logic in view.cpp - remove sizehint from dialogue subview - add tooltip hints in user preferences --- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/model/settings/usersettings.cpp | 4 ++++ apps/opencs/view/doc/sizehint.cpp | 17 ++++++++++++++++ apps/opencs/view/doc/sizehint.hpp | 22 +++++++++++++++++++++ apps/opencs/view/doc/subview.cpp | 16 --------------- apps/opencs/view/doc/subview.hpp | 13 ------------ apps/opencs/view/doc/view.cpp | 7 +------ apps/opencs/view/world/dialoguesubview.cpp | 12 +---------- apps/opencs/view/world/tablesubview.cpp | 1 + 9 files changed, 47 insertions(+), 47 deletions(-) create mode 100644 apps/opencs/view/doc/sizehint.cpp create mode 100644 apps/opencs/view/doc/sizehint.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 9fb80324ec..438f3c6941 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -46,7 +46,7 @@ opencs_units_noqt (model/tools opencs_units (view/doc viewmanager view operations operation subview startup filedialog newgame - filewidget adjusterwidget loader globaldebugprofilemenu runlogsubview + filewidget adjusterwidget loader globaldebugprofilemenu runlogsubview sizehint ) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index bd31b6e384..ea002c5edd 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -151,6 +151,10 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() "Add a horizontal scrollbar to the main view window."); mainwinScroll->setDefaultValue (defaultScroll); mainwinScroll->setDeclaredValues (scrollValues); + mainwinScroll->setToolTip ("Scrollbar Only: Simple addition of scrollbars, the view window does not grow" + " automatically.\n" + "Grow Only: Original Editor behaviour. The view window grows as subviews are added. No scrollbars.\n" + "Grow then Scroll: The view window grows. The scrollbar appears once it cannot grow any further."); Setting *grow = createSetting (Type_CheckBox, "grow-limit", "Grow Limit Screen"); grow->setDefaultValue ("false"); diff --git a/apps/opencs/view/doc/sizehint.cpp b/apps/opencs/view/doc/sizehint.cpp new file mode 100644 index 0000000000..038bd9e4d1 --- /dev/null +++ b/apps/opencs/view/doc/sizehint.cpp @@ -0,0 +1,17 @@ +#include "sizehint.hpp" + +CSVDoc::SizeHintWidget::SizeHintWidget(QWidget *parent) : QWidget(parent) +{} + +CSVDoc::SizeHintWidget::~SizeHintWidget() +{} + +QSize CSVDoc::SizeHintWidget::sizeHint() const +{ + return mSize; +} + +void CSVDoc::SizeHintWidget::setSizeHint(const QSize &size) +{ + mSize = size; +} diff --git a/apps/opencs/view/doc/sizehint.hpp b/apps/opencs/view/doc/sizehint.hpp new file mode 100644 index 0000000000..cf5a02580e --- /dev/null +++ b/apps/opencs/view/doc/sizehint.hpp @@ -0,0 +1,22 @@ +#ifndef CSV_DOC_SIZEHINT_H +#define CSV_DOC_SIZEHINT_H + +#include +#include + +namespace CSVDoc +{ + class SizeHintWidget : public QWidget + { + QSize mSize; + + public: + SizeHintWidget(QWidget *parent = 0); + ~SizeHintWidget(); + + virtual QSize sizeHint() const; + void setSizeHint(const QSize &size); + }; +} + +#endif // CSV_DOC_SIZEHINT_H diff --git a/apps/opencs/view/doc/subview.cpp b/apps/opencs/view/doc/subview.cpp index 09128d9191..df1e7ee492 100644 --- a/apps/opencs/view/doc/subview.cpp +++ b/apps/opencs/view/doc/subview.cpp @@ -43,19 +43,3 @@ void CSVDoc::SubView::closeRequest() { emit closeRequest (this); } - -CSVDoc::SizeHintWidget::SizeHintWidget(QWidget *parent) : QWidget(parent) -{} - -CSVDoc::SizeHintWidget::~SizeHintWidget() -{} - -QSize CSVDoc::SizeHintWidget::sizeHint() const -{ - return mSize; -} - -void CSVDoc::SizeHintWidget::setSizeHint(const QSize &size) -{ - mSize = size; -} diff --git a/apps/opencs/view/doc/subview.hpp b/apps/opencs/view/doc/subview.hpp index f327107c21..a8aa3cda1e 100644 --- a/apps/opencs/view/doc/subview.hpp +++ b/apps/opencs/view/doc/subview.hpp @@ -8,7 +8,6 @@ #include "subviewfactory.hpp" #include -#include class QUndoStack; @@ -71,18 +70,6 @@ namespace CSVDoc void closeRequest(); }; - - class SizeHintWidget : public QWidget - { - QSize mSize; - - public: - SizeHintWidget(QWidget *parent = 0); - ~SizeHintWidget(); - - virtual QSize sizeHint() const; - void setSizeHint(const QSize &size); - }; } #endif diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 16b96ed4d3..47810a1155 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -563,12 +563,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin // CSMSettings::UserSettings &settings = CSMSettings::UserSettings::instance(); QString mainwinScroll = settings.settingValue ("window/mainwindow-scrollbar"); - if (mainwinScroll.isEmpty() || mainwinScroll == "Scrollbar Only") - mScrollbarOnly = true; - else if(mainwinScroll == "Grow Only") - mScrollbarOnly = false; - else - mScrollbarOnly = false; + mScrollbarOnly = mainwinScroll.isEmpty() || mainwinScroll == "Scrollbar Only"; QDesktopWidget *dw = QApplication::desktop(); QRect rect; diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index ccab576fa0..0d0e82dbf3 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -20,8 +20,6 @@ #include #include #include -#include -#include #include "../../model/world/nestedtableproxymodel.hpp" #include "../../model/world/columnbase.hpp" @@ -583,15 +581,7 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM changeCurrentId(id.getId()); - //QWidget *mainWidget = new QWidget(this); - CSVDoc::SizeHintWidget *mainWidget = new CSVDoc::SizeHintWidget; - - const QRect rect = QApplication::desktop()->screenGeometry(this); - int frameHeight = 40; // set a reasonable default - QWidget *topLevel = QApplication::topLevelAt(pos()); - if (topLevel) - frameHeight = topLevel->frameGeometry().height() - topLevel->height(); - mainWidget->setSizeHint(QSize(400, rect.height()-frameHeight)); // FIXME: 400 + QWidget *mainWidget = new QWidget(this); QHBoxLayout *buttonsLayout = new QHBoxLayout; QToolButton* prevButton = new QToolButton(mainWidget); diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index dde04fb3f7..af0b644475 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -10,6 +10,7 @@ #include "../../model/doc/document.hpp" #include "../../model/world/tablemimedata.hpp" +#include "../doc/sizehint.hpp" #include "../filter/filterbox.hpp" #include "table.hpp" #include "tablebottombox.hpp" From 7494340b66500c08aa6f6f7fe41c957d293cdcab Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 18 May 2015 22:08:36 +1000 Subject: [PATCH 040/119] Add the remaining NPC data for editing with dialogue subview. Should resolve Bug #2547. --- apps/opencs/model/world/columns.cpp | 15 + apps/opencs/model/world/columns.hpp | 15 + apps/opencs/model/world/refidadapterimp.cpp | 350 +++++++++++++++++++- apps/opencs/model/world/refidadapterimp.hpp | 95 ++++++ apps/opencs/model/world/refidcollection.cpp | 56 ++++ apps/opencs/view/world/dialoguesubview.cpp | 6 +- 6 files changed, 535 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/columns.cpp b/apps/opencs/model/world/columns.cpp index 89ee6258b5..2bfe79464f 100644 --- a/apps/opencs/model/world/columns.cpp +++ b/apps/opencs/model/world/columns.cpp @@ -281,6 +281,21 @@ namespace CSMWorld { ColumnId_InfoCondValue, "Value" }, { ColumnId_OriginalCell, "Original Cell" }, + { ColumnId_NpcAttributes, "Attributes" }, + { ColumnId_NpcSkills, "Skills" }, + { ColumnId_UChar, "Value [0..255]" }, + { ColumnId_NpcMisc, "Misc" }, + { ColumnId_NpcLevel, "Level" }, + { ColumnId_NpcFactionID, "Faction ID" }, + { ColumnId_NpcHealth, "Health" }, + { ColumnId_NpcMana, "Mana" }, + { ColumnId_NpcFatigue, "Fatigue" }, + { ColumnId_NpcDisposition, "Disposition" }, + { ColumnId_NpcReputation, "Reputation" }, + { ColumnId_NpcRank, "Rank" }, + { ColumnId_NpcGold, "Gold" }, + { ColumnId_NpcPersistence, "Persistent" }, + { ColumnId_UseValue1, "Use value 1" }, { ColumnId_UseValue2, "Use value 2" }, { ColumnId_UseValue3, "Use value 3" }, diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index f971f3fd89..b2234ad49c 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -272,6 +272,21 @@ namespace CSMWorld ColumnId_OriginalCell = 247, + ColumnId_NpcAttributes = 248, + ColumnId_NpcSkills = 249, + ColumnId_UChar = 250, + ColumnId_NpcMisc = 251, + ColumnId_NpcLevel = 252, + ColumnId_NpcFactionID = 253, + ColumnId_NpcHealth = 254, + ColumnId_NpcMana = 255, + ColumnId_NpcFatigue = 256, + ColumnId_NpcDisposition = 257, + ColumnId_NpcReputation = 258, + ColumnId_NpcRank = 259, + ColumnId_NpcGold = 260, + ColumnId_NpcPersistence = 261, + // Allocated to a separate value range, so we don't get a collision should we ever need // to extend the number of use values. ColumnId_UseValue1 = 0x10000, diff --git a/apps/opencs/model/world/refidadapterimp.cpp b/apps/opencs/model/world/refidadapterimp.cpp index 98c1b6f0f3..a5f0b22449 100644 --- a/apps/opencs/model/world/refidadapterimp.cpp +++ b/apps/opencs/model/world/refidadapterimp.cpp @@ -468,7 +468,10 @@ CSMWorld::NpcColumns::NpcColumns (const ActorColumns& actorColumns) mClass(NULL), mFaction(NULL), mHair(NULL), - mHead(NULL) + mHead(NULL), + mAttributes(NULL), + mSkills(NULL), + mMisc(NULL) {} CSMWorld::NpcRefIdAdapter::NpcRefIdAdapter (const NpcColumns& columns) @@ -496,6 +499,17 @@ QVariant CSMWorld::NpcRefIdAdapter::getData (const RefIdColumn *column, const Re if (column==mColumns.mHead) return QString::fromUtf8 (record.get().mHead.c_str()); + if (column==mColumns.mAttributes || column==mColumns.mSkills) + { + if ((record.get().mFlags & ESM::NPC::Autocalc) != 0) + return QVariant(); + else + return true; + } + + if (column==mColumns.mMisc) + return true; + std::map::const_iterator iter = mColumns.mFlags.find (column); @@ -538,6 +552,340 @@ void CSMWorld::NpcRefIdAdapter::setData (const RefIdColumn *column, RefIdData& d } } +CSMWorld::NpcAttributesRefIdAdapter::NpcAttributesRefIdAdapter () +{} + +void CSMWorld::NpcAttributesRefIdAdapter::addNestedRow (const RefIdColumn *column, + RefIdData& data, int index, int position) const +{ + // Do nothing, this table cannot be changed by the user +} + +void CSMWorld::NpcAttributesRefIdAdapter::removeNestedRow (const RefIdColumn *column, + RefIdData& data, int index, int rowToRemove) const +{ + // Do nothing, this table cannot be changed by the user +} + +void CSMWorld::NpcAttributesRefIdAdapter::setNestedTable (const RefIdColumn* column, + RefIdData& data, int index, const NestedTableWrapperBase& nestedTable) const +{ + Record& record = + static_cast&> (data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Npc))); + ESM::NPC npc = record.get(); + + // store the whole struct + npc.mNpdt52 = + static_cast > &>(nestedTable).mNestedTable.at(0); + + record.setModified (npc); +} + +CSMWorld::NestedTableWrapperBase* CSMWorld::NpcAttributesRefIdAdapter::nestedTable (const RefIdColumn* column, + const RefIdData& data, int index) const +{ + const Record& record = + static_cast&> (data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Npc))); + + // return the whole struct + std::vector wrap; + wrap.push_back(record.get().mNpdt52); + // deleted by dtor of NestedTableStoring + return new NestedTableWrapper >(wrap); +} + +QVariant CSMWorld::NpcAttributesRefIdAdapter::getNestedData (const RefIdColumn *column, + const RefIdData& data, int index, int subRowIndex, int subColIndex) const +{ + const Record& record = + static_cast&> (data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Npc))); + + const ESM::NPC::NPDTstruct52& npcStruct = record.get().mNpdt52; + + if (subColIndex == 0) + switch (subRowIndex) + { + case 0: return QString("Strength"); + case 1: return QString("Intelligence"); + case 2: return QString("Willpower"); + case 3: return QString("Agility"); + case 4: return QString("Speed"); + case 5: return QString("Endurance"); + case 6: return QString("Personality"); + case 7: return QString("Luck"); + default: return QVariant(); // throw an exception here? + } + else if (subColIndex == 1) + switch (subRowIndex) + { + case 0: return static_cast(npcStruct.mStrength); + case 1: return static_cast(npcStruct.mIntelligence); + case 2: return static_cast(npcStruct.mWillpower); + case 3: return static_cast(npcStruct.mAgility); + case 4: return static_cast(npcStruct.mSpeed); + case 5: return static_cast(npcStruct.mEndurance); + case 6: return static_cast(npcStruct.mPersonality); + case 7: return static_cast(npcStruct.mLuck); + default: return QVariant(); // throw an exception here? + } + else + return QVariant(); // throw an exception here? +} + +void CSMWorld::NpcAttributesRefIdAdapter::setNestedData (const RefIdColumn *column, + RefIdData& data, int row, const QVariant& value, int subRowIndex, int subColIndex) const +{ + Record& record = + static_cast&> (data.getRecord (RefIdData::LocalIndex (row, UniversalId::Type_Npc))); + ESM::NPC npc = record.get(); + ESM::NPC::NPDTstruct52& npcStruct = npc.mNpdt52; + + if (subColIndex == 1) + switch(subRowIndex) + { + case 0: npcStruct.mStrength = static_cast(value.toInt()); break; + case 1: npcStruct.mIntelligence = static_cast(value.toInt()); break; + case 2: npcStruct.mWillpower = static_cast(value.toInt()); break; + case 3: npcStruct.mAgility = static_cast(value.toInt()); break; + case 4: npcStruct.mSpeed = static_cast(value.toInt()); break; + case 5: npcStruct.mEndurance = static_cast(value.toInt()); break; + case 6: npcStruct.mPersonality = static_cast(value.toInt()); break; + case 7: npcStruct.mLuck = static_cast(value.toInt()); break; + default: return; // throw an exception here? + } + else + return; // throw an exception here? + + record.setModified (npc); +} + +int CSMWorld::NpcAttributesRefIdAdapter::getNestedColumnsCount(const RefIdColumn *column, const RefIdData& data) const +{ + return 2; +} + +int CSMWorld::NpcAttributesRefIdAdapter::getNestedRowsCount(const RefIdColumn *column, const RefIdData& data, int index) const +{ + // There are 8 attributes + return 8; +} + +CSMWorld::NpcSkillsRefIdAdapter::NpcSkillsRefIdAdapter () +{} + +void CSMWorld::NpcSkillsRefIdAdapter::addNestedRow (const RefIdColumn *column, + RefIdData& data, int index, int position) const +{ + // Do nothing, this table cannot be changed by the user +} + +void CSMWorld::NpcSkillsRefIdAdapter::removeNestedRow (const RefIdColumn *column, + RefIdData& data, int index, int rowToRemove) const +{ + // Do nothing, this table cannot be changed by the user +} + +void CSMWorld::NpcSkillsRefIdAdapter::setNestedTable (const RefIdColumn* column, + RefIdData& data, int index, const NestedTableWrapperBase& nestedTable) const +{ + Record& record = + static_cast&> (data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Npc))); + ESM::NPC npc = record.get(); + + // store the whole struct + npc.mNpdt52 = + static_cast > &>(nestedTable).mNestedTable.at(0); + + record.setModified (npc); +} + +CSMWorld::NestedTableWrapperBase* CSMWorld::NpcSkillsRefIdAdapter::nestedTable (const RefIdColumn* column, + const RefIdData& data, int index) const +{ + const Record& record = + static_cast&> (data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Npc))); + + // return the whole struct + std::vector wrap; + wrap.push_back(record.get().mNpdt52); + // deleted by dtor of NestedTableStoring + return new NestedTableWrapper >(wrap); +} + +QVariant CSMWorld::NpcSkillsRefIdAdapter::getNestedData (const RefIdColumn *column, + const RefIdData& data, int index, int subRowIndex, int subColIndex) const +{ + const Record& record = + static_cast&> (data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Npc))); + + const ESM::NPC::NPDTstruct52& npcStruct = record.get().mNpdt52; + + if (subRowIndex < 0 || subRowIndex >= ESM::Skill::Length) + std::cout << "getNestedDatat index" << std::endl; + //throw std::runtime_error ("index out of range"); + + if (subColIndex == 0) + return QString(ESM::Skill::sSkillNames[subRowIndex].c_str()); + else if (subColIndex == 1) + return static_cast(npcStruct.mSkills[subRowIndex]); + else + return QVariant(); // throw an exception here? +} + +void CSMWorld::NpcSkillsRefIdAdapter::setNestedData (const RefIdColumn *column, + RefIdData& data, int row, const QVariant& value, int subRowIndex, int subColIndex) const +{ + Record& record = + static_cast&> (data.getRecord (RefIdData::LocalIndex (row, UniversalId::Type_Npc))); + ESM::NPC npc = record.get(); + ESM::NPC::NPDTstruct52& npcStruct = npc.mNpdt52; + + if (subRowIndex < 0 || subRowIndex >= ESM::Skill::Length) + std::cout << "setNestedDatat index" << std::endl; + //throw std::runtime_error ("index out of range"); + + if (subColIndex == 1) + npcStruct.mSkills[subRowIndex] = static_cast(value.toInt()); + else + return; // throw an exception here? + + record.setModified (npc); +} + +int CSMWorld::NpcSkillsRefIdAdapter::getNestedColumnsCount(const RefIdColumn *column, const RefIdData& data) const +{ + return 2; +} + +int CSMWorld::NpcSkillsRefIdAdapter::getNestedRowsCount(const RefIdColumn *column, const RefIdData& data, int index) const +{ + // There are 27 skills + return ESM::Skill::Length; +} + +CSMWorld::NpcMiscRefIdAdapter::NpcMiscRefIdAdapter () +{} + +CSMWorld::NpcMiscRefIdAdapter::~NpcMiscRefIdAdapter() +{} + +void CSMWorld::NpcMiscRefIdAdapter::addNestedRow (const RefIdColumn *column, + RefIdData& data, int index, int position) const +{ + throw std::logic_error ("cannot add a row to a fixed table"); +} + +void CSMWorld::NpcMiscRefIdAdapter::removeNestedRow (const RefIdColumn *column, + RefIdData& data, int index, int rowToRemove) const +{ + throw std::logic_error ("cannot remove a row to a fixed table"); +} + +void CSMWorld::NpcMiscRefIdAdapter::setNestedTable (const RefIdColumn* column, + RefIdData& data, int index, const NestedTableWrapperBase& nestedTable) const +{ + throw std::logic_error ("table operation not supported"); +} + +CSMWorld::NestedTableWrapperBase* CSMWorld::NpcMiscRefIdAdapter::nestedTable (const RefIdColumn* column, + const RefIdData& data, int index) const +{ + throw std::logic_error ("table operation not supported"); +} + +QVariant CSMWorld::NpcMiscRefIdAdapter::getNestedData (const RefIdColumn *column, + const RefIdData& data, int index, int subRowIndex, int subColIndex) const +{ + const Record& record = + static_cast&> (data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Npc))); + + bool autoCalc = (record.get().mFlags & ESM::NPC::Autocalc) != 0; + + if (autoCalc) + switch (subColIndex) + { + case 0: return static_cast(record.get().mNpdt12.mLevel); + case 1: return QVariant(); + case 2: return QVariant(); + case 3: return QVariant(); + case 4: return QVariant(); + case 5: return static_cast(record.get().mNpdt12.mDisposition); + case 6: return static_cast(record.get().mNpdt12.mReputation); + case 7: return static_cast(record.get().mNpdt12.mRank); + case 8: return record.get().mNpdt12.mGold; + case 9: return record.get().mPersistent == true; + default: return QVariant(); // throw an exception here? + } + else + switch (subColIndex) + { + case 0: return static_cast(record.get().mNpdt52.mLevel); + case 1: return static_cast(record.get().mNpdt52.mFactionID); + case 2: return static_cast(record.get().mNpdt52.mHealth); + case 3: return static_cast(record.get().mNpdt52.mMana); + case 4: return static_cast(record.get().mNpdt52.mFatigue); + case 5: return static_cast(record.get().mNpdt52.mDisposition); + case 6: return static_cast(record.get().mNpdt52.mReputation); + case 7: return static_cast(record.get().mNpdt52.mRank); + case 8: return record.get().mNpdt52.mGold; + case 9: return record.get().mPersistent == true; + default: return QVariant(); // throw an exception here? + } +} + +void CSMWorld::NpcMiscRefIdAdapter::setNestedData (const RefIdColumn *column, + RefIdData& data, int row, const QVariant& value, int subRowIndex, int subColIndex) const +{ + Record& record = + static_cast&> (data.getRecord (RefIdData::LocalIndex (row, UniversalId::Type_Npc))); + ESM::NPC npc = record.get(); + + bool autoCalc = (record.get().mFlags & ESM::NPC::Autocalc) != 0; + + if (autoCalc) + switch(subColIndex) + { + case 0: npc.mNpdt12.mLevel = static_cast(value.toInt()); break; + case 1: return; + case 2: return; + case 3: return; + case 4: return; + case 5: npc.mNpdt12.mDisposition = static_cast(value.toInt()); break; + case 6: npc.mNpdt12.mReputation = static_cast(value.toInt()); break; + case 7: npc.mNpdt12.mRank = static_cast(value.toInt()); break; + case 8: npc.mNpdt12.mGold = value.toInt(); break; + case 9: npc.mPersistent = value.toBool(); break; + default: return; // throw an exception here? + } + else + switch(subColIndex) + { + case 0: npc.mNpdt52.mLevel = static_cast(value.toInt()); break; + case 1: npc.mNpdt52.mFactionID = static_cast(value.toInt()); break; + case 2: npc.mNpdt52.mHealth = static_cast(value.toInt()); break; + case 3: npc.mNpdt52.mMana = static_cast(value.toInt()); break; + case 4: npc.mNpdt52.mFatigue = static_cast(value.toInt()); break; + case 5: npc.mNpdt52.mDisposition = static_cast(value.toInt()); break; + case 6: npc.mNpdt52.mReputation = static_cast(value.toInt()); break; + case 7: npc.mNpdt52.mRank = static_cast(value.toInt()); break; + case 8: npc.mNpdt52.mGold = value.toInt(); break; + case 9: npc.mPersistent = value.toBool(); break; + default: return; // throw an exception here? + } + + record.setModified (npc); +} + +int CSMWorld::NpcMiscRefIdAdapter::getNestedColumnsCount(const RefIdColumn *column, const RefIdData& data) const +{ + return 10; // Level, FactionID, Health, Mana, Fatigue, Disposition, Reputation, Rank, Gold, Persist +} + +int CSMWorld::NpcMiscRefIdAdapter::getNestedRowsCount(const RefIdColumn *column, const RefIdData& data, int index) const +{ + return 1; // fixed at size 1 +} + CSMWorld::WeaponColumns::WeaponColumns (const EnchantableColumns& columns) : EnchantableColumns (columns) {} diff --git a/apps/opencs/model/world/refidadapterimp.hpp b/apps/opencs/model/world/refidadapterimp.hpp index 61e8115c0e..143b46c44b 100644 --- a/apps/opencs/model/world/refidadapterimp.hpp +++ b/apps/opencs/model/world/refidadapterimp.hpp @@ -792,6 +792,9 @@ namespace CSMWorld const RefIdColumn *mFaction; const RefIdColumn *mHair; const RefIdColumn *mHead; + const RefIdColumn *mAttributes; // depends on npc type + const RefIdColumn *mSkills; // depends on npc type + const RefIdColumn *mMisc; // may depend on npc type, e.g. FactionID NpcColumns (const ActorColumns& actorColumns); }; @@ -842,8 +845,100 @@ namespace CSMWorld ///< If the data type does not match an exception is thrown. }; + class NestedRefIdAdapterBase; + class NpcAttributesRefIdAdapter : public NestedRefIdAdapterBase + { + public: + + NpcAttributesRefIdAdapter (); + + virtual void addNestedRow (const RefIdColumn *column, + RefIdData& data, int index, int position) const; + + virtual void removeNestedRow (const RefIdColumn *column, + RefIdData& data, int index, int rowToRemove) const; + + virtual void setNestedTable (const RefIdColumn* column, + RefIdData& data, int index, const NestedTableWrapperBase& nestedTable) const; + + virtual NestedTableWrapperBase* nestedTable (const RefIdColumn* column, + const RefIdData& data, int index) const; + + virtual QVariant getNestedData (const RefIdColumn *column, + const RefIdData& data, int index, int subRowIndex, int subColIndex) const; + + virtual void setNestedData (const RefIdColumn *column, + RefIdData& data, int row, const QVariant& value, int subRowIndex, int subColIndex) const; + + virtual int getNestedColumnsCount(const RefIdColumn *column, const RefIdData& data) const; + + virtual int getNestedRowsCount(const RefIdColumn *column, const RefIdData& data, int index) const; + }; + + class NpcSkillsRefIdAdapter : public NestedRefIdAdapterBase + { + public: + + NpcSkillsRefIdAdapter (); + + virtual void addNestedRow (const RefIdColumn *column, + RefIdData& data, int index, int position) const; + + virtual void removeNestedRow (const RefIdColumn *column, + RefIdData& data, int index, int rowToRemove) const; + + virtual void setNestedTable (const RefIdColumn* column, + RefIdData& data, int index, const NestedTableWrapperBase& nestedTable) const; + + virtual NestedTableWrapperBase* nestedTable (const RefIdColumn* column, + const RefIdData& data, int index) const; + + virtual QVariant getNestedData (const RefIdColumn *column, + const RefIdData& data, int index, int subRowIndex, int subColIndex) const; + + virtual void setNestedData (const RefIdColumn *column, + RefIdData& data, int row, const QVariant& value, int subRowIndex, int subColIndex) const; + + virtual int getNestedColumnsCount(const RefIdColumn *column, const RefIdData& data) const; + + virtual int getNestedRowsCount(const RefIdColumn *column, const RefIdData& data, int index) const; + }; + + class NpcMiscRefIdAdapter : public NestedRefIdAdapterBase + { + NpcMiscRefIdAdapter (const NpcMiscRefIdAdapter&); + NpcMiscRefIdAdapter& operator= (const NpcMiscRefIdAdapter&); + + public: + + NpcMiscRefIdAdapter (); + virtual ~NpcMiscRefIdAdapter(); + + virtual void addNestedRow (const RefIdColumn *column, + RefIdData& data, int index, int position) const; + + virtual void removeNestedRow (const RefIdColumn *column, + RefIdData& data, int index, int rowToRemove) const; + + virtual void setNestedTable (const RefIdColumn* column, + RefIdData& data, int index, const NestedTableWrapperBase& nestedTable) const; + + virtual NestedTableWrapperBase* nestedTable (const RefIdColumn* column, + const RefIdData& data, int index) const; + + virtual QVariant getNestedData (const RefIdColumn *column, + const RefIdData& data, int index, int subRowIndex, int subColIndex) const; + + virtual void setNestedData (const RefIdColumn *column, + RefIdData& data, int row, const QVariant& value, int subRowIndex, int subColIndex) const; + + virtual int getNestedColumnsCount(const RefIdColumn *column, const RefIdData& data) const; + + virtual int getNestedRowsCount(const RefIdColumn *column, const RefIdData& data, int index) const; + }; + template class EffectsListAdapter; diff --git a/apps/opencs/model/world/refidcollection.cpp b/apps/opencs/model/world/refidcollection.cpp index 1941c505a2..9d9e9826af 100644 --- a/apps/opencs/model/world/refidcollection.cpp +++ b/apps/opencs/model/world/refidcollection.cpp @@ -427,6 +427,62 @@ CSMWorld::RefIdCollection::RefIdCollection() npcColumns.mFlags.insert (std::make_pair (metalBlood, ESM::NPC::Metal)); + // Need a way to add a table of stats and values (rather than adding a long list of + // entries in the dialogue subview) E.g. attributes+stats(health, mana, fatigue), skills + // These needs to be driven from the autocalculated setting. + + // Nested table + mColumns.push_back(RefIdColumn (Columns::ColumnId_NpcAttributes, + ColumnBase::Display_NestedHeader, ColumnBase::Flag_Dialogue)); + npcColumns.mAttributes = &mColumns.back(); + std::map attrMap; + attrMap.insert(std::make_pair(UniversalId::Type_Npc, new NpcAttributesRefIdAdapter())); + mNestedAdapters.push_back (std::make_pair(&mColumns.back(), attrMap)); + mColumns.back().addColumn( + new RefIdColumn (Columns::ColumnId_NpcAttributes, CSMWorld::ColumnBase::Display_String, false, false)); + mColumns.back().addColumn( + new RefIdColumn (Columns::ColumnId_UChar, CSMWorld::ColumnBase::Display_Integer)); + + // Nested table + mColumns.push_back(RefIdColumn (Columns::ColumnId_NpcSkills, + ColumnBase::Display_NestedHeader, ColumnBase::Flag_Dialogue)); + npcColumns.mSkills = &mColumns.back(); + std::map skillsMap; + skillsMap.insert(std::make_pair(UniversalId::Type_Npc, new NpcSkillsRefIdAdapter())); + mNestedAdapters.push_back (std::make_pair(&mColumns.back(), skillsMap)); + mColumns.back().addColumn( + new RefIdColumn (Columns::ColumnId_NpcSkills, CSMWorld::ColumnBase::Display_String, false, false)); + mColumns.back().addColumn( + new RefIdColumn (Columns::ColumnId_UChar, CSMWorld::ColumnBase::Display_Integer)); + + // Nested list + mColumns.push_back(RefIdColumn (Columns::ColumnId_NpcMisc, + ColumnBase::Display_NestedHeader, ColumnBase::Flag_Dialogue | ColumnBase::Flag_Dialogue_List)); + npcColumns.mMisc = &mColumns.back(); + std::map miscMap; + miscMap.insert(std::make_pair(UniversalId::Type_Npc, new NpcMiscRefIdAdapter())); + mNestedAdapters.push_back (std::make_pair(&mColumns.back(), miscMap)); + mColumns.back().addColumn( + new RefIdColumn (Columns::ColumnId_NpcLevel, CSMWorld::ColumnBase::Display_Integer)); + mColumns.back().addColumn( + new RefIdColumn (Columns::ColumnId_NpcFactionID, CSMWorld::ColumnBase::Display_Integer)); + mColumns.back().addColumn( + new RefIdColumn (Columns::ColumnId_NpcHealth, CSMWorld::ColumnBase::Display_Integer)); + mColumns.back().addColumn( + new RefIdColumn (Columns::ColumnId_NpcMana, CSMWorld::ColumnBase::Display_Integer)); + mColumns.back().addColumn( + new RefIdColumn (Columns::ColumnId_NpcFatigue, CSMWorld::ColumnBase::Display_Integer)); + mColumns.back().addColumn( + new RefIdColumn (Columns::ColumnId_NpcDisposition, CSMWorld::ColumnBase::Display_Integer)); + mColumns.back().addColumn( + new RefIdColumn (Columns::ColumnId_NpcReputation, CSMWorld::ColumnBase::Display_Integer)); + mColumns.back().addColumn( + new RefIdColumn (Columns::ColumnId_NpcRank, CSMWorld::ColumnBase::Display_Integer)); + mColumns.back().addColumn( + new RefIdColumn (Columns::ColumnId_NpcGold, CSMWorld::ColumnBase::Display_Integer)); + mColumns.back().addColumn( + new RefIdColumn (Columns::ColumnId_NpcPersistence, CSMWorld::ColumnBase::Display_Boolean)); + WeaponColumns weaponColumns (enchantableColumns); mColumns.push_back (RefIdColumn (Columns::ColumnId_WeaponType, ColumnBase::Display_WeaponType)); diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 0d0e82dbf3..4b4afc6668 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "../../model/world/nestedtableproxymodel.hpp" #include "../../model/world/columnbase.hpp" @@ -511,7 +512,7 @@ void CSVWorld::EditWidget::remake(int row) mNestedTableMapper->setModel(mNestedModels.back()); // FIXME: lack MIME support? mNestedTableDispatcher = - new DialogueDelegateDispatcher (this, mTable, mCommandDispatcher, mDocument, mNestedModels.back()); + new DialogueDelegateDispatcher (0/*this*/, mTable, mCommandDispatcher, mDocument, mNestedModels.back()); mNestedTableMapper->setItemDelegate(mNestedTableDispatcher); int columnCount = @@ -763,6 +764,9 @@ void CSVWorld::DialogueSubView::dataChanged (const QModelIndex & index) CSMWorld::RecordBase::State state = static_cast(mTable->data (mTable->index (currentIndex.row(), 1)).toInt()); mEditWidget->setDisabled (state==CSMWorld::RecordBase::State_Deleted || mLocked); + int y = mEditWidget->verticalScrollBar()->value(); + mEditWidget->remake (index.row()); + mEditWidget->verticalScrollBar()->setValue(y); } } From 0ecfd9119f1c7ec5c2326c7d15a1b1a1813fa354 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 19 May 2015 06:56:38 +1000 Subject: [PATCH 041/119] Add the remaining Race data for editing with dialogue subview. Should resolve Bug #2546. --- apps/opencs/model/world/columnbase.cpp | 1 + apps/opencs/model/world/columnbase.hpp | 1 + apps/opencs/model/world/columns.cpp | 8 + apps/opencs/model/world/columns.hpp | 7 + apps/opencs/model/world/data.cpp | 18 +++ .../model/world/nestedcoladapterimp.cpp | 153 ++++++++++++++++++ .../model/world/nestedcoladapterimp.hpp | 51 ++++++ apps/opencs/view/doc/viewmanager.cpp | 3 +- 8 files changed, 241 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/world/columnbase.cpp b/apps/opencs/model/world/columnbase.cpp index cf125aa639..087a1df7bd 100644 --- a/apps/opencs/model/world/columnbase.cpp +++ b/apps/opencs/model/world/columnbase.cpp @@ -84,6 +84,7 @@ bool CSMWorld::ColumnBase::isId (Display display) Display_InfoCondFunc, Display_InfoCondVar, Display_InfoCondComp, + Display_RaceSkill, Display_None }; diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index 2d2513774a..d6dd4b291b 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -119,6 +119,7 @@ namespace CSMWorld Display_InfoCondFunc, Display_InfoCondVar, Display_InfoCondComp, + Display_RaceSkill, //top level columns that nest other columns Display_NestedHeader diff --git a/apps/opencs/model/world/columns.cpp b/apps/opencs/model/world/columns.cpp index 2bfe79464f..daf537c0c9 100644 --- a/apps/opencs/model/world/columns.cpp +++ b/apps/opencs/model/world/columns.cpp @@ -296,6 +296,13 @@ namespace CSMWorld { ColumnId_NpcGold, "Gold" }, { ColumnId_NpcPersistence, "Persistent" }, + { ColumnId_RaceAttributes, "Attributes" }, + { ColumnId_RaceMaleValue, "Male" }, + { ColumnId_RaceFemaleValue, "Female" }, + { ColumnId_RaceSkillBonus, "Skill Bonus" }, + { ColumnId_RaceSkill, "Skills" }, + { ColumnId_RaceBonus, "Bonus" }, + { ColumnId_UseValue1, "Use value 1" }, { ColumnId_UseValue2, "Use value 2" }, { ColumnId_UseValue3, "Use value 3" }, @@ -566,6 +573,7 @@ namespace // FIXME: don't have dynamic value enum delegate, use Display_String for now //case CSMWorld::Columns::ColumnId_InfoCond: return sInfoCond; case CSMWorld::Columns::ColumnId_InfoCondComp: return sInfoCondComp; + case CSMWorld::Columns::ColumnId_RaceSkill: return sSkills; default: return 0; } diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index b2234ad49c..85276a695f 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -287,6 +287,13 @@ namespace CSMWorld ColumnId_NpcGold = 260, ColumnId_NpcPersistence = 261, + ColumnId_RaceAttributes = 262, + ColumnId_RaceMaleValue = 263, + ColumnId_RaceFemaleValue = 264, + ColumnId_RaceSkillBonus = 265, + ColumnId_RaceSkill = 266, + ColumnId_RaceBonus = 267, + // Allocated to a separate value range, so we don't get a collision should we ever need // to extend the number of use values. ColumnId_UseValue1 = 0x10000, diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index e2fab0a25b..fa7e48a0ea 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -136,6 +136,24 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mRaces.addAdapter (std::make_pair(&mRaces.getColumn(index), new SpellListAdapter ())); mRaces.getNestableColumn(index)->addColumn( new NestedChildColumn (Columns::ColumnId_SpellId, ColumnBase::Display_String)); + // Race attributes + mRaces.addColumn (new NestedParentColumn (Columns::ColumnId_RaceAttributes)); + index = mRaces.getColumns()-1; + mRaces.addAdapter (std::make_pair(&mRaces.getColumn(index), new RaceAttributeAdapter())); + mRaces.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_RaceAttributes, ColumnBase::Display_String, false)); + mRaces.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_RaceMaleValue, ColumnBase::Display_Integer)); + mRaces.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_RaceFemaleValue, ColumnBase::Display_Integer)); + // Race skill bonus + mRaces.addColumn (new NestedParentColumn (Columns::ColumnId_RaceSkillBonus)); + index = mRaces.getColumns()-1; + mRaces.addAdapter (std::make_pair(&mRaces.getColumn(index), new RaceSkillsBonusAdapter())); + mRaces.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_RaceSkill, ColumnBase::Display_RaceSkill)); + mRaces.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_RaceBonus, ColumnBase::Display_Integer)); mSounds.addColumn (new StringIdColumn); mSounds.addColumn (new RecordStateColumn); diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index a0d7645767..7efe14dee2 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -880,4 +880,157 @@ namespace CSMWorld { return static_cast(record.get().mSelects.size()); } + + RaceAttributeAdapter::RaceAttributeAdapter () {} + + void RaceAttributeAdapter::addRow(Record& record, int position) const + { + // Do nothing, this table cannot be changed by the user + } + + void RaceAttributeAdapter::removeRow(Record& record, int rowToRemove) const + { + // Do nothing, this table cannot be changed by the user + } + + void RaceAttributeAdapter::setTable(Record& record, + const NestedTableWrapperBase& nestedTable) const + { + ESM::Race race = record.get(); + + race.mData = + static_cast >&>(nestedTable).mNestedTable.at(0); + + record.setModified (race); + } + + NestedTableWrapperBase* RaceAttributeAdapter::table(const Record& record) const + { + std::vector wrap; + wrap.push_back(record.get().mData); + // deleted by dtor of NestedTableStoring + return new NestedTableWrapper >(wrap); + } + + QVariant RaceAttributeAdapter::getData(const Record& record, + int subRowIndex, int subColIndex) const + { + ESM::Race race = record.get(); + + if (subRowIndex < 0 || subRowIndex >= ESM::Attribute::Length) + throw std::runtime_error ("index out of range"); + + switch (subColIndex) + { + case 0: return QString(ESM::Attribute::sAttributeNames[subRowIndex].c_str()); + case 1: return race.mData.mAttributeValues[subRowIndex].mMale; + case 2: return race.mData.mAttributeValues[subRowIndex].mFemale; + default: throw std::runtime_error("Race Attribute subcolumn index out of range"); + } + } + + void RaceAttributeAdapter::setData(Record& record, + const QVariant& value, int subRowIndex, int subColIndex) const + { + ESM::Race race = record.get(); + + if (subRowIndex < 0 || subRowIndex >= ESM::Attribute::Length) + throw std::runtime_error ("index out of range"); + + switch (subColIndex) + { + case 0: return; // throw an exception here? + case 1: race.mData.mAttributeValues[subRowIndex].mMale = value.toInt(); break; + case 2: race.mData.mAttributeValues[subRowIndex].mFemale = value.toInt(); break; + default: throw std::runtime_error("Race Attribute subcolumn index out of range"); + } + + record.setModified (race); + } + + int RaceAttributeAdapter::getColumnsCount(const Record& record) const + { + return 3; // attrib, male, female + } + + int RaceAttributeAdapter::getRowsCount(const Record& record) const + { + return ESM::Attribute::Length; // there are 8 attributes + } + + RaceSkillsBonusAdapter::RaceSkillsBonusAdapter () {} + + void RaceSkillsBonusAdapter::addRow(Record& record, int position) const + { + // Do nothing, this table cannot be changed by the user + } + + void RaceSkillsBonusAdapter::removeRow(Record& record, int rowToRemove) const + { + // Do nothing, this table cannot be changed by the user + } + + void RaceSkillsBonusAdapter::setTable(Record& record, + const NestedTableWrapperBase& nestedTable) const + { + ESM::Race race = record.get(); + + race.mData = + static_cast >&>(nestedTable).mNestedTable.at(0); + + record.setModified (race); + } + + NestedTableWrapperBase* RaceSkillsBonusAdapter::table(const Record& record) const + { + std::vector wrap; + wrap.push_back(record.get().mData); + // deleted by dtor of NestedTableStoring + return new NestedTableWrapper >(wrap); + } + + QVariant RaceSkillsBonusAdapter::getData(const Record& record, + int subRowIndex, int subColIndex) const + { + ESM::Race race = record.get(); + + if (subRowIndex < 0 || subRowIndex >= static_cast(sizeof(race.mData.mBonus)/sizeof(race.mData.mBonus[0]))) + throw std::runtime_error ("index out of range"); + + switch (subColIndex) + { + case 0: return race.mData.mBonus[subRowIndex].mSkill; // can be -1 + case 1: return race.mData.mBonus[subRowIndex].mBonus; + default: throw std::runtime_error("Race skill bonus subcolumn index out of range"); + } + } + + void RaceSkillsBonusAdapter::setData(Record& record, + const QVariant& value, int subRowIndex, int subColIndex) const + { + ESM::Race race = record.get(); + + if (subRowIndex < 0 || subRowIndex >= static_cast(sizeof(race.mData.mBonus)/sizeof(race.mData.mBonus[0]))) + throw std::runtime_error ("index out of range"); + + switch (subColIndex) + { + case 0: race.mData.mBonus[subRowIndex].mSkill = value.toInt(); break; // can be -1 + case 1: race.mData.mBonus[subRowIndex].mBonus = value.toInt(); break; + default: throw std::runtime_error("Race skill bonus subcolumn index out of range"); + } + + record.setModified (race); + } + + int RaceSkillsBonusAdapter::getColumnsCount(const Record& record) const + { + return 2; // skill, bonus + } + + int RaceSkillsBonusAdapter::getRowsCount(const Record& record) const + { + // there are 7 skill bonuses + return static_cast(sizeof(record.get().mData.mBonus)/sizeof(record.get().mData.mBonus[0])); + } } diff --git a/apps/opencs/model/world/nestedcoladapterimp.hpp b/apps/opencs/model/world/nestedcoladapterimp.hpp index 776a908bad..4b1e2cd09e 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.hpp +++ b/apps/opencs/model/world/nestedcoladapterimp.hpp @@ -8,6 +8,7 @@ #include // for converting magic effect id to string & back #include // for converting skill names #include // for converting attributes +#include #include "nestedcolumnadapter.hpp" #include "nestedtablewrapper.hpp" @@ -437,6 +438,56 @@ namespace CSMWorld virtual int getRowsCount(const Record& record) const; }; + + class RaceAttributeAdapter : public NestedColumnAdapter + { + public: + RaceAttributeAdapter (); + + virtual void addRow(Record& record, int position) const; + + virtual void removeRow(Record& record, int rowToRemove) const; + + virtual void setTable(Record& record, + const NestedTableWrapperBase& nestedTable) const; + + virtual NestedTableWrapperBase* table(const Record& record) const; + + virtual QVariant getData(const Record& record, + int subRowIndex, int subColIndex) const; + + virtual void setData(Record& record, + const QVariant& value, int subRowIndex, int subColIndex) const; + + virtual int getColumnsCount(const Record& record) const; + + virtual int getRowsCount(const Record& record) const; + }; + + class RaceSkillsBonusAdapter : public NestedColumnAdapter + { + public: + RaceSkillsBonusAdapter (); + + virtual void addRow(Record& record, int position) const; + + virtual void removeRow(Record& record, int rowToRemove) const; + + virtual void setTable(Record& record, + const NestedTableWrapperBase& nestedTable) const; + + virtual NestedTableWrapperBase* table(const Record& record) const; + + virtual QVariant getData(const Record& record, + int subRowIndex, int subColIndex) const; + + virtual void setData(Record& record, + const QVariant& value, int subRowIndex, int subColIndex) const; + + virtual int getColumnsCount(const Record& record) const; + + virtual int getRowsCount(const Record& record) const; + }; } #endif // CSM_WOLRD_NESTEDCOLADAPTERIMP_H diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index 6362f96590..97b7aac19a 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -92,7 +92,8 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager) { CSMWorld::ColumnBase::Display_AiPackageType, CSMWorld::Columns::ColumnId_AiPackageType, false }, { CSMWorld::ColumnBase::Display_YesNo, CSMWorld::Columns::ColumnId_AiWanderRepeat, false }, { CSMWorld::ColumnBase::Display_InfoCondFunc, CSMWorld::Columns::ColumnId_InfoCondFunc, false }, - { CSMWorld::ColumnBase::Display_InfoCondComp, CSMWorld::Columns::ColumnId_InfoCondComp, false } + { CSMWorld::ColumnBase::Display_InfoCondComp, CSMWorld::Columns::ColumnId_InfoCondComp, false }, + { CSMWorld::ColumnBase::Display_RaceSkill, CSMWorld::Columns::ColumnId_RaceSkill, true }, }; for (std::size_t i=0; i Date: Tue, 19 May 2015 19:19:52 +1000 Subject: [PATCH 042/119] Fix occasional crash with DialogueSubView, e.g. when deleting a row of a subtable. --- apps/opencs/view/world/dialoguesubview.cpp | 57 ++++++++++++---------- apps/opencs/view/world/dialoguesubview.hpp | 2 +- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 4b4afc6668..fee302e2c7 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -348,16 +348,19 @@ CSVWorld::DialogueDelegateDispatcher::~DialogueDelegateDispatcher() CSVWorld::EditWidget::~EditWidget() { for (unsigned i = 0; i < mNestedModels.size(); ++i) - { delete mNestedModels[i]; - } - delete mNestedTableDispatcher; + + if (mDispatcher) + delete mDispatcher; + + if (mNestedTableDispatcher) + delete mNestedTableDispatcher; } CSVWorld::EditWidget::EditWidget(QWidget *parent, int row, CSMWorld::IdTable* table, CSMWorld::CommandDispatcher& commandDispatcher, CSMDoc::Document& document, bool createAndDelete) : -mDispatcher(this, table, commandDispatcher, document), +mDispatcher(0), mNestedTableDispatcher(NULL), QScrollArea(parent), mWidgetMapper(NULL), @@ -369,41 +372,41 @@ mTable(table) { remake (row); - connect(&mDispatcher, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)), + connect(mDispatcher, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)), this, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*))); } void CSVWorld::EditWidget::remake(int row) { for (unsigned i = 0; i < mNestedModels.size(); ++i) - { delete mNestedModels[i]; - } - mNestedModels.clear(); - delete mNestedTableDispatcher; - if (mMainWidget) - { - delete mMainWidget; - mMainWidget = 0; - } - mMainWidget = new QWidget (this); + mNestedModels.clear(); + + if (mDispatcher) + delete mDispatcher; + mDispatcher = new DialogueDelegateDispatcher(0/*this*/, mTable, mCommandDispatcher, mDocument); + + if (mNestedTableDispatcher) + delete mNestedTableDispatcher; //not sure if widget mapper can handle deleting the widgets that were mapped if (mWidgetMapper) - { delete mWidgetMapper; - mWidgetMapper = 0; - } - if (mNestedTableMapper) - { - delete mNestedTableMapper; - mNestedTableMapper = 0; - } - mWidgetMapper = new QDataWidgetMapper (this); + mWidgetMapper = new QDataWidgetMapper (this); mWidgetMapper->setModel(mTable); - mWidgetMapper->setItemDelegate(&mDispatcher); + mWidgetMapper->setItemDelegate(mDispatcher); + + if (mNestedTableMapper) + delete mNestedTableMapper; + + if (mMainWidget) + { + QWidget *del = this->takeWidget(); + del->deleteLater(); + } + mMainWidget = new QWidget (this); QFrame* line = new QFrame(mMainWidget); line->setObjectName(QString::fromUtf8("line")); @@ -476,8 +479,8 @@ void CSVWorld::EditWidget::remake(int row) } else if (!(flags & CSMWorld::ColumnBase::Flag_Dialogue_List)) { - mDispatcher.makeDelegate (display); - QWidget* editor = mDispatcher.makeEditor (display, (mTable->index (row, i))); + mDispatcher->makeDelegate (display); + QWidget* editor = mDispatcher->makeEditor (display, (mTable->index (row, i))); if (editor) { diff --git a/apps/opencs/view/world/dialoguesubview.hpp b/apps/opencs/view/world/dialoguesubview.hpp index b5a44d266f..8783d935f6 100644 --- a/apps/opencs/view/world/dialoguesubview.hpp +++ b/apps/opencs/view/world/dialoguesubview.hpp @@ -165,7 +165,7 @@ namespace CSVWorld Q_OBJECT QDataWidgetMapper *mWidgetMapper; QDataWidgetMapper *mNestedTableMapper; - DialogueDelegateDispatcher mDispatcher; + DialogueDelegateDispatcher *mDispatcher; DialogueDelegateDispatcher *mNestedTableDispatcher; QWidget* mMainWidget; CSMWorld::IdTable* mTable; From b27a879352b155205a9809f567007e97bf7dd1a6 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 19 May 2015 22:01:40 +1000 Subject: [PATCH 043/119] Add the remaining Cell data for editing with dialogue subview. Should resolve Bug #2551. - NOTE: the interior water flag and water level logic needs reviewing - does not automatically disable region names for interiors without mQuasiEx flag - Colour values can't be entered as RGB - Region names are not drop down menus --- apps/opencs/model/world/columns.cpp | 11 +- apps/opencs/model/world/columns.hpp | 11 +- apps/opencs/model/world/data.cpp | 25 ++- apps/opencs/model/world/data.hpp | 2 +- .../model/world/nestedcoladapterimp.cpp | 161 +++++++++++++++++- .../model/world/nestedcoladapterimp.hpp | 26 +++ 6 files changed, 230 insertions(+), 6 deletions(-) diff --git a/apps/opencs/model/world/columns.cpp b/apps/opencs/model/world/columns.cpp index daf537c0c9..ee7a00ca0f 100644 --- a/apps/opencs/model/world/columns.cpp +++ b/apps/opencs/model/world/columns.cpp @@ -62,7 +62,7 @@ namespace CSMWorld { ColumnId_StarterSpell, "Starter Spell" }, { ColumnId_AlwaysSucceeds, "Always Succeeds" }, { ColumnId_SleepForbidden, "Sleep Forbidden" }, - { ColumnId_InteriorWater, "Interior Water" }, + { ColumnId_Water, "Has Water" }, { ColumnId_InteriorSky, "Interior Sky" }, { ColumnId_Model, "Model" }, { ColumnId_Script, "Script" }, @@ -303,6 +303,15 @@ namespace CSMWorld { ColumnId_RaceSkill, "Skills" }, { ColumnId_RaceBonus, "Bonus" }, + { ColumnId_Interior, "Interior" }, + { ColumnId_Ambient, "Ambient" }, + { ColumnId_Sunlight, "Sunlight" }, + { ColumnId_Fog, "Fog" }, + { ColumnId_FogDensity, "Fog Density" }, + { ColumnId_WaterLevel, "Water Level" }, + { ColumnId_InteriorWater, "Interior Water" }, + { ColumnId_MapColor, "Map Color" }, + { ColumnId_UseValue1, "Use value 1" }, { ColumnId_UseValue2, "Use value 2" }, { ColumnId_UseValue3, "Use value 3" }, diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index 85276a695f..3a345b3ecd 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -57,7 +57,7 @@ namespace CSMWorld ColumnId_StarterSpell = 42, ColumnId_AlwaysSucceeds = 43, ColumnId_SleepForbidden = 44, - ColumnId_InteriorWater = 45, + ColumnId_Water = 45, ColumnId_InteriorSky = 46, ColumnId_Model = 47, ColumnId_Script = 48, @@ -294,6 +294,15 @@ namespace CSMWorld ColumnId_RaceSkill = 266, ColumnId_RaceBonus = 267, + ColumnId_Interior = 268, + ColumnId_Ambient = 269, + ColumnId_Sunlight = 270, + ColumnId_Fog = 271, + ColumnId_FogDensity = 272, + ColumnId_WaterLevel = 273, + ColumnId_InteriorWater = 274, + ColumnId_MapColor = 275, + // Allocated to a separate value range, so we don't get a collision should we ever need // to extend the number of use values. ColumnId_UseValue1 = 0x10000, diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index fa7e48a0ea..00349d4765 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -287,10 +287,31 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mCells.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Cell)); mCells.addColumn (new NameColumn); mCells.addColumn (new FlagColumn (Columns::ColumnId_SleepForbidden, ESM::Cell::NoSleep)); - mCells.addColumn (new FlagColumn (Columns::ColumnId_InteriorWater, ESM::Cell::HasWater)); + mCells.addColumn (new FlagColumn (Columns::ColumnId_Water, ESM::Cell::HasWater)); mCells.addColumn (new FlagColumn (Columns::ColumnId_InteriorSky, ESM::Cell::QuasiEx)); mCells.addColumn (new RegionColumn); mCells.addColumn (new RefNumCounterColumn); + // Misc Cell data + mCells.addColumn (new NestedParentColumn (Columns::ColumnId_Cell, + ColumnBase::Flag_Dialogue | ColumnBase::Flag_Dialogue_List)); + index = mCells.getColumns()-1; + mCells.addAdapter (std::make_pair(&mCells.getColumn(index), new CellListAdapter ())); + mCells.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_Interior, ColumnBase::Display_Boolean)); + mCells.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_Ambient, ColumnBase::Display_Integer)); + mCells.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_Sunlight, ColumnBase::Display_Integer)); + mCells.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_Fog, ColumnBase::Display_Integer)); + mCells.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_FogDensity, ColumnBase::Display_Float)); + mCells.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_InteriorWater, ColumnBase::Display_Boolean)); + mCells.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_WaterLevel, ColumnBase::Display_Float)); + mCells.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_MapColor, ColumnBase::Display_Integer)); mEnchantments.addColumn (new StringIdColumn); mEnchantments.addColumn (new RecordStateColumn); @@ -465,7 +486,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc addModel (new IdTree (&mTopicInfos, &mTopicInfos, IdTable::Feature_ReorderWithinTopic), UniversalId::Type_TopicInfo); addModel (new IdTable (&mJournalInfos, IdTable::Feature_ReorderWithinTopic), UniversalId::Type_JournalInfo); - addModel (new IdTable (&mCells, IdTable::Feature_ViewId), UniversalId::Type_Cell); + addModel (new IdTree (&mCells, &mCells, IdTable::Feature_ViewId), UniversalId::Type_Cell); addModel (new IdTree (&mEnchantments, &mEnchantments), UniversalId::Type_Enchantment); addModel (new IdTable (&mBodyParts), UniversalId::Type_BodyPart); addModel (new IdTable (&mSoundGens), UniversalId::Type_SoundGen); diff --git a/apps/opencs/model/world/data.hpp b/apps/opencs/model/world/data.hpp index 8689b98c0c..060e47bd95 100644 --- a/apps/opencs/model/world/data.hpp +++ b/apps/opencs/model/world/data.hpp @@ -88,7 +88,7 @@ namespace CSMWorld IdCollection mStartScripts; NestedInfoCollection mTopicInfos; InfoCollection mJournalInfos; - IdCollection mCells; + NestedIdCollection mCells; IdCollection mLandTextures; IdCollection mLand; RefIdCollection mReferenceables; diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index 7efe14dee2..a63ebe672d 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -481,7 +481,7 @@ namespace CSMWorld void InfoListAdapter::removeRow(Record& record, int rowToRemove) const { - throw std::logic_error ("cannot add a row to a fixed table"); + throw std::logic_error ("cannot remove a row to a fixed table"); } void InfoListAdapter::setTable(Record& record, @@ -1033,4 +1033,163 @@ namespace CSMWorld // there are 7 skill bonuses return static_cast(sizeof(record.get().mData.mBonus)/sizeof(record.get().mData.mBonus[0])); } + + CellListAdapter::CellListAdapter () {} + + void CellListAdapter::addRow(Record& record, int position) const + { + throw std::logic_error ("cannot add a row to a fixed table"); + } + + void CellListAdapter::removeRow(Record& record, int rowToRemove) const + { + throw std::logic_error ("cannot remove a row to a fixed table"); + } + + void CellListAdapter::setTable(Record& record, + const NestedTableWrapperBase& nestedTable) const + { + throw std::logic_error ("table operation not supported"); + } + + NestedTableWrapperBase* CellListAdapter::table(const Record& record) const + { + throw std::logic_error ("table operation not supported"); + } + + QVariant CellListAdapter::getData(const Record& record, + int subRowIndex, int subColIndex) const + { + CSMWorld::Cell cell = record.get(); + + bool isInterior = (cell.mData.mFlags & ESM::Cell::Interior) != 0; + bool behaveLikeExterior = (cell.mData.mFlags & ESM::Cell::QuasiEx) != 0; + + switch (subColIndex) + { + case 0: return isInterior; + case 1: return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mAmbient : QVariant(); + case 2: return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mSunlight : QVariant(); + case 3: return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mFog : QVariant(); + case 4: return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mFogDensity : QVariant(); + case 5: return (isInterior && !behaveLikeExterior) ? cell.mWaterInt==true : QVariant(); + case 6: + { + if (isInterior && !behaveLikeExterior && cell.mWaterInt) + return cell.mWater; + else + return QVariant(); + } + case 7: return isInterior ? QVariant() : cell.mMapColor; // TODO: how to select? + //case 8: return isInterior ? behaveLikeExterior : QVariant(); + default: throw std::runtime_error("Cell subcolumn index out of range"); + } + } + + void CellListAdapter::setData(Record& record, + const QVariant& value, int subRowIndex, int subColIndex) const + { + CSMWorld::Cell cell = record.get(); + + bool isInterior = (cell.mData.mFlags & ESM::Cell::Interior) != 0; + bool behaveLikeExterior = (cell.mData.mFlags & ESM::Cell::QuasiEx) != 0; + + switch (subColIndex) + { + case 0: + { + if (value.toBool()) + cell.mData.mFlags |= ESM::Cell::Interior; + else + cell.mData.mFlags &= ~ESM::Cell::Interior; + break; + } + case 1: + { + if (isInterior && !behaveLikeExterior) + cell.mAmbi.mAmbient = static_cast(value.toInt()); + else + return; // return without saving + break; + } + case 2: + { + if (isInterior && !behaveLikeExterior) + cell.mAmbi.mSunlight = static_cast(value.toInt()); + else + return; // return without saving + break; + } + case 3: + { + if (isInterior && !behaveLikeExterior) + cell.mAmbi.mFog = static_cast(value.toInt()); + else + return; // return without saving + break; + } + case 4: + { + if (isInterior && !behaveLikeExterior) + cell.mAmbi.mFogDensity = value.toFloat(); + else + return; // return without saving + break; + } + case 5: + { + if (isInterior && !behaveLikeExterior) + cell.mWaterInt = value.toBool(); + else + return; // return without saving + break; + } + case 6: + { + if (isInterior && !behaveLikeExterior && cell.mWaterInt) + cell.mWater = value.toFloat(); + else + return; // return without saving + break; + } + case 7: + { + if (!isInterior) + cell.mMapColor = value.toInt(); + else + return; // return without saving + break; + } +#if 0 + // redundant since this flag is shown in the main table as "Interior Sky" + // keep here for documenting the logic based on vanilla + case 8: + { + if (isInterior) + { + if (value.toBool()) + cell.mData.mFlags |= ESM::Cell::QuasiEx; + else + cell.mData.mFlags &= ~ESM::Cell::QuasiEx; + } + else + return; // return without saving + break; + } +#endif + default: throw std::runtime_error("Cell subcolumn index out of range"); + } + + record.setModified (cell); + } + + int CellListAdapter::getColumnsCount(const Record& record) const + { + return 8; + } + + int CellListAdapter::getRowsCount(const Record& record) const + { + return 1; // fixed at size 1 + } } diff --git a/apps/opencs/model/world/nestedcoladapterimp.hpp b/apps/opencs/model/world/nestedcoladapterimp.hpp index 4b1e2cd09e..81c52588bb 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.hpp +++ b/apps/opencs/model/world/nestedcoladapterimp.hpp @@ -12,6 +12,7 @@ #include "nestedcolumnadapter.hpp" #include "nestedtablewrapper.hpp" +#include "cell.hpp" namespace ESM { @@ -488,6 +489,31 @@ namespace CSMWorld virtual int getRowsCount(const Record& record) const; }; + + class CellListAdapter : public NestedColumnAdapter + { + public: + CellListAdapter (); + + virtual void addRow(Record& record, int position) const; + + virtual void removeRow(Record& record, int rowToRemove) const; + + virtual void setTable(Record& record, + const NestedTableWrapperBase& nestedTable) const; + + virtual NestedTableWrapperBase* table(const Record& record) const; + + virtual QVariant getData(const Record& record, + int subRowIndex, int subColIndex) const; + + virtual void setData(Record& record, + const QVariant& value, int subRowIndex, int subColIndex) const; + + virtual int getColumnsCount(const Record& record) const; + + virtual int getRowsCount(const Record& record) const; + }; } #endif // CSM_WOLRD_NESTEDCOLADAPTERIMP_H From 196be7283d07cb371d699fdb1f9d4b19c6841774 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Tue, 19 May 2015 21:39:17 +0300 Subject: [PATCH 044/119] Reset an activated reference after activation's exectution (Fix #1738) --- apps/openmw/mwscript/interpretercontext.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index a8c04aa4bc..df675aebbd 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -505,7 +505,10 @@ namespace MWScript boost::shared_ptr action = (ptr.getClass().activate(ptr, actor)); action->execute (actor); if (mActivated == ptr) + { mActivationHandled = true; + mActivated = MWWorld::Ptr(); + } } float InterpreterContext::getSecondsPassed() const From ca7829032eac7e43e0edb58cf4d27137433f0aee Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 20 May 2015 11:45:16 +0200 Subject: [PATCH 045/119] updated credits file --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 0cd961c613..4fef9233aa 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -98,6 +98,7 @@ Programmers Sebastian Wick (swick) Sergey Shambir sir_herrbatka + smbas Stefan Galowicz (bogglez) Stanislav Bobrov (Jiub) Sylvain Thesnieres (Garvek) From 1d0b8587a1682dd1116b0a254f4b0ea4416fefd9 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 20 May 2015 21:14:17 +1000 Subject: [PATCH 046/119] Use HasWater bit flag rather than mWaterInt bool. --- apps/opencs/model/world/columns.cpp | 3 +-- apps/opencs/model/world/columns.hpp | 5 ++-- apps/opencs/model/world/data.cpp | 4 +-- .../model/world/nestedcoladapterimp.cpp | 27 +++++++------------ 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/apps/opencs/model/world/columns.cpp b/apps/opencs/model/world/columns.cpp index ee7a00ca0f..c937997a92 100644 --- a/apps/opencs/model/world/columns.cpp +++ b/apps/opencs/model/world/columns.cpp @@ -62,7 +62,7 @@ namespace CSMWorld { ColumnId_StarterSpell, "Starter Spell" }, { ColumnId_AlwaysSucceeds, "Always Succeeds" }, { ColumnId_SleepForbidden, "Sleep Forbidden" }, - { ColumnId_Water, "Has Water" }, + { ColumnId_InteriorWater, "Interior Water" }, { ColumnId_InteriorSky, "Interior Sky" }, { ColumnId_Model, "Model" }, { ColumnId_Script, "Script" }, @@ -309,7 +309,6 @@ namespace CSMWorld { ColumnId_Fog, "Fog" }, { ColumnId_FogDensity, "Fog Density" }, { ColumnId_WaterLevel, "Water Level" }, - { ColumnId_InteriorWater, "Interior Water" }, { ColumnId_MapColor, "Map Color" }, { ColumnId_UseValue1, "Use value 1" }, diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index 3a345b3ecd..191bbdea8c 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -57,7 +57,7 @@ namespace CSMWorld ColumnId_StarterSpell = 42, ColumnId_AlwaysSucceeds = 43, ColumnId_SleepForbidden = 44, - ColumnId_Water = 45, + ColumnId_InteriorWater = 45, ColumnId_InteriorSky = 46, ColumnId_Model = 47, ColumnId_Script = 48, @@ -300,8 +300,7 @@ namespace CSMWorld ColumnId_Fog = 271, ColumnId_FogDensity = 272, ColumnId_WaterLevel = 273, - ColumnId_InteriorWater = 274, - ColumnId_MapColor = 275, + ColumnId_MapColor = 274, // Allocated to a separate value range, so we don't get a collision should we ever need // to extend the number of use values. diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 00349d4765..920c7db719 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -287,7 +287,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mCells.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Cell)); mCells.addColumn (new NameColumn); mCells.addColumn (new FlagColumn (Columns::ColumnId_SleepForbidden, ESM::Cell::NoSleep)); - mCells.addColumn (new FlagColumn (Columns::ColumnId_Water, ESM::Cell::HasWater)); + mCells.addColumn (new FlagColumn (Columns::ColumnId_InteriorWater, ESM::Cell::HasWater)); mCells.addColumn (new FlagColumn (Columns::ColumnId_InteriorSky, ESM::Cell::QuasiEx)); mCells.addColumn (new RegionColumn); mCells.addColumn (new RefNumCounterColumn); @@ -306,8 +306,6 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc new NestedChildColumn (Columns::ColumnId_Fog, ColumnBase::Display_Integer)); mCells.getNestableColumn(index)->addColumn( new NestedChildColumn (Columns::ColumnId_FogDensity, ColumnBase::Display_Float)); - mCells.getNestableColumn(index)->addColumn( - new NestedChildColumn (Columns::ColumnId_InteriorWater, ColumnBase::Display_Boolean)); mCells.getNestableColumn(index)->addColumn( new NestedChildColumn (Columns::ColumnId_WaterLevel, ColumnBase::Display_Float)); mCells.getNestableColumn(index)->addColumn( diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index a63ebe672d..8c897f71cb 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -1064,6 +1064,7 @@ namespace CSMWorld bool isInterior = (cell.mData.mFlags & ESM::Cell::Interior) != 0; bool behaveLikeExterior = (cell.mData.mFlags & ESM::Cell::QuasiEx) != 0; + bool interiorWater = (cell.mData.mFlags & ESM::Cell::HasWater) != 0; switch (subColIndex) { @@ -1072,16 +1073,15 @@ namespace CSMWorld case 2: return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mSunlight : QVariant(); case 3: return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mFog : QVariant(); case 4: return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mFogDensity : QVariant(); - case 5: return (isInterior && !behaveLikeExterior) ? cell.mWaterInt==true : QVariant(); - case 6: + case 5: { - if (isInterior && !behaveLikeExterior && cell.mWaterInt) + if (isInterior && !behaveLikeExterior && interiorWater) return cell.mWater; else return QVariant(); } - case 7: return isInterior ? QVariant() : cell.mMapColor; // TODO: how to select? - //case 8: return isInterior ? behaveLikeExterior : QVariant(); + case 6: return isInterior ? QVariant() : cell.mMapColor; // TODO: how to select? + //case 7: return isInterior ? behaveLikeExterior : QVariant(); default: throw std::runtime_error("Cell subcolumn index out of range"); } } @@ -1093,6 +1093,7 @@ namespace CSMWorld bool isInterior = (cell.mData.mFlags & ESM::Cell::Interior) != 0; bool behaveLikeExterior = (cell.mData.mFlags & ESM::Cell::QuasiEx) != 0; + bool interiorWater = (cell.mData.mFlags & ESM::Cell::HasWater) != 0; switch (subColIndex) { @@ -1138,21 +1139,13 @@ namespace CSMWorld } case 5: { - if (isInterior && !behaveLikeExterior) - cell.mWaterInt = value.toBool(); - else - return; // return without saving - break; - } - case 6: - { - if (isInterior && !behaveLikeExterior && cell.mWaterInt) + if (isInterior && !behaveLikeExterior && interiorWater) cell.mWater = value.toFloat(); else return; // return without saving break; } - case 7: + case 6: { if (!isInterior) cell.mMapColor = value.toInt(); @@ -1163,7 +1156,7 @@ namespace CSMWorld #if 0 // redundant since this flag is shown in the main table as "Interior Sky" // keep here for documenting the logic based on vanilla - case 8: + case 7: { if (isInterior) { @@ -1185,7 +1178,7 @@ namespace CSMWorld int CellListAdapter::getColumnsCount(const Record& record) const { - return 8; + return 7; } int CellListAdapter::getRowsCount(const Record& record) const From 2fc964ca7372b7f67055706c661f79202ddbe539 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 21 May 2015 13:11:07 +1000 Subject: [PATCH 047/119] Grey out disabled entries rather than hiding them. --- .../model/world/nestedcoladapterimp.cpp | 20 ++++++++++------ apps/opencs/model/world/refidadapterimp.cpp | 10 ++++---- apps/opencs/model/world/refidadapterimp.hpp | 2 +- apps/opencs/view/world/dialoguesubview.cpp | 23 ++++++++++++++++++- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index 8c897f71cb..b7d09777d4 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -1069,19 +1069,25 @@ namespace CSMWorld switch (subColIndex) { case 0: return isInterior; - case 1: return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mAmbient : QVariant(); - case 2: return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mSunlight : QVariant(); - case 3: return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mFog : QVariant(); - case 4: return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mFogDensity : QVariant(); + case 1: return (isInterior && !behaveLikeExterior) ? + cell.mAmbi.mAmbient : QVariant(QVariant::UserType); + case 2: return (isInterior && !behaveLikeExterior) ? + cell.mAmbi.mSunlight : QVariant(QVariant::UserType); + case 3: return (isInterior && !behaveLikeExterior) ? + cell.mAmbi.mFog : QVariant(QVariant::UserType); + case 4: return (isInterior && !behaveLikeExterior) ? + cell.mAmbi.mFogDensity : QVariant(QVariant::UserType); case 5: { if (isInterior && !behaveLikeExterior && interiorWater) return cell.mWater; else - return QVariant(); + return QVariant(QVariant::UserType); } - case 6: return isInterior ? QVariant() : cell.mMapColor; // TODO: how to select? - //case 7: return isInterior ? behaveLikeExterior : QVariant(); + case 6: return isInterior ? + QVariant(QVariant::UserType) : cell.mMapColor; // TODO: how to select? + //case 7: return isInterior ? + //behaveLikeExterior : QVariant(QVariant::UserType); default: throw std::runtime_error("Cell subcolumn index out of range"); } } diff --git a/apps/opencs/model/world/refidadapterimp.cpp b/apps/opencs/model/world/refidadapterimp.cpp index a5f0b22449..ee045afd0b 100644 --- a/apps/opencs/model/world/refidadapterimp.cpp +++ b/apps/opencs/model/world/refidadapterimp.cpp @@ -502,7 +502,7 @@ QVariant CSMWorld::NpcRefIdAdapter::getData (const RefIdColumn *column, const Re if (column==mColumns.mAttributes || column==mColumns.mSkills) { if ((record.get().mFlags & ESM::NPC::Autocalc) != 0) - return QVariant(); + return QVariant(QVariant::UserType); else return true; } @@ -805,10 +805,10 @@ QVariant CSMWorld::NpcMiscRefIdAdapter::getNestedData (const RefIdColumn *column switch (subColIndex) { case 0: return static_cast(record.get().mNpdt12.mLevel); - case 1: return QVariant(); - case 2: return QVariant(); - case 3: return QVariant(); - case 4: return QVariant(); + case 1: return QVariant(QVariant::UserType); + case 2: return QVariant(QVariant::UserType); + case 3: return QVariant(QVariant::UserType); + case 4: return QVariant(QVariant::UserType); case 5: return static_cast(record.get().mNpdt12.mDisposition); case 6: return static_cast(record.get().mNpdt12.mReputation); case 7: return static_cast(record.get().mNpdt12.mRank); diff --git a/apps/opencs/model/world/refidadapterimp.hpp b/apps/opencs/model/world/refidadapterimp.hpp index 143b46c44b..3411429d05 100644 --- a/apps/opencs/model/world/refidadapterimp.hpp +++ b/apps/opencs/model/world/refidadapterimp.hpp @@ -1976,7 +1976,7 @@ namespace CSMWorld { switch (subColIndex) { - case 0: return QVariant(); // don't allow checkbox editor to be created + case 0: return QVariant(QVariant::UserType); // disable the checkbox editor case 1: return record.get().mFlags & ESM::CreatureLevList::AllLevels; case 2: return static_cast (record.get().mChanceNone); default: diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index fee302e2c7..0a5eb52027 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -461,7 +461,14 @@ void CSVWorld::EditWidget::remake(int row) NestedTable* table = new NestedTable(mDocument, id, mNestedModels.back(), this); // FIXME: does not work well when enum delegates are used //table->resizeColumnsToContents(); - table->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::CurrentChanged); + + if(mTable->index(row, i).data().type() == QVariant::UserType) + { + table->setEditTriggers(QAbstractItemView::NoEditTriggers); + table->setEnabled(false); + } + else + table->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::CurrentChanged); int rows = mTable->rowCount(mTable->index(row, i)); int rowHeight = (rows == 0) ? table->horizontalHeader()->height() : table->rowHeight(0); @@ -473,6 +480,8 @@ void CSVWorld::EditWidget::remake(int row) new QLabel (mTable->headerData (i, Qt::Horizontal, Qt::DisplayRole).toString(), mMainWidget); label->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed); + if(mTable->index(row, i).data().type() == QVariant::UserType) + label->setEnabled(false); tablesLayout->addWidget(label); tablesLayout->addWidget(table); @@ -503,6 +512,12 @@ void CSVWorld::EditWidget::remake(int row) unlockedLayout->addWidget (editor, unlocked, 1); ++unlocked; } + + if(mTable->index(row, i).data().type() == QVariant::UserType) + { + editor->setEnabled(false); + label->setEnabled(false); + } } } else @@ -550,6 +565,12 @@ void CSVWorld::EditWidget::remake(int row) unlockedLayout->addWidget (label, unlocked, 0); unlockedLayout->addWidget (editor, unlocked, 1); ++unlocked; + + if(mNestedModels.back()->index(0, col).data().type() == QVariant::UserType) + { + editor->setEnabled(false); + label->setEnabled(false); + } } } mNestedTableMapper->setCurrentModelIndex(mNestedModels.back()->index(0, 0)); From 8f8fdedcde09552f79114357d78ed3bda2f2eba7 Mon Sep 17 00:00:00 2001 From: Nicola Bodill Date: Thu, 21 May 2015 14:20:35 +1000 Subject: [PATCH 048/119] Some more edits Responding to sirherrbatka's feedback. --- manual/opencs/files_and_directories.tex | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/manual/opencs/files_and_directories.tex b/manual/opencs/files_and_directories.tex index 1b07fe267a..55d3011b46 100644 --- a/manual/opencs/files_and_directories.tex +++ b/manual/opencs/files_and_directories.tex @@ -1,8 +1,8 @@ \section{Files and Directories} \subsection{Introduction} -This section of the manual describes the directories and file types used by OpenCS. A file is a resource for storing data, identified by its -filename extension (e.g. .exe, .jpg, .txt), whereas a directory is a folder or file system structure in which these files are stored. You -are most likely already familiar with these concepts. +This section of the manual describes the directories and file types used by OpenCS. A file is a resource for storing data (e.g. .exe, .jpg, .txt), +whereas a directory is a folder or file system structure which points to these files (or other directories). You are most likely already familiar +with these concepts. \subsection{Used terms} %TODO @@ -15,7 +15,7 @@ files and several other folders. The location of the user directory is hard code %TODO list paths. In addition to the user directory, both \OMW{} and \OCS{} need a place to store the game’s actual data files: for example, the textures, models, sounds and records of in-game objects. We support multiple paths to these files (termed \textbf{data paths}), -as specified in the configuration. Usually, one data path points to the directory where \MW{} is installed, however, you are +as specified in the configuration. Usually, one data path points to the directory where \MW{} is installed; however, you are free to specify as many data paths as you would like. In addition, one particular data path, as described below, is used to store newly created content files. @@ -23,7 +23,7 @@ newly created content files. \BS{} \MW{} engine uses two file types: ESM (master) and ESP (plugin). The distinction between the two is often confusing. You would expect that the ESM (master) file is used to specify a single master which is modified by the ESP files (plugins), and indeed: this is the basic idea. However, the original expansions are also ESM files, even though they can be described as very large plugins. -There were technical reasons behind this decision -- somewhat valid in the case of the original engine, but a more logical file system is +There were technical reasons behind this decision -- somewhat valid in the case of the original engine -- but a more logical file system is much preferable. \OMW{} achieves this through the creation of our own types of content file. We support both ESM and ESP files, but, in order to make use of \OMW{}'s new features, one should consider using new file types designed @@ -42,9 +42,9 @@ Furthermore, our content files’ extensions are .omwaddon for addon files and . \subparagraph{\MW{} content files} Using our content files is the recommended solution for projects that employ the \OMW{} engine. However, some players will wish to use the original \MW{} engine, despite its large flaws and lacking features\footnote{If this is wrong, we are a very successful project. Yay!}. -In addition, since 2002 thousands of ESP/ESM files have been created, some with truly outstanding content. Because of this, \OCS{} is -committed to supporting ESP/ESM files. If you do decide to use ESP/ESM files rather than our own content files, you are most likely aiming -for original engine compatibility. This subject is covered in the very last section of the manual. +In addition, since 2002, thousands of ESP/ESM files have been created, some with truly outstanding content. Because of this, \OCS{} +will support ESP/ESM files, although this will impose limitations on the user. If you do decide to use ESP/ESM files rather than our own content +files, you are most likely aiming for original engine compatibility. This subject is covered in the very last section of the manual. %not finished TODO add the said section. Most likely when more features are present. The actual creation of new files is described in the next chapter. Here we are going to focus only on the essential information needed From 9767910f0615e8c5f68502798f1aae0a55bc420b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 21 May 2015 17:51:20 +0200 Subject: [PATCH 049/119] updated credits file --- AUTHORS.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AUTHORS.md b/AUTHORS.md index 4fef9233aa..fb83a1a91d 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -110,6 +110,12 @@ Programmers Vincent Heuken vocollapse +Manual +------ + + Bodillium + sir_herrbatka + Packagers --------- From aecd9a275e34d5e539e90713ca0e4158220f526d Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 22 May 2015 06:09:55 +1000 Subject: [PATCH 050/119] Remove debugging comments. --- apps/opencs/model/world/refidadapterimp.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/world/refidadapterimp.cpp b/apps/opencs/model/world/refidadapterimp.cpp index ee045afd0b..0bb565e519 100644 --- a/apps/opencs/model/world/refidadapterimp.cpp +++ b/apps/opencs/model/world/refidadapterimp.cpp @@ -721,8 +721,7 @@ QVariant CSMWorld::NpcSkillsRefIdAdapter::getNestedData (const RefIdColumn *colu const ESM::NPC::NPDTstruct52& npcStruct = record.get().mNpdt52; if (subRowIndex < 0 || subRowIndex >= ESM::Skill::Length) - std::cout << "getNestedDatat index" << std::endl; - //throw std::runtime_error ("index out of range"); + throw std::runtime_error ("index out of range"); if (subColIndex == 0) return QString(ESM::Skill::sSkillNames[subRowIndex].c_str()); @@ -741,8 +740,7 @@ void CSMWorld::NpcSkillsRefIdAdapter::setNestedData (const RefIdColumn *column, ESM::NPC::NPDTstruct52& npcStruct = npc.mNpdt52; if (subRowIndex < 0 || subRowIndex >= ESM::Skill::Length) - std::cout << "setNestedDatat index" << std::endl; - //throw std::runtime_error ("index out of range"); + throw std::runtime_error ("index out of range"); if (subColIndex == 1) npcStruct.mSkills[subRowIndex] = static_cast(value.toInt()); From d27b92e9f1b093798cbe2404ed0b998c8f3b750f Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Fri, 22 May 2015 00:57:47 +0300 Subject: [PATCH 051/119] Avoid gaps between local indexes in RefIdData after removal of records (Fix #2545) --- apps/opencs/model/world/refiddata.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index f67ab21526..7f5c25f368 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -176,7 +176,6 @@ void CSMWorld::RefIdData::erase (const LocalIndex& index, int count) { std::map::iterator iter = mRecordContainers.find (index.second); - if (iter==mRecordContainers.end()) throw std::logic_error ("invalid local index type"); @@ -189,6 +188,20 @@ void CSMWorld::RefIdData::erase (const LocalIndex& index, int count) mIndex.erase (result); } + // Adjust the local indexes to avoid gaps between them after removal of records + int recordIndex = index.first + count; + int recordCount = iter->second->getSize(); + while (recordIndex < recordCount) + { + std::map::iterator recordIndexFound = + mIndex.find(Misc::StringUtils::lowerCase(iter->second->getId(recordIndex))); + if (recordIndexFound != mIndex.end()) + { + recordIndexFound->second.first -= count; + } + ++recordIndex; + } + iter->second->erase (index.first, count); } From 396fba7fa9891dad8c11dd4877278467cd9e19b8 Mon Sep 17 00:00:00 2001 From: Rohit Nirmal Date: Thu, 30 Apr 2015 19:24:27 -0500 Subject: [PATCH 052/119] Silence -Wreorder warnings, and remove -Wno-reorder. --- CMakeLists.txt | 2 +- apps/launcher/graphicspage.cpp | 4 +-- apps/launcher/settingspage.cpp | 4 +-- apps/opencs/editor.cpp | 4 +-- apps/opencs/model/doc/document.cpp | 3 +- apps/opencs/model/filter/valuenode.cpp | 2 +- apps/opencs/model/settings/connector.cpp | 2 +- .../opencs/model/tools/referenceablecheck.cpp | 2 +- apps/opencs/model/tools/tools.cpp | 4 +-- apps/opencs/model/world/columnbase.cpp | 2 +- apps/opencs/model/world/commanddispatcher.cpp | 2 +- apps/opencs/model/world/commands.cpp | 18 +++++----- apps/opencs/model/world/refidadapterimp.cpp | 2 +- apps/opencs/view/doc/filedialog.cpp | 2 +- apps/opencs/view/render/cell.cpp | 2 +- apps/opencs/view/render/mousestate.cpp | 10 +++--- apps/opencs/view/render/textoverlay.cpp | 4 +-- apps/opencs/view/render/worldspacewidget.cpp | 2 +- apps/opencs/view/settings/booleanview.cpp | 2 +- apps/opencs/view/settings/dialog.cpp | 2 +- apps/opencs/view/settings/frame.cpp | 4 +-- apps/opencs/view/settings/listview.cpp | 2 +- apps/opencs/view/settings/page.cpp | 2 +- apps/opencs/view/settings/spinbox.cpp | 2 +- apps/opencs/view/settings/view.cpp | 6 ++-- apps/opencs/view/world/dialoguesubview.cpp | 10 +++--- apps/opencs/view/world/dragrecordtable.cpp | 2 +- apps/opencs/view/world/genericcreator.cpp | 4 +-- apps/opencs/view/world/scenesubview.cpp | 2 +- apps/opencs/view/world/scriptedit.cpp | 9 ++--- apps/opencs/view/world/table.cpp | 4 +-- apps/openmw/mwbase/environment.cpp | 4 +-- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 13 ++++--- apps/openmw/mwgui/alchemywindow.cpp | 4 +-- apps/openmw/mwgui/bookpage.cpp | 16 ++++----- apps/openmw/mwgui/bookwindow.cpp | 2 +- apps/openmw/mwgui/companionwindow.cpp | 6 ++-- apps/openmw/mwgui/container.cpp | 6 ++-- apps/openmw/mwgui/dialogue.cpp | 4 +-- apps/openmw/mwgui/draganddrop.cpp | 6 ++-- apps/openmw/mwgui/inventorywindow.cpp | 16 ++++----- apps/openmw/mwgui/itemmodel.cpp | 12 +++---- apps/openmw/mwgui/jailscreen.cpp | 4 +-- apps/openmw/mwgui/journalbooks.cpp | 6 ++-- apps/openmw/mwgui/journalviewmodel.cpp | 2 +- apps/openmw/mwgui/loadingscreen.cpp | 6 ++-- apps/openmw/mwgui/mapwindow.cpp | 22 ++++++------ apps/openmw/mwgui/messagebox.cpp | 6 ++-- apps/openmw/mwgui/sortfilteritemmodel.cpp | 2 +- apps/openmw/mwgui/spellbuyingwindow.cpp | 2 +- apps/openmw/mwgui/spellcreationdialog.cpp | 6 ++-- apps/openmw/mwgui/tooltips.cpp | 6 ++-- apps/openmw/mwgui/waitdialog.cpp | 2 +- apps/openmw/mwgui/windowbase.cpp | 2 +- apps/openmw/mwmechanics/aiavoiddoor.cpp | 2 +- apps/openmw/mwmechanics/aicombat.cpp | 6 ++-- apps/openmw/mwmechanics/aiescort.cpp | 7 ++-- apps/openmw/mwmechanics/aifollow.cpp | 12 +++---- apps/openmw/mwmechanics/aiwander.cpp | 2 +- apps/openmw/mwmechanics/character.cpp | 2 +- apps/openmw/mwmechanics/creaturestats.cpp | 16 ++++----- apps/openmw/mwmechanics/npcstats.cpp | 6 ++-- apps/openmw/mwmechanics/obstacle.cpp | 2 +- apps/openmw/mwmechanics/pathgrid.cpp | 4 +-- apps/openmw/mwrender/globalmap.cpp | 5 +-- apps/openmw/mwrender/water.cpp | 6 ++-- apps/openmw/mwsound/soundmanagerimp.cpp | 6 ++-- apps/openmw/mwworld/action.cpp | 2 +- apps/openmw/mwworld/esmloader.cpp | 2 +- apps/openmw/mwworld/inventorystore.cpp | 8 ++--- apps/openmw/mwworld/physicssystem.cpp | 2 +- apps/openmw/mwworld/player.cpp | 2 +- apps/openmw/mwworld/refdata.cpp | 18 +++++----- apps/openmw/mwworld/weather.cpp | 9 +++-- apps/openmw/mwworld/worldimp.cpp | 14 ++++---- components/compiler/lineparser.cpp | 4 +-- components/interpreter/runtime.cpp | 2 +- .../ogre-ffmpeg-videoplayer/audiodecoder.cpp | 14 ++++---- extern/ogre-ffmpeg-videoplayer/videostate.cpp | 8 +++-- extern/oics/ICSControl.cpp | 4 +-- extern/oics/ICSInputControlSystem.cpp | 36 +++++++++---------- extern/sdl4ogre/sdlinputwrapper.cpp | 36 +++++++++---------- extern/shiny/Main/Factory.cpp | 12 +++---- extern/shiny/Main/MaterialInstance.cpp | 6 ++-- extern/shiny/Main/Platform.cpp | 4 +-- extern/shiny/Main/ShaderSet.cpp | 2 +- 86 files changed, 270 insertions(+), 268 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c19c57eb0..1fefc673ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -351,7 +351,7 @@ endif() # CXX Compiler settings if (CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-reorder -std=c++98 -pedantic -Wno-long-long") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -std=c++98 -pedantic -Wno-long-long") if (CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT APPLE) execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE CLANG_VERSION) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index cdb51348c8..5176d7fa0d 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -36,13 +36,13 @@ QString getAspect(int x, int y) } Launcher::GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &graphicsSetting, QWidget *parent) - : mOgre(NULL) + : QWidget(parent) + , mOgre(NULL) , mSelectedRenderSystem(NULL) , mOpenGLRenderSystem(NULL) , mDirect3DRenderSystem(NULL) , mCfgMgr(cfg) , mGraphicsSettings(graphicsSetting) - , QWidget(parent) { setObjectName ("GraphicsPage"); setupUi(this); diff --git a/apps/launcher/settingspage.cpp b/apps/launcher/settingspage.cpp index 34b4b41a9e..843b513914 100644 --- a/apps/launcher/settingspage.cpp +++ b/apps/launcher/settingspage.cpp @@ -18,10 +18,10 @@ using namespace Process; Launcher::SettingsPage::SettingsPage(Files::ConfigurationManager &cfg, Config::GameSettings &gameSettings, Config::LauncherSettings &launcherSettings, MainDialog *parent) - : mCfgMgr(cfg) + : QWidget(parent) + , mCfgMgr(cfg) , mGameSettings(gameSettings) , mLauncherSettings(launcherSettings) - , QWidget(parent) , mMain(parent) { setupUi(this); diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 1d31c83969..53a9e9e838 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -23,8 +23,8 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) : mUserSettings (mCfgMgr), mOverlaySystem (0), mDocumentManager (mCfgMgr), - mViewManager (mDocumentManager), - mIpcServerName ("org.openmw.OpenCS"), mServer(NULL), mClientSocket(NULL), mPid(""), mLock() + mViewManager (mDocumentManager), mPid(""), + mLock(), mIpcServerName ("org.openmw.OpenCS"), mServer(NULL), mClientSocket(NULL) { std::pair > config = readConfig(); diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index 31d0aaccdd..a73201ec0f 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -2251,11 +2251,12 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, ToUTF8::FromType encoding, const CSMWorld::ResourcesManager& resourcesManager, const std::vector& blacklistedScripts) : mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, resourcesManager), - mTools (*this), mResDir(resDir), + mTools (*this), mProjectPath ((configuration.getUserDataPath() / "projects") / (savePath.filename().string() + ".project")), mSavingOperation (*this, mProjectPath, encoding), mSaving (&mSavingOperation), + mResDir(resDir), mRunner (mProjectPath), mPhysics(boost::shared_ptr()) { if (mContentFiles.empty()) diff --git a/apps/opencs/model/filter/valuenode.cpp b/apps/opencs/model/filter/valuenode.cpp index 6fdae3e1ba..6fdb5cb021 100644 --- a/apps/opencs/model/filter/valuenode.cpp +++ b/apps/opencs/model/filter/valuenode.cpp @@ -9,7 +9,7 @@ CSMFilter::ValueNode::ValueNode (int columnId, Type lowerType, Type upperType, double lower, double upper) -: mColumnId (columnId), mLowerType (lowerType), mUpperType (upperType), mLower (lower), mUpper (upper){} +: mColumnId (columnId), mLower (lower), mUpper (upper), mLowerType (lowerType), mUpperType (upperType){} bool CSMFilter::ValueNode::test (const CSMWorld::IdTableBase& table, int row, const std::map& columns) const diff --git a/apps/opencs/model/settings/connector.cpp b/apps/opencs/model/settings/connector.cpp index 5e1d64544d..3cf21123c5 100644 --- a/apps/opencs/model/settings/connector.cpp +++ b/apps/opencs/model/settings/connector.cpp @@ -4,7 +4,7 @@ CSMSettings::Connector::Connector(CSVSettings::View *master, QObject *parent) - : mMasterView (master), QObject(parent) + : QObject(parent), mMasterView (master) {} void CSMSettings::Connector::addSlaveView (CSVSettings::View *view, diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 5190aacd59..c0991a330d 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -11,8 +11,8 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage( const CSMWorld::IdCollection& faction) : mReferencables(referenceable), - mClasses(classes), mRaces(races), + mClasses(classes), mFactions(faction), mPlayerPresent(false) { diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 970a8ac4fe..99e462b1d2 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -103,8 +103,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier() } CSMTools::Tools::Tools (CSMDoc::Document& document) -: mDocument (document), mData (document.getData()), mVerifierOperation (0), mNextReportNumber (0), - mSearchOperation (0) +: mDocument (document), mData (document.getData()), mVerifierOperation (0), + mSearchOperation (0), mNextReportNumber (0) { // index 0: load error log mReports.insert (std::make_pair (mNextReportNumber++, new ReportModel)); diff --git a/apps/opencs/model/world/columnbase.cpp b/apps/opencs/model/world/columnbase.cpp index cf125aa639..53987b23c9 100644 --- a/apps/opencs/model/world/columnbase.cpp +++ b/apps/opencs/model/world/columnbase.cpp @@ -3,7 +3,7 @@ #include "columns.hpp" CSMWorld::ColumnBase::ColumnBase (int columnId, Display displayType, int flags) - : mColumnId (columnId), mDisplayType (displayType), mFlags (flags) + : mColumnId (columnId), mFlags (flags), mDisplayType (displayType) {} CSMWorld::ColumnBase::~ColumnBase() {} diff --git a/apps/opencs/model/world/commanddispatcher.cpp b/apps/opencs/model/world/commanddispatcher.cpp index 2d32624872..b9d5bd7fec 100644 --- a/apps/opencs/model/world/commanddispatcher.cpp +++ b/apps/opencs/model/world/commanddispatcher.cpp @@ -83,7 +83,7 @@ std::vector CSMWorld::CommandDispatcher::getRevertableRecords() con CSMWorld::CommandDispatcher::CommandDispatcher (CSMDoc::Document& document, const CSMWorld::UniversalId& id, QObject *parent) -: QObject (parent), mDocument (document), mId (id), mLocked (false) +: QObject (parent), mLocked (false), mDocument (document), mId (id) {} void CSMWorld::CommandDispatcher::setEditLock (bool locked) diff --git a/apps/opencs/model/world/commands.cpp b/apps/opencs/model/world/commands.cpp index 9a0401081b..fbb4de7562 100644 --- a/apps/opencs/model/world/commands.cpp +++ b/apps/opencs/model/world/commands.cpp @@ -235,12 +235,12 @@ CSMWorld::DeleteNestedCommand::DeleteNestedCommand (IdTree& model, int nestedRow, int parentColumn, QUndoCommand* parent) : - mId(id), - mModel(model), - mParentColumn(parentColumn), QUndoCommand(parent), - mNestedRow(nestedRow), - NestedTableStoring(model, id, parentColumn) + NestedTableStoring(model, id, parentColumn), + mModel(model), + mId(id), + mParentColumn(parentColumn), + mNestedRow(nestedRow) { std::string title = model.headerData(parentColumn, Qt::Horizontal, Qt::DisplayRole).toString().toUtf8().constData(); @@ -263,12 +263,12 @@ void CSMWorld::DeleteNestedCommand::undo() } CSMWorld::AddNestedCommand::AddNestedCommand(IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent) - : mModel(model), + : QUndoCommand(parent), + NestedTableStoring(model, id, parentColumn), + mModel(model), mId(id), mNewRow(nestedRow), - mParentColumn(parentColumn), - QUndoCommand(parent), - NestedTableStoring(model, id, parentColumn) + mParentColumn(parentColumn) { std::string title = model.headerData(parentColumn, Qt::Horizontal, Qt::DisplayRole).toString().toUtf8().constData(); diff --git a/apps/opencs/model/world/refidadapterimp.cpp b/apps/opencs/model/world/refidadapterimp.cpp index 98c1b6f0f3..c784e14ce2 100644 --- a/apps/opencs/model/world/refidadapterimp.cpp +++ b/apps/opencs/model/world/refidadapterimp.cpp @@ -13,7 +13,7 @@ CSMWorld::PotionColumns::PotionColumns (const InventoryColumns& columns) CSMWorld::PotionRefIdAdapter::PotionRefIdAdapter (const PotionColumns& columns, const RefIdColumn *autoCalc) : InventoryRefIdAdapter (UniversalId::Type_Potion, columns), - mAutoCalc (autoCalc), mColumns(columns) + mColumns(columns), mAutoCalc (autoCalc) {} QVariant CSMWorld::PotionRefIdAdapter::getData (const RefIdColumn *column, const RefIdData& data, diff --git a/apps/opencs/view/doc/filedialog.cpp b/apps/opencs/view/doc/filedialog.cpp index 1b3196112d..eeec81109f 100644 --- a/apps/opencs/view/doc/filedialog.cpp +++ b/apps/opencs/view/doc/filedialog.cpp @@ -18,7 +18,7 @@ #include "adjusterwidget.hpp" CSVDoc::FileDialog::FileDialog(QWidget *parent) : - QDialog(parent), mSelector (0), mFileWidget (0), mAdjusterWidget (0), mDialogBuilt(false), mAction(ContentAction_Undefined) + QDialog(parent), mSelector (0), mAction(ContentAction_Undefined), mFileWidget (0), mAdjusterWidget (0), mDialogBuilt(false) { ui.setupUi (this); resize(400, 400); diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index a030ea11f8..99658e1c8f 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -55,7 +55,7 @@ bool CSVRender::Cell::addObjects (int start, int end) CSVRender::Cell::Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager, const std::string& id, boost::shared_ptr physics, const Ogre::Vector3& origin) -: mData (data), mId (Misc::StringUtils::lowerCase (id)), mSceneMgr(sceneManager), mPhysics(physics), mX(0), mY(0) +: mData (data), mId (Misc::StringUtils::lowerCase (id)), mPhysics(physics), mSceneMgr(sceneManager), mX(0), mY(0) { mCellNode = sceneManager->getRootSceneNode()->createChildSceneNode(); mCellNode->setPosition (origin); diff --git a/apps/opencs/view/render/mousestate.cpp b/apps/opencs/view/render/mousestate.cpp index a94f4f8ab1..206820194d 100644 --- a/apps/opencs/view/render/mousestate.cpp +++ b/apps/opencs/view/render/mousestate.cpp @@ -56,11 +56,11 @@ namespace CSVRender // MouseState::MouseState(WorldspaceWidget *parent) - : mParent(parent), mPhysics(parent->mDocument.getPhysics()), mSceneManager(parent->getSceneManager()) - , mCurrentObj(""), mMouseState(Mouse_Default), mOldPos(0,0), mMouseEventTimer(0), mPlane(0) - , mGrabbedSceneNode(""), mOrigObjPos(Ogre::Vector3()), mOrigMousePos(Ogre::Vector3()) - , mCurrentMousePos(Ogre::Vector3()), mOffset(0.0f) - , mColIndexPosX(0), mColIndexPosY(0), mColIndexPosZ(0), mIdTableModel(0) + : mMouseState(Mouse_Default), mParent(parent), mPhysics(parent->mDocument.getPhysics()) + , mSceneManager(parent->getSceneManager()), mOldPos(0,0), mCurrentObj(""), mGrabbedSceneNode("") + , mMouseEventTimer(0), mPlane(0), mOrigObjPos(Ogre::Vector3()), mOrigMousePos(Ogre::Vector3()) + , mCurrentMousePos(Ogre::Vector3()), mOffset(0.0f), mIdTableModel(0), mColIndexPosX(0) + , mColIndexPosY(0), mColIndexPosZ(0) { const CSMWorld::RefCollection& references = mParent->mDocument.getData().getReferences(); diff --git a/apps/opencs/view/render/textoverlay.cpp b/apps/opencs/view/render/textoverlay.cpp index 656ea959c7..c41d5f3180 100644 --- a/apps/opencs/view/render/textoverlay.cpp +++ b/apps/opencs/view/render/textoverlay.cpp @@ -27,8 +27,8 @@ namespace CSVRender // http://www.ogre3d.org/tikiwiki/Creating+dynamic+textures // http://www.ogre3d.org/tikiwiki/ManualObject TextOverlay::TextOverlay(const Ogre::MovableObject* obj, const Ogre::Camera* camera, const Ogre::String& id) - : mOverlay(0), mCaption(""), mDesc(""), mEnabled(true), mCamera(camera), mObj(obj), mId(id) - , mOnScreen(false) , mInstance(0), mFontHeight(16) // FIXME: make font height configurable + : mOverlay(0), mCaption(""), mDesc(""), mObj(obj), mCamera(camera), mFontHeight(16), mId(id) + , mEnabled(true), mOnScreen(false), mInstance(0) // FIXME: make font height configurable { if(id == "" || !camera || !obj) throw std::runtime_error("TextOverlay could not be created."); diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index e3e5ce50e6..e888148186 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -22,7 +22,7 @@ #include "editmode.hpp" CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent) -: SceneWidget (parent), mDocument(document), mSceneElements(0), mRun(0), mPhysics(boost::shared_ptr()), mMouse(0), +: SceneWidget (parent), mSceneElements(0), mRun(0), mDocument(document), mPhysics(boost::shared_ptr()), mMouse(0), mInteractionMask (0) { setAcceptDrops(true); diff --git a/apps/opencs/view/settings/booleanview.cpp b/apps/opencs/view/settings/booleanview.cpp index 29f9775af4..8c759cabb0 100644 --- a/apps/opencs/view/settings/booleanview.cpp +++ b/apps/opencs/view/settings/booleanview.cpp @@ -12,7 +12,7 @@ CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting, Page *parent) - : mType(setting->type()), View (setting, parent) + : View (setting, parent), mType(setting->type()) { foreach (const QString &value, setting->declaredValues()) { diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 0b12312661..e8832e2bcc 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -23,7 +23,7 @@ #include CSVSettings::Dialog::Dialog(QMainWindow *parent) - : mStackedWidget (0), mDebugMode (false), SettingWindow (parent) + : SettingWindow (parent), mStackedWidget (0), mDebugMode (false) { setWindowTitle(QString::fromUtf8 ("User Settings")); diff --git a/apps/opencs/view/settings/frame.cpp b/apps/opencs/view/settings/frame.cpp index 32e094274e..454d3fefa4 100644 --- a/apps/opencs/view/settings/frame.cpp +++ b/apps/opencs/view/settings/frame.cpp @@ -7,8 +7,8 @@ const QString CSVSettings::Frame::sInvisibleBoxStyle = CSVSettings::Frame::Frame (bool isVisible, const QString &title, QWidget *parent) - : mIsHorizontal (true), mLayout (new SettingLayout()), - QGroupBox (title, parent) + : QGroupBox (title, parent), mIsHorizontal (true), + mLayout (new SettingLayout()) { setFlat (true); mVisibleBoxStyle = styleSheet(); diff --git a/apps/opencs/view/settings/listview.cpp b/apps/opencs/view/settings/listview.cpp index 36cdbb0ae6..0876b39820 100644 --- a/apps/opencs/view/settings/listview.cpp +++ b/apps/opencs/view/settings/listview.cpp @@ -7,7 +7,7 @@ CSVSettings::ListView::ListView(CSMSettings::Setting *setting, Page *parent) - : mComboBox (0), mAbstractItemView (0), View(setting, parent) + : View(setting, parent), mAbstractItemView (0), mComboBox (0) { QWidget *widget = buildWidget(setting->isMultiLine(), setting->widgetWidth()); diff --git a/apps/opencs/view/settings/page.cpp b/apps/opencs/view/settings/page.cpp index e846840b87..c009cdd7a5 100644 --- a/apps/opencs/view/settings/page.cpp +++ b/apps/opencs/view/settings/page.cpp @@ -19,7 +19,7 @@ QMap CSVSettings::Page::Page (const QString &pageName, QList settingList, SettingWindow *parent, const QString& label) -: mParent(parent), mIsEditorPage (false), Frame(false, "", parent), mLabel (label) +: Frame(false, "", parent), mParent(parent), mIsEditorPage (false), mLabel (label) { setObjectName (pageName); diff --git a/apps/opencs/view/settings/spinbox.cpp b/apps/opencs/view/settings/spinbox.cpp index c70fc36d12..043107bb76 100644 --- a/apps/opencs/view/settings/spinbox.cpp +++ b/apps/opencs/view/settings/spinbox.cpp @@ -3,7 +3,7 @@ #include CSVSettings::SpinBox::SpinBox(QWidget *parent) - : mValueList(QStringList()), QSpinBox(parent) + : QSpinBox(parent), mValueList(QStringList()) { setRange (0, 0); } diff --git a/apps/opencs/view/settings/view.cpp b/apps/opencs/view/settings/view.cpp index 39c7f89b22..21cf55fddd 100644 --- a/apps/opencs/view/settings/view.cpp +++ b/apps/opencs/view/settings/view.cpp @@ -12,12 +12,12 @@ CSVSettings::View::View(CSMSettings::Setting *setting, Page *parent) - : mDataModel(0), mParentPage (parent), + : Frame(true, setting->getLabel(), parent), + mParentPage (parent), mDataModel(0), mHasFixedValues (!setting->declaredValues().isEmpty()), mIsMultiValue (setting->isMultiValue()), mViewKey (setting->page() + '/' + setting->name()), - mSerializable (setting->serializable()), - Frame(true, setting->getLabel(), parent) + mSerializable (setting->serializable()) { if (!setting->getToolTip().isEmpty()) setToolTip (setting->getToolTip()); diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 0d0e82dbf3..647accd4c3 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -356,15 +356,15 @@ CSVWorld::EditWidget::~EditWidget() CSVWorld::EditWidget::EditWidget(QWidget *parent, int row, CSMWorld::IdTable* table, CSMWorld::CommandDispatcher& commandDispatcher, CSMDoc::Document& document, bool createAndDelete) : -mDispatcher(this, table, commandDispatcher, document), -mNestedTableDispatcher(NULL), QScrollArea(parent), mWidgetMapper(NULL), mNestedTableMapper(NULL), +mDispatcher(this, table, commandDispatcher, document), +mNestedTableDispatcher(NULL), mMainWidget(NULL), +mTable(table), mCommandDispatcher (commandDispatcher), -mDocument (document), -mTable(table) +mDocument (document) { remake (row); @@ -571,8 +571,8 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM SubView (id), mEditWidget(0), mMainLayout(NULL), - mUndoStack(document.getUndoStack()), mTable(dynamic_cast(document.getData().getTableModel(id))), + mUndoStack(document.getUndoStack()), mLocked(false), mDocument(document), mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType())) diff --git a/apps/opencs/view/world/dragrecordtable.cpp b/apps/opencs/view/world/dragrecordtable.cpp index f45c458091..7032fee6d2 100644 --- a/apps/opencs/view/world/dragrecordtable.cpp +++ b/apps/opencs/view/world/dragrecordtable.cpp @@ -17,8 +17,8 @@ void CSVWorld::DragRecordTable::startDragFromTable (const CSVWorld::DragRecordTa } CSVWorld::DragRecordTable::DragRecordTable (CSMDoc::Document& document, QWidget* parent) : -mDocument(document), QTableView(parent), +mDocument(document), mEditLock(false) {} diff --git a/apps/opencs/view/world/genericcreator.cpp b/apps/opencs/view/world/genericcreator.cpp index 4269679bfd..a123e127f9 100644 --- a/apps/opencs/view/world/genericcreator.cpp +++ b/apps/opencs/view/world/genericcreator.cpp @@ -129,9 +129,9 @@ void CSVWorld::GenericCreator::addScope (const QString& name, CSMWorld::Scope sc CSVWorld::GenericCreator::GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id, bool relaxedIdRules) -: mData (data), mUndoStack (undoStack), mListId (id), mLocked (false), mCloneMode (false), +: mData (data), mUndoStack (undoStack), mListId (id), mLocked (false), mClonedType (CSMWorld::UniversalId::Type_None), mScopes (CSMWorld::Scope_Content), mScope (0), - mScopeLabel (0) + mScopeLabel (0), mCloneMode (false) { mLayout = new QHBoxLayout; mLayout->setContentsMargins (0, 0, 0, 0); diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 3fdf2f6e5c..aa21612599 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -27,7 +27,7 @@ #include "creator.hpp" CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) -: SubView (id), mLayout(new QHBoxLayout), mDocument(document), mScene(NULL), mToolbar(NULL) +: SubView (id), mScene(NULL), mLayout(new QHBoxLayout), mDocument(document), mToolbar(NULL) { QVBoxLayout *layout = new QVBoxLayout; diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 2e05fa110e..2f0d82ae1c 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -42,13 +42,14 @@ bool CSVWorld::ScriptEdit::event (QEvent *event) CSVWorld::ScriptEdit::ScriptEdit (const CSMDoc::Document& document, ScriptHighlighter::Mode mode, QWidget* parent) : QPlainTextEdit (parent), - mDocument (document), - mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive), mChangeLocked (0), - mLineNumberArea(0), mShowLineNum(false), + mLineNumberArea(0), mDefaultFont(font()), - mMonoFont(QFont("Monospace")) + mMonoFont(QFont("Monospace")), + mDocument (document), + mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive) + { // setAcceptRichText (false); setLineWrapMode (QPlainTextEdit::NoWrap); diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 86daf8af7b..b8972edbe4 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -253,8 +253,8 @@ void CSVWorld::Table::mouseDoubleClickEvent (QMouseEvent *event) CSVWorld::Table::Table (const CSMWorld::UniversalId& id, bool createAndDelete, bool sorting, CSMDoc::Document& document) -: mCreateAction (0), mCloneAction(0), mRecordStatusDisplay (0), - DragRecordTable(document) +: DragRecordTable(document), mCreateAction (0), + mCloneAction(0),mRecordStatusDisplay (0) { CSMSettings::UserSettings &settings = CSMSettings::UserSettings::instance(); QString jumpSetting = settings.settingValue ("table-input/jump-to-added"); diff --git a/apps/openmw/mwbase/environment.cpp b/apps/openmw/mwbase/environment.cpp index 3bc15746ec..a90eec5bf6 100644 --- a/apps/openmw/mwbase/environment.cpp +++ b/apps/openmw/mwbase/environment.cpp @@ -17,8 +17,8 @@ MWBase::Environment *MWBase::Environment::sThis = 0; MWBase::Environment::Environment() : mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0), - mMechanicsManager (0), mDialogueManager (0), mJournal (0), mInputManager (0), mFrameDuration (0), - mStateManager (0) + mMechanicsManager (0), mDialogueManager (0), mJournal (0), mInputManager (0), mStateManager (0), + mFrameDuration (0) { assert (!sThis); sThis = this; diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 0b9fd65d20..1785575fcf 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -48,12 +48,15 @@ namespace MWDialogue { DialogueManager::DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose, Translation::Storage& translationDataStorage) : - mCompilerContext (MWScript::CompilerContext::Type_Dialogue), - mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream) - , mTemporaryDispositionChange(0.f) - , mPermanentDispositionChange(0.f), mScriptVerbose (scriptVerbose) - , mTranslationDataStorage(translationDataStorage) + mTranslationDataStorage(translationDataStorage) + , mCompilerContext (MWScript::CompilerContext::Type_Dialogue) + , mErrorStream(std::cout.rdbuf()) + , mErrorHandler(mErrorStream) , mTalkedTo(false) + , mTemporaryDispositionChange(0.f) + , mPermanentDispositionChange(0.f) + , mScriptVerbose (scriptVerbose) + { mChoice = -1; mIsInChoice = false; diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index b28e4de09f..a54744370c 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -26,10 +26,10 @@ namespace MWGui { AlchemyWindow::AlchemyWindow() : WindowBase("openmw_alchemy_window.layout") - , mApparatus (4) - , mIngredients (4) , mSortModel(NULL) , mAlchemy(new MWMechanics::Alchemy()) + , mApparatus (4) + , mIngredients (4) { getWidget(mCreateButton, "CreateButton"); getWidget(mCancelButton, "CancelButton"); diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp index 962e594aeb..cfb49ebffb 100644 --- a/apps/openmw/mwgui/bookpage.cpp +++ b/apps/openmw/mwgui/bookpage.cpp @@ -228,8 +228,8 @@ struct TypesetBookImpl::Typesetter : BookTypesetter Typesetter (size_t width, size_t height) : mPageWidth (width), mPageHeight(height), mSection (NULL), mLine (NULL), mRun (NULL), - mCurrentAlignment (AlignLeft), - mCurrentContent (NULL) + mCurrentContent (NULL), + mCurrentAlignment (AlignLeft) { mBook = boost::make_shared (); } @@ -697,10 +697,10 @@ namespace GlyphStream (MyGUI::IFont* font, float left, float top, float Z, MyGUI::Vertex* vertices, RenderXform const & renderXform) : - mZ(Z), mOrigin (left, top), - mFont (font), mVertices (vertices), - mRenderXform (renderXform), - mC(0) + mZ(Z), + mC(0), mFont (font), mOrigin (left, top), + mVertices (vertices), + mRenderXform (renderXform) { mVertexColourType = MyGUI::RenderManager::getInstance().getVertexFormat(); } @@ -801,10 +801,10 @@ protected: TextFormat (MyGUI::IFont* id, PageDisplay * display) : mFont (id), + mCountVertex (0), mTexture (NULL), mRenderItem (NULL), - mDisplay (display), - mCountVertex (0) + mDisplay (display) { } diff --git a/apps/openmw/mwgui/bookwindow.cpp b/apps/openmw/mwgui/bookwindow.cpp index 55a9b61918..6863994b8a 100644 --- a/apps/openmw/mwgui/bookwindow.cpp +++ b/apps/openmw/mwgui/bookwindow.cpp @@ -18,9 +18,9 @@ namespace MWGui BookWindow::BookWindow () : WindowBase("openmw_book.layout") + , mCurrentPage(0) , mTakeButtonShow(true) , mTakeButtonAllowed(true) - , mCurrentPage(0) { getWidget(mCloseButton, "CloseButton"); mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onCloseButtonClicked); diff --git a/apps/openmw/mwgui/companionwindow.cpp b/apps/openmw/mwgui/companionwindow.cpp index fe47437cad..4433f9ef8c 100644 --- a/apps/openmw/mwgui/companionwindow.cpp +++ b/apps/openmw/mwgui/companionwindow.cpp @@ -37,11 +37,11 @@ namespace MWGui CompanionWindow::CompanionWindow(DragAndDrop *dragAndDrop, MessageBoxManager* manager) : WindowBase("openmw_companion_window.layout") + , mSortModel(NULL) + , mModel(NULL) + , mSelectedItem(-1) , mDragAndDrop(dragAndDrop) , mMessageBoxManager(manager) - , mSelectedItem(-1) - , mModel(NULL) - , mSortModel(NULL) { getWidget(mCloseButton, "CloseButton"); getWidget(mProfitLabel, "ProfitLabel"); diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 579730f42f..1317e1e253 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -33,10 +33,10 @@ namespace MWGui ContainerWindow::ContainerWindow(DragAndDrop* dragAndDrop) : WindowBase("openmw_container_window.layout") , mDragAndDrop(dragAndDrop) - , mSelectedItem(-1) - , mModel(NULL) - , mSortModel(NULL) , mPickpocketDetected(false) + , mSortModel(NULL) + , mModel(NULL) + , mSelectedItem(-1) { getWidget(mDisposeCorpseButton, "DisposeCorpseButton"); getWidget(mTakeButton, "TakeButton"); diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 1b07522f38..692cea952d 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -248,10 +248,10 @@ namespace MWGui DialogueWindow::DialogueWindow() : WindowBase("openmw_dialogue_window.layout") - , mPersuasionDialog() - , mEnabled(false) , mServices(0) + , mEnabled(false) , mGoodbye(false) + , mPersuasionDialog() { // Centre dialog center(); diff --git a/apps/openmw/mwgui/draganddrop.cpp b/apps/openmw/mwgui/draganddrop.cpp index fcb381b954..55aeb969c5 100644 --- a/apps/openmw/mwgui/draganddrop.cpp +++ b/apps/openmw/mwgui/draganddrop.cpp @@ -20,12 +20,12 @@ namespace MWGui DragAndDrop::DragAndDrop() - : mDraggedWidget(NULL) - , mDraggedCount(0) + : mIsOnDragAndDrop(false) + , mDraggedWidget(NULL) , mSourceModel(NULL) , mSourceView(NULL) , mSourceSortModel(NULL) - , mIsOnDragAndDrop(false) + , mDraggedCount(0) { } diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 9aa8a8ea1d..af24f3f794 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -50,17 +50,17 @@ namespace MWGui InventoryWindow::InventoryWindow(DragAndDrop* dragAndDrop) : WindowPinnableBase("openmw_inventory_window.layout") - , mTrading(false) + , mDragAndDrop(dragAndDrop) + , mPreviewDirty(true) + , mPreviewResize(true) + , mSelectedItem(-1) + , mSortModel(NULL) + , mTradeModel(NULL) + , mGuiMode(GM_Inventory) , mLastXSize(0) , mLastYSize(0) , mPreview(new MWRender::InventoryPreview(MWBase::Environment::get().getWorld ()->getPlayerPtr())) - , mPreviewDirty(true) - , mPreviewResize(true) - , mDragAndDrop(dragAndDrop) - , mSortModel(NULL) - , mTradeModel(NULL) - , mSelectedItem(-1) - , mGuiMode(GM_Inventory) + , mTrading(false) { mMainWidget->castType()->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize); diff --git a/apps/openmw/mwgui/itemmodel.cpp b/apps/openmw/mwgui/itemmodel.cpp index 8224fd55b0..9fce6e84dd 100644 --- a/apps/openmw/mwgui/itemmodel.cpp +++ b/apps/openmw/mwgui/itemmodel.cpp @@ -14,10 +14,10 @@ namespace MWGui { ItemStack::ItemStack(const MWWorld::Ptr &base, ItemModel *creator, size_t count) - : mCreator(creator) - , mCount(count) + : mType(Type_Normal) , mFlags(0) - , mType(Type_Normal) + , mCreator(creator) + , mCount(count) , mBase(base) { if (base.getClass().getEnchantment(base) != "") @@ -59,10 +59,10 @@ namespace MWGui } ItemStack::ItemStack() - : mCreator(NULL) - , mCount(0) + : mType(Type_Normal) , mFlags(0) - , mType(Type_Normal) + , mCreator(NULL) + , mCount(0) { } diff --git a/apps/openmw/mwgui/jailscreen.cpp b/apps/openmw/mwgui/jailscreen.cpp index 5c0a6ec5f2..936da2d8e2 100644 --- a/apps/openmw/mwgui/jailscreen.cpp +++ b/apps/openmw/mwgui/jailscreen.cpp @@ -19,9 +19,9 @@ namespace MWGui { JailScreen::JailScreen() : WindowBase("openmw_jail_screen.layout"), - mTimeAdvancer(0.01f), mDays(1), - mFadeTimeRemaining(0) + mFadeTimeRemaining(0), + mTimeAdvancer(0.01f) { getWidget(mProgressBar, "ProgressBar"); diff --git a/apps/openmw/mwgui/journalbooks.cpp b/apps/openmw/mwgui/journalbooks.cpp index 34a8525628..f84fb517bc 100644 --- a/apps/openmw/mwgui/journalbooks.cpp +++ b/apps/openmw/mwgui/journalbooks.cpp @@ -68,8 +68,8 @@ namespace AddJournalEntry (MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* body_style, MWGui::BookTypesetter::Style* header_style, bool add_header) : AddEntry (typesetter, body_style), - mHeaderStyle (header_style), - mAddHeader (add_header) + mAddHeader (add_header), + mHeaderStyle (header_style) { } @@ -94,7 +94,7 @@ namespace AddTopicEntry (MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* body_style, MWGui::BookTypesetter::Style* header_style, intptr_t contentId) : - AddEntry (typesetter, body_style), mHeaderStyle (header_style), mContentId (contentId) + AddEntry (typesetter, body_style), mContentId (contentId), mHeaderStyle (header_style) { } diff --git a/apps/openmw/mwgui/journalviewmodel.cpp b/apps/openmw/mwgui/journalviewmodel.cpp index 9a47070c2f..d05257e46c 100644 --- a/apps/openmw/mwgui/journalviewmodel.cpp +++ b/apps/openmw/mwgui/journalviewmodel.cpp @@ -92,7 +92,7 @@ struct JournalViewModelImpl : JournalViewModel JournalViewModelImpl const * mModel; BaseEntry (JournalViewModelImpl const * model, iterator_t itr) : - mModel (model), itr (itr), loaded (false) + itr (itr), mModel (model), loaded (false) {} virtual ~BaseEntry () {} diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 3204c65482..db7b320183 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -32,11 +32,11 @@ namespace MWGui { LoadingScreen::LoadingScreen(Ogre::SceneManager* sceneMgr, Ogre::RenderWindow* rw) - : mSceneMgr(sceneMgr) + : WindowBase("openmw_loading_screen.layout") + , mSceneMgr(sceneMgr) , mWindow(rw) - , WindowBase("openmw_loading_screen.layout") - , mLastRenderTime(0) , mLastWallpaperChangeTime(0) + , mLastRenderTime(0) , mProgress(0) , mVSyncWasEnabled(false) { diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 9adfeffe88..c594327961 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -144,16 +144,16 @@ namespace MWGui : mCurX(0) , mCurY(0) , mInterior(false) - , mFogOfWar(true) , mLocalMap(NULL) + , mCompass(NULL) , mPrefix() , mChanged(true) + , mFogOfWar(true) + , mMapWidgetSize(0) + , mCustomMarkers(markers) + , mMarkerUpdateTimer(0.0f) , mLastDirectionX(0.0f) , mLastDirectionY(0.0f) - , mCompass(NULL) - , mMarkerUpdateTimer(0.0f) - , mCustomMarkers(markers) - , mMapWidgetSize(0) { mCustomMarkers.eventMarkersChanged += MyGUI::newDelegate(this, &LocalMapBase::updateCustomMarkers); } @@ -550,16 +550,16 @@ namespace MWGui MapWindow::MapWindow(CustomMarkerCollection &customMarkers, DragAndDrop* drag, const std::string& cacheDir) : WindowPinnableBase("openmw_map_window.layout") - , NoDrop(drag, mMainWidget) , LocalMapBase(customMarkers) - , mGlobal(false) + , NoDrop(drag, mMainWidget) , mGlobalMap(0) - , mGlobalMapRender(0) - , mEditNoteDialog() - , mEventBoxGlobal(NULL) - , mEventBoxLocal(NULL) , mGlobalMapImage(NULL) , mGlobalMapOverlay(NULL) + , mGlobal(false) + , mEventBoxGlobal(NULL) + , mEventBoxLocal(NULL) + , mGlobalMapRender(0) + , mEditNoteDialog() { static bool registered = false; if (!registered) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index b7c67e68bf..6e81ed6262 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -161,10 +161,10 @@ namespace MWGui MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message) : Layout("openmw_messagebox.layout") - , mMessageBoxManager(parMessageBoxManager) - , mMessage(message) , mCurrentTime(0) , mMaxTime(0) + , mMessageBoxManager(parMessageBoxManager) + , mMessage(message) { // defines mBottomPadding = 48; @@ -195,8 +195,8 @@ namespace MWGui InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector& buttons) : WindowModal("openmw_interactive_messagebox.layout") , mMessageBoxManager(parMessageBoxManager) + , mTextButtonPadding(0) , mButtonPressed(-1) - , mTextButtonPadding(0) { WindowModal::open(); diff --git a/apps/openmw/mwgui/sortfilteritemmodel.cpp b/apps/openmw/mwgui/sortfilteritemmodel.cpp index 6c164df888..183ab07ff9 100644 --- a/apps/openmw/mwgui/sortfilteritemmodel.cpp +++ b/apps/openmw/mwgui/sortfilteritemmodel.cpp @@ -70,9 +70,9 @@ namespace MWGui SortFilterItemModel::SortFilterItemModel(ItemModel *sourceModel) : mCategory(Category_All) + , mFilter(0) , mShowEquipped(true) , mSortByType(true) - , mFilter(0) { mSourceModel = sourceModel; } diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index 76a1d51e5b..ae7b7588ab 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -23,8 +23,8 @@ namespace MWGui SpellBuyingWindow::SpellBuyingWindow() : WindowBase("openmw_spell_buying_window.layout") - , mCurrentY(0) , mLastPos(0) + , mCurrentY(0) { setCoord(0, 0, 450, 300); diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index c744d3ed63..1c670838f4 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -483,15 +483,15 @@ namespace MWGui EffectEditorBase::EffectEditorBase(Type type) - : mAddEffectDialog() - , mAvailableEffectsList(NULL) + : mAvailableEffectsList(NULL) , mUsedEffectsView(NULL) + , mAddEffectDialog() , mSelectAttributeDialog(NULL) , mSelectSkillDialog(NULL) , mSelectedEffect(0) , mSelectedKnownEffectId(0) - , mType(type) , mConstantEffect(false) + , mType(type) { mAddEffectDialog.eventEffectAdded += MyGUI::newDelegate(this, &EffectEditorBase::onEffectAdded); mAddEffectDialog.eventEffectModified += MyGUI::newDelegate(this, &EffectEditorBase::onEffectModified); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 4e83c25db3..34896c0bd2 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -30,15 +30,15 @@ namespace MWGui ToolTips::ToolTips() : Layout("openmw_tooltips.layout") - , mFullHelp(false) - , mEnabled(true) , mFocusToolTipX(0.0) , mFocusToolTipY(0.0) + , mHorizontalScrollIndex(0) , mDelay(0.0) , mRemainingDelay(0.0) , mLastMouseX(0) , mLastMouseY(0) - , mHorizontalScrollIndex(0) + , mEnabled(true) + , mFullHelp(false) { getWidget(mDynamicToolTipBox, "DynamicToolTipBox"); diff --git a/apps/openmw/mwgui/waitdialog.cpp b/apps/openmw/mwgui/waitdialog.cpp index 28e3be5911..ed261e7eb0 100644 --- a/apps/openmw/mwgui/waitdialog.cpp +++ b/apps/openmw/mwgui/waitdialog.cpp @@ -50,13 +50,13 @@ namespace MWGui WaitDialog::WaitDialog() : WindowBase("openmw_wait_dialog.layout") - , mProgressBar() , mTimeAdvancer(0.05f) , mSleeping(false) , mHours(1) , mManualHours(1) , mFadeTimeRemaining(0) , mInterruptAt(-1) + , mProgressBar() { getWidget(mDateTimeText, "DateTimeText"); getWidget(mRestText, "RestText"); diff --git a/apps/openmw/mwgui/windowbase.cpp b/apps/openmw/mwgui/windowbase.cpp index 8fdcf6b207..899f8a5e84 100644 --- a/apps/openmw/mwgui/windowbase.cpp +++ b/apps/openmw/mwgui/windowbase.cpp @@ -78,7 +78,7 @@ void WindowModal::close() } NoDrop::NoDrop(DragAndDrop *drag, MyGUI::Widget *widget) - : mDrag(drag), mWidget(widget), mTransparent(false) + : mWidget(widget), mDrag(drag), mTransparent(false) { if (!mWidget) throw std::runtime_error("NoDrop needs a non-NULL widget!"); diff --git a/apps/openmw/mwmechanics/aiavoiddoor.cpp b/apps/openmw/mwmechanics/aiavoiddoor.cpp index a73d955c56..fccace55c2 100644 --- a/apps/openmw/mwmechanics/aiavoiddoor.cpp +++ b/apps/openmw/mwmechanics/aiavoiddoor.cpp @@ -13,7 +13,7 @@ #include "steering.hpp" MWMechanics::AiAvoidDoor::AiAvoidDoor(const MWWorld::Ptr& doorPtr) -: AiPackage(), mDoorPtr(doorPtr), mDuration(1), mAdjAngle(0) +: AiPackage(), mDuration(1), mDoorPtr(doorPtr), mAdjAngle(0) { } diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index 2f68087e58..649f259d9a 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -111,17 +111,17 @@ namespace MWMechanics mTimerAttack(0), mTimerReact(0), mTimerCombatMove(0), + mReadyToAttack(false), mAttack(false), mFollowTarget(false), mCombatMove(false), - mReadyToAttack(false), - mForceNoShortcut(false), + mLastTargetPos(0,0,0), mCell(NULL), mCurrentAction(), mActionCooldown(0), mStrength(), mMinMaxAttackDurationInitialised(false), - mLastTargetPos(0,0,0), + mForceNoShortcut(false), mLastActorPos(0,0,0), mMovement(){} }; diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index 91bf7c9b03..f9ebefe136 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -49,12 +49,11 @@ namespace MWMechanics } AiEscort::AiEscort(const ESM::AiSequence::AiEscort *escort) - : mActorId(escort->mTargetId), mX(escort->mData.mX), mY(escort->mData.mY), mZ(escort->mData.mZ) + : mActorId(escort->mTargetId), mCellId(escort->mCellId), mX(escort->mData.mX), mY(escort->mData.mY), mZ(escort->mData.mZ) + , mMaxDist(450) + , mRemainingDuration(escort->mRemainingDuration) , mCellX(std::numeric_limits::max()) , mCellY(std::numeric_limits::max()) - , mCellId(escort->mCellId) - , mRemainingDuration(escort->mRemainingDuration) - , mMaxDist(450) { } diff --git a/apps/openmw/mwmechanics/aifollow.cpp b/apps/openmw/mwmechanics/aifollow.cpp index 161f4bb905..ddfc145812 100644 --- a/apps/openmw/mwmechanics/aifollow.cpp +++ b/apps/openmw/mwmechanics/aifollow.cpp @@ -32,27 +32,27 @@ int AiFollow::mFollowIndexCounter = 0; AiFollow::AiFollow(const std::string &actorId,float duration, float x, float y, float z) : mAlwaysFollow(false), mCommanded(false), mRemainingDuration(duration), mX(x), mY(y), mZ(z) -, mActorRefId(actorId), mCellId(""), mActorId(-1), mFollowIndex(mFollowIndexCounter++), mActive(false) +, mActorRefId(actorId), mActorId(-1), mCellId(""), mActive(false), mFollowIndex(mFollowIndexCounter++) { } AiFollow::AiFollow(const std::string &actorId,const std::string &cellId,float duration, float x, float y, float z) : mAlwaysFollow(false), mCommanded(false), mRemainingDuration(duration), mX(x), mY(y), mZ(z) -, mActorRefId(actorId), mCellId(cellId), mActorId(-1), mFollowIndex(mFollowIndexCounter++), mActive(false) +, mActorRefId(actorId), mActorId(-1), mCellId(cellId), mActive(false), mFollowIndex(mFollowIndexCounter++) { } AiFollow::AiFollow(const std::string &actorId, bool commanded) : mAlwaysFollow(true), mCommanded(commanded), mRemainingDuration(0), mX(0), mY(0), mZ(0) -, mActorRefId(actorId), mCellId(""), mActorId(-1), mFollowIndex(mFollowIndexCounter++), mActive(false) +, mActorRefId(actorId), mActorId(-1), mCellId(""), mActive(false), mFollowIndex(mFollowIndexCounter++) { } AiFollow::AiFollow(const ESM::AiSequence::AiFollow *follow) - : mAlwaysFollow(follow->mAlwaysFollow), mRemainingDuration(follow->mRemainingDuration) + : mAlwaysFollow(follow->mAlwaysFollow), mCommanded(follow->mCommanded), mRemainingDuration(follow->mRemainingDuration) , mX(follow->mData.mX), mY(follow->mData.mY), mZ(follow->mData.mZ) - , mActorRefId(follow->mTargetId), mActorId(-1), mCellId(follow->mCellId) - , mCommanded(follow->mCommanded), mFollowIndex(mFollowIndexCounter++), mActive(follow->mActive) + , mActorRefId(follow->mTargetId), mActorId(-1) + , mCellId(follow->mCellId), mActive(follow->mActive), mFollowIndex(mFollowIndexCounter++) { } diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 560e756ce2..0766369747 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -786,10 +786,10 @@ namespace MWMechanics AiWander::AiWander (const ESM::AiSequence::AiWander* wander) : mDistance(wander->mData.mDistance) , mDuration(wander->mData.mDuration) - , mStartTime(MWWorld::TimeStamp(wander->mStartTime)) , mTimeOfDay(wander->mData.mTimeOfDay) , mRepeat(wander->mData.mShouldRepeat != 0) , mStoredInitialActorPosition(wander->mStoredInitialActorPosition) + , mStartTime(MWWorld::TimeStamp(wander->mStartTime)) { if (mStoredInitialActorPosition) mInitialActorPosition = wander->mInitialActorPosition; diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index ffde59aee6..399b51151b 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -642,8 +642,8 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim , mJumpState(JumpState_None) , mWeaponType(WeapType_None) , mSkipAnim(false) - , mSecondsOfRunning(0) , mSecondsOfSwimming(0) + , mSecondsOfRunning(0) , mTurnAnimationThreshold(0) { if(!mAnimation) diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 4c338e23fc..308e720279 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -15,16 +15,12 @@ namespace MWMechanics int CreatureStats::sActorId = 0; CreatureStats::CreatureStats() - : mLevel (0), mDead (false), mDied (false), mMurdered(false), mFriendlyHits (0), - mTalkedTo (false), mAlarmed (false), - mAttacked (false), - mAttackingOrSpell(false), - mIsWerewolf(false), - mFallHeight(0), mRecalcMagicka(false), mKnockdown(false), mKnockdownOneFrame(false), - mKnockdownOverOneFrame(false), mHitRecovery(false), mBlock(false), - mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f), - mLastRestock(0,0), mGoldPool(0), mActorId(-1), - mDeathAnimation(0) + : mDrawState (DrawState_Nothing), mDead (false), mDied (false), mMurdered(false), mFriendlyHits (0), + mTalkedTo (false), mAlarmed (false), mAttacked (false), mAttackingOrSpell(false), + mKnockdown(false), mKnockdownOneFrame(false), mKnockdownOverOneFrame(false), + mHitRecovery(false), mBlock(false), mMovementFlags(0), mAttackStrength(0.f), + mFallHeight(0), mRecalcMagicka(false), mLastRestock(0,0), mGoldPool(0), mActorId(-1), + mDeathAnimation(0), mIsWerewolf(false), mLevel (0) { for (int i=0; i<4; ++i) mAiSettings[i] = 0; diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 7f468f6d41..94819e6260 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -25,12 +25,12 @@ #include "../mwbase/soundmanager.hpp" MWMechanics::NpcStats::NpcStats() - : mBounty (0) -, mLevelProgress(0) -, mDisposition(0) + : mDisposition (0) , mReputation(0) , mCrimeId(-1) +, mBounty(0) , mWerewolfKills (0) +, mLevelProgress(0) , mTimeToStartDrowning(20.0) { mSkillIncreases.resize (ESM::Attribute::Length, 0); diff --git a/apps/openmw/mwmechanics/obstacle.cpp b/apps/openmw/mwmechanics/obstacle.cpp index 6bf81e8611..7cfa6fcd5f 100644 --- a/apps/openmw/mwmechanics/obstacle.cpp +++ b/apps/openmw/mwmechanics/obstacle.cpp @@ -63,10 +63,10 @@ namespace MWMechanics ObstacleCheck::ObstacleCheck(): mPrevX(0) // to see if the moved since last time , mPrevY(0) - , mDistSameSpot(-1) // avoid calculating it each time , mWalkState(State_Norm) , mStuckDuration(0) , mEvadeDuration(0) + , mDistSameSpot(-1) // avoid calculating it each time { } diff --git a/apps/openmw/mwmechanics/pathgrid.cpp b/apps/openmw/mwmechanics/pathgrid.cpp index c1e094bb1e..4e9bc89048 100644 --- a/apps/openmw/mwmechanics/pathgrid.cpp +++ b/apps/openmw/mwmechanics/pathgrid.cpp @@ -51,12 +51,12 @@ namespace MWMechanics { PathgridGraph::PathgridGraph() : mCell(NULL) - , mIsGraphConstructed(false) , mPathgrid(NULL) + , mIsExterior(0) , mGraph(0) + , mIsGraphConstructed(false) , mSCCId(0) , mSCCIndex(0) - , mIsExterior(0) { } diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 95d4429d6f..90cf270497 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -25,10 +25,11 @@ namespace MWRender GlobalMap::GlobalMap(const std::string &cacheDir) : mCacheDir(cacheDir) - , mMinX(0), mMaxX(0) - , mMinY(0), mMaxY(0) , mWidth(0) , mHeight(0) + , mMinX(0), mMaxX(0) + , mMinY(0), mMaxY(0) + { mCellSize = Settings::Manager::getInt("global map cell size", "Map"); } diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index a16b156ae3..f2175ced57 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -186,10 +186,10 @@ void PlaneReflection::setVisibilityMask (int flags) Water::Water (Ogre::Camera *camera, RenderingManager* rend, const MWWorld::Fallback* fallback) : mCamera (camera), mSceneMgr (camera->getSceneManager()), - mIsUnderwater(false), mVisibilityFlags(0), - mActive(1), mToggled(1), + mIsUnderwater(false), mActive(1), + mToggled(1), mWaterTimer(0.f), mRendering(rend), - mWaterTimer(0.f), + mVisibilityFlags(0), mReflection(NULL), mRefraction(NULL), mSimulation(NULL), diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 06c40dd8e8..c7fb9ea506 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -33,13 +33,13 @@ namespace MWSound , mMasterVolume(1.0f) , mSFXVolume(1.0f) , mMusicVolume(1.0f) - , mFootstepsVolume(1.0f) , mVoiceVolume(1.0f) - , mPausedSoundTypes(0) + , mFootstepsVolume(1.0f) + , mListenerUnderwater(false) , mListenerPos(0,0,0) , mListenerDir(1,0,0) , mListenerUp(0,0,1) - , mListenerUnderwater(false) + , mPausedSoundTypes(0) { if(!useSound) return; diff --git a/apps/openmw/mwworld/action.cpp b/apps/openmw/mwworld/action.cpp index 1c360fd4dd..5e1fb41a6c 100644 --- a/apps/openmw/mwworld/action.cpp +++ b/apps/openmw/mwworld/action.cpp @@ -11,7 +11,7 @@ const MWWorld::Ptr& MWWorld::Action::getTarget() const return mTarget; } -MWWorld::Action::Action (bool keepSound, const Ptr& target) : mKeepSound (keepSound), mTarget (target), mSoundOffset(0) +MWWorld::Action::Action (bool keepSound, const Ptr& target) : mKeepSound (keepSound), mSoundOffset(0), mTarget (target) {} MWWorld::Action::~Action() {} diff --git a/apps/openmw/mwworld/esmloader.cpp b/apps/openmw/mwworld/esmloader.cpp index 13a786d008..b12d646e70 100644 --- a/apps/openmw/mwworld/esmloader.cpp +++ b/apps/openmw/mwworld/esmloader.cpp @@ -9,8 +9,8 @@ namespace MWWorld EsmLoader::EsmLoader(MWWorld::ESMStore& store, std::vector& readers, ToUTF8::Utf8Encoder* encoder, Loading::Listener& listener) : ContentLoader(listener) - , mStore(store) , mEsm(readers) + , mStore(store) , mEncoder(encoder) { } diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 2de3abc750..a2e445d581 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -96,10 +96,10 @@ void MWWorld::InventoryStore::readEquipmentState(const MWWorld::ContainerStoreIt } MWWorld::InventoryStore::InventoryStore() - : mSelectedEnchantItem(end()) + : mListener(NULL) , mUpdatesEnabled (true) , mFirstAutoEquip(true) - , mListener(NULL) + , mSelectedEnchantItem(end()) , mRechargingItemsUpToDate(false) { initSlots (mSlots); @@ -107,12 +107,12 @@ MWWorld::InventoryStore::InventoryStore() MWWorld::InventoryStore::InventoryStore (const InventoryStore& store) : ContainerStore (store) - , mSelectedEnchantItem(end()) , mMagicEffects(store.mMagicEffects) - , mFirstAutoEquip(store.mFirstAutoEquip) , mListener(store.mListener) , mUpdatesEnabled(store.mUpdatesEnabled) + , mFirstAutoEquip(store.mFirstAutoEquip) , mPermanentMagicEffectMagnitudes(store.mPermanentMagicEffectMagnitudes) + , mSelectedEnchantItem(end()) , mRechargingItemsUpToDate(false) { copySlots (store); diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index d31ae520bd..bec4c6db32 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -499,7 +499,7 @@ namespace MWWorld PhysicsSystem::PhysicsSystem(OEngine::Render::OgreRenderer &_rend) : - mRender(_rend), mEngine(0), mTimeAccum(0.0f), mWaterEnabled(false), mWaterHeight(0) + mRender(_rend), mEngine(0), mTimeAccum(0.0f), mWaterHeight(0), mWaterEnabled(false) { // Create physics. shapeLoader is deleted by the physic engine NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader(); diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 58718074ee..0b81532e18 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -32,10 +32,10 @@ namespace MWWorld Player::Player (const ESM::NPC *player, const MWBase::World& world) : mCellStore(0), mLastKnownExteriorPosition(0,0,0), + mMarkedCell(NULL), mAutoMove(false), mForwardBackward(0), mTeleported(false), - mMarkedCell(NULL), mCurrentCrimeId(-1), mPaidCrimeId(-1) { diff --git a/apps/openmw/mwworld/refdata.cpp b/apps/openmw/mwworld/refdata.cpp index 14a315a81b..ae985f8574 100644 --- a/apps/openmw/mwworld/refdata.cpp +++ b/apps/openmw/mwworld/refdata.cpp @@ -37,7 +37,7 @@ namespace MWWorld } RefData::RefData() - : mBaseNode(0), mHasLocals (false), mEnabled (true), mCount (1), mCustomData (0), mChanged(false), mDeleted(false) + : mBaseNode(0), mDeleted(false), mHasLocals (false), mEnabled (true), mCount (1), mCustomData (0), mChanged(false) { for (int i=0; i<3; ++i) { @@ -48,10 +48,10 @@ namespace MWWorld } RefData::RefData (const ESM::CellRef& cellRef) - : mBaseNode(0), mHasLocals (false), mEnabled (true), mCount (1), mPosition (cellRef.mPos), + : mBaseNode(0), mDeleted(false), mHasLocals (false), mEnabled (true), + mCount (1), mPosition (cellRef.mPos), mCustomData (0), - mChanged(false), // Loading from ESM/ESP files -> assume unchanged - mDeleted(false) + mChanged(false) // Loading from ESM/ESP files -> assume unchanged { mLocalRotation.rot[0]=0; mLocalRotation.rot[1]=0; @@ -59,10 +59,12 @@ namespace MWWorld } RefData::RefData (const ESM::ObjectState& objectState) - : mBaseNode (0), mHasLocals (false), mEnabled (objectState.mEnabled != 0), - mCount (objectState.mCount), mPosition (objectState.mPosition), mCustomData (0), - mChanged(true), // Loading from a savegame -> assume changed - mDeleted(false) + : mBaseNode (0), mDeleted(false), mHasLocals (false), + mEnabled (objectState.mEnabled != 0), + mCount (objectState.mCount), + mPosition (objectState.mPosition), + mCustomData (0), + mChanged(true) // Loading from a savegame -> assume changed { for (int i=0; i<3; ++i) mLocalRotation.rot[i] = objectState.mLocalRotation[i]; diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index a9ca8e72b5..41ed7c20da 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -114,11 +114,10 @@ float WeatherManager::calculateAngleFade (const std::string& moonName, float ang } WeatherManager::WeatherManager(MWRender::RenderingManager* rendering,MWWorld::Fallback* fallback) : - mHour(14), mCurrentWeather("clear"), mNextWeather(""), mFirstUpdate(true), - mWeatherUpdateTime(0), mThunderFlash(0), mThunderChance(0), - mThunderChanceNeeded(50), mThunderSoundDelay(0), mRemainingTransitionTime(0), - mTimePassed(0), mFallback(fallback), mWindSpeed(0.f), mRendering(rendering), mIsStorm(false), - mStormDirection(0,1,0) + mHour(14), mWindSpeed(0.f), mIsStorm(false), mStormDirection(0,1,0), mFallback(fallback), + mRendering(rendering), mCurrentWeather("clear"), mNextWeather(""), mFirstUpdate(true), + mRemainingTransitionTime(0), mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), + mTimePassed(0), mWeatherUpdateTime(0), mThunderSoundDelay(0) { //Globals mThunderSoundID0 = mFallback->getFallbackString("Weather_Thunderstorm_Thunder_Sound_ID_0"); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index bb0402c4e5..b1bac2f4b0 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -147,14 +147,12 @@ namespace MWWorld const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir, ToUTF8::Utf8Encoder* encoder, const std::map& fallbackMap, int activationDistanceOverride, const std::string& startCell, const std::string& startupScript) - : mPlayer (0), mLocalScripts (mStore), + : mFallback(fallbackMap), mPlayer (0), mLocalScripts (mStore), mSky (true), mCells (mStore, mEsm), - mActivationDistanceOverride (activationDistanceOverride), - mFallback(fallbackMap), mTeleportEnabled(true), mLevitationEnabled(true), - mGodMode(false), mContentFiles (contentFiles), - mGoToJail(false), mDaysInPrison(0), - mStartCell (startCell), mStartupScript(startupScript), - mScriptsEnabled(true) + mGodMode(false), mScriptsEnabled(true), mContentFiles (contentFiles), + mActivationDistanceOverride (activationDistanceOverride), mStartupScript(startupScript), + mStartCell (startCell), mTeleportEnabled(true), + mLevitationEnabled(true), mGoToJail(false), mDaysInPrison(0) { mPhysics = new PhysicsSystem(renderer); mPhysEngine = mPhysics->getEngine(); @@ -2939,7 +2937,7 @@ namespace MWWorld struct AddDetectedReference { AddDetectedReference(std::vector& out, Ptr detector, World::DetectionType type, float squaredDist) - : mOut(out), mDetector(detector), mType(type), mSquaredDist(squaredDist) + : mOut(out), mDetector(detector), mSquaredDist(squaredDist), mType(type) { } diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 88b5f5ddb3..a71672916b 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -56,8 +56,8 @@ namespace Compiler LineParser::LineParser (ErrorHandler& errorHandler, const Context& context, Locals& locals, Literals& literals, std::vector& code, bool allowExpression) : Parser (errorHandler, context), mLocals (locals), mLiterals (literals), mCode (code), - mState (BeginState), mExprParser (errorHandler, context, locals, literals), - mAllowExpression (allowExpression), mButtons(0), mType(0), mReferenceMember(false) + mState (BeginState), mReferenceMember(false), mButtons(0), mType(0), + mExprParser (errorHandler, context, locals, literals), mAllowExpression (allowExpression) {} bool LineParser::parseInt (int value, const TokenLoc& loc, Scanner& scanner) diff --git a/components/interpreter/runtime.cpp b/components/interpreter/runtime.cpp index c71aef95c5..dc3da07a8d 100644 --- a/components/interpreter/runtime.cpp +++ b/components/interpreter/runtime.cpp @@ -7,7 +7,7 @@ namespace Interpreter { - Runtime::Runtime() : mContext (0), mCode (0), mPC (0), mCodeSize(0) {} + Runtime::Runtime() : mContext (0), mCode (0), mCodeSize(0), mPC (0) {} int Runtime::getPC() const { diff --git a/extern/ogre-ffmpeg-videoplayer/audiodecoder.cpp b/extern/ogre-ffmpeg-videoplayer/audiodecoder.cpp index 1a56802dae..77e6b4b6c0 100644 --- a/extern/ogre-ffmpeg-videoplayer/audiodecoder.cpp +++ b/extern/ogre-ffmpeg-videoplayer/audiodecoder.cpp @@ -60,21 +60,21 @@ struct AudioResampler MovieAudioDecoder::MovieAudioDecoder(VideoState* videoState) : mVideoState(videoState) , mAVStream(*videoState->audio_st) - , mFrame(av_frame_alloc()) + , mOutputSampleFormat(AV_SAMPLE_FMT_NONE) + , mOutputChannelLayout(0) + , mOutputSampleRate(0) , mFramePos(0) , mFrameSize(0) , mAudioClock(0.0) + , mDataBuf(NULL) + , mFrameData(NULL) + , mDataBufLen(0) + , mFrame(av_frame_alloc()) , mAudioDiffAccum(0.0) , mAudioDiffAvgCoef(exp(log(0.01 / AUDIO_DIFF_AVG_NB))) /* Correct audio only if larger error than this */ , mAudioDiffThreshold(2.0 * 0.050/* 50 ms */) , mAudioDiffAvgCount(0) - , mOutputSampleFormat(AV_SAMPLE_FMT_NONE) - , mOutputSampleRate(0) - , mOutputChannelLayout(0) - , mDataBuf(NULL) - , mFrameData(NULL) - , mDataBufLen(0) { mAudioResampler.reset(new AudioResampler()); } diff --git a/extern/ogre-ffmpeg-videoplayer/videostate.cpp b/extern/ogre-ffmpeg-videoplayer/videostate.cpp index 66c7c2ad50..877906f6df 100644 --- a/extern/ogre-ffmpeg-videoplayer/videostate.cpp +++ b/extern/ogre-ffmpeg-videoplayer/videostate.cpp @@ -59,16 +59,18 @@ namespace Video { VideoState::VideoState() - : format_ctx(NULL), av_sync_type(AV_SYNC_DEFAULT) + : mAudioFactory(NULL) + , format_ctx(NULL) + , av_sync_type(AV_SYNC_DEFAULT) , audio_st(NULL) , video_st(NULL), frame_last_pts(0.0) , video_clock(0.0), sws_context(NULL), rgbaFrame(NULL), pictq_size(0) , pictq_rindex(0), pictq_windex(0) - , mQuit(false), mPaused(false) - , mAudioFactory(NULL) , mSeekRequested(false) , mSeekPos(0) , mVideoEnded(false) + , mPaused(false) + , mQuit(false) { mFlushPktData = flush_pkt.data; diff --git a/extern/oics/ICSControl.cpp b/extern/oics/ICSControl.cpp index 974d69f081..1e9679d1f8 100644 --- a/extern/oics/ICSControl.cpp +++ b/extern/oics/ICSControl.cpp @@ -32,9 +32,9 @@ namespace ICS { Control::Control(const std::string& name, bool autoChangeDirectionOnLimitsAfterStop, bool autoReverseToInitialValue , float initialValue, float stepSize, float stepsPerSeconds, bool axisBindable) - : mName(name) - , mValue(initialValue) + : mValue(initialValue) , mInitialValue(initialValue) + , mName(name) , mStepSize(stepSize) , mStepsPerSeconds(stepsPerSeconds) , mAutoReverseToInitialValue(autoReverseToInitialValue) diff --git a/extern/oics/ICSInputControlSystem.cpp b/extern/oics/ICSInputControlSystem.cpp index 2599c57614..a8aedfd2e5 100644 --- a/extern/oics/ICSInputControlSystem.cpp +++ b/extern/oics/ICSInputControlSystem.cpp @@ -32,13 +32,13 @@ namespace ICS , DetectingBindingListener* detectingBindingListener , InputControlSystemLog* log, size_t channelCount) : mFileName(file) + , mLog(log) , mDetectingBindingListener(detectingBindingListener) , mDetectingBindingControl(NULL) - , mLog(log) - , mXmouseAxisBinded(false), mYmouseAxisBinded(false) - , mClientHeight(1) - , mClientWidth(1) , mDetectingBindingDirection(Control::STOP) + , mXmouseAxisBinded(false), mYmouseAxisBinded(false) + , mClientWidth(1) + , mClientHeight(1) { ICS_LOG(" - Creating InputControlSystem - "); @@ -539,10 +539,10 @@ namespace ICS } binder.SetAttribute( "direction", "DECREASE" ); control.InsertEndChild(binder); - } - JoystickIDList::const_iterator it = mJoystickIDList.begin(); - while(it!=mJoystickIDList.end()) - { + } + JoystickIDList::const_iterator it = mJoystickIDList.begin(); + while(it!=mJoystickIDList.end()) + { int deviceID = *it; if(getJoystickAxisBinding(*o, deviceID, Control/*::ControlChangingDirection*/::INCREASE) != /*NamedAxis::*/UNASSIGNED) @@ -552,8 +552,8 @@ namespace ICS binder.SetAttribute( "axis", ToString( getJoystickAxisBinding(*o, deviceID, Control/*::ControlChangingDirection*/::INCREASE)).c_str() ); - binder.SetAttribute( "direction", "INCREASE" ); - + binder.SetAttribute( "direction", "INCREASE" ); + binder.SetAttribute( "deviceId", deviceID ); //completely useless, but required for backwards compatability control.InsertEndChild(binder); @@ -567,8 +567,8 @@ namespace ICS binder.SetAttribute( "axis", ToString( getJoystickAxisBinding(*o, deviceID, Control/*::ControlChangingDirection*/::DECREASE)).c_str() ); - binder.SetAttribute( "direction", "DECREASE" ); - + binder.SetAttribute( "direction", "DECREASE" ); + binder.SetAttribute( "deviceId", deviceID ); //completely useless, but required for backwards compatability control.InsertEndChild(binder); @@ -582,8 +582,8 @@ namespace ICS binder.SetAttribute( "button", ToString( getJoystickButtonBinding(*o, deviceID, Control/*::ControlChangingDirection*/::INCREASE)).c_str() ); - binder.SetAttribute( "direction", "INCREASE" ); - + binder.SetAttribute( "direction", "INCREASE" ); + binder.SetAttribute( "deviceId", deviceID ); //completely useless, but required for backwards compatability control.InsertEndChild(binder); @@ -597,13 +597,13 @@ namespace ICS binder.SetAttribute( "button", ToString( getJoystickButtonBinding(*o, deviceID, Control/*::ControlChangingDirection*/::DECREASE)).c_str() ); - binder.SetAttribute( "direction", "DECREASE" ); - + binder.SetAttribute( "direction", "DECREASE" ); + binder.SetAttribute( "deviceId", deviceID ); //completely useless, but required for backwards compatability control.InsertEndChild(binder); - } - it++; + } + it++; } diff --git a/extern/sdl4ogre/sdlinputwrapper.cpp b/extern/sdl4ogre/sdlinputwrapper.cpp index aaf669ff43..7e3536ab40 100644 --- a/extern/sdl4ogre/sdlinputwrapper.cpp +++ b/extern/sdl4ogre/sdlinputwrapper.cpp @@ -10,28 +10,28 @@ namespace SFO /// \brief General purpose wrapper for OGRE applications around SDL's event /// queue, mostly used for handling input-related events. InputWrapper::InputWrapper(SDL_Window* window, Ogre::RenderWindow* ogreWindow, bool grab) : - mSDLWindow(window), - mOgreWindow(ogreWindow), - mWarpCompensate(false), - mMouseRelative(false), - mGrabPointer(false), - mWrapPointer(false), - mMouseZ(0), - mMouseY(0), - mMouseX(0), - mMouseInWindow(true), - mConListener(NULL), - mKeyboardListener(NULL), mMouseListener(NULL), + mKeyboardListener(NULL), mWindowListener(NULL), - mWindowHasFocus(true), - mWantGrab(false), - mWantRelative(false), - mWantMouseVisible(false), - mAllowGrab(grab), + mConListener(NULL), mWarpX(0), mWarpY(0), - mFirstMouseMove(true) + mWarpCompensate(false), + mWrapPointer(false), + mAllowGrab(grab), + mWantMouseVisible(false), + mWantGrab(false), + mWantRelative(false), + mGrabPointer(false), + mMouseRelative(false), + mFirstMouseMove(true), + mMouseZ(0), + mMouseX(0), + mMouseY(0), + mWindowHasFocus(true), + mMouseInWindow(true), + mSDLWindow(window), + mOgreWindow(ogreWindow) { _setupOISKeys(); } diff --git a/extern/shiny/Main/Factory.cpp b/extern/shiny/Main/Factory.cpp index d7c4234cb7..d0b86cbf94 100644 --- a/extern/shiny/Main/Factory.cpp +++ b/extern/shiny/Main/Factory.cpp @@ -29,17 +29,17 @@ namespace sh } Factory::Factory (Platform* platform) - : mPlatform(platform) - , mShadersEnabled(true) + : mShadersEnabled(true) , mShaderDebugOutputEnabled(false) - , mCurrentLanguage(Language_None) - , mListener(NULL) - , mCurrentConfiguration(NULL) - , mCurrentLodConfiguration(NULL) , mReadMicrocodeCache(false) , mWriteMicrocodeCache(false) , mReadSourceCache(false) , mWriteSourceCache(false) + , mCurrentConfiguration(NULL) + , mCurrentLodConfiguration(NULL) + , mCurrentLanguage(Language_None) + , mListener(NULL) + , mPlatform(platform) { assert (!sThis); sThis = this; diff --git a/extern/shiny/Main/MaterialInstance.cpp b/extern/shiny/Main/MaterialInstance.cpp index c69d134010..5d1a8e7f9d 100644 --- a/extern/shiny/Main/MaterialInstance.cpp +++ b/extern/shiny/Main/MaterialInstance.cpp @@ -9,11 +9,11 @@ namespace sh { MaterialInstance::MaterialInstance (const std::string& name, Factory* f) - : mName(name) + : mFailedToCreate(false) + , mListener(NULL) + , mName(name) , mShadersEnabled(true) , mFactory(f) - , mListener(NULL) - , mFailedToCreate(false) { } diff --git a/extern/shiny/Main/Platform.cpp b/extern/shiny/Main/Platform.cpp index 3eb7f4ad34..f09956e0fd 100644 --- a/extern/shiny/Main/Platform.cpp +++ b/extern/shiny/Main/Platform.cpp @@ -7,9 +7,9 @@ namespace sh { Platform::Platform (const std::string& basePath) - : mBasePath(basePath) - , mCacheFolder("./") + : mCacheFolder("./") , mFactory(NULL) + , mBasePath(basePath) { } diff --git a/extern/shiny/Main/ShaderSet.cpp b/extern/shiny/Main/ShaderSet.cpp index 8fb530d394..4e19948ad9 100644 --- a/extern/shiny/Main/ShaderSet.cpp +++ b/extern/shiny/Main/ShaderSet.cpp @@ -15,9 +15,9 @@ namespace sh ShaderSet::ShaderSet (const std::string& type, const std::string& cgProfile, const std::string& hlslProfile, const std::string& sourceFile, const std::string& basePath, const std::string& name, PropertySetGet* globalSettingsPtr) : mBasePath(basePath) - , mName(name) , mCgProfile(cgProfile) , mHlslProfile(hlslProfile) + , mName(name) { if (type == "vertex") mType = GPT_Vertex; From d1b6289cad544ddf71b59c22e0edbc92404f81b1 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 22 May 2015 19:56:39 +0200 Subject: [PATCH 053/119] Don't teleport followers when using teleportation spells --- apps/openmw/mwclass/door.cpp | 2 +- apps/openmw/mwgui/travelwindow.cpp | 2 +- apps/openmw/mwmechanics/spellcasting.cpp | 2 +- apps/openmw/mwworld/actionteleport.cpp | 25 +++++++++++++----------- apps/openmw/mwworld/actionteleport.hpp | 4 +++- apps/openmw/mwworld/worldimp.cpp | 2 +- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 2d39881b1f..48fc3b64c1 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -147,7 +147,7 @@ namespace MWClass if (ptr.getCellRef().getTeleport()) { - boost::shared_ptr action(new MWWorld::ActionTeleport (ptr.getCellRef().getDestCell(), ptr.getCellRef().getDoorDest())); + boost::shared_ptr action(new MWWorld::ActionTeleport (ptr.getCellRef().getDestCell(), ptr.getCellRef().getDoorDest(), true)); action->setSound(openSound); diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 4da1ab33a0..ba6fc2a786 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -183,7 +183,7 @@ namespace MWGui MWBase::Environment::get().getDialogueManager()->goodbyeSelected(); // Teleports any followers, too. - MWWorld::ActionTeleport action(interior ? cellname : "", pos); + MWWorld::ActionTeleport action(interior ? cellname : "", pos, true); action.execute(player); MWBase::Environment::get().getWindowManager()->fadeScreenOut(0); diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 8a43cc9322..1f3a888279 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -679,7 +679,7 @@ namespace MWMechanics if (markedCell) { MWWorld::ActionTeleport action(markedCell->isExterior() ? "" : markedCell->getCell()->mName, - markedPosition); + markedPosition, false); action.execute(target); } } diff --git a/apps/openmw/mwworld/actionteleport.cpp b/apps/openmw/mwworld/actionteleport.cpp index 8bbb080086..fccd176a85 100644 --- a/apps/openmw/mwworld/actionteleport.cpp +++ b/apps/openmw/mwworld/actionteleport.cpp @@ -25,23 +25,26 @@ namespace namespace MWWorld { ActionTeleport::ActionTeleport (const std::string& cellName, - const ESM::Position& position) - : Action (true), mCellName (cellName), mPosition (position) + const ESM::Position& position, bool teleportFollowers) + : Action (true), mCellName (cellName), mPosition (position), mTeleportFollowers(teleportFollowers) { } void ActionTeleport::executeImp (const Ptr& actor) { - //find any NPC that is following the actor and teleport him too - std::set followers; - getFollowers(actor, followers); - for(std::set::iterator it = followers.begin();it != followers.end();++it) + if (mTeleportFollowers) { - MWWorld::Ptr follower = *it; - if (Ogre::Vector3(follower.getRefData().getPosition().pos).squaredDistance( - Ogre::Vector3( actor.getRefData().getPosition().pos)) - <= 800*800) - teleport(*it); + //find any NPC that is following the actor and teleport him too + std::set followers; + getFollowers(actor, followers); + for(std::set::iterator it = followers.begin();it != followers.end();++it) + { + MWWorld::Ptr follower = *it; + if (Ogre::Vector3(follower.getRefData().getPosition().pos).squaredDistance( + Ogre::Vector3( actor.getRefData().getPosition().pos)) + <= 800*800) + teleport(*it); + } } teleport(actor); diff --git a/apps/openmw/mwworld/actionteleport.hpp b/apps/openmw/mwworld/actionteleport.hpp index 9ca664de84..6191ee9f6f 100644 --- a/apps/openmw/mwworld/actionteleport.hpp +++ b/apps/openmw/mwworld/actionteleport.hpp @@ -13,6 +13,7 @@ namespace MWWorld { std::string mCellName; ESM::Position mPosition; + bool mTeleportFollowers; /// Teleports this actor and also teleports anyone following that actor. virtual void executeImp (const Ptr& actor); @@ -22,8 +23,9 @@ namespace MWWorld public: - ActionTeleport (const std::string& cellName, const ESM::Position& position); + ActionTeleport (const std::string& cellName, const ESM::Position& position, bool teleportFollowers); ///< If cellName is empty, an exterior cell is assumed. + /// @param teleportFollowers Whether to teleport any following actors of the target actor as well. }; } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index bb0402c4e5..96fad106e9 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2921,7 +2921,7 @@ namespace MWWorld if ( !closestMarker.mCell->isExterior() ) cellName = closestMarker.mCell->getCell()->mName; - MWWorld::ActionTeleport action(cellName, closestMarker.getRefData().getPosition()); + MWWorld::ActionTeleport action(cellName, closestMarker.getRefData().getPosition(), false); action.execute(ptr); } From a5183aefbe41a99dd1481249bb180f3314966c81 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Fri, 22 May 2015 23:53:25 +0300 Subject: [PATCH 054/119] Add record state tracking to the ModifyCommand (Fix #2555) --- apps/opencs/model/world/commands.cpp | 15 ++++++++++++++- apps/opencs/model/world/commands.hpp | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/world/commands.cpp b/apps/opencs/model/world/commands.cpp index 9a0401081b..11cb911765 100644 --- a/apps/opencs/model/world/commands.cpp +++ b/apps/opencs/model/world/commands.cpp @@ -14,7 +14,7 @@ CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelIndex& index, const QVariant& new_, QUndoCommand* parent) -: QUndoCommand (parent), mModel (&model), mIndex (index), mNew (new_) +: QUndoCommand (parent), mModel (&model), mIndex (index), mNew (new_), mHasRecordState(false) { if (QAbstractProxyModel *proxy = dynamic_cast (&model)) { @@ -27,6 +27,15 @@ CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelI } else setText ("Modify " + mModel->headerData (mIndex.column(), Qt::Horizontal, Qt::DisplayRole).toString()); + + // Remember record state before the modification + if (CSMWorld::IdTable *table = dynamic_cast(mModel)) + { + mHasRecordState = true; + int stateColumnIndex = table->findColumnIndex(Columns::ColumnId_Modification); + mRecordStateIndex = table->index(mIndex.row(), stateColumnIndex); + mOldRecordState = static_cast(table->data(mRecordStateIndex).toInt()); + } } void CSMWorld::ModifyCommand::redo() @@ -38,6 +47,10 @@ void CSMWorld::ModifyCommand::redo() void CSMWorld::ModifyCommand::undo() { mModel->setData (mIndex, mOld); + if (mHasRecordState) + { + mModel->setData(mRecordStateIndex, mOldRecordState); + } } diff --git a/apps/opencs/model/world/commands.hpp b/apps/opencs/model/world/commands.hpp index f133761450..cdd398153c 100644 --- a/apps/opencs/model/world/commands.hpp +++ b/apps/opencs/model/world/commands.hpp @@ -31,6 +31,10 @@ namespace CSMWorld QVariant mNew; QVariant mOld; + bool mHasRecordState; + QModelIndex mRecordStateIndex; + CSMWorld::RecordBase::State mOldRecordState; + public: ModifyCommand (QAbstractItemModel& model, const QModelIndex& index, const QVariant& new_, From 10ca6cf3796b3035d97b50d6ac092bc36ee21600 Mon Sep 17 00:00:00 2001 From: Cramal Date: Sat, 23 May 2015 14:39:16 +0900 Subject: [PATCH 055/119] debug latex code --- manual/opencs/tables.tex | 2 -- 1 file changed, 2 deletions(-) diff --git a/manual/opencs/tables.tex b/manual/opencs/tables.tex index b47d5f3d4e..5034898729 100644 --- a/manual/opencs/tables.tex +++ b/manual/opencs/tables.tex @@ -92,5 +92,3 @@ when you hover your reticle over the object. This is a library of all the items, triggers, containers, NPCs, etc. in the game. There are several kinds of Record Types. Depending on which type a record is, it will need specific information to function. For example, an NPC needs a value attached to its aggression level. A chest, of course, does not. All Record Types contain at least a model. How else would the player see them? Usually they also have a Name, which is what you see when you hover your reticle over the object. Please refer to the Record Types section for an overview of what each type of Referenceable does and what you can tell OpenCS about these objects. - -\end{description} From 45f6e3b39ef99b4be5ec33e9027e0e010cb79a48 Mon Sep 17 00:00:00 2001 From: Cramal Date: Sat, 23 May 2015 14:40:04 +0900 Subject: [PATCH 056/119] debug latex code --- manual/opencs/recordtypes.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manual/opencs/recordtypes.tex b/manual/opencs/recordtypes.tex index afe5a67e35..4dbfbe2864 100644 --- a/manual/opencs/recordtypes.tex +++ b/manual/opencs/recordtypes.tex @@ -9,8 +9,8 @@ Let's go through all Record Types and discuss what you can tell OpenCS about the \item[Activator:] When the player enters the same cell as this object, a script is started. Often it also has a \textbf{Script} attached to it, though it not mandatory. These scripts are small bits of code written in a special scripting language that OpenCS can read and interpret. \item[Potion:] This is a potion that is not self-made. It has an \textbf{Icon} for your inventory, Aside from the self-explanatory \textbf{Weight} and \textbf{Coin Value}, it has an attribute called \textbf{Auto Calc} set to ``False''. This means that the effects of this potion are preconfigured. This does not happen when the player makes their own potion. \item[Apparatus:] This is a tool to make potions. Again there's an icon for your inventory as well as a weight and a coin value. It also has a \textbf{Quality} value attached to it: higher the number, the better the effect on your potions will be. The \textbf{Apparatus Type} describes if the item is a Calcinator, Retort, Alembir or Mortar & Pestal. Each has a different effect on the potion the player makes. For more information on this subject, please refer to the \href{http://www.uesp.net/wiki/Morrowind:Alchemy#Tools}{UESP page on Alchemy Tools}. - \item[Armor:] This type of item adds \textbf{Enchantment Points} to the mix. Every piece of clothing or armor has a ''pool'' of potential magicka that gets unlocked when you enchant it. Strong enchantments consume more magicka from this pool: the stronger the enchantment, the more Enchantment Points each cast will take up. For more information on this subject, please refer to the \href{Enchant page on UESP}{http://www.uesp.net/wiki/Morrowind:Enchant}. \textbf{Health} means the amount of hit points this piece of armor has. If it sustains enough damage, the armor will be destroyed. Finally, \textbf{Armor Value} tells the game how much points to add to the player character's Armor Rating. - \item[Book:] This includes scrolls and notes. For the game to make the distinction between books and scrolls, an extra property, \textbf{Scroll}, has been added. Under the \textbf{Skill} column a scroll or book can have an in-game skill listed. Reading this item will raise the player's level in that specific skill. For more information on this, please refer to the \href{Skill Books page on UESP}{http://www.uesp.net/wiki/Morrowind:Skill_Books}. + \item[Armor:] This type of item adds \textbf{Enchantment Points} to the mix. Every piece of clothing or armor has a ''pool'' of potential magicka that gets unlocked when you enchant it. Strong enchantments consume more magicka from this pool: the stronger the enchantment, the more Enchantment Points each cast will take up. For more information on this subject, please refer to the \href{http://www.uesp.net/wiki/Morrowind:Enchant}{Enchant page on UESP}. \textbf{Health} means the amount of hit points this piece of armor has. If it sustains enough damage, the armor will be destroyed. Finally, \textbf{Armor Value} tells the game how much points to add to the player character's Armor Rating. + \item[Book:] This includes scrolls and notes. For the game to make the distinction between books and scrolls, an extra property, \textbf{Scroll}, has been added. Under the \textbf{Skill} column a scroll or book can have an in-game skill listed. Reading this item will raise the player's level in that specific skill. For more information on this, please refer to the \href{http://www.uesp.net/wiki/Morrowind:Skill_Books}{Skill Books page on UESP}. \item[Clothing:] These items work just like Armors, but confer no protective properties. Rather than ``Armor Type'', these items have a ``Clothing Type''. \item[Container:] This is all the stuff that stores items, from chests to sacks to plants. Its \textbf{Capacity} shows how much stuff you can put in the container. You can compare it to the maximum allowed load a player character can carry (who will get over-encumbered and unable to move if he crosses this threshold). A container, however, will just refuse to take the item in question when it gets ''over-encumbered''. \textbf{Organic Container}s are containers such as plants. Containers that \textbf{Respawn} are not safe to store stuff in. After a certain amount of time they will reset to their default contents, meaning that everything in it is gone forever. \item[Creature:] These can be monsters, animals and the like. From 63c3d8df2e38dac647e6f50a4a1e5c0e14a2e4da Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 23 May 2015 09:46:48 +0200 Subject: [PATCH 057/119] updated credits file --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index fb83a1a91d..ce76c104e1 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -114,6 +114,7 @@ Manual ------ Bodillium + Cramal sir_herrbatka Packagers From 21af1913e1d1e30dc3fc91e503ff862dba0fae1d Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 24 May 2015 19:18:54 +1000 Subject: [PATCH 058/119] Ensure ColumnId names are unique. --- apps/opencs/model/world/columns.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/opencs/model/world/columns.cpp b/apps/opencs/model/world/columns.cpp index c937997a92..9491c32469 100644 --- a/apps/opencs/model/world/columns.cpp +++ b/apps/opencs/model/world/columns.cpp @@ -176,7 +176,7 @@ namespace CSMWorld { ColumnId_ContainerContent, "Content" }, { ColumnId_ItemCount, "Count" }, - { ColumnId_InventoryItemId, "ID"}, + { ColumnId_InventoryItemId, "Item ID"}, { ColumnId_CombatState, "Combat" }, { ColumnId_MagicState, "Magic" }, @@ -188,10 +188,10 @@ namespace CSMWorld { ColumnId_ActorInventory, "Inventory" }, { ColumnId_SpellList, "Spells" }, - { ColumnId_SpellId, "ID"}, + { ColumnId_SpellId, "Spell ID"}, { ColumnId_NpcDestinations, "Destinations" }, - { ColumnId_DestinationCell, "Cell"}, + { ColumnId_DestinationCell, "Dest Cell"}, { ColumnId_PosX, "Dest X"}, { ColumnId_PosY, "Dest Y"}, { ColumnId_PosZ, "Dest Z"}, @@ -224,17 +224,17 @@ namespace CSMWorld { ColumnId_BoltSound, "Bolt Sound" }, { ColumnId_PathgridPoints, "Points" }, - { ColumnId_PathgridIndex, "Index" }, + { ColumnId_PathgridIndex, "pIndex" }, { ColumnId_PathgridPosX, "X" }, { ColumnId_PathgridPosY, "Y" }, { ColumnId_PathgridPosZ, "Z" }, { ColumnId_PathgridEdges, "Edges" }, - { ColumnId_PathgridEdgeIndex, "Index" }, + { ColumnId_PathgridEdgeIndex, "eIndex" }, { ColumnId_PathgridEdge0, "Point 0" }, { ColumnId_PathgridEdge1, "Point 1" }, { ColumnId_RegionSounds, "Sounds" }, - { ColumnId_SoundName, "Name" }, + { ColumnId_SoundName, "Sound Name" }, { ColumnId_SoundChance, "Chance" }, { ColumnId_FactionReactions, "Reactions" }, @@ -250,7 +250,7 @@ namespace CSMWorld { ColumnId_AiPackageList, "Ai Packages" }, { ColumnId_AiPackageType, "Package" }, { ColumnId_AiWanderDist, "Wander Dist" }, - { ColumnId_AiDuration, "Duration" }, + { ColumnId_AiDuration, "Ai Duration" }, { ColumnId_AiWanderToD, "Wander ToD" }, { ColumnId_AiWanderIdle, "Wander Idle" }, { ColumnId_AiWanderRepeat, "Wander Repeat" }, @@ -260,11 +260,11 @@ namespace CSMWorld { ColumnId_PartRefList, "Part Reference" }, { ColumnId_PartRefType, "Type" }, - { ColumnId_PartRefMale, "Male" }, - { ColumnId_PartRefFemale, "Female" }, + { ColumnId_PartRefMale, "Male Part" }, + { ColumnId_PartRefFemale, "Female Part" }, { ColumnId_LevelledList,"Levelled List" }, - { ColumnId_LevelledItemId,"Item ID" }, + { ColumnId_LevelledItemId,"Levelled Item" }, { ColumnId_LevelledItemLevel,"Level" }, { ColumnId_LevelledItemType, "Calculate all levels <= player" }, { ColumnId_LevelledItemTypeEach, "Select a new item each instance" }, @@ -278,7 +278,7 @@ namespace CSMWorld { ColumnId_InfoCondFunc, "Function" }, { ColumnId_InfoCondVar, "Func/Variable" }, { ColumnId_InfoCondComp, "Comp" }, - { ColumnId_InfoCondValue, "Value" }, + { ColumnId_InfoCondValue, "Values" }, { ColumnId_OriginalCell, "Original Cell" }, { ColumnId_NpcAttributes, "Attributes" }, From 22420c3a83e5294bbf9d2ef73383d7fc151ca87f Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 24 May 2015 23:19:06 +1000 Subject: [PATCH 059/119] Close DialogueSubView if the corresponding record is deleted. Should resolve Bug #2575. - ToDo: Doesn't seem to shrink the widget width properly (when horizontal scrollbar is active) --- apps/opencs/view/world/dialoguesubview.cpp | 19 +++++++++++++++++++ apps/opencs/view/world/dialoguesubview.hpp | 2 ++ 2 files changed, 21 insertions(+) diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 647accd4c3..0860cf2b2c 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -578,6 +578,7 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType())) { connect(mTable, SIGNAL(dataChanged (const QModelIndex&, const QModelIndex&)), this, SLOT(dataChanged(const QModelIndex&))); + connect(mTable, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int, int)), this, SLOT(rowsAboutToBeRemoved(const QModelIndex&, int, int))); changeCurrentId(id.getId()); @@ -740,6 +741,9 @@ void CSVWorld::DialogueSubView::nextId () void CSVWorld::DialogueSubView::setEditLock (bool locked) { + if (!mEditWidget) // hack to indicate that mCurrentId is no longer valid + return; + mLocked = locked; QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0)); @@ -766,6 +770,21 @@ void CSVWorld::DialogueSubView::dataChanged (const QModelIndex & index) } } +void CSVWorld::DialogueSubView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) +{ + QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0)); + + if (currentIndex.isValid() && currentIndex.row() >= start && currentIndex.row() <= end) + { + if(mEditWidget) + { + delete mEditWidget; + mEditWidget = 0; + } + emit closeRequest(this); + } +} + void CSVWorld::DialogueSubView::tableMimeDataDropped (QWidget* editor, const QModelIndex& index, const CSMWorld::UniversalId& id, diff --git a/apps/opencs/view/world/dialoguesubview.hpp b/apps/opencs/view/world/dialoguesubview.hpp index b5a44d266f..6d12d62c14 100644 --- a/apps/opencs/view/world/dialoguesubview.hpp +++ b/apps/opencs/view/world/dialoguesubview.hpp @@ -235,6 +235,8 @@ namespace CSVWorld const CSMDoc::Document* document); void requestFocus (const std::string& id); + + void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); }; } From e6d2821b78affea63b588988f1b338dcc4667315 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 25 May 2015 09:15:07 +1000 Subject: [PATCH 060/119] Refresh table filters when the model is updated. Should resolve Bug #2579. --- apps/opencs/model/world/idtableproxymodel.cpp | 6 ++++++ apps/opencs/model/world/idtableproxymodel.hpp | 2 ++ apps/opencs/view/world/table.cpp | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/apps/opencs/model/world/idtableproxymodel.cpp b/apps/opencs/model/world/idtableproxymodel.cpp index 93c1749c63..84869716e2 100644 --- a/apps/opencs/model/world/idtableproxymodel.cpp +++ b/apps/opencs/model/world/idtableproxymodel.cpp @@ -53,3 +53,9 @@ bool CSMWorld::IdTableProxyModel::lessThan(const QModelIndex &left, const QModel { return QSortFilterProxyModel::lessThan(left, right); } + +void CSMWorld::IdTableProxyModel::refreshFilter() +{ + updateColumnMap(); + invalidateFilter(); +} diff --git a/apps/opencs/model/world/idtableproxymodel.hpp b/apps/opencs/model/world/idtableproxymodel.hpp index 23e3193fb2..8683c2b9e5 100644 --- a/apps/opencs/model/world/idtableproxymodel.hpp +++ b/apps/opencs/model/world/idtableproxymodel.hpp @@ -34,6 +34,8 @@ namespace CSMWorld void setFilter (const boost::shared_ptr& filter); + void refreshFilter(); + protected: bool lessThan(const QModelIndex &left, const QModelIndex &right) const; diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index b8972edbe4..bb3dfa4d32 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -649,6 +649,10 @@ void CSVWorld::Table::tableSizeUpdate() } emit tableSizeChanged (size, deleted, modified); + + // not really related to tableSizeUpdate() but placed here for convenience rather than + // creating a bunch of extra connections & slot + mProxyModel->refreshFilter(); } void CSVWorld::Table::selectionSizeUpdate() From 3c82e6d03401795d1e147a8e2f5d32e812eb9c4a Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 25 May 2015 16:36:42 +1000 Subject: [PATCH 061/119] Retrieve the correct index for the type of record being un-deleted. --- apps/opencs/model/world/idtable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/world/idtable.cpp b/apps/opencs/model/world/idtable.cpp index a0dd0b47bd..36b3f5c970 100644 --- a/apps/opencs/model/world/idtable.cpp +++ b/apps/opencs/model/world/idtable.cpp @@ -160,7 +160,7 @@ void CSMWorld::IdTable::setRecord (const std::string& id, const RecordBase& reco if (index==-1) { - int index = mIdCollection->getAppendIndex (id); + int index = mIdCollection->getAppendIndex (id, type); beginInsertRows (QModelIndex(), index, index); From 18f047f50e1f720bafd486a1185f113f2dc35d60 Mon Sep 17 00:00:00 2001 From: Cramal Date: Mon, 25 May 2015 18:40:13 +0900 Subject: [PATCH 062/119] Moving to Object/Instance terminology + minor spelling corrections --- manual/opencs/creating_file.tex | 2 +- manual/opencs/main.tex | 2 ++ manual/opencs/recordmodification.tex | 16 ++++++++-------- manual/opencs/recordtypes.tex | 8 ++++---- manual/opencs/tables.tex | 18 +++++++++--------- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/manual/opencs/creating_file.tex b/manual/opencs/creating_file.tex index 317e453b73..8cab33fb9b 100644 --- a/manual/opencs/creating_file.tex +++ b/manual/opencs/creating_file.tex @@ -17,7 +17,7 @@ It is simple. When you click either \textbf{Create new Addon} you will be asked The last thing to do is to name your your addon and click create. \paragraph{Selecting File for Editing} -Clicking \textbf{Edit A Content File} will show somewhat similar window. Here you should select your Game file with drop down menu. If you want to edit this game file, simply click \textbf{OK} button. If you want to alter addon depending on that file, mark it with checkbox and than click \textbf{Ok} button. +Clicking \textbf{Edit A Content File} will show somewhat similar window. Here you should select your Game file with drop down menu. If you want to edit this game file, simply click \textbf{OK} button. If you want to alter addon depending on that file, mark it with check-box and than click \textbf{Ok} button. \subsection{Advanced} If you are paying attention, you noticed any extra icon with wrench. This one will open small settings window. Those are general OpenCS settings. We will cover this is separate section.\\ diff --git a/manual/opencs/main.tex b/manual/opencs/main.tex index f3a46c1b7b..fd85baee4f 100644 --- a/manual/opencs/main.tex +++ b/manual/opencs/main.tex @@ -25,7 +25,9 @@ \title{OpenCS User Manual} \maketitle +\newpage \tableofcontents{} +\newpage \input{files_and_directories} \input{creating_file} \input{windows} diff --git a/manual/opencs/recordmodification.tex b/manual/opencs/recordmodification.tex index b1cf866d65..570bd4a95b 100644 --- a/manual/opencs/recordmodification.tex +++ b/manual/opencs/recordmodification.tex @@ -1,17 +1,17 @@ \section{Records Modification} \subsection{Introduction} -So far you learned how to browse trough records stored inside the content files, but not how to modify them using the \OCS{} editor. Although browsing is certainly a usefull ability on it's own, You probabbly counted on doing actual editing with this editor. There are few ways user can alter records stored in the content files, each suited for certain class of a problem. In this section We will describe how to do change records using tables interface and edit panel. +So far you learned how to browse trough records stored inside the content files, but not how to modify them using the \OCS{} editor. Although browsing is certainly a useful ability on it's own, You probably counted on doing actual editing with this editor. There are few ways user can alter records stored in the content files, each suited for certain class of a problem. In this section We will describe how to do change records using tables interface and edit panel. \subsubsection{Glossary} \begin{description} - \item[Edit Panel] Interface element used inside the \OCS{} to present records data for editing. Unlike table it showes only one record at the time. However it also presents fields that are not visible inside the table. It is also safe to say that Edit Panel presents data in way that is easier to read thanks to it's horizontal layout. + \item[Edit Panel] Interface element used inside the \OCS{} to present records data for editing. Unlike table it shows only one record at the time. However it also presents fields that are not visible inside the table. It is also safe to say that Edit Panel presents data in way that is easier to read thanks to it's horizontal layout. \end{description} \subsection{Edit Panel Interface} -Edit Panel is designed to aid you with record modification tasks. As It has been said, it uses vertical layout and presents some additional fields when compared with the table -- and some fields, even if they are actually displayed in the table, clearly ill-suited for modification isnide of them (this applies to fields that holds long text strings -- like descriptions). It also displays visual difference beetween non-editable field and editable.\\ +Edit Panel is designed to aid you with record modification tasks. As It has been said, it uses vertical layout and presents some additional fields when compared with the table -- and some fields, even if they are actually displayed in the table, clearly ill-suited for modification inside of them (this applies to fields that holds long text strings -- like descriptions). It also displays visual difference between non-editable field and editable.\\ To open edit panel, please open context menu on any record and choose edit action. This will open edit panel in the same window as your table and will present you the record fields. First data fields are actually not user editable and presented in the form of the text labels at the top of the edit panel. Lower data fields are presented in the form of actually user-editable widgets. Those includes spinboxes, text edits and text fields\footnote{Those are actually a valid terms used to describe classes of the user interface elements. If you don't understand those, don't worry -- those are very standard {GUI} elements present in almost every application since the rise of the desktop metaphor.}. Once you will finish editing one of those fields, data will be updated. There is no apply button of any sort -- simply use one of those widgets and be merry.\\ -In addition to that you probabbly noticed some icons in the bar located at the very bottom of the edit panel. Those can be used to perform the following actions: +In addition to that you probably noticed some icons in the bar located at the very bottom of the edit panel. Those can be used to perform the following actions: \begin{description} \item[Preview] This will launch simple preview panel -- which will be described later. @@ -20,7 +20,7 @@ In addition to that you probabbly noticed some icons in the bar located at the v \end{description} \subsection{Verification tool} -As you could notice there is nothing that can stop you from breaking the game by violating record fields logic, and yet -- it is something that you are always trying to avoid. To adress this problem \OCS{} utilizes so called verification tool (or verifer as many prefer to call it) that basicly goes trough all records and checks if it contains any illogical fields. This includes for instance torch duration equal 0\footnote{Interestingly negative values are perfectly fine: they indicate that light source has no duration limit at all. There are records like this in the original game.} or characters without name, race or any other record with a mandatory field missing.\\ -This tool is even more usefull than it seems. If you somehow delete race that is used by some of the characters, all those characters will be suddenly broken. As a rule of thumb it is a good idea to use verifer before saving your content file.\\ -To launch this usefull tool %don't remember, todo... -Resoults are presented as a yet another table with short (and hopefully descriptive enough) description of the identified problem. It is worth noticing that some records located in the \MW{} esm files are listed by the verification tool -- it is not fault of our tool: those records are just broken. For instance, you actually may find the 0 duration torch. However, those records are usually not placed in game world itself -- and that's good since \MW{} game engine will crash if player equip light source like this!\footnote{We would like to thanks \BS{} for such a usefull testing material. It makes us feel special.} +As you could notice there is nothing that can stop you from breaking the game by violating record fields logic, and yet -- it is something that you are always trying to avoid. To address this problem \OCS{} utilizes so called verification tool (or verifer as many prefer to call it) that basically goes trough all records and checks if it contains any illogical fields. This includes for instance torch duration equal 0\footnote{Interestingly negative values are perfectly fine: they indicate that light source has no duration limit at all. There are records like this in the original game.} or characters without name, race or any other record with a mandatory field missing.\\ +This tool is even more useful than it seems. If you somehow delete race that is used by some of the characters, all those characters will be suddenly broken. As a rule of thumb it is a good idea to use verifer before saving your content file.\\ +To launch this useful tool %don't remember, todo... +Results are presented as a yet another table with short (and hopefully descriptive enough) description of the identified problem. It is worth noticing that some records located in the \MW{} esm files are listed by the verification tool -- it is not fault of our tool: those records are just broken. For instance, you actually may find the 0 duration torch. However, those records are usually not placed in game world itself -- and that's good since \MW{} game engine will crash if player equip light source like this!\footnote{We would like to thanks \BS{} for such a useful testing material. It makes us feel special.} diff --git a/manual/opencs/recordtypes.tex b/manual/opencs/recordtypes.tex index 4dbfbe2864..6db338e7ed 100644 --- a/manual/opencs/recordtypes.tex +++ b/manual/opencs/recordtypes.tex @@ -1,15 +1,15 @@ \section{Record Types} \subsection{Introduction} -A gameworld contains many objects, such as chests, weapons and monsters. All these objects are merely instances of templates that we call Referenceables. The OpenCS Referenceables table contains information about each of these template objects, eg. its value and weight in the case of items and an aggression level in the case of NPCs. +A gameworld contains many items, such as chests, weapons and monsters. All these items are merely instances of templates that we call \textbf{Objects}. The OpenCS \textbf{Objects} table contains information about each of these template objects, eg. its value and weight in the case of items and an aggression level in the case of NPCs. Let's go through all Record Types and discuss what you can tell OpenCS about them. \begin{description} \item[Activator:] When the player enters the same cell as this object, a script is started. Often it also has a \textbf{Script} attached to it, though it not mandatory. These scripts are small bits of code written in a special scripting language that OpenCS can read and interpret. - \item[Potion:] This is a potion that is not self-made. It has an \textbf{Icon} for your inventory, Aside from the self-explanatory \textbf{Weight} and \textbf{Coin Value}, it has an attribute called \textbf{Auto Calc} set to ``False''. This means that the effects of this potion are preconfigured. This does not happen when the player makes their own potion. - \item[Apparatus:] This is a tool to make potions. Again there's an icon for your inventory as well as a weight and a coin value. It also has a \textbf{Quality} value attached to it: higher the number, the better the effect on your potions will be. The \textbf{Apparatus Type} describes if the item is a Calcinator, Retort, Alembir or Mortar & Pestal. Each has a different effect on the potion the player makes. For more information on this subject, please refer to the \href{http://www.uesp.net/wiki/Morrowind:Alchemy#Tools}{UESP page on Alchemy Tools}. - \item[Armor:] This type of item adds \textbf{Enchantment Points} to the mix. Every piece of clothing or armor has a ''pool'' of potential magicka that gets unlocked when you enchant it. Strong enchantments consume more magicka from this pool: the stronger the enchantment, the more Enchantment Points each cast will take up. For more information on this subject, please refer to the \href{http://www.uesp.net/wiki/Morrowind:Enchant}{Enchant page on UESP}. \textbf{Health} means the amount of hit points this piece of armor has. If it sustains enough damage, the armor will be destroyed. Finally, \textbf{Armor Value} tells the game how much points to add to the player character's Armor Rating. + \item[Potion:] This is a potion that is not self-made. It has an \textbf{Icon} for your inventory, Aside from the self-explanatory \textbf{Weight} and \textbf{Coin Value}, it has an attribute called \textbf{Auto Calc} set to ``False''. This means that the effects of this potion are pre-configured. This does not happen when the player makes their own potion. + \item[Apparatus:] This is a tool to make potions. Again there's an icon for your inventory as well as a weight and a coin value. It also has a \textbf{Quality} value attached to it: higher the number, the better the effect on your potions will be. The \textbf{Apparatus Type} describes if the item is a Calcinator, Retort, Alembic or Mortar & Pestle. Each has a different effect on the potion the player makes. For more information on this subject, please refer to the \href{http://www.uesp.net/wiki/Morrowind:Alchemy#Tools}{UESP page on Alchemy Tools}. + \item[Armor:] This type of item adds \textbf{Enchantment Points} to the mix. Every piece of clothing or armor has a ''pool'' of potential Magicka that gets unlocked when you enchant it. Strong enchantments consume more Magicka from this pool: the stronger the enchantment, the more Enchantment Points each cast will take up. For more information on this subject, please refer to the \href{http://www.uesp.net/wiki/Morrowind:Enchant}{Enchant page on UESP}. \textbf{Health} means the amount of hit points this piece of armor has. If it sustains enough damage, the armor will be destroyed. Finally, \textbf{Armor Value} tells the game how much points to add to the player character's Armor Rating. \item[Book:] This includes scrolls and notes. For the game to make the distinction between books and scrolls, an extra property, \textbf{Scroll}, has been added. Under the \textbf{Skill} column a scroll or book can have an in-game skill listed. Reading this item will raise the player's level in that specific skill. For more information on this, please refer to the \href{http://www.uesp.net/wiki/Morrowind:Skill_Books}{Skill Books page on UESP}. \item[Clothing:] These items work just like Armors, but confer no protective properties. Rather than ``Armor Type'', these items have a ``Clothing Type''. \item[Container:] This is all the stuff that stores items, from chests to sacks to plants. Its \textbf{Capacity} shows how much stuff you can put in the container. You can compare it to the maximum allowed load a player character can carry (who will get over-encumbered and unable to move if he crosses this threshold). A container, however, will just refuse to take the item in question when it gets ''over-encumbered''. \textbf{Organic Container}s are containers such as plants. Containers that \textbf{Respawn} are not safe to store stuff in. After a certain amount of time they will reset to their default contents, meaning that everything in it is gone forever. diff --git a/manual/opencs/tables.tex b/manual/opencs/tables.tex index 5034898729..51aac50fd7 100644 --- a/manual/opencs/tables.tex +++ b/manual/opencs/tables.tex @@ -14,7 +14,7 @@ Let's browse through the various screens and see what all these tables show. \begin{description} \item[Record:] An entry in \OCS{} representing an item, location, sound, NPC or anything else. - \item[Reference, Referenceable:] When an item is placed in the world, it isn't an isolated and unique object. For example, the game world might contain a lot of exquisite belts on different NPCs and in many crates, but they all refer to one specific record in the game's library: the Exquisite Belt record. In this case, all those belts in crates and on NPCs are references. The central Exquisite Belt record is called a referenceable. This allows modders to make changes to all items of the same type. For example, if you want all exquisite belts to have 4000 enchantment points rather than 400, you will only need to change the referenceable Exquisite Belt rather than all exquisite belts references individually. + \item[Instance, Object:] When an item is placed in the world, it isn't an isolated and unique object. For example, the game world might contain a lot of exquisite belts on different NPCs and in many crates, but they all refer to one specific record in the game's library: the Exquisite Belt record. In this case, all those belts in crates and on NPCs are \textbf{instances}. The central Exquisite Belt record is called a \textbf{object}. This allows modders to make changes to all items of the same type. For example, if you want all exquisite belts to have 4000 enchantment points rather than 400, you will only need to change the \textbf{object}} Exquisite Belt rather than all exquisite belts \textbf{instances}} individually. \end{description} \subsubsection{Recurring Terms} @@ -29,7 +29,7 @@ optionally the Bloodmoon and Tribunal expansions. \item[Modified] means that the record is part of the base game, but has been changed in some way. \item[Deleted] means that this record used to be part of the base game, but has been removed as an entry. This does not mean, however, that the occurrences in the game itself have been removed! For example, if you remove the CharGen\_Bed entry from morrowind.esm, it does not mean the bedroll in the basement -of the Census and Excise Office in Seyda Neen is gone. You're going to have to delete that reference yourself or make sure that that object is replaced +of the Census and Excise Office in Seyda Neen is gone. You're going to have to delete that instance yourself or make sure that that object is replaced by something that still exists otherwise you will get crashes in the worst case scenario. \end{description} @@ -37,12 +37,12 @@ by something that still exists otherwise you will get crashes in the worst case The contents of the game world can be changed by choosing one of the options in the appropriate menu at the top of the screen. \subsubsection{Regions} -This describes the general areas of Vvardenfell. Each of these areas has different rules about things such as encounters and weather. +This describes the general areas of the gameworld. Each of these areas has different rules about things such as encounters and weather. \begin{description} \item[Name:] This is how the game will show your location in-game. - \item[Map Colour:] This is a six-digit hexidecimal representation of the colour used to identify the region on the map available in - World > Region Map. If you do not have an application with a colour picker, you can use your favourite search engine to find a colour picker online. + \item[Map Colour:] This is a six-digit hexadecimal representation of the color used to identify the region on the map available in + World > Region Map. If you do not have an application with a color picker, you can use your favorite search engine to find a color picker on-line. \item[Sleep Encounter:] These are the rules for what kind of enemies you might encounter when you sleep outside in the wild. \end{description} @@ -52,7 +52,7 @@ why would the computer need to keep track the exact locations of NPCs walking th be quite useless and bring your system to its knees! So the world has been divided up into squares we call "cells". Once your character enters a cell, the game will load everything that is going on in that cell so you can interact with it. -In the original \MW{} this could be seen when you were travelling and you would see a small loading bar at the bottom of the screen; +In the original \MW{} this could be seen when you were traveling and you would see a small loading bar at the bottom of the screen; you had just entered a new cell and the game would have to load all the items and NPCs. The Cells screen in \OCS{} provides you with a list of cells in the game, both the interior cells (houses, dungeons, mines, etc.) and the exterior cells (the outside world). @@ -71,7 +71,7 @@ in the game, both the interior cells (houses, dungeons, mines, etc.) and the ext \item[Interior Sky:] Should this interior cell have a sky? This is a rather unique case. The \TB{} expansion took place in a city on the mainland. Normally this would require the city to be composed of exterior cells so it has a sky, weather and the like. But if the player is - in an exterior cell and looks at his in-game map, he sees Vvardenfell with an overview of all exterior cells. The player would have to see + in an exterior cell and looks at his in-game map, he sees the map of the gameworld with an overview of all exterior cells. The player would have to see the city's very own map, as if he was walking around in an interior cell. So the developers decided to create a workaround and take a bit of both: The whole city would technically work exactly like an interior cell, @@ -83,7 +83,7 @@ in the game, both the interior cells (houses, dungeons, mines, etc.) and the ext \end{description} -\subsubsection{Referenceables} +\subsubsection{Objects} This is a library of all the items, triggers, containers, NPCs, etc. in the game. There are several kinds of Record Types. Depending on which type a record is, it will need specific information to function. For example, an NPC needs a value attached to its aggression level. A chest, of course, does not. All Record Types contain at least a~model. How else would the player see them? Usually they also have a Name, which is what you see @@ -91,4 +91,4 @@ when you hover your reticle over the object. This is a library of all the items, triggers, containers, NPCs, etc. in the game. There are several kinds of Record Types. Depending on which type a record is, it will need specific information to function. For example, an NPC needs a value attached to its aggression level. A chest, of course, does not. All Record Types contain at least a model. How else would the player see them? Usually they also have a Name, which is what you see when you hover your reticle over the object. -Please refer to the Record Types section for an overview of what each type of Referenceable does and what you can tell OpenCS about these objects. +Please refer to the Record Types section for an overview of what each type of object does and what you can tell OpenCS about these objects. From ad77c662aaffab0db65712187ae80dba556611ce Mon Sep 17 00:00:00 2001 From: Cramal Date: Mon, 25 May 2015 18:44:21 +0900 Subject: [PATCH 063/119] correct latex error --- manual/opencs/tables.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manual/opencs/tables.tex b/manual/opencs/tables.tex index 51aac50fd7..984157f88f 100644 --- a/manual/opencs/tables.tex +++ b/manual/opencs/tables.tex @@ -14,7 +14,7 @@ Let's browse through the various screens and see what all these tables show. \begin{description} \item[Record:] An entry in \OCS{} representing an item, location, sound, NPC or anything else. - \item[Instance, Object:] When an item is placed in the world, it isn't an isolated and unique object. For example, the game world might contain a lot of exquisite belts on different NPCs and in many crates, but they all refer to one specific record in the game's library: the Exquisite Belt record. In this case, all those belts in crates and on NPCs are \textbf{instances}. The central Exquisite Belt record is called a \textbf{object}. This allows modders to make changes to all items of the same type. For example, if you want all exquisite belts to have 4000 enchantment points rather than 400, you will only need to change the \textbf{object}} Exquisite Belt rather than all exquisite belts \textbf{instances}} individually. + \item[Instance, Object:] When an item is placed in the world, it isn't an isolated and unique object. For example, the game world might contain a lot of exquisite belts on different NPCs and in many crates, but they all refer to one specific record in the game's library: the Exquisite Belt record. In this case, all those belts in crates and on NPCs are \textbf{instances}. The central Exquisite Belt record is called a \textbf{object}. This allows modders to make changes to all items of the same type. For example, if you want all exquisite belts to have 4000 enchantment points rather than 400, you will only need to change the \textbf{object} Exquisite Belt rather than all exquisite belts \textbf{instances} individually. \end{description} \subsubsection{Recurring Terms} From 08484a46c7e8ed17202eb28d1cbf4f43799e5320 Mon Sep 17 00:00:00 2001 From: Cramal Date: Mon, 25 May 2015 18:45:42 +0900 Subject: [PATCH 064/119] remove latex error --- manual/opencs/recordtypes.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manual/opencs/recordtypes.tex b/manual/opencs/recordtypes.tex index 6db338e7ed..661f5ac7d5 100644 --- a/manual/opencs/recordtypes.tex +++ b/manual/opencs/recordtypes.tex @@ -8,7 +8,7 @@ Let's go through all Record Types and discuss what you can tell OpenCS about the \begin{description} \item[Activator:] When the player enters the same cell as this object, a script is started. Often it also has a \textbf{Script} attached to it, though it not mandatory. These scripts are small bits of code written in a special scripting language that OpenCS can read and interpret. \item[Potion:] This is a potion that is not self-made. It has an \textbf{Icon} for your inventory, Aside from the self-explanatory \textbf{Weight} and \textbf{Coin Value}, it has an attribute called \textbf{Auto Calc} set to ``False''. This means that the effects of this potion are pre-configured. This does not happen when the player makes their own potion. - \item[Apparatus:] This is a tool to make potions. Again there's an icon for your inventory as well as a weight and a coin value. It also has a \textbf{Quality} value attached to it: higher the number, the better the effect on your potions will be. The \textbf{Apparatus Type} describes if the item is a Calcinator, Retort, Alembic or Mortar & Pestle. Each has a different effect on the potion the player makes. For more information on this subject, please refer to the \href{http://www.uesp.net/wiki/Morrowind:Alchemy#Tools}{UESP page on Alchemy Tools}. + \item[Apparatus:] This is a tool to make potions. Again there's an icon for your inventory as well as a weight and a coin value. It also has a \textbf{Quality} value attached to it: higher the number, the better the effect on your potions will be. The \textbf{Apparatus Type} describes if the item is a Calcinator, Retort, Alembic or Mortar \& Pestle. Each has a different effect on the potion the player makes. For more information on this subject, please refer to the \href{http://www.uesp.net/wiki/Morrowind:Alchemy#Tools}{UESP page on Alchemy Tools}. \item[Armor:] This type of item adds \textbf{Enchantment Points} to the mix. Every piece of clothing or armor has a ''pool'' of potential Magicka that gets unlocked when you enchant it. Strong enchantments consume more Magicka from this pool: the stronger the enchantment, the more Enchantment Points each cast will take up. For more information on this subject, please refer to the \href{http://www.uesp.net/wiki/Morrowind:Enchant}{Enchant page on UESP}. \textbf{Health} means the amount of hit points this piece of armor has. If it sustains enough damage, the armor will be destroyed. Finally, \textbf{Armor Value} tells the game how much points to add to the player character's Armor Rating. \item[Book:] This includes scrolls and notes. For the game to make the distinction between books and scrolls, an extra property, \textbf{Scroll}, has been added. Under the \textbf{Skill} column a scroll or book can have an in-game skill listed. Reading this item will raise the player's level in that specific skill. For more information on this, please refer to the \href{http://www.uesp.net/wiki/Morrowind:Skill_Books}{Skill Books page on UESP}. \item[Clothing:] These items work just like Armors, but confer no protective properties. Rather than ``Armor Type'', these items have a ``Clothing Type''. From 95f740ec40b76db5892ef9c93ef35480fb6a00a7 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 25 May 2015 22:28:41 +1000 Subject: [PATCH 065/119] Give CSVWorld::EditWidget::mMainWidget a chance to clean up its children. Should resolve Bug #2578. --- apps/opencs/view/world/dialoguesubview.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 2cf30dcbe0..7a25a7fc14 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -378,6 +378,13 @@ mDocument (document) void CSVWorld::EditWidget::remake(int row) { + if (mMainWidget) + { + QWidget *del = this->takeWidget(); + del->deleteLater(); + } + mMainWidget = new QWidget (this); + for (unsigned i = 0; i < mNestedModels.size(); ++i) delete mNestedModels[i]; @@ -401,12 +408,6 @@ void CSVWorld::EditWidget::remake(int row) if (mNestedTableMapper) delete mNestedTableMapper; - if (mMainWidget) - { - QWidget *del = this->takeWidget(); - del->deleteLater(); - } - mMainWidget = new QWidget (this); QFrame* line = new QFrame(mMainWidget); line->setObjectName(QString::fromUtf8("line")); From ec808843c3614e4615a6c7afb6f0acc5a28a94c7 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 26 May 2015 13:35:10 +1000 Subject: [PATCH 066/119] Do not rebuild the dialogue subview unless required. Should resolve Bug #2581. The loss of focus was caused by each text change (i.e. character entry) to a QPlainTextEdit resulting in dataChanged() signal which in turn rebuilt the dialogue subview. Changes in this commit include: - Do not send signal to update entire row if only a single item has changed. - Do not rebuild the dialogue subview unless the data item that triggers a conditional display is changed. - Add column flags to indicate whether the data in this column should rebuild the dialogue subview. - Return the correct flags for nested columns - Disable, rather than grey out, checkbox that does not apply to creature levelled list --- apps/opencs/model/world/columnbase.cpp | 4 ++-- apps/opencs/model/world/columnbase.hpp | 8 ++++--- apps/opencs/model/world/columnimp.hpp | 4 ++-- apps/opencs/model/world/data.cpp | 21 +++++++++++------ apps/opencs/model/world/idtable.cpp | 3 +-- apps/opencs/model/world/idtree.cpp | 6 ++--- apps/opencs/model/world/refidadapterimp.hpp | 2 +- apps/opencs/model/world/refidcollection.cpp | 3 ++- apps/opencs/view/world/dialoguesubview.cpp | 26 +++++++++++++++++---- 9 files changed, 52 insertions(+), 25 deletions(-) diff --git a/apps/opencs/model/world/columnbase.cpp b/apps/opencs/model/world/columnbase.cpp index 0e0ff11d40..3d13538c03 100644 --- a/apps/opencs/model/world/columnbase.cpp +++ b/apps/opencs/model/world/columnbase.cpp @@ -138,8 +138,8 @@ bool CSMWorld::NestableColumn::hasChildren() const } CSMWorld::NestedChildColumn::NestedChildColumn (int id, - CSMWorld::ColumnBase::Display display, bool isEditable) - : NestableColumn (id, display, CSMWorld::ColumnBase::Flag_Dialogue) , mIsEditable(isEditable) + CSMWorld::ColumnBase::Display display, int flags, bool isEditable) + : NestableColumn (id, display, flags) , mIsEditable(isEditable) {} bool CSMWorld::NestedChildColumn::isEditable () const diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index d6dd4b291b..70b2a35b76 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -25,7 +25,8 @@ namespace CSMWorld { Flag_Table = 1, // column should be displayed in table view Flag_Dialogue = 2, // column should be displayed in dialogue view - Flag_Dialogue_List = 4 // column should be diaplyed in dialogue view + Flag_Dialogue_List = 4, // column should be diaplyed in dialogue view + Flag_Dialogue_Refresh = 8 // refresh dialogue view if this column is modified }; enum Display @@ -183,7 +184,7 @@ namespace CSMWorld template struct NestedParentColumn : public Column { - NestedParentColumn (int id, int flags = ColumnBase::Flag_Dialogue) : Column (id, + NestedParentColumn (int id, int flags = Flag_Dialogue) : Column (id, ColumnBase::Display_NestedHeader, flags) {} @@ -200,7 +201,8 @@ namespace CSMWorld struct NestedChildColumn : public NestableColumn { - NestedChildColumn (int id, Display display, bool isEditable = true); + NestedChildColumn (int id, + Display display, int flags = Flag_Dialogue, bool isEditable = true); virtual bool isEditable() const; diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index cbe0d74c41..64a1cf3d70 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -467,8 +467,8 @@ namespace CSMWorld int mMask; bool mInverted; - FlagColumn (int columnId, int mask, bool inverted = false) - : Column (columnId, ColumnBase::Display_Boolean), mMask (mask), + FlagColumn (int columnId, int mask, int flags = Flag_Table | Flag_Dialogue, bool inverted = false) + : Column (columnId, ColumnBase::Display_Boolean, flags), mMask (mask), mInverted (inverted) {} diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 920c7db719..c27c068f10 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -141,7 +141,8 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc index = mRaces.getColumns()-1; mRaces.addAdapter (std::make_pair(&mRaces.getColumn(index), new RaceAttributeAdapter())); mRaces.getNestableColumn(index)->addColumn( - new NestedChildColumn (Columns::ColumnId_RaceAttributes, ColumnBase::Display_String, false)); + new NestedChildColumn (Columns::ColumnId_RaceAttributes, ColumnBase::Display_String, + ColumnBase::Flag_Dialogue, false)); mRaces.getNestableColumn(index)->addColumn( new NestedChildColumn (Columns::ColumnId_RaceMaleValue, ColumnBase::Display_Integer)); mRaces.getNestableColumn(index)->addColumn( @@ -287,8 +288,10 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mCells.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Cell)); mCells.addColumn (new NameColumn); mCells.addColumn (new FlagColumn (Columns::ColumnId_SleepForbidden, ESM::Cell::NoSleep)); - mCells.addColumn (new FlagColumn (Columns::ColumnId_InteriorWater, ESM::Cell::HasWater)); - mCells.addColumn (new FlagColumn (Columns::ColumnId_InteriorSky, ESM::Cell::QuasiEx)); + mCells.addColumn (new FlagColumn (Columns::ColumnId_InteriorWater, ESM::Cell::HasWater, + ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue | ColumnBase::Flag_Dialogue_Refresh)); + mCells.addColumn (new FlagColumn (Columns::ColumnId_InteriorSky, ESM::Cell::QuasiEx, + ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue | ColumnBase::Flag_Dialogue_Refresh)); mCells.addColumn (new RegionColumn); mCells.addColumn (new RefNumCounterColumn); // Misc Cell data @@ -297,7 +300,8 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc index = mCells.getColumns()-1; mCells.addAdapter (std::make_pair(&mCells.getColumn(index), new CellListAdapter ())); mCells.getNestableColumn(index)->addColumn( - new NestedChildColumn (Columns::ColumnId_Interior, ColumnBase::Display_Boolean)); + new NestedChildColumn (Columns::ColumnId_Interior, ColumnBase::Display_Boolean, + ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue | ColumnBase::Flag_Dialogue_Refresh)); mCells.getNestableColumn(index)->addColumn( new NestedChildColumn (Columns::ColumnId_Ambient, ColumnBase::Display_Integer)); mCells.getNestableColumn(index)->addColumn( @@ -346,7 +350,8 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mBodyParts.addColumn (new BodyPartTypeColumn); mBodyParts.addColumn (new VampireColumn); mBodyParts.addColumn (new FlagColumn (Columns::ColumnId_Female, ESM::BodyPart::BPF_Female)); - mBodyParts.addColumn (new FlagColumn (Columns::ColumnId_Playable, ESM::BodyPart::BPF_NotPlayable, true)); + mBodyParts.addColumn (new FlagColumn (Columns::ColumnId_Playable, + ESM::BodyPart::BPF_NotPlayable, ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, true)); mBodyParts.addColumn (new MeshTypeColumn); mBodyParts.addColumn (new ModelColumn); mBodyParts.addColumn (new RaceColumn); @@ -393,7 +398,8 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc // new objects deleted in dtor of NestableColumn // WARNING: The order of the columns below are assumed in PathgridPointListAdapter mPathgrids.getNestableColumn(index)->addColumn( - new NestedChildColumn (Columns::ColumnId_PathgridIndex, ColumnBase::Display_Integer, false)); + new NestedChildColumn (Columns::ColumnId_PathgridIndex, ColumnBase::Display_Integer, + ColumnBase::Flag_Dialogue, false)); mPathgrids.getNestableColumn(index)->addColumn( new NestedChildColumn (Columns::ColumnId_PathgridPosX, ColumnBase::Display_Integer)); mPathgrids.getNestableColumn(index)->addColumn( @@ -405,7 +411,8 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc index = mPathgrids.getColumns()-1; mPathgrids.addAdapter (std::make_pair(&mPathgrids.getColumn(index), new PathgridEdgeListAdapter ())); mPathgrids.getNestableColumn(index)->addColumn( - new NestedChildColumn (Columns::ColumnId_PathgridEdgeIndex, ColumnBase::Display_Integer, false)); + new NestedChildColumn (Columns::ColumnId_PathgridEdgeIndex, ColumnBase::Display_Integer, + ColumnBase::Flag_Dialogue, false)); mPathgrids.getNestableColumn(index)->addColumn( new NestedChildColumn (Columns::ColumnId_PathgridEdge0, ColumnBase::Display_Integer)); mPathgrids.getNestableColumn(index)->addColumn( diff --git a/apps/opencs/model/world/idtable.cpp b/apps/opencs/model/world/idtable.cpp index 36b3f5c970..04aa271ccc 100644 --- a/apps/opencs/model/world/idtable.cpp +++ b/apps/opencs/model/world/idtable.cpp @@ -74,8 +74,7 @@ bool CSMWorld::IdTable::setData (const QModelIndex &index, const QVariant &value { mIdCollection->setData (index.row(), index.column(), value); - emit dataChanged (CSMWorld::IdTable::index (index.row(), 0), - CSMWorld::IdTable::index (index.row(), mIdCollection->getColumns()-1)); + emit dataChanged (index, index); return true; } diff --git a/apps/opencs/model/world/idtree.cpp b/apps/opencs/model/world/idtree.cpp index 06db09a0fc..7351c03a77 100644 --- a/apps/opencs/model/world/idtree.cpp +++ b/apps/opencs/model/world/idtree.cpp @@ -74,7 +74,7 @@ QVariant CSMWorld::IdTree::nestedHeaderData(int section, int subSection, Qt::Ori return tr(parentColumn->nestedColumn(subSection).getTitle().c_str()); if (role==ColumnBase::Role_Flags) - return idCollection()->getColumn (section).mFlags; + return parentColumn->nestedColumn(subSection).mFlags; if (role==ColumnBase::Role_Display) return parentColumn->nestedColumn(subSection).mDisplayType; @@ -92,8 +92,8 @@ bool CSMWorld::IdTree::setData (const QModelIndex &index, const QVariant &value, mNestedCollection->setNestedData(parentAddress.first, parentAddress.second, value, index.row(), index.column()); - emit dataChanged (CSMWorld::IdTree::index (parentAddress.first, 0), - CSMWorld::IdTree::index (parentAddress.first, idCollection()->getColumns()-1)); + emit dataChanged (index, index); + return true; } else diff --git a/apps/opencs/model/world/refidadapterimp.hpp b/apps/opencs/model/world/refidadapterimp.hpp index 3411429d05..869996da5b 100644 --- a/apps/opencs/model/world/refidadapterimp.hpp +++ b/apps/opencs/model/world/refidadapterimp.hpp @@ -1976,7 +1976,7 @@ namespace CSMWorld { switch (subColIndex) { - case 0: return QVariant(QVariant::UserType); // disable the checkbox editor + case 0: return QVariant(); // disable the checkbox editor case 1: return record.get().mFlags & ESM::CreatureLevList::AllLevels; case 2: return static_cast (record.get().mChanceNone); default: diff --git a/apps/opencs/model/world/refidcollection.cpp b/apps/opencs/model/world/refidcollection.cpp index 9d9e9826af..cda19c87bb 100644 --- a/apps/opencs/model/world/refidcollection.cpp +++ b/apps/opencs/model/world/refidcollection.cpp @@ -245,7 +245,8 @@ CSMWorld::RefIdCollection::RefIdCollection() actorsColumns.mServices.insert (std::make_pair (&mColumns.back(), sServiceTable[i].mFlag)); } - mColumns.push_back (RefIdColumn (Columns::ColumnId_AutoCalc, ColumnBase::Display_Boolean)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_AutoCalc, ColumnBase::Display_Boolean, + ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue | ColumnBase::Flag_Dialogue_Refresh)); const RefIdColumn *autoCalc = &mColumns.back(); mColumns.push_back (RefIdColumn (Columns::ColumnId_ApparatusType, diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 2cf30dcbe0..03fa532c55 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -787,14 +787,32 @@ void CSVWorld::DialogueSubView::dataChanged (const QModelIndex & index) { QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0)); - if (currentIndex.isValid() && index.row() == currentIndex.row()) + if (currentIndex.isValid() && + (index.parent().isValid() ? index.parent().row() : index.row()) == currentIndex.row()) { CSMWorld::RecordBase::State state = static_cast(mTable->data (mTable->index (currentIndex.row(), 1)).toInt()); mEditWidget->setDisabled (state==CSMWorld::RecordBase::State_Deleted || mLocked); - int y = mEditWidget->verticalScrollBar()->value(); - mEditWidget->remake (index.row()); - mEditWidget->verticalScrollBar()->setValue(y); + + // Check if the changed data should force refresh (rebuild) the dialogue subview + int flags = 0; + if (index.parent().isValid()) // TODO: check that index is topLeft + { + flags = static_cast(mTable)->nestedHeaderData (index.parent().column(), + index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt(); + } + else + { + flags = mTable->headerData (index.column(), + Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt(); + } + + if (flags & CSMWorld::ColumnBase::Flag_Dialogue_Refresh) + { + int y = mEditWidget->verticalScrollBar()->value(); + mEditWidget->remake (index.parent().isValid() ? index.parent().row() : index.row()); + mEditWidget->verticalScrollBar()->setValue(y); + } } } From 2f29c2c077491f378e3abad231010e1643c64319 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 26 May 2015 13:58:58 +1000 Subject: [PATCH 067/119] Qualify the scope of Flag_Dialogue. --- apps/opencs/model/world/columnbase.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index 70b2a35b76..bf8378e37b 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -184,7 +184,7 @@ namespace CSMWorld template struct NestedParentColumn : public Column { - NestedParentColumn (int id, int flags = Flag_Dialogue) : Column (id, + NestedParentColumn (int id, int flags = ColumnBase::Flag_Dialogue) : Column (id, ColumnBase::Display_NestedHeader, flags) {} @@ -202,7 +202,7 @@ namespace CSMWorld struct NestedChildColumn : public NestableColumn { NestedChildColumn (int id, - Display display, int flags = Flag_Dialogue, bool isEditable = true); + Display display, int flags = ColumnBase::Flag_Dialogue, bool isEditable = true); virtual bool isEditable() const; From aafcaf32c5ba50bb1b92c44dda31e1d0f4ba1d5b Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 26 May 2015 16:12:54 +1000 Subject: [PATCH 068/119] Qualify the scope of Flag_Dialogue. (another one) --- apps/opencs/model/world/columnimp.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index 64a1cf3d70..6b496e0ca7 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -467,7 +467,8 @@ namespace CSMWorld int mMask; bool mInverted; - FlagColumn (int columnId, int mask, int flags = Flag_Table | Flag_Dialogue, bool inverted = false) + FlagColumn (int columnId, int mask, + int flags = ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, bool inverted = false) : Column (columnId, ColumnBase::Display_Boolean, flags), mMask (mask), mInverted (inverted) {} From f06ddd47c40f100a9610af3baf8b572d6308bbed Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 26 May 2015 17:38:22 +1000 Subject: [PATCH 069/119] Return the correct range for a given topic. Should resolve Bug #2569. --- apps/opencs/model/world/infocollection.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/opencs/model/world/infocollection.cpp b/apps/opencs/model/world/infocollection.cpp index f2d81823cf..a508d28f3d 100644 --- a/apps/opencs/model/world/infocollection.cpp +++ b/apps/opencs/model/world/infocollection.cpp @@ -173,6 +173,17 @@ CSMWorld::InfoCollection::Range CSMWorld::InfoCollection::getTopicRange (const s RecordConstIterator begin = getRecords().begin()+iter->second; + while (begin != getRecords().begin()) + { + if (!Misc::StringUtils::ciEqual(begin->get().mTopicId, topic2)) + { + // we've gone one too far, go back + ++begin; + break; + } + --begin; + } + // Find end RecordConstIterator end = begin; From 2f976495403ddc5ed39038632021ef536697df11 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 27 May 2015 00:30:39 +0200 Subject: [PATCH 070/119] Fix for cleanup issue when exiting after a failed savegame load (Fixes #2580) --- apps/openmw/mwrender/npcanimation.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 6a6d52e262..f4943ba554 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -196,7 +196,11 @@ const NpcAnimation::PartBoneMap NpcAnimation::sPartList = createPartListMap(); NpcAnimation::~NpcAnimation() { - if (!mListenerDisabled) + if (!mListenerDisabled + // No need to getInventoryStore() to reset, if none exists + // This is to avoid triggering the listener via ensureCustomData()->autoEquip()->fireEquipmentChanged() + // all from within this destructor. ouch! + && mPtr.getRefData().getCustomData()) mPtr.getClass().getInventoryStore(mPtr).setListener(NULL, mPtr); } From 5fd107a95c7a763d3fe7a84d433b8bc7de1dac69 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 27 May 2015 10:19:26 +1000 Subject: [PATCH 071/119] Fix crash with array out of bounds when refNum index is incorrect. --- components/esm/loadcell.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/esm/loadcell.cpp b/components/esm/loadcell.cpp index 0f8897c488..94f4b0b6e7 100644 --- a/components/esm/loadcell.cpp +++ b/components/esm/loadcell.cpp @@ -18,9 +18,11 @@ namespace ///< Translate 8bit/24bit code (stored in refNum.mIndex) into a proper refNum void adjustRefNum (ESM::RefNum& refNum, ESM::ESMReader& reader) { - int local = (refNum.mIndex & 0xff000000) >> 24; + unsigned int local = (refNum.mIndex & 0xff000000) >> 24; - if (local) + // If we have an index value that does not make sense, assume that it was an addition + // by the present plugin (but a faulty one) + if (local && local <= reader.getGameFiles().size()) { // If the most significant 8 bits are used, then this reference already exists. // In this case, do not spawn a new reference, but overwrite the old one. From b7044ac119b6bbbdd7b74749c5201a462fec0d59 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 27 May 2015 10:27:57 +1000 Subject: [PATCH 072/119] Fix crash loading some addon files. Should resolve Bug #2583. - This may be a bug within QSortFilterProxyModel - It isn't 100% clear what aspects of these addon files cause the issue, but something about them causes Qt to lose track of its internal row numbers. --- apps/opencs/model/world/idtableproxymodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/world/idtableproxymodel.cpp b/apps/opencs/model/world/idtableproxymodel.cpp index 84869716e2..987d274620 100644 --- a/apps/opencs/model/world/idtableproxymodel.cpp +++ b/apps/opencs/model/world/idtableproxymodel.cpp @@ -46,7 +46,7 @@ void CSMWorld::IdTableProxyModel::setFilter (const boost::shared_ptr Date: Wed, 27 May 2015 15:55:00 +1000 Subject: [PATCH 073/119] Object verifier check to see if the script used by that object actually exists. Should resolve Bug #2582. --- .../opencs/model/tools/referenceablecheck.cpp | 83 ++++++++++++++++--- .../opencs/model/tools/referenceablecheck.hpp | 20 +++-- apps/opencs/model/tools/tools.cpp | 14 ++-- 3 files changed, 93 insertions(+), 24 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index c0991a330d..548fcd36f6 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -8,12 +8,14 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage( const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, const CSMWorld::IdCollection& classes, - const CSMWorld::IdCollection& faction) + const CSMWorld::IdCollection& faction, + const CSMWorld::IdCollection& scripts) : mReferencables(referenceable), mRaces(races), mClasses(classes), mFactions(faction), + mScripts(scripts), mPlayerPresent(false) { } @@ -245,6 +247,9 @@ void CSMTools::ReferenceableCheckStage::bookCheck( CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Book, book.mId); inventoryItemCheck(book, messages, id.toString(), true); + + // Check that mentioned scripts exist + scriptCheck(book, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::activatorCheck( @@ -265,6 +270,9 @@ void CSMTools::ReferenceableCheckStage::activatorCheck( //Checking for model, IIRC all activators should have a model if (activator.mModel.empty()) messages.push_back (std::make_pair (id, activator.mId + " has no model")); + + // Check that mentioned scripts exist + scriptCheck(activator, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::potionCheck( @@ -284,6 +292,9 @@ void CSMTools::ReferenceableCheckStage::potionCheck( inventoryItemCheck(potion, messages, id.toString()); //IIRC potion can have empty effects list just fine. + + // Check that mentioned scripts exist + scriptCheck(potion, messages, id.toString()); } @@ -305,6 +316,9 @@ void CSMTools::ReferenceableCheckStage::apparatusCheck( inventoryItemCheck(apparatus, messages, id.toString()); toolCheck(apparatus, messages, id.toString()); + + // Check that mentioned scripts exist + scriptCheck(apparatus, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::armorCheck( @@ -331,6 +345,9 @@ void CSMTools::ReferenceableCheckStage::armorCheck( //checking for health. Only positive numbers are allowed, or 0 is illegal if (armor.mData.mHealth <= 0) messages.push_back (std::make_pair (id, armor.mId + " has non positive health")); + + // Check that mentioned scripts exist + scriptCheck(armor, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::clothingCheck( @@ -348,6 +365,9 @@ void CSMTools::ReferenceableCheckStage::clothingCheck( const ESM::Clothing& clothing = (dynamic_cast& >(baseRecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Clothing, clothing.mId); inventoryItemCheck(clothing, messages, id.toString(), true); + + // Check that mentioned scripts exist + scriptCheck(clothing, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::containerCheck( @@ -377,6 +397,9 @@ void CSMTools::ReferenceableCheckStage::containerCheck( //checking for name if (container.mName.empty()) messages.push_back (std::make_pair (id, container.mId + " has an empty name")); + + // Check that mentioned scripts exist + scriptCheck(container, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::creatureCheck ( @@ -444,6 +467,9 @@ void CSMTools::ReferenceableCheckStage::creatureCheck ( //TODO, find meaning of other values if (creature.mData.mGold < 0) //It seems that this is for gold in merchant creatures messages.push_back (std::make_pair (id, creature.mId + " has negative gold ")); + + // Check that mentioned scripts exist + scriptCheck(creature, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::doorCheck( @@ -455,15 +481,18 @@ void CSMTools::ReferenceableCheckStage::doorCheck( if (baseRecord.isDeleted()) return; - const ESM::Door& Door = (dynamic_cast&>(baseRecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Door, Door.mId); + const ESM::Door& door = (dynamic_cast&>(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Door, door.mId); //usual, name or model - if (Door.mName.empty()) - messages.push_back (std::make_pair (id, Door.mId + " has an empty name")); + if (door.mName.empty()) + messages.push_back (std::make_pair (id, door.mId + " has an empty name")); - if (Door.mModel.empty()) - messages.push_back (std::make_pair (id, Door.mId + " has no model")); + if (door.mModel.empty()) + messages.push_back (std::make_pair (id, door.mId + " has no model")); + + // Check that mentioned scripts exist + scriptCheck(door, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::ingredientCheck( @@ -478,10 +507,13 @@ void CSMTools::ReferenceableCheckStage::ingredientCheck( return; } - const ESM::Ingredient& Ingredient = (dynamic_cast& >(baseRecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Ingredient, Ingredient.mId); + const ESM::Ingredient& ingredient = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Ingredient, ingredient.mId); - inventoryItemCheck(Ingredient, messages, id.toString()); + inventoryItemCheck(ingredient, messages, id.toString()); + + // Check that mentioned scripts exist + scriptCheck(ingredient, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::creaturesLevListCheck( @@ -542,6 +574,9 @@ void CSMTools::ReferenceableCheckStage::lightCheck( if (light.mData.mTime == 0) messages.push_back (std::make_pair (id, light.mId + " has zero duration")); } + + // Check that mentioned scripts exist + scriptCheck(light, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::lockpickCheck( @@ -562,6 +597,9 @@ void CSMTools::ReferenceableCheckStage::lockpickCheck( inventoryItemCheck(lockpick, messages, id.toString()); toolCheck(lockpick, messages, id.toString(), true); + + // Check that mentioned scripts exist + scriptCheck(lockpick, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::miscCheck( @@ -580,6 +618,9 @@ void CSMTools::ReferenceableCheckStage::miscCheck( CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Miscellaneous, miscellaneous.mId); inventoryItemCheck(miscellaneous, messages, id.toString()); + + // Check that mentioned scripts exist + scriptCheck(miscellaneous, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::npcCheck ( @@ -697,6 +738,9 @@ void CSMTools::ReferenceableCheckStage::npcCheck ( messages.push_back (std::make_pair (id, npc.mId + " has no hair")); //TODO: reputation, Disposition, rank, everything else + + // Check that mentioned scripts exist + scriptCheck(npc, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::weaponCheck( @@ -773,6 +817,9 @@ void CSMTools::ReferenceableCheckStage::weaponCheck( messages.push_back (std::make_pair (id, weapon.mId + " has negative reach")); } } + + // Check that mentioned scripts exist + scriptCheck(weapon, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::probeCheck( @@ -792,6 +839,9 @@ void CSMTools::ReferenceableCheckStage::probeCheck( inventoryItemCheck(probe, messages, id.toString()); toolCheck(probe, messages, id.toString(), true); + + // Check that mentioned scripts exist + scriptCheck(probe, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::repairCheck ( @@ -808,6 +858,9 @@ void CSMTools::ReferenceableCheckStage::repairCheck ( inventoryItemCheck (repair, messages, id.toString()); toolCheck (repair, messages, id.toString(), true); + + // Check that mentioned scripts exist + scriptCheck(repair, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::staticCheck ( @@ -919,3 +972,13 @@ template void CSMTools::ReferenceableCheckStage::listCheck ( someList.mId + " contains item with non-positive level")); } } + +template void CSMTools::ReferenceableCheckStage::scriptCheck ( + const Tool& someTool, CSMDoc::Messages& messages, const std::string& someID) +{ + if (!someTool.mScript.empty()) + { + if (mScripts.searchId(someTool.mScript) == -1) + messages.push_back (std::make_pair (someID, someTool.mId + " refers to an unknown script \""+someTool.mScript+"\"")); + } +} diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index ac7ed70821..a34f3a7891 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -15,7 +15,8 @@ namespace CSMTools ReferenceableCheckStage (const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, const CSMWorld::IdCollection& classes, - const CSMWorld::IdCollection& factions); + const CSMWorld::IdCollection& factions, + const CSMWorld::IdCollection& scripts); virtual void perform(int stage, CSMDoc::Messages& messages); virtual int setup(); @@ -46,26 +47,30 @@ namespace CSMTools //FINAL CHECK void finalCheck (CSMDoc::Messages& messages); - //TEMPLATE CHECKS - template void inventoryItemCheck(const ITEM& someItem, + //TEMPLATE CHECKS + template void inventoryItemCheck(const ITEM& someItem, CSMDoc::Messages& messages, const std::string& someID, bool enchantable); //for all enchantable items. - template void inventoryItemCheck(const ITEM& someItem, + template void inventoryItemCheck(const ITEM& someItem, CSMDoc::Messages& messages, const std::string& someID); //for non-enchantable items. - template void toolCheck(const TOOL& someTool, + template void toolCheck(const TOOL& someTool, CSMDoc::Messages& messages, const std::string& someID, bool canbebroken); //for tools with uses. - template void toolCheck(const TOOL& someTool, + template void toolCheck(const TOOL& someTool, CSMDoc::Messages& messages, const std::string& someID); //for tools without uses. - template void listCheck(const LIST& someList, + template void listCheck(const LIST& someList, + CSMDoc::Messages& messages, + const std::string& someID); + + template void scriptCheck(const TOOL& someTool, CSMDoc::Messages& messages, const std::string& someID); @@ -73,6 +78,7 @@ namespace CSMTools const CSMWorld::IdCollection& mRaces; const CSMWorld::IdCollection& mClasses; const CSMWorld::IdCollection& mFactions; + const CSMWorld::IdCollection& mScripts; bool mPlayerPresent; }; } diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 99e462b1d2..979f724860 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -81,7 +81,7 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier() mVerifierOperation->appendStage (new SpellCheckStage (mData.getSpells())); - mVerifierOperation->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions())); + mVerifierOperation->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions(), mData.getScripts())); mVerifierOperation->appendStage (new ReferenceCheckStage(mData.getReferences(), mData.getReferenceables(), mData.getCells(), mData.getFactions())); @@ -114,7 +114,7 @@ CSMTools::Tools::Tools (CSMDoc::Document& document) connect (&mSearch, SIGNAL (done (int, bool)), this, SIGNAL (done (int, bool))); connect (&mSearch, SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)), - this, SLOT (verifierMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int))); + this, SLOT (verifierMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int))); } CSMTools::Tools::~Tools() @@ -130,7 +130,7 @@ CSMTools::Tools::~Tools() mSearch.abortAndWait(); delete mSearchOperation; } - + for (std::map::iterator iter (mReports.begin()); iter!=mReports.end(); ++iter) delete iter->second; } @@ -149,7 +149,7 @@ CSMWorld::UniversalId CSMTools::Tools::newSearch() { mReports.insert (std::make_pair (mNextReportNumber++, new ReportModel (true))); - return CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Search, mNextReportNumber-1); + return CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Search, mNextReportNumber-1); } void CSMTools::Tools::runSearch (const CSMWorld::UniversalId& searchId, const Search& search) @@ -159,11 +159,11 @@ void CSMTools::Tools::runSearch (const CSMWorld::UniversalId& searchId, const Se if (!mSearchOperation) { mSearchOperation = new SearchOperation (mDocument); - mSearch.setOperation (mSearchOperation); + mSearch.setOperation (mSearchOperation); } mSearchOperation->configure (search); - + mSearch.start(); } @@ -198,7 +198,7 @@ CSMTools::ReportModel *CSMTools::Tools::getReport (const CSMWorld::UniversalId& id.getType()!=CSMWorld::UniversalId::Type_LoadErrorLog && id.getType()!=CSMWorld::UniversalId::Type_Search) throw std::logic_error ("invalid request for report model: " + id.toString()); - + return mReports.at (id.getIndex()); } From 3a31468af07548a17d2a0cd45020bb9aa552c349 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 27 May 2015 22:12:11 +1000 Subject: [PATCH 074/119] Pathgrid record verifier. Feature #2000. --- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/model/tools/pathgridcheck.cpp | 158 ++++++++++++++++++++++ apps/opencs/model/tools/pathgridcheck.hpp | 31 +++++ apps/opencs/model/tools/tools.cpp | 3 + 4 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 apps/opencs/model/tools/pathgridcheck.cpp create mode 100644 apps/opencs/model/tools/pathgridcheck.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 438f3c6941..78b2deb7a8 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -40,7 +40,7 @@ opencs_units (model/tools opencs_units_noqt (model/tools mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck birthsigncheck spellcheck referencecheck referenceablecheck scriptcheck bodypartcheck - startscriptcheck search searchoperation searchstage + startscriptcheck search searchoperation searchstage pathgridcheck ) diff --git a/apps/opencs/model/tools/pathgridcheck.cpp b/apps/opencs/model/tools/pathgridcheck.cpp new file mode 100644 index 0000000000..71f596f4f4 --- /dev/null +++ b/apps/opencs/model/tools/pathgridcheck.cpp @@ -0,0 +1,158 @@ +#include "pathgridcheck.hpp" + +#include +#include + +#include "../world/universalid.hpp" +#include "../world/idcollection.hpp" +#include "../world/subcellcollection.hpp" +#include "../world/pathgrid.hpp" + + +CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection& pathgrids) +: mPathgrids (pathgrids) +{} + +int CSMTools::PathgridCheckStage::setup() +{ + return mPathgrids.getSize(); +} + +void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& messages) +{ + const CSMWorld::Record& record = mPathgrids.getRecord (stage); + + if (record.isDeleted()) + return; + + const CSMWorld::Pathgrid& pathgrid = record.get(); + + CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Pathgrid, pathgrid.mId); + + // check the number of pathgrid points + if (pathgrid.mData.mS2 > static_cast(pathgrid.mPoints.size())) + messages.push_back (std::make_pair (id, pathgrid.mId + " has less points than expected")); + else if (pathgrid.mData.mS2 > static_cast(pathgrid.mPoints.size())) + messages.push_back (std::make_pair (id, pathgrid.mId + " has more points than expected")); + + struct Point + { + unsigned char mConnectionNum; + std::vector mOtherIndex; + Point() : mConnectionNum(0), mOtherIndex(0) {} + }; + std::vector pointList(pathgrid.mPoints.size()); + std::vector duplList; + + for (unsigned int i = 0; i < pathgrid.mEdges.size(); ++i) + { + if (pathgrid.mEdges[i].mV0 < static_cast(pathgrid.mPoints.size()) && pathgrid.mEdges[i].mV0 >= 0) + { + pointList[pathgrid.mEdges[i].mV0].mConnectionNum++; + // first check for duplicate edges + unsigned int j = 0; + for (; j < pointList[pathgrid.mEdges[i].mV0].mOtherIndex.size(); ++j) + { + if (pointList[pathgrid.mEdges[i].mV0].mOtherIndex[j] == pathgrid.mEdges[i].mV1) + { + std::ostringstream ss; + ss << "has a duplicate edge between points" << pathgrid.mEdges[i].mV0 + << " and " << pathgrid.mEdges[i].mV1; + messages.push_back (std::make_pair (id, pathgrid.mId + ss.str())); + break; + } + } + + // only add if not a duplicate + if (j == pointList[pathgrid.mEdges[i].mV0].mOtherIndex.size()) + pointList[pathgrid.mEdges[i].mV0].mOtherIndex.push_back(pathgrid.mEdges[i].mV1); + } + else + { + std::ostringstream ss; + ss << " has an edge connecting a non-existent point " << pathgrid.mEdges[i].mV0; + messages.push_back (std::make_pair (id, pathgrid.mId + ss.str())); + } + } + + for (unsigned int i = 0; i < pathgrid.mPoints.size(); ++i) + { + // check the connection number for each point matches the edge connections + if (pathgrid.mPoints[i].mConnectionNum > pointList[i].mConnectionNum) + { + std::ostringstream ss; + ss << " has has less edges than expected for point " << i; + messages.push_back (std::make_pair (id, pathgrid.mId + ss.str())); + } + else if (pathgrid.mPoints[i].mConnectionNum < pointList[i].mConnectionNum) + { + std::ostringstream ss; + ss << " has has more edges than expected for point " << i; + messages.push_back (std::make_pair (id, pathgrid.mId + ss.str())); + } + + // check that edges are bidirectional + bool foundReverse = false; + for (unsigned int j = 0; j < pointList[i].mOtherIndex.size(); ++j) + { + for (unsigned int k = 0; k < pointList[pointList[i].mOtherIndex[j]].mOtherIndex.size(); ++k) + { + if (pointList[pointList[i].mOtherIndex[j]].mOtherIndex[k] == static_cast(i)) + { + foundReverse = true; + break; + } + } + + if (!foundReverse) + { + std::ostringstream ss; + ss << " has a missing edge between points " << i << " and " << pointList[i].mOtherIndex[j]; + messages.push_back (std::make_pair (id, pathgrid.mId + ss.str())); + } + } + + // check duplicate points + // FIXME: how to do this efficiently? + for (unsigned int j = 0; j < pathgrid.mPoints.size(); ++j) + { + if (j == i) + continue; + + if (pathgrid.mPoints[i].mX == pathgrid.mPoints[j].mX && + pathgrid.mPoints[i].mY == pathgrid.mPoints[j].mY && + pathgrid.mPoints[i].mZ == pathgrid.mPoints[j].mZ) + { + std::vector::const_iterator it = find(duplList.begin(), duplList.end(), i); + if (it == duplList.end()) + { + std::ostringstream ss; + ss << " has a duplicated point (" << i + << ") x=" << pathgrid.mPoints[i].mX + << ", y=" << pathgrid.mPoints[i].mY + << ", z=" << pathgrid.mPoints[i].mZ; + messages.push_back (std::make_pair (id, pathgrid.mId + ss.str())); + + duplList.push_back(i); + break; + } + } + } + } + + // check pathgrid points that are not connected to anything + for (unsigned int i = 0; i < pointList.size(); ++i) + { + if (pointList[i].mConnectionNum == 0) + { + std::ostringstream ss; + ss << " has an orphaned point (" << i + << ") x=" << pathgrid.mPoints[i].mX + << ", y=" << pathgrid.mPoints[i].mY + << ", z=" << pathgrid.mPoints[i].mZ; + messages.push_back (std::make_pair (id, pathgrid.mId + ss.str())); + } + } + + // TODO: check whether there are disconnected graphs +} diff --git a/apps/opencs/model/tools/pathgridcheck.hpp b/apps/opencs/model/tools/pathgridcheck.hpp new file mode 100644 index 0000000000..c90dbc8ed9 --- /dev/null +++ b/apps/opencs/model/tools/pathgridcheck.hpp @@ -0,0 +1,31 @@ +#ifndef CSM_TOOLS_PATHGRIDCHECK_H +#define CSM_TOOLS_PATHGRIDCHECK_H + +#include "../world/collection.hpp" + +#include "../doc/stage.hpp" + +namespace CSMWorld +{ + struct Pathgrid; + template + class SubCellCollection; +} + +namespace CSMTools +{ + class PathgridCheckStage : public CSMDoc::Stage + { + const CSMWorld::SubCellCollection >& mPathgrids; + + public: + + PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids); + + virtual int setup(); + + virtual void perform (int stage, CSMDoc::Messages& messages); + }; +} + +#endif // CSM_TOOLS_PATHGRIDCHECK_H diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 99e462b1d2..fd15696975 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -26,6 +26,7 @@ #include "referencecheck.hpp" #include "startscriptcheck.hpp" #include "searchoperation.hpp" +#include "pathgridcheck.hpp" CSMDoc::OperationHolder *CSMTools::Tools::get (int type) { @@ -96,6 +97,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier() CSMWorld::UniversalId( CSMWorld::UniversalId::Type_Meshes )), mData.getRaces() )); + mVerifierOperation->appendStage (new PathgridCheckStage (mData.getPathgrids())); + mVerifier.setOperation (mVerifierOperation); } From 674a124bc6efe5afeba544a5ebb9eb3fd8e855ef Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 27 May 2015 22:27:32 +1000 Subject: [PATCH 075/119] Don't use local type as a template parameter. --- apps/opencs/model/tools/pathgridcheck.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/opencs/model/tools/pathgridcheck.cpp b/apps/opencs/model/tools/pathgridcheck.cpp index 71f596f4f4..8f22cc8cd3 100644 --- a/apps/opencs/model/tools/pathgridcheck.cpp +++ b/apps/opencs/model/tools/pathgridcheck.cpp @@ -8,6 +8,15 @@ #include "../world/subcellcollection.hpp" #include "../world/pathgrid.hpp" +namespace +{ + struct Point + { + unsigned char mConnectionNum; + std::vector mOtherIndex; + Point() : mConnectionNum(0), mOtherIndex(0) {} + }; +} CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection& pathgrids) : mPathgrids (pathgrids) @@ -35,12 +44,6 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message else if (pathgrid.mData.mS2 > static_cast(pathgrid.mPoints.size())) messages.push_back (std::make_pair (id, pathgrid.mId + " has more points than expected")); - struct Point - { - unsigned char mConnectionNum; - std::vector mOtherIndex; - Point() : mConnectionNum(0), mOtherIndex(0) {} - }; std::vector pointList(pathgrid.mPoints.size()); std::vector duplList; From b6878c2e0c02bc6c3c5f8d14b96e991f2cb1f6bd Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 27 May 2015 19:45:26 +0200 Subject: [PATCH 076/119] improved error handling in LocalScripts::add --- apps/openmw/mwworld/localscripts.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/localscripts.cpp b/apps/openmw/mwworld/localscripts.cpp index 5be66ccea3..e30246f7cb 100644 --- a/apps/openmw/mwworld/localscripts.cpp +++ b/apps/openmw/mwworld/localscripts.cpp @@ -93,7 +93,7 @@ std::pair MWWorld::LocalScripts::getNext() void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr) { - if (const ESM::Script *script = mStore.get().find (scriptName)) + if (const ESM::Script *script = mStore.get().search (scriptName)) { try { @@ -108,6 +108,10 @@ void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr) << " because an exception has been thrown: " << exception.what() << std::endl; } } + else + std::cerr + << "failed to add local script " << scriptName + << " because the script does not exist." << std::endl; } void MWWorld::LocalScripts::addCell (CellStore *cell) From 00c165d3a5e1ef5b79c95d54e6edb8421e1ae7c9 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 28 May 2015 08:44:17 +1000 Subject: [PATCH 077/119] Add user preference option to check unused or redundant pathgrid points. Also resolve namespace clash issue in osx. --- apps/opencs/model/settings/usersettings.cpp | 7 ++++++ apps/opencs/model/tools/pathgridcheck.cpp | 24 ++++++++++++--------- apps/opencs/model/tools/pathgridcheck.hpp | 14 ++++++++++-- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index ea002c5edd..ea75fd6d93 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -264,6 +264,13 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() monoFont->setToolTip ("Whether to use monospaced fonts on script edit subview."); } + declareSection ("verifier", "Verifier"); + { + Setting *extraPathgrid = createSetting (Type_CheckBox, "pathgrid-extra-check", "Pathgrid: Extra Check"); + extraPathgrid->setDefaultValue ("false"); + extraPathgrid->setToolTip ("Additional checks for orphaned or duplicated pathgrid points"); + } + { /****************************************************************** * There are three types of values: diff --git a/apps/opencs/model/tools/pathgridcheck.cpp b/apps/opencs/model/tools/pathgridcheck.cpp index 8f22cc8cd3..c436cfe044 100644 --- a/apps/opencs/model/tools/pathgridcheck.cpp +++ b/apps/opencs/model/tools/pathgridcheck.cpp @@ -8,15 +8,7 @@ #include "../world/subcellcollection.hpp" #include "../world/pathgrid.hpp" -namespace -{ - struct Point - { - unsigned char mConnectionNum; - std::vector mOtherIndex; - Point() : mConnectionNum(0), mOtherIndex(0) {} - }; -} +#include "../settings/usersettings.hpp" CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection& pathgrids) : mPathgrids (pathgrids) @@ -29,6 +21,12 @@ int CSMTools::PathgridCheckStage::setup() void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& messages) { + // NOTE: This is horribly inefficient but in order to use signals the entire Stage class + // hierarchy needs to be braught under Qt which seems like an overkill for a small + // performance gain during verify operations + CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); + bool extraCheck = userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true"; + const CSMWorld::Record& record = mPathgrids.getRecord (stage); if (record.isDeleted()) @@ -44,7 +42,7 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message else if (pathgrid.mData.mS2 > static_cast(pathgrid.mPoints.size())) messages.push_back (std::make_pair (id, pathgrid.mId + " has more points than expected")); - std::vector pointList(pathgrid.mPoints.size()); + std::vector pointList(pathgrid.mPoints.size()); std::vector duplList; for (unsigned int i = 0; i < pathgrid.mEdges.size(); ++i) @@ -115,6 +113,9 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message } } + if (!extraCheck) + continue; + // check duplicate points // FIXME: how to do this efficiently? for (unsigned int j = 0; j < pathgrid.mPoints.size(); ++j) @@ -143,6 +144,9 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message } } + if (!extraCheck) + return; + // check pathgrid points that are not connected to anything for (unsigned int i = 0; i < pointList.size(); ++i) { diff --git a/apps/opencs/model/tools/pathgridcheck.hpp b/apps/opencs/model/tools/pathgridcheck.hpp index c90dbc8ed9..603235552e 100644 --- a/apps/opencs/model/tools/pathgridcheck.hpp +++ b/apps/opencs/model/tools/pathgridcheck.hpp @@ -14,13 +14,23 @@ namespace CSMWorld namespace CSMTools { + + struct Point + { + unsigned char mConnectionNum; + std::vector mOtherIndex; + Point() : mConnectionNum(0), mOtherIndex(0) {} + }; + class PathgridCheckStage : public CSMDoc::Stage { - const CSMWorld::SubCellCollection >& mPathgrids; + const CSMWorld::SubCellCollection >& mPathgrids; public: - PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids); + PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids); virtual int setup(); From 6821cb4133e0456a42ac279a3fd69b312a6b6c5e Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 29 May 2015 05:40:20 +1000 Subject: [PATCH 078/119] Use the tree model rather than a nested proxy for the dialogue only listing (i.e. non table) items. Should resolve Bug #2586. - QDataWidgetMapper requires the rootindex to be set, which was not possible with the nested proxy model. --- apps/opencs/view/world/dialoguesubview.cpp | 39 +++++++++++++--------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 5e2fa29a55..66e8fcb7a2 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -211,8 +211,17 @@ void CSVWorld::DialogueDelegateDispatcher::editorDataCommited(QWidget* editor, void CSVWorld::DialogueDelegateDispatcher::setEditorData (QWidget* editor, const QModelIndex& index) const { - CSMWorld::ColumnBase::Display display = static_cast - (mTable->headerData (index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); + CSMWorld::ColumnBase::Display display = CSMWorld::ColumnBase::Display_None; + if (index.parent().isValid()) + { + display = static_cast + (static_cast(mTable)->nestedHeaderData (index.parent().column(), index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); + } + else + { + display = static_cast + (mTable->headerData (index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); + } QLabel* label = qobject_cast(editor); if(label) @@ -523,22 +532,20 @@ void CSVWorld::EditWidget::remake(int row) } else { - mNestedModels.push_back(new CSMWorld::NestedTableProxyModel ( - static_cast(mTable)->index(row, i), - display, static_cast(mTable))); + CSMWorld::IdTree *tree = static_cast(mTable); mNestedTableMapper = new QDataWidgetMapper (this); - mNestedTableMapper->setModel(mNestedModels.back()); + mNestedTableMapper->setModel(tree); // FIXME: lack MIME support? mNestedTableDispatcher = - new DialogueDelegateDispatcher (0/*this*/, mTable, mCommandDispatcher, mDocument, mNestedModels.back()); + new DialogueDelegateDispatcher (0/*this*/, mTable, mCommandDispatcher, mDocument, tree); + mNestedTableMapper->setRootIndex (tree->index(row, i)); mNestedTableMapper->setItemDelegate(mNestedTableDispatcher); - int columnCount = - mTable->columnCount(mTable->getModelIndex (mNestedModels.back()->getParentId(), i)); + int columnCount = tree->columnCount(tree->index(row, i)); for (int col = 0; col < columnCount; ++col) { - int displayRole = mNestedModels.back()->headerData (col, + int displayRole = tree->nestedHeaderData (i, col, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt(); CSMWorld::ColumnBase::Display display = @@ -548,16 +555,16 @@ void CSVWorld::EditWidget::remake(int row) // FIXME: assumed all columns are editable QWidget* editor = - mNestedTableDispatcher->makeEditor (display, mNestedModels.back()->index (0, col)); + mNestedTableDispatcher->makeEditor (display, tree->index (0, col, tree->index(row, i))); if (editor) { mNestedTableMapper->addMapping (editor, col); - std::string disString = mNestedModels.back()->headerData (col, + std::string disString = tree->nestedHeaderData (i, col, Qt::Horizontal, Qt::DisplayRole).toString().toStdString(); - // Need ot use Qt::DisplayRole in order to get the correct string + // Need to use Qt::DisplayRole in order to get the correct string // from CSMWorld::Columns - QLabel* label = new QLabel (mNestedModels.back()->headerData (col, + QLabel* label = new QLabel (tree->nestedHeaderData (i, col, Qt::Horizontal, Qt::DisplayRole).toString(), mMainWidget); label->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed); @@ -567,14 +574,14 @@ void CSVWorld::EditWidget::remake(int row) unlockedLayout->addWidget (editor, unlocked, 1); ++unlocked; - if(mNestedModels.back()->index(0, col).data().type() == QVariant::UserType) + if(tree->index(0, col, tree->index(row, i)).data().type() == QVariant::UserType) { editor->setEnabled(false); label->setEnabled(false); } } } - mNestedTableMapper->setCurrentModelIndex(mNestedModels.back()->index(0, 0)); + mNestedTableMapper->setCurrentModelIndex(tree->index(0, 0, tree->index(row, i))); } } } From 9ad69d908529edfecdd830fd970af6ffb3451a88 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 29 May 2015 05:44:35 +1000 Subject: [PATCH 079/119] Allow wheel events in dialogue spin box types only when they have focus. Should resolve Feature #2585. --- apps/opencs/CMakeLists.txt | 1 + apps/opencs/view/world/dialoguespinbox.cpp | 53 ++++++++++++++++++++++ apps/opencs/view/world/dialoguespinbox.hpp | 40 ++++++++++++++++ apps/opencs/view/world/util.cpp | 8 ++-- 4 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 apps/opencs/view/world/dialoguespinbox.cpp create mode 100644 apps/opencs/view/world/dialoguespinbox.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 78b2deb7a8..7723b15f5e 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -63,6 +63,7 @@ opencs_units (view/world table tablesubview scriptsubview util regionmapsubview tablebottombox creator genericcreator cellcreator referenceablecreator referencecreator scenesubview infocreator scriptedit dialoguesubview previewsubview regionmap dragrecordtable nestedtable + dialoguespinbox ) opencs_units_noqt (view/world diff --git a/apps/opencs/view/world/dialoguespinbox.cpp b/apps/opencs/view/world/dialoguespinbox.cpp new file mode 100644 index 0000000000..1228ca0da9 --- /dev/null +++ b/apps/opencs/view/world/dialoguespinbox.cpp @@ -0,0 +1,53 @@ +#include "dialoguespinbox.hpp" + +#include + +CSVWorld::DialogueSpinBox::DialogueSpinBox(QWidget *parent) : QSpinBox(parent) +{ + setFocusPolicy(Qt::StrongFocus); +} + +void CSVWorld::DialogueSpinBox::focusInEvent(QFocusEvent *event) +{ + setFocusPolicy(Qt::WheelFocus); + QSpinBox::focusInEvent(event); +} + +void CSVWorld::DialogueSpinBox::focusOutEvent(QFocusEvent *event) +{ + setFocusPolicy(Qt::StrongFocus); + QSpinBox::focusOutEvent(event); +} + +void CSVWorld::DialogueSpinBox::wheelEvent(QWheelEvent *event) +{ + if (!hasFocus()) + event->ignore(); + else + QSpinBox::wheelEvent(event); +} + +CSVWorld::DialogueDoubleSpinBox::DialogueDoubleSpinBox(QWidget *parent) : QDoubleSpinBox(parent) +{ + setFocusPolicy(Qt::StrongFocus); +} + +void CSVWorld::DialogueDoubleSpinBox::focusInEvent(QFocusEvent *event) +{ + setFocusPolicy(Qt::WheelFocus); + QDoubleSpinBox::focusInEvent(event); +} + +void CSVWorld::DialogueDoubleSpinBox::focusOutEvent(QFocusEvent *event) +{ + setFocusPolicy(Qt::StrongFocus); + QDoubleSpinBox::focusOutEvent(event); +} + +void CSVWorld::DialogueDoubleSpinBox::wheelEvent(QWheelEvent *event) +{ + if (!hasFocus()) + event->ignore(); + else + QDoubleSpinBox::wheelEvent(event); +} diff --git a/apps/opencs/view/world/dialoguespinbox.hpp b/apps/opencs/view/world/dialoguespinbox.hpp new file mode 100644 index 0000000000..a68e0c3148 --- /dev/null +++ b/apps/opencs/view/world/dialoguespinbox.hpp @@ -0,0 +1,40 @@ +#ifndef CSV_WORLD_DIALOGUESPINBOX_H +#define CSV_WORLD_DIALOGUESPINBOX_H + +#include +#include + +namespace CSVWorld +{ + class DialogueSpinBox : public QSpinBox + { + Q_OBJECT + + public: + + DialogueSpinBox (QWidget *parent = 0); + + protected: + + virtual void focusInEvent(QFocusEvent *event); + virtual void focusOutEvent(QFocusEvent *event); + virtual void wheelEvent(QWheelEvent *event); + }; + + class DialogueDoubleSpinBox : public QDoubleSpinBox + { + Q_OBJECT + + public: + + DialogueDoubleSpinBox (QWidget *parent = 0); + + protected: + + virtual void focusInEvent(QFocusEvent *event); + virtual void focusOutEvent(QFocusEvent *event); + virtual void wheelEvent(QWheelEvent *event); + }; +} + +#endif // CSV_WORLD_DIALOGUESPINBOX_H diff --git a/apps/opencs/view/world/util.cpp b/apps/opencs/view/world/util.cpp index a11b5bdded..5452214ef4 100644 --- a/apps/opencs/view/world/util.cpp +++ b/apps/opencs/view/world/util.cpp @@ -9,8 +9,6 @@ #include #include #include -#include -#include #include #include #include @@ -19,7 +17,7 @@ #include "../../model/world/commands.hpp" #include "../../model/world/tablemimedata.hpp" #include "../../model/world/commanddispatcher.hpp" - +#include "dialoguespinbox.hpp" #include "scriptedit.hpp" CSVWorld::NastyTableModelHack::NastyTableModelHack (QAbstractItemModel& model) @@ -174,7 +172,7 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO case CSMWorld::ColumnBase::Display_Integer: { - QSpinBox *sb = new QSpinBox(parent); + DialogueSpinBox *sb = new DialogueSpinBox(parent); sb->setRange(INT_MIN, INT_MAX); return sb; } @@ -185,7 +183,7 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO case CSMWorld::ColumnBase::Display_Float: { - QDoubleSpinBox *dsb = new QDoubleSpinBox(parent); + DialogueDoubleSpinBox *dsb = new DialogueDoubleSpinBox(parent); dsb->setRange(-FLT_MAX, FLT_MAX); dsb->setSingleStep(0.01f); dsb->setDecimals(3); From 734e52d1c82e2f2a250c3a11fbaecd53592ee27f Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 29 May 2015 06:40:40 +1000 Subject: [PATCH 080/119] Move the user preference check to the preparation step before the running of the operation. --- apps/opencs/model/tools/pathgridcheck.cpp | 13 +++++-------- apps/opencs/model/tools/pathgridcheck.hpp | 15 ++++++++------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/apps/opencs/model/tools/pathgridcheck.cpp b/apps/opencs/model/tools/pathgridcheck.cpp index c436cfe044..58fdbeb2db 100644 --- a/apps/opencs/model/tools/pathgridcheck.cpp +++ b/apps/opencs/model/tools/pathgridcheck.cpp @@ -16,17 +16,14 @@ CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollect int CSMTools::PathgridCheckStage::setup() { + CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); + mExtraCheck = userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true"; + return mPathgrids.getSize(); } void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& messages) { - // NOTE: This is horribly inefficient but in order to use signals the entire Stage class - // hierarchy needs to be braught under Qt which seems like an overkill for a small - // performance gain during verify operations - CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - bool extraCheck = userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true"; - const CSMWorld::Record& record = mPathgrids.getRecord (stage); if (record.isDeleted()) @@ -113,7 +110,7 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message } } - if (!extraCheck) + if (!mExtraCheck) continue; // check duplicate points @@ -144,7 +141,7 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message } } - if (!extraCheck) + if (!mExtraCheck) return; // check pathgrid points that are not connected to anything diff --git a/apps/opencs/model/tools/pathgridcheck.hpp b/apps/opencs/model/tools/pathgridcheck.hpp index 603235552e..86ace6af27 100644 --- a/apps/opencs/model/tools/pathgridcheck.hpp +++ b/apps/opencs/model/tools/pathgridcheck.hpp @@ -24,17 +24,18 @@ namespace CSMTools class PathgridCheckStage : public CSMDoc::Stage { - const CSMWorld::SubCellCollection >& mPathgrids; + bool mExtraCheck; + const CSMWorld::SubCellCollection >& mPathgrids; - public: + public: - PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids); + PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids); - virtual int setup(); + virtual int setup(); - virtual void perform (int stage, CSMDoc::Messages& messages); + virtual void perform (int stage, CSMDoc::Messages& messages); }; } From 393cee406fce7f0781c55451b53efd06427d2ab7 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 29 May 2015 19:28:25 +1000 Subject: [PATCH 081/119] Use signals for user preference setting updates. --- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/model/tools/pathgridcheck.cpp | 15 +++++++++---- apps/opencs/model/tools/pathgridcheck.hpp | 7 +++++- apps/opencs/model/tools/signalhandler.cpp | 23 ++++++++++++++++++++ apps/opencs/model/tools/signalhandler.hpp | 26 +++++++++++++++++++++++ apps/opencs/model/tools/tools.cpp | 9 ++++++-- apps/opencs/model/tools/tools.hpp | 2 +- 7 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 apps/opencs/model/tools/signalhandler.cpp create mode 100644 apps/opencs/model/tools/signalhandler.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 78b2deb7a8..9ed0d6a8b1 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -34,7 +34,7 @@ opencs_hdrs_noqt (model/world opencs_units (model/tools - tools reportmodel + tools reportmodel signalhandler ) opencs_units_noqt (model/tools diff --git a/apps/opencs/model/tools/pathgridcheck.cpp b/apps/opencs/model/tools/pathgridcheck.cpp index 58fdbeb2db..2b11b70661 100644 --- a/apps/opencs/model/tools/pathgridcheck.cpp +++ b/apps/opencs/model/tools/pathgridcheck.cpp @@ -10,14 +10,21 @@ #include "../settings/usersettings.hpp" -CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection& pathgrids) -: mPathgrids (pathgrids) +#include "signalhandler.hpp" + +CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection& pathgrids, + CSMTools::SignalHandler *signalHandler) +: mPathgrids (pathgrids), mSigHandler(signalHandler) {} +CSMTools::PathgridCheckStage::~PathgridCheckStage () +{ + delete mSigHandler; +} + int CSMTools::PathgridCheckStage::setup() { - CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - mExtraCheck = userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true"; + mExtraCheck = mSigHandler->extraCheck(); return mPathgrids.getSize(); } diff --git a/apps/opencs/model/tools/pathgridcheck.hpp b/apps/opencs/model/tools/pathgridcheck.hpp index 86ace6af27..8b5dc08a7d 100644 --- a/apps/opencs/model/tools/pathgridcheck.hpp +++ b/apps/opencs/model/tools/pathgridcheck.hpp @@ -14,6 +14,7 @@ namespace CSMWorld namespace CSMTools { + class SignalHandler; struct Point { @@ -25,13 +26,17 @@ namespace CSMTools class PathgridCheckStage : public CSMDoc::Stage { bool mExtraCheck; + CSMTools::SignalHandler *mSigHandler; + const CSMWorld::SubCellCollection >& mPathgrids; public: PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids); + CSMWorld::IdAccessor >& pathgrids, CSMTools::SignalHandler *signallHandler); + + ~PathgridCheckStage (); virtual int setup(); diff --git a/apps/opencs/model/tools/signalhandler.cpp b/apps/opencs/model/tools/signalhandler.cpp new file mode 100644 index 0000000000..cfb52ed63c --- /dev/null +++ b/apps/opencs/model/tools/signalhandler.cpp @@ -0,0 +1,23 @@ +#include "signalhandler.hpp" + +#include "../settings/usersettings.hpp" + +CSMTools::SignalHandler::SignalHandler(bool extraCheck) + : mExtraCheck(extraCheck) +{ + connect (&CSMSettings::UserSettings::instance(), + SIGNAL (userSettingUpdated(const QString &, const QStringList &)), + this, + SLOT (updateUserSetting (const QString &, const QStringList &))); +} + +void CSMTools::SignalHandler::updateUserSetting (const QString &name, const QStringList &list) +{ + if (name=="verifier/pathgrid-extra-check") + mExtraCheck = list.at(0) == "true"; +} + +bool CSMTools::SignalHandler::extraCheck () +{ + return mExtraCheck; +} diff --git a/apps/opencs/model/tools/signalhandler.hpp b/apps/opencs/model/tools/signalhandler.hpp new file mode 100644 index 0000000000..c3d075fdfb --- /dev/null +++ b/apps/opencs/model/tools/signalhandler.hpp @@ -0,0 +1,26 @@ +#ifndef CSM_TOOLS_SIGNALHANDLER_H +#define CSM_TOOLS_SIGNALHANDLER_H + +#include + +namespace CSMTools +{ + class SignalHandler : public QObject + { + Q_OBJECT + + bool mExtraCheck; + + public: + + SignalHandler (bool extraCheck); + + bool extraCheck (); + + public slots: + + void updateUserSetting (const QString &name, const QStringList &list); + }; +} + +#endif diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 8d93a94332..45c7fbae35 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -10,6 +10,8 @@ #include "../world/data.hpp" #include "../world/universalid.hpp" +#include "../settings/usersettings.hpp" + #include "reportmodel.hpp" #include "mandatoryid.hpp" #include "skillcheck.hpp" @@ -27,6 +29,7 @@ #include "startscriptcheck.hpp" #include "searchoperation.hpp" #include "pathgridcheck.hpp" +#include "signalhandler.hpp" CSMDoc::OperationHolder *CSMTools::Tools::get (int type) { @@ -56,6 +59,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier() SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)), this, SLOT (verifierMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int))); + CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); + std::vector mandatoryIds; // I want C++11, damn it! mandatoryIds.push_back ("Day"); mandatoryIds.push_back ("DaysPassed"); @@ -97,7 +102,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier() CSMWorld::UniversalId( CSMWorld::UniversalId::Type_Meshes )), mData.getRaces() )); - mVerifierOperation->appendStage (new PathgridCheckStage (mData.getPathgrids())); + mVerifierOperation->appendStage (new PathgridCheckStage (mData.getPathgrids(), + new SignalHandler(userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true"))); mVerifier.setOperation (mVerifierOperation); } @@ -213,4 +219,3 @@ void CSMTools::Tools::verifierMessage (const CSMWorld::UniversalId& id, const st if (iter!=mActiveReports.end()) mReports[iter->second]->add (id, message, hint); } - diff --git a/apps/opencs/model/tools/tools.hpp b/apps/opencs/model/tools/tools.hpp index 0f9e570445..dc19cf456b 100644 --- a/apps/opencs/model/tools/tools.hpp +++ b/apps/opencs/model/tools/tools.hpp @@ -64,7 +64,7 @@ namespace CSMTools CSMWorld::UniversalId newSearch(); void runSearch (const CSMWorld::UniversalId& searchId, const Search& search); - + void abortOperation (int type); ///< \attention The operation is not aborted immediately. From 9cbda0ffada698d45e404c02775bc78d09351636 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 29 May 2015 22:20:43 +1000 Subject: [PATCH 082/119] Allow users to select syntax highlighting colours. Should resolve Feature #2507. --- apps/opencs/model/settings/usersettings.cpp | 36 +++++ apps/opencs/view/world/scriptedit.cpp | 22 ++-- apps/opencs/view/world/scriptedit.hpp | 7 +- apps/opencs/view/world/scripthighlighter.cpp | 132 +++++++++++++++++-- apps/opencs/view/world/scripthighlighter.hpp | 2 + 5 files changed, 182 insertions(+), 17 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index ea002c5edd..5b6e7ab8b7 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -262,6 +262,42 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() Setting *monoFont = createSetting (Type_CheckBox, "mono-font", "Use monospace font"); monoFont->setDefaultValue ("true"); monoFont->setToolTip ("Whether to use monospaced fonts on script edit subview."); + + QString tooltip = + "\n#RGB (each of R, G, and B is a single hex digit)" + "\n#RRGGBB" + "\n#RRRGGGBBB" + "\n#RRRRGGGGBBBB" + "\nA name from the list of colors defined in the list of SVG color keyword names." + "\nX11 color names may also work."; + + Setting *formatInt = createSetting (Type_LineEdit, "colour-int", "Highlight Colour: Int"); + formatInt->setDefaultValues (QStringList() << "Dark magenta"); + formatInt->setToolTip ("(Default: Green) Use one of the following formats:" + tooltip); + + Setting *formatFloat = createSetting (Type_LineEdit, "colour-float", "Highlight Colour: Float"); + formatFloat->setDefaultValues (QStringList() << "Magenta"); + formatFloat->setToolTip ("(Default: Magenta) Use one of the following formats:" + tooltip); + + Setting *formatName = createSetting (Type_LineEdit, "colour-name", "Highlight Colour: Name"); + formatName->setDefaultValues (QStringList() << "Gray"); + formatName->setToolTip ("(Default: Gray) Use one of the following formats:" + tooltip); + + Setting *formatKeyword = createSetting (Type_LineEdit, "colour-keyword", "Highlight Colour: Keyword"); + formatKeyword->setDefaultValues (QStringList() << "Red"); + formatKeyword->setToolTip ("(Default: Red) Use one of the following formats:" + tooltip); + + Setting *formatSpecial = createSetting (Type_LineEdit, "colour-special", "Highlight Colour: Special"); + formatSpecial->setDefaultValues (QStringList() << "Dark yellow"); + formatSpecial->setToolTip ("(Default: Dark yellow) Use one of the following formats:" + tooltip); + + Setting *formatComment = createSetting (Type_LineEdit, "colour-comment", "Highlight Colour: Comment"); + formatComment->setDefaultValues (QStringList() << "Green"); + formatComment->setToolTip ("(Default: Green) Use one of the following formats:" + tooltip); + + Setting *formatId = createSetting (Type_LineEdit, "colour-id", "Highlight Colour: Id"); + formatId->setDefaultValues (QStringList() << "Blue"); + formatId->setToolTip ("(Default: Blue) Use one of the following formats:" + tooltip); } { diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 2f0d82ae1c..ad2cddbf84 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -31,11 +31,11 @@ bool CSVWorld::ScriptEdit::event (QEvent *event) if (event->type()==QEvent::ShortcutOverride) { QKeyEvent *keyEvent = static_cast (event); - + if (keyEvent->matches (QKeySequence::Undo) || keyEvent->matches (QKeySequence::Redo)) return true; } - + return QPlainTextEdit::event (event); } @@ -92,13 +92,16 @@ CSVWorld::ScriptEdit::ScriptEdit (const CSMDoc::Document& document, ScriptHighli connect (&mUpdateTimer, SIGNAL (timeout()), this, SLOT (updateHighlighting())); + CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); + connect (&userSettings, SIGNAL (userSettingUpdated(const QString &, const QStringList &)), + this, SLOT (updateUserSetting (const QString &, const QStringList &))); + mUpdateTimer.setSingleShot (true); // TODO: provide a font selector dialogue mMonoFont.setStyleHint(QFont::TypeWriter); - std::string useMonoFont = - CSMSettings::UserSettings::instance().setting("script-editor/mono-font", "true").toStdString(); - if (useMonoFont == "true") + + if (userSettings.setting("script-editor/mono-font", "true") == "true") setFont(mMonoFont); mLineNumberArea = new LineNumberArea(this); @@ -107,10 +110,13 @@ CSVWorld::ScriptEdit::ScriptEdit (const CSMDoc::Document& document, ScriptHighli connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); - std::string showStatusBar = - CSMSettings::UserSettings::instance().settingValue("script-editor/show-linenum").toStdString(); + showLineNum(userSettings.settingValue("script-editor/show-linenum") == "true"); +} - showLineNum(showStatusBar == "true"); +void CSVWorld::ScriptEdit::updateUserSetting (const QString &name, const QStringList &list) +{ + if (mHighlighter->updateUserSetting (name, list)) + updateHighlighting(); } void CSVWorld::ScriptEdit::showLineNum(bool show) diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp index fb577e60e4..d17abf24ed 100644 --- a/apps/opencs/view/world/scriptedit.hpp +++ b/apps/opencs/view/world/scriptedit.hpp @@ -56,7 +56,7 @@ namespace CSVWorld protected: bool event (QEvent *event); - + public: ScriptEdit (const CSMDoc::Document& document, ScriptHighlighter::Mode mode, @@ -96,7 +96,12 @@ namespace CSVWorld void updateHighlighting(); void updateLineNumberAreaWidth(int newBlockCount); + void updateLineNumberArea(const QRect &, int); + + public slots: + + void updateUserSetting (const QString &name, const QStringList &list); }; class LineNumberArea : public QWidget diff --git a/apps/opencs/view/world/scripthighlighter.cpp b/apps/opencs/view/world/scripthighlighter.cpp index 6dda8d4faf..4923a44d89 100644 --- a/apps/opencs/view/world/scripthighlighter.cpp +++ b/apps/opencs/view/world/scripthighlighter.cpp @@ -6,6 +6,8 @@ #include #include +#include "../../model/settings/usersettings.hpp" + bool CSVWorld::ScriptHighlighter::parseInt (int value, const Compiler::TokenLoc& loc, Compiler::Scanner& scanner) { @@ -78,46 +80,77 @@ CSVWorld::ScriptHighlighter::ScriptHighlighter (const CSMWorld::Data& data, Mode : QSyntaxHighlighter (parent), Compiler::Parser (mErrorHandler, mContext), mContext (data), mMode (mode) { - /// \todo replace this with user settings + CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); + + QColor color = QColor(); + { + color.setNamedColor(userSettings.setting("script-editor/colour-int", "Dark magenta")); + if (!color.isValid()) + color = QColor(Qt::darkMagenta); + QTextCharFormat format; - format.setForeground (Qt::darkMagenta); + format.setForeground (color); mScheme.insert (std::make_pair (Type_Int, format)); } { + color.setNamedColor(userSettings.setting ("script-editor/colour-float", "Magenta")); + if (!color.isValid()) + color = QColor(Qt::magenta); + QTextCharFormat format; - format.setForeground (Qt::magenta); + format.setForeground (color); mScheme.insert (std::make_pair (Type_Float, format)); } { + color.setNamedColor(userSettings.setting ("script-editor/colour-name", "Gray")); + if (!color.isValid()) + color = QColor(Qt::gray); + QTextCharFormat format; - format.setForeground (Qt::gray); + format.setForeground (color); mScheme.insert (std::make_pair (Type_Name, format)); } { + color.setNamedColor(userSettings.setting ("script-editor/colour-keyword", "Red")); + if (!color.isValid()) + color = QColor(Qt::red); + QTextCharFormat format; - format.setForeground (Qt::red); + format.setForeground (color); mScheme.insert (std::make_pair (Type_Keyword, format)); } { + color.setNamedColor(userSettings.setting ("script-editor/colour-special", "Dark yellow")); + if (!color.isValid()) + color = QColor(Qt::darkYellow); + QTextCharFormat format; - format.setForeground (Qt::darkYellow); + format.setForeground (color); mScheme.insert (std::make_pair (Type_Special, format)); } { + color.setNamedColor(userSettings.setting ("script-editor/colour-comment", "Green")); + if (!color.isValid()) + color = QColor(Qt::green); + QTextCharFormat format; - format.setForeground (Qt::green); + format.setForeground (color); mScheme.insert (std::make_pair (Type_Comment, format)); } { + color.setNamedColor(userSettings.setting ("script-editor/colour-id", "Blue")); + if (!color.isValid()) + color = QColor(Qt::blue); + QTextCharFormat format; - format.setForeground (Qt::blue); + format.setForeground (color); mScheme.insert (std::make_pair (Type_Id, format)); } @@ -143,3 +176,86 @@ void CSVWorld::ScriptHighlighter::invalidateIds() { mContext.invalidateIds(); } + +bool CSVWorld::ScriptHighlighter::updateUserSetting (const QString &name, const QStringList &list) +{ + if (list.empty()) + return false; + + QColor color = QColor(); + + if (name == "script-editor/colour-int") + { + color.setNamedColor(list.at(0)); + if (!color.isValid()) + return false; + + QTextCharFormat format; + format.setForeground (color); + mScheme[Type_Int] = format; + } + else if (name == "script-editor/colour-float") + { + color.setNamedColor(list.at(0)); + if (!color.isValid()) + return false; + + QTextCharFormat format; + format.setForeground (color); + mScheme[Type_Float] = format; + } + else if (name == "script-editor/colour-name") + { + color.setNamedColor(list.at(0)); + if (!color.isValid()) + return false; + + QTextCharFormat format; + format.setForeground (color); + mScheme[Type_Name] = format; + } + else if (name == "script-editor/colour-keyword") + { + color.setNamedColor(list.at(0)); + if (!color.isValid()) + return false; + + QTextCharFormat format; + format.setForeground (color); + mScheme[Type_Keyword] = format; + } + else if (name == "script-editor/colour-special") + { + color.setNamedColor(list.at(0)); + if (!color.isValid()) + return false; + + QTextCharFormat format; + format.setForeground (color); + mScheme[Type_Special] = format; + } + else if (name == "script-editor/colour-comment") + { + color.setNamedColor(list.at(0)); + if (!color.isValid()) + return false; + + QTextCharFormat format; + format.setForeground (color); + mScheme[Type_Comment] = format; + } + else if (name == "script-editor/colour-id") + { + color.setNamedColor(list.at(0)); + if (!color.isValid()) + return false; + + QTextCharFormat format; + format.setForeground (color); + mScheme[Type_Id] = format; + } + else + return false; + + return true; +} diff --git a/apps/opencs/view/world/scripthighlighter.hpp b/apps/opencs/view/world/scripthighlighter.hpp index 953f2f953a..6f1f58e823 100644 --- a/apps/opencs/view/world/scripthighlighter.hpp +++ b/apps/opencs/view/world/scripthighlighter.hpp @@ -87,6 +87,8 @@ namespace CSVWorld virtual void highlightBlock (const QString& text); void invalidateIds(); + + bool updateUserSetting (const QString &name, const QStringList &list); }; } From 0aaac59cc3cfdd834ed36d3585ffc96b38237f67 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 30 May 2015 08:37:58 +1000 Subject: [PATCH 083/119] Return to startup dialog when the open/create action is cancelled. Should resolve Bug #2588. --- apps/opencs/editor.cpp | 30 +++++++++++++++++++++++ apps/opencs/editor.hpp | 2 ++ apps/opencs/model/doc/documentmanager.cpp | 5 ++++ apps/opencs/model/doc/documentmanager.hpp | 2 ++ apps/opencs/view/doc/newgame.cpp | 6 +++++ apps/opencs/view/doc/newgame.hpp | 4 +++ 6 files changed, 49 insertions(+) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 53a9e9e838..84849cbbba 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -67,9 +67,11 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) connect (&mFileDialog, SIGNAL(signalCreateNewFile (const boost::filesystem::path&)), this, SLOT(createNewFile (const boost::filesystem::path&))); + connect (&mFileDialog, SIGNAL (rejected()), this, SLOT (cancelFileDialog ())); connect (&mNewGame, SIGNAL (createRequest (const boost::filesystem::path&)), this, SLOT (createNewGame (const boost::filesystem::path&))); + connect (&mNewGame, SIGNAL (cancelCreateGame()), this, SLOT (cancelCreateGame ())); } CS::Editor::~Editor () @@ -176,12 +178,40 @@ void CS::Editor::createGame() mNewGame.activateWindow(); } +void CS::Editor::cancelCreateGame() +{ + if (!mDocumentManager.isEmpty()) + return; + + mNewGame.hide(); + + if (mStartup.isHidden()) + mStartup.show(); + + mStartup.raise(); + mStartup.activateWindow(); +} + void CS::Editor::createAddon() { mStartup.hide(); mFileDialog.showDialog (CSVDoc::ContentAction_New); } +void CS::Editor::cancelFileDialog() +{ + if (!mDocumentManager.isEmpty()) + return; + + mFileDialog.hide(); + + if (mStartup.isHidden()) + mStartup.show(); + + mStartup.raise(); + mStartup.activateWindow(); +} + void CS::Editor::loadDocument() { mStartup.hide(); diff --git a/apps/opencs/editor.hpp b/apps/opencs/editor.hpp index 273f0825b8..eb85743a39 100644 --- a/apps/opencs/editor.hpp +++ b/apps/opencs/editor.hpp @@ -87,6 +87,8 @@ namespace CS void createGame(); void createAddon(); + void cancelCreateGame(); + void cancelFileDialog(); void loadDocument(); void openFiles (const boost::filesystem::path &path); diff --git a/apps/opencs/model/doc/documentmanager.cpp b/apps/opencs/model/doc/documentmanager.cpp index 2d444f2451..29d7a8d3a8 100644 --- a/apps/opencs/model/doc/documentmanager.cpp +++ b/apps/opencs/model/doc/documentmanager.cpp @@ -49,6 +49,11 @@ CSMDoc::DocumentManager::~DocumentManager() delete *iter; } +bool CSMDoc::DocumentManager::isEmpty() +{ + return mDocuments.empty(); +} + void CSMDoc::DocumentManager::addDocument (const std::vector& files, const boost::filesystem::path& savePath, bool new_) { diff --git a/apps/opencs/model/doc/documentmanager.hpp b/apps/opencs/model/doc/documentmanager.hpp index 0ae73e70c0..f3fcbf8ec6 100644 --- a/apps/opencs/model/doc/documentmanager.hpp +++ b/apps/opencs/model/doc/documentmanager.hpp @@ -59,6 +59,8 @@ namespace CSMDoc /// Ask OGRE for a list of available resources. void listResources(); + bool isEmpty(); + private: boost::filesystem::path mResDir; diff --git a/apps/opencs/view/doc/newgame.cpp b/apps/opencs/view/doc/newgame.cpp index 98681c499d..32b4837285 100644 --- a/apps/opencs/view/doc/newgame.cpp +++ b/apps/opencs/view/doc/newgame.cpp @@ -66,3 +66,9 @@ void CSVDoc::NewGameDialogue::create() { emit createRequest (mAdjusterWidget->getPath()); } + +void CSVDoc::NewGameDialogue::reject() +{ + emit cancelCreateGame (); + QDialog::reject(); +} diff --git a/apps/opencs/view/doc/newgame.hpp b/apps/opencs/view/doc/newgame.hpp index 9ad7ea1690..70e9d684b0 100644 --- a/apps/opencs/view/doc/newgame.hpp +++ b/apps/opencs/view/doc/newgame.hpp @@ -36,11 +36,15 @@ namespace CSVDoc void createRequest (const boost::filesystem::path& file); + void cancelCreateGame (); + private slots: void stateChanged (bool valid); void create(); + + void reject(); }; } From 76196d815dcd4172b16a751352a52b056b5ab58b Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 30 May 2015 18:58:33 +1000 Subject: [PATCH 084/119] Update user preference setting value via an event message queue. --- apps/opencs/model/tools/signalhandler.cpp | 14 ++++++++++++-- apps/opencs/model/tools/signalhandler.hpp | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/tools/signalhandler.cpp b/apps/opencs/model/tools/signalhandler.cpp index cfb52ed63c..64e5ead557 100644 --- a/apps/opencs/model/tools/signalhandler.cpp +++ b/apps/opencs/model/tools/signalhandler.cpp @@ -1,5 +1,7 @@ #include "signalhandler.hpp" +#include + #include "../settings/usersettings.hpp" CSMTools::SignalHandler::SignalHandler(bool extraCheck) @@ -11,12 +13,20 @@ CSMTools::SignalHandler::SignalHandler(bool extraCheck) SLOT (updateUserSetting (const QString &, const QStringList &))); } +// called from the main thread void CSMTools::SignalHandler::updateUserSetting (const QString &name, const QStringList &list) { - if (name=="verifier/pathgrid-extra-check") - mExtraCheck = list.at(0) == "true"; + if (name=="verifier/pathgrid-extra-check" && !list.empty()) + QMetaObject::invokeMethod(this, "updateExtraCheck", Qt::AutoConnection, Q_ARG(bool, list.at(0) == "true")); } +// should be in the operations thread via an event message queue +void CSMTools::SignalHandler::updateExtraCheck (bool extraCheck) +{ + mExtraCheck = extraCheck; +} + +// called from the operations thread bool CSMTools::SignalHandler::extraCheck () { return mExtraCheck; diff --git a/apps/opencs/model/tools/signalhandler.hpp b/apps/opencs/model/tools/signalhandler.hpp index c3d075fdfb..bc063ebd69 100644 --- a/apps/opencs/model/tools/signalhandler.hpp +++ b/apps/opencs/model/tools/signalhandler.hpp @@ -20,6 +20,10 @@ namespace CSMTools public slots: void updateUserSetting (const QString &name, const QStringList &list); + + private slots: + + void updateExtraCheck (bool extraCheck); }; } From 01eba7b721be21a71f54431721b0da039d7c1074 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 30 May 2015 19:17:42 +1000 Subject: [PATCH 085/119] Extra check for thread affinity. --- apps/opencs/model/tools/signalhandler.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/opencs/model/tools/signalhandler.cpp b/apps/opencs/model/tools/signalhandler.cpp index 64e5ead557..2e94e1f872 100644 --- a/apps/opencs/model/tools/signalhandler.cpp +++ b/apps/opencs/model/tools/signalhandler.cpp @@ -1,6 +1,7 @@ #include "signalhandler.hpp" #include +#include #include "../settings/usersettings.hpp" @@ -23,6 +24,13 @@ void CSMTools::SignalHandler::updateUserSetting (const QString &name, const QStr // should be in the operations thread via an event message queue void CSMTools::SignalHandler::updateExtraCheck (bool extraCheck) { + if (thread()!=QThread::currentThread()) + { + QMetaObject::invokeMethod(this,"updateExtraCheck", Qt::QueuedConnection, Q_ARG(bool, extraCheck)); + return; + } + + // extra safety mExtraCheck = extraCheck; } From 88d5aed62d65e2798bf6f21f8e2b053f9af77fd8 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 30 May 2015 12:05:35 +0200 Subject: [PATCH 086/119] removed code that interfered with the default window size on Linux (Fixes #2568) --- apps/opencs/view/doc/view.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 5e3df27399..fca9b27157 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -404,11 +404,7 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to width = std::max(width, 300); height = std::max(height, 300); - // trick to get the window decorations and their sizes - show(); - hide(); - resize (width - (frameGeometry().width() - geometry().width()), - height - (frameGeometry().height() - geometry().height())); + resize (width, height); mSubViewWindow.setDockOptions (QMainWindow::AllowNestedDocks); From c4aa3d3ee319a884e77f05313f3a4441cd6f98dc Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 30 May 2015 21:12:47 +1000 Subject: [PATCH 087/119] Revert user preference setting checks until a thread safe method is worked out. The OSX namespace issue is retained. --- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/model/settings/usersettings.cpp | 7 ---- apps/opencs/model/tools/pathgridcheck.cpp | 22 +---------- apps/opencs/model/tools/pathgridcheck.hpp | 9 +---- apps/opencs/model/tools/signalhandler.cpp | 41 --------------------- apps/opencs/model/tools/signalhandler.hpp | 30 --------------- apps/opencs/model/tools/tools.cpp | 9 +---- apps/opencs/model/tools/tools.hpp | 2 +- 8 files changed, 7 insertions(+), 115 deletions(-) delete mode 100644 apps/opencs/model/tools/signalhandler.cpp delete mode 100644 apps/opencs/model/tools/signalhandler.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 9ed0d6a8b1..78b2deb7a8 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -34,7 +34,7 @@ opencs_hdrs_noqt (model/world opencs_units (model/tools - tools reportmodel signalhandler + tools reportmodel ) opencs_units_noqt (model/tools diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index ea75fd6d93..ea002c5edd 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -264,13 +264,6 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() monoFont->setToolTip ("Whether to use monospaced fonts on script edit subview."); } - declareSection ("verifier", "Verifier"); - { - Setting *extraPathgrid = createSetting (Type_CheckBox, "pathgrid-extra-check", "Pathgrid: Extra Check"); - extraPathgrid->setDefaultValue ("false"); - extraPathgrid->setToolTip ("Additional checks for orphaned or duplicated pathgrid points"); - } - { /****************************************************************** * There are three types of values: diff --git a/apps/opencs/model/tools/pathgridcheck.cpp b/apps/opencs/model/tools/pathgridcheck.cpp index 2b11b70661..76edeb573d 100644 --- a/apps/opencs/model/tools/pathgridcheck.cpp +++ b/apps/opencs/model/tools/pathgridcheck.cpp @@ -8,24 +8,12 @@ #include "../world/subcellcollection.hpp" #include "../world/pathgrid.hpp" -#include "../settings/usersettings.hpp" - -#include "signalhandler.hpp" - -CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection& pathgrids, - CSMTools::SignalHandler *signalHandler) -: mPathgrids (pathgrids), mSigHandler(signalHandler) +CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection& pathgrids) +: mPathgrids (pathgrids) {} -CSMTools::PathgridCheckStage::~PathgridCheckStage () -{ - delete mSigHandler; -} - int CSMTools::PathgridCheckStage::setup() { - mExtraCheck = mSigHandler->extraCheck(); - return mPathgrids.getSize(); } @@ -117,9 +105,6 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message } } - if (!mExtraCheck) - continue; - // check duplicate points // FIXME: how to do this efficiently? for (unsigned int j = 0; j < pathgrid.mPoints.size(); ++j) @@ -148,9 +133,6 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message } } - if (!mExtraCheck) - return; - // check pathgrid points that are not connected to anything for (unsigned int i = 0; i < pointList.size(); ++i) { diff --git a/apps/opencs/model/tools/pathgridcheck.hpp b/apps/opencs/model/tools/pathgridcheck.hpp index 8b5dc08a7d..f45b5bc93a 100644 --- a/apps/opencs/model/tools/pathgridcheck.hpp +++ b/apps/opencs/model/tools/pathgridcheck.hpp @@ -14,8 +14,6 @@ namespace CSMWorld namespace CSMTools { - class SignalHandler; - struct Point { unsigned char mConnectionNum; @@ -25,18 +23,13 @@ namespace CSMTools class PathgridCheckStage : public CSMDoc::Stage { - bool mExtraCheck; - CSMTools::SignalHandler *mSigHandler; - const CSMWorld::SubCellCollection >& mPathgrids; public: PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids, CSMTools::SignalHandler *signallHandler); - - ~PathgridCheckStage (); + CSMWorld::IdAccessor >& pathgrids); virtual int setup(); diff --git a/apps/opencs/model/tools/signalhandler.cpp b/apps/opencs/model/tools/signalhandler.cpp deleted file mode 100644 index 2e94e1f872..0000000000 --- a/apps/opencs/model/tools/signalhandler.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "signalhandler.hpp" - -#include -#include - -#include "../settings/usersettings.hpp" - -CSMTools::SignalHandler::SignalHandler(bool extraCheck) - : mExtraCheck(extraCheck) -{ - connect (&CSMSettings::UserSettings::instance(), - SIGNAL (userSettingUpdated(const QString &, const QStringList &)), - this, - SLOT (updateUserSetting (const QString &, const QStringList &))); -} - -// called from the main thread -void CSMTools::SignalHandler::updateUserSetting (const QString &name, const QStringList &list) -{ - if (name=="verifier/pathgrid-extra-check" && !list.empty()) - QMetaObject::invokeMethod(this, "updateExtraCheck", Qt::AutoConnection, Q_ARG(bool, list.at(0) == "true")); -} - -// should be in the operations thread via an event message queue -void CSMTools::SignalHandler::updateExtraCheck (bool extraCheck) -{ - if (thread()!=QThread::currentThread()) - { - QMetaObject::invokeMethod(this,"updateExtraCheck", Qt::QueuedConnection, Q_ARG(bool, extraCheck)); - return; - } - - // extra safety - mExtraCheck = extraCheck; -} - -// called from the operations thread -bool CSMTools::SignalHandler::extraCheck () -{ - return mExtraCheck; -} diff --git a/apps/opencs/model/tools/signalhandler.hpp b/apps/opencs/model/tools/signalhandler.hpp deleted file mode 100644 index bc063ebd69..0000000000 --- a/apps/opencs/model/tools/signalhandler.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef CSM_TOOLS_SIGNALHANDLER_H -#define CSM_TOOLS_SIGNALHANDLER_H - -#include - -namespace CSMTools -{ - class SignalHandler : public QObject - { - Q_OBJECT - - bool mExtraCheck; - - public: - - SignalHandler (bool extraCheck); - - bool extraCheck (); - - public slots: - - void updateUserSetting (const QString &name, const QStringList &list); - - private slots: - - void updateExtraCheck (bool extraCheck); - }; -} - -#endif diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 45c7fbae35..8d93a94332 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -10,8 +10,6 @@ #include "../world/data.hpp" #include "../world/universalid.hpp" -#include "../settings/usersettings.hpp" - #include "reportmodel.hpp" #include "mandatoryid.hpp" #include "skillcheck.hpp" @@ -29,7 +27,6 @@ #include "startscriptcheck.hpp" #include "searchoperation.hpp" #include "pathgridcheck.hpp" -#include "signalhandler.hpp" CSMDoc::OperationHolder *CSMTools::Tools::get (int type) { @@ -59,8 +56,6 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier() SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)), this, SLOT (verifierMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int))); - CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - std::vector mandatoryIds; // I want C++11, damn it! mandatoryIds.push_back ("Day"); mandatoryIds.push_back ("DaysPassed"); @@ -102,8 +97,7 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier() CSMWorld::UniversalId( CSMWorld::UniversalId::Type_Meshes )), mData.getRaces() )); - mVerifierOperation->appendStage (new PathgridCheckStage (mData.getPathgrids(), - new SignalHandler(userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true"))); + mVerifierOperation->appendStage (new PathgridCheckStage (mData.getPathgrids())); mVerifier.setOperation (mVerifierOperation); } @@ -219,3 +213,4 @@ void CSMTools::Tools::verifierMessage (const CSMWorld::UniversalId& id, const st if (iter!=mActiveReports.end()) mReports[iter->second]->add (id, message, hint); } + diff --git a/apps/opencs/model/tools/tools.hpp b/apps/opencs/model/tools/tools.hpp index dc19cf456b..0f9e570445 100644 --- a/apps/opencs/model/tools/tools.hpp +++ b/apps/opencs/model/tools/tools.hpp @@ -64,7 +64,7 @@ namespace CSMTools CSMWorld::UniversalId newSearch(); void runSearch (const CSMWorld::UniversalId& searchId, const Search& search); - + void abortOperation (int type); ///< \attention The operation is not aborted immediately. From 87a1f9f9aa2e05db33df52b3a35efe94e9935988 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Sat, 30 May 2015 15:31:44 +0300 Subject: [PATCH 088/119] Add ID completion manager --- apps/opencs/CMakeLists.txt | 1 + .../model/world/idcompletionmanager.cpp | 121 ++++++++++++++++++ .../model/world/idcompletionmanager.hpp | 38 ++++++ 3 files changed, 160 insertions(+) create mode 100644 apps/opencs/model/world/idcompletionmanager.cpp create mode 100644 apps/opencs/model/world/idcompletionmanager.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 7723b15f5e..99ba54ac1c 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -26,6 +26,7 @@ opencs_units_noqt (model/world universalid record commands columnbase scriptcontext cell refidcollection refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection tablemimedata cellcoordinates cellselection resources resourcesmanager scope pathgrid landtexture land nestedtablewrapper nestedcollection nestedcoladapterimp nestedinfocollection + idcompletionmanager ) opencs_hdrs_noqt (model/world diff --git a/apps/opencs/model/world/idcompletionmanager.cpp b/apps/opencs/model/world/idcompletionmanager.cpp new file mode 100644 index 0000000000..ca614dcd9e --- /dev/null +++ b/apps/opencs/model/world/idcompletionmanager.cpp @@ -0,0 +1,121 @@ +#include "idcompletionmanager.hpp" + +#include + +#include + +#include "data.hpp" +#include "idtablebase.hpp" + +namespace +{ + std::map generateModelTypes() + { + std::map types; + + types[CSMWorld::Columns::ColumnId_Actor] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::Columns::ColumnId_AreaObject] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::Columns::ColumnId_AreaSound] = CSMWorld::UniversalId::Type_Sound; + types[CSMWorld::Columns::ColumnId_BoltObject] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::Columns::ColumnId_BoltSound] = CSMWorld::UniversalId::Type_Sound; + types[CSMWorld::Columns::ColumnId_CastingObject] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::Columns::ColumnId_CastingSound] = CSMWorld::UniversalId::Type_Sound; + types[CSMWorld::Columns::ColumnId_Cell] = CSMWorld::UniversalId::Type_Cell; + types[CSMWorld::Columns::ColumnId_Class] = CSMWorld::UniversalId::Type_Class; + types[CSMWorld::Columns::ColumnId_Creature] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::Columns::ColumnId_DestinationCell] = CSMWorld::UniversalId::Type_Cell; + types[CSMWorld::Columns::ColumnId_Enchantment] = CSMWorld::UniversalId::Type_Enchantment; + types[CSMWorld::Columns::ColumnId_Faction] = CSMWorld::UniversalId::Type_Faction; + types[CSMWorld::Columns::Columnid_Hair] = CSMWorld::UniversalId::Type_Mesh; + types[CSMWorld::Columns::ColumnId_Head] = CSMWorld::UniversalId::Type_Mesh; + types[CSMWorld::Columns::ColumnId_HitObject] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::Columns::ColumnId_HitSound] = CSMWorld::UniversalId::Type_Sound; + types[CSMWorld::Columns::ColumnId_Icon] = CSMWorld::UniversalId::Type_Icon; + types[CSMWorld::Columns::ColumnId_InventoryItemId] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::Columns::ColumnId_MajorSkill1] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_MajorSkill2] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_MajorSkill3] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_MajorSkill4] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_MajorSkill5] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_MinorSkill1] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_MinorSkill2] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_MinorSkill3] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_MinorSkill4] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_MinorSkill5] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_Model] = CSMWorld::UniversalId::Type_Mesh; + types[CSMWorld::Columns::ColumnId_Owner] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::Columns::ColumnId_OwnerGlobal] = CSMWorld::UniversalId::Type_Global; + types[CSMWorld::Columns::ColumnId_Particle] = CSMWorld::UniversalId::Type_Texture; + types[CSMWorld::Columns::ColumnId_PcFaction] = CSMWorld::UniversalId::Type_Faction; + types[CSMWorld::Columns::ColumnId_Race] = CSMWorld::UniversalId::Type_Race; + types[CSMWorld::Columns::ColumnId_ReferenceableId] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::Columns::ColumnId_Region] = CSMWorld::UniversalId::Type_Region; + types[CSMWorld::Columns::ColumnId_Skill1] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_Skill2] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_Skill3] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_Skill4] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_Skill5] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_Skill6] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_Skill7] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::Columns::ColumnId_SleepEncounter] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::Columns::ColumnId_Soul] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::Columns::ColumnId_Sound] = CSMWorld::UniversalId::Type_Sound; + types[CSMWorld::Columns::ColumnId_SoundFile] = CSMWorld::UniversalId::Type_SoundRes; + types[CSMWorld::Columns::ColumnId_SoundName] = CSMWorld::UniversalId::Type_Sound; + types[CSMWorld::Columns::ColumnId_SpellId] = CSMWorld::UniversalId::Type_Spell; + types[CSMWorld::Columns::ColumnId_Script] = CSMWorld::UniversalId::Type_Script; + types[CSMWorld::Columns::ColumnId_TeleportCell] = CSMWorld::UniversalId::Type_Cell; + types[CSMWorld::Columns::ColumnId_Texture] = CSMWorld::UniversalId::Type_Texture; + types[CSMWorld::Columns::ColumnId_Trap] = CSMWorld::UniversalId::Type_Spell; + + return types; + } +} + +const std::map + CSMWorld::IdCompletionManager::sCompleterModelTypes = generateModelTypes(); + +CSMWorld::IdCompletionManager::IdCompletionManager(CSMWorld::Data &data) +{ + generateCompleters(data); +} + +bool CSMWorld::IdCompletionManager::isCompleterExistFor(CSMWorld::Columns::ColumnId id) const +{ + return mCompleters.find(id) != mCompleters.end(); +} + +boost::shared_ptr CSMWorld::IdCompletionManager::getCompleter(CSMWorld::Columns::ColumnId id) +{ + if (!isCompleterExistFor(id)) + { + throw std::logic_error("This column doesn't have an ID completer"); + } + return mCompleters[id]; +} + +void CSMWorld::IdCompletionManager::generateCompleters(CSMWorld::Data &data) +{ + typedef std::map::const_iterator ModelTypeConstIterator; + + ModelTypeConstIterator current = sCompleterModelTypes.begin(); + ModelTypeConstIterator end = sCompleterModelTypes.end(); + for (; current != end; ++current) + { + QAbstractItemModel *model = data.getTableModel(current->second); + CSMWorld::IdTableBase *table = dynamic_cast(model); + if (table != NULL) + { + int idColumn = table->searchColumnIndex(CSMWorld::Columns::ColumnId_Id); + if (idColumn != -1) + { + boost::shared_ptr completer = boost::make_shared(table); + completer->setCompletionColumn(idColumn); + // The completion role must be Qt::DisplayRole to get the ID values from the model + completer->setCompletionRole(Qt::DisplayRole); + completer->setCaseSensitivity(Qt::CaseInsensitive); + mCompleters[current->first] = completer; + } + } + } +} \ No newline at end of file diff --git a/apps/opencs/model/world/idcompletionmanager.hpp b/apps/opencs/model/world/idcompletionmanager.hpp new file mode 100644 index 0000000000..725cfa3312 --- /dev/null +++ b/apps/opencs/model/world/idcompletionmanager.hpp @@ -0,0 +1,38 @@ +#ifndef CSM_WORLD_IDCOMPLETIONMANAGER_HPP +#define CSM_WORLD_IDCOMPLETIONMANAGER_HPP + +#include + +#include + +#include "columns.hpp" +#include "universalid.hpp" + +class QCompleter; + +namespace CSMWorld +{ + class Data; + + /// \brief Creates and stores all ID completers + class IdCompletionManager + { + static const std::map sCompleterModelTypes; + + std::map > mCompleters; + + // Don't allow copying + IdCompletionManager(const IdCompletionManager &); + IdCompletionManager &operator = (const IdCompletionManager &); + + void generateCompleters(CSMWorld::Data &data); + + public: + IdCompletionManager(CSMWorld::Data &data); + + bool isCompleterExistFor(CSMWorld::Columns::ColumnId id) const; + boost::shared_ptr getCompleter(CSMWorld::Columns::ColumnId id); + }; +} + +#endif \ No newline at end of file From 19cc6b83e5c795f8b1a8b8fb9989ab84d262b1ed Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Sat, 30 May 2015 15:40:23 +0300 Subject: [PATCH 089/119] Integrate the Id completion manager into the Document class --- apps/opencs/model/doc/document.cpp | 8 +++++++- apps/opencs/model/doc/document.hpp | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index a73201ec0f..1e3d1c59b2 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -2257,7 +2257,8 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, mSavingOperation (*this, mProjectPath, encoding), mSaving (&mSavingOperation), mResDir(resDir), - mRunner (mProjectPath), mPhysics(boost::shared_ptr()) + mRunner (mProjectPath), mPhysics(boost::shared_ptr()), + mIdCompletionManager(mData) { if (mContentFiles.empty()) throw std::runtime_error ("Empty content file sequence"); @@ -2488,3 +2489,8 @@ boost::shared_ptr CSMDoc::Document::getPhysics () return mPhysics; } + +CSMWorld::IdCompletionManager &CSMDoc::Document::getIdCompletionManager() +{ + return mIdCompletionManager; +} \ No newline at end of file diff --git a/apps/opencs/model/doc/document.hpp b/apps/opencs/model/doc/document.hpp index 6b1a1fc1e8..14daeeb758 100644 --- a/apps/opencs/model/doc/document.hpp +++ b/apps/opencs/model/doc/document.hpp @@ -13,6 +13,7 @@ #include #include "../world/data.hpp" +#include "../world/idcompletionmanager.hpp" #include "../tools/tools.hpp" @@ -66,6 +67,7 @@ namespace CSMDoc Blacklist mBlacklist; Runner mRunner; boost::shared_ptr mPhysics; + CSMWorld::IdCompletionManager mIdCompletionManager; // It is important that the undo stack is declared last, because on desctruction it fires a signal, that is connected to a slot, that is // using other member variables. Unfortunately this connection is cut only in the QObject destructor, which is way too late. @@ -144,6 +146,8 @@ namespace CSMDoc boost::shared_ptr getPhysics(); + CSMWorld::IdCompletionManager &getIdCompletionManager(); + signals: void stateChanged (int state, CSMDoc::Document *document); From 33e36ee9227d88e334c8dbc9f0fd8017216d54ee Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Sat, 30 May 2015 15:51:33 +0300 Subject: [PATCH 090/119] Add the ID completion delegate --- apps/opencs/CMakeLists.txt | 2 +- .../view/world/idcompletiondelegate.cpp | 41 +++++++++++++++++++ .../view/world/idcompletiondelegate.hpp | 36 ++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 apps/opencs/view/world/idcompletiondelegate.cpp create mode 100644 apps/opencs/view/world/idcompletiondelegate.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 99ba54ac1c..efbe77ccb7 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -69,7 +69,7 @@ opencs_units (view/world opencs_units_noqt (view/world subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate - scripthighlighter idvalidator dialoguecreator physicssystem + scripthighlighter idvalidator dialoguecreator physicssystem idcompletiondelegate ) opencs_units (view/widget diff --git a/apps/opencs/view/world/idcompletiondelegate.cpp b/apps/opencs/view/world/idcompletiondelegate.cpp new file mode 100644 index 0000000000..0f309054b7 --- /dev/null +++ b/apps/opencs/view/world/idcompletiondelegate.cpp @@ -0,0 +1,41 @@ +#include "idcompletiondelegate.hpp" + +#include "../../model/world/idcompletionmanager.hpp" + +CSVWorld::IdCompletionDelegate::IdCompletionDelegate(CSMWorld::CommandDispatcher *dispatcher, + CSMDoc::Document& document, + QObject *parent) + : CommandDelegate(dispatcher, document, parent) +{} + +QWidget *CSVWorld::IdCompletionDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + return createEditor(parent, option, index, CSMWorld::ColumnBase::Display_None); +} + +QWidget *CSVWorld::IdCompletionDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem &option, + const QModelIndex &index, + CSMWorld::ColumnBase::Display display) const +{ + int columnIdData = index.data(CSMWorld::ColumnBase::Role_ColumnId).toInt(); + CSMWorld::Columns::ColumnId columnId = static_cast(columnIdData); + CSMWorld::IdCompletionManager &completionManager = getDocument().getIdCompletionManager(); + + QWidget *editor = CSVWorld::CommandDelegate::createEditor(parent, option, index, display); + QLineEdit *lineEditor = qobject_cast(editor); + if (lineEditor != NULL && completionManager.isCompleterExistFor(columnId)) + { + lineEditor->setCompleter(completionManager.getCompleter(columnId).get()); + } + return editor; +} + +CSVWorld::CommandDelegate *CSVWorld::IdCompletionDelegateFactory::makeDelegate(CSMWorld::CommandDispatcher *dispatcher, + CSMDoc::Document& document, + QObject *parent) const +{ + return new IdCompletionDelegate(dispatcher, document, parent); +} \ No newline at end of file diff --git a/apps/opencs/view/world/idcompletiondelegate.hpp b/apps/opencs/view/world/idcompletiondelegate.hpp new file mode 100644 index 0000000000..11ecc1cb9b --- /dev/null +++ b/apps/opencs/view/world/idcompletiondelegate.hpp @@ -0,0 +1,36 @@ +#ifndef CSV_WORLD_IDCOMPLETIONMANAGER_HPP +#define CSV_WORLD_IDCOMPLETIONMANAGER_HPP + +#include "util.hpp" + +namespace CSVWorld +{ + /// \brief Enables the Id completion for a column + class IdCompletionDelegate : public CommandDelegate + { + public: + IdCompletionDelegate(CSMWorld::CommandDispatcher *dispatcher, + CSMDoc::Document& document, + QObject *parent); + + virtual QWidget *createEditor (QWidget *parent, + const QStyleOptionViewItem &option, + const QModelIndex &index) const; + + virtual QWidget *createEditor (QWidget *parent, + const QStyleOptionViewItem &option, + const QModelIndex &index, + CSMWorld::ColumnBase::Display display) const; + }; + + class IdCompletionDelegateFactory : public CommandDelegateFactory + { + public: + virtual CommandDelegate *makeDelegate(CSMWorld::CommandDispatcher *dispatcher, + CSMDoc::Document& document, + QObject *parent) const; + ///< The ownership of the returned CommandDelegate is transferred to the caller. + }; +} + +#endif \ No newline at end of file From 7f2dd21c6642147a0cf7f27df29ab6559cab8938 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 30 May 2015 17:20:49 +0200 Subject: [PATCH 091/119] Fix for StartScript regression (Fixes #2590) --- apps/openmw/mwworld/store.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index d6aeeb51ed..ba8be733a0 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -366,6 +366,19 @@ namespace MWWorld inserted.first->second = scpt; } + template <> + inline void Store::load(ESM::ESMReader &esm, const std::string &id) + { + ESM::StartScript s; + s.load(esm); + s.mId = Misc::StringUtils::toLower(s.mId); + std::pair inserted = mStatic.insert(std::make_pair(s.mId, s)); + if (inserted.second) + mShared.push_back(&inserted.first->second); + else + inserted.first->second = s; + } + template <> class Store : public StoreBase { From 5e8718d8b2ba976f7e1c4a339a464f7786b047c1 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Sat, 30 May 2015 18:37:13 +0300 Subject: [PATCH 092/119] Add the ID completion delegate factory to the delegate factory collection --- apps/opencs/view/doc/viewmanager.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index 97b7aac19a..3e7c2cb972 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -16,6 +16,7 @@ #include "../world/vartypedelegate.hpp" #include "../world/recordstatusdelegate.hpp" #include "../world/idtypedelegate.hpp" +#include "../world/idcompletiondelegate.hpp" #include "../../model/settings/usersettings.hpp" @@ -60,6 +61,33 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager) mDelegateFactories->add (CSMWorld::ColumnBase::Display_RefRecordType, new CSVWorld::IdTypeDelegateFactory()); + // Columns with QLineEdit editor + static const CSMWorld::ColumnBase::Display sIdCompletionColumns[] = + { + CSMWorld::ColumnBase::Display_Class, + CSMWorld::ColumnBase::Display_Faction, + CSMWorld::ColumnBase::Display_String, + CSMWorld::ColumnBase::Display_GlobalVariable, + CSMWorld::ColumnBase::Display_Icon, + CSMWorld::ColumnBase::Display_Mesh, + CSMWorld::ColumnBase::Display_Miscellaneous, + CSMWorld::ColumnBase::Display_Music, + CSMWorld::ColumnBase::Display_None, + CSMWorld::ColumnBase::Display_Race, + CSMWorld::ColumnBase::Display_Region, + CSMWorld::ColumnBase::Display_Script, + CSMWorld::ColumnBase::Display_Skill, + CSMWorld::ColumnBase::Display_Sound, + CSMWorld::ColumnBase::Display_SoundRes, + CSMWorld::ColumnBase::Display_Texture, + CSMWorld::ColumnBase::Display_Video + }; + + for (std::size_t i = 0; i < sizeof(sIdCompletionColumns) / sizeof(CSMWorld::ColumnBase::Display); ++i) + { + mDelegateFactories->add(sIdCompletionColumns[i], new CSVWorld::IdCompletionDelegateFactory()); + } + struct Mapping { CSMWorld::ColumnBase::Display mDisplay; From 602f33bd91dfcc87da6d8a0cef37d40d2f482594 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Sat, 30 May 2015 21:30:25 +0300 Subject: [PATCH 093/119] Add ColumnId role to the IdTree data methods --- apps/opencs/model/world/idtree.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/opencs/model/world/idtree.cpp b/apps/opencs/model/world/idtree.cpp index 7351c03a77..a9ec2c4cd6 100644 --- a/apps/opencs/model/world/idtree.cpp +++ b/apps/opencs/model/world/idtree.cpp @@ -35,28 +35,26 @@ QVariant CSMWorld::IdTree::data (const QModelIndex & index, int role) const if (!index.isValid()) return QVariant(); - if ((role!=Qt::DisplayRole && role!=Qt::EditRole) || index.row() < 0 || index.column() < 0) - return QVariant(); - if (index.internalId() != 0) { std::pair parentAddress(unfoldIndexAddress(index.internalId())); + const NestableColumn *parentColumn = mNestedCollection->getNestableColumn(parentAddress.second); - if (role == Qt::EditRole && - !mNestedCollection->getNestableColumn(parentAddress.second)->nestedColumn(index.column()).isEditable()) - { + if (role == ColumnBase::Role_ColumnId) + return parentColumn->nestedColumn(index.column()).mColumnId; + + if (role == Qt::EditRole && !parentColumn->nestedColumn(index.column()).isEditable()) + return QVariant(); + + if (role != Qt::DisplayRole && role != Qt::EditRole) return QVariant(); - } return mNestedCollection->getNestedData(parentAddress.first, parentAddress.second, index.row(), index.column()); } else { - if (role==Qt::EditRole && !idCollection()->getColumn (index.column()).isEditable()) - return QVariant(); - - return idCollection()->getData (index.row(), index.column()); + return IdTable::data(index, role); } } @@ -79,6 +77,9 @@ QVariant CSMWorld::IdTree::nestedHeaderData(int section, int subSection, Qt::Ori if (role==ColumnBase::Role_Display) return parentColumn->nestedColumn(subSection).mDisplayType; + if (role==ColumnBase::Role_ColumnId) + return parentColumn->nestedColumn(subSection).mColumnId; + return QVariant(); } From e943d17b2905fb3b509662cda4800f6e5129191d Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Sat, 30 May 2015 22:01:21 +0300 Subject: [PATCH 094/119] Check for invalid index in IdTable::flags(). This prevents QCompleter from crashes --- apps/opencs/model/world/idtable.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/opencs/model/world/idtable.cpp b/apps/opencs/model/world/idtable.cpp index 04aa271ccc..bde6412ece 100644 --- a/apps/opencs/model/world/idtable.cpp +++ b/apps/opencs/model/world/idtable.cpp @@ -84,6 +84,9 @@ bool CSMWorld::IdTable::setData (const QModelIndex &index, const QVariant &value Qt::ItemFlags CSMWorld::IdTable::flags (const QModelIndex & index) const { + if (!index.isValid()) + return 0; + Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled; if (mIdCollection->getColumn (index.column()).isUserEditable()) From 994c6833bcd91f72d00d1784a227dfcc14f0cfbc Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Sat, 30 May 2015 23:54:16 +0300 Subject: [PATCH 095/119] Add missing columns for the ID completion --- apps/opencs/model/world/idcompletionmanager.cpp | 11 +++++++++-- apps/opencs/view/doc/viewmanager.cpp | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/world/idcompletionmanager.cpp b/apps/opencs/model/world/idcompletionmanager.cpp index ca614dcd9e..c9e135c834 100644 --- a/apps/opencs/model/world/idcompletionmanager.cpp +++ b/apps/opencs/model/world/idcompletionmanager.cpp @@ -22,16 +22,19 @@ namespace types[CSMWorld::Columns::ColumnId_CastingSound] = CSMWorld::UniversalId::Type_Sound; types[CSMWorld::Columns::ColumnId_Cell] = CSMWorld::UniversalId::Type_Cell; types[CSMWorld::Columns::ColumnId_Class] = CSMWorld::UniversalId::Type_Class; + types[CSMWorld::Columns::ColumnId_CloseSound] = CSMWorld::UniversalId::Type_Sound; types[CSMWorld::Columns::ColumnId_Creature] = CSMWorld::UniversalId::Type_Referenceable; types[CSMWorld::Columns::ColumnId_DestinationCell] = CSMWorld::UniversalId::Type_Cell; types[CSMWorld::Columns::ColumnId_Enchantment] = CSMWorld::UniversalId::Type_Enchantment; types[CSMWorld::Columns::ColumnId_Faction] = CSMWorld::UniversalId::Type_Faction; - types[CSMWorld::Columns::Columnid_Hair] = CSMWorld::UniversalId::Type_Mesh; - types[CSMWorld::Columns::ColumnId_Head] = CSMWorld::UniversalId::Type_Mesh; + types[CSMWorld::Columns::Columnid_Hair] = CSMWorld::UniversalId::Type_BodyPart; + types[CSMWorld::Columns::ColumnId_Head] = CSMWorld::UniversalId::Type_BodyPart; types[CSMWorld::Columns::ColumnId_HitObject] = CSMWorld::UniversalId::Type_Referenceable; types[CSMWorld::Columns::ColumnId_HitSound] = CSMWorld::UniversalId::Type_Sound; types[CSMWorld::Columns::ColumnId_Icon] = CSMWorld::UniversalId::Type_Icon; types[CSMWorld::Columns::ColumnId_InventoryItemId] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::Columns::ColumnId_Key] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::Columns::ColumnId_LevelledItemId] = CSMWorld::UniversalId::Type_Referenceable; types[CSMWorld::Columns::ColumnId_MajorSkill1] = CSMWorld::UniversalId::Type_Skill; types[CSMWorld::Columns::ColumnId_MajorSkill2] = CSMWorld::UniversalId::Type_Skill; types[CSMWorld::Columns::ColumnId_MajorSkill3] = CSMWorld::UniversalId::Type_Skill; @@ -43,9 +46,13 @@ namespace types[CSMWorld::Columns::ColumnId_MinorSkill4] = CSMWorld::UniversalId::Type_Skill; types[CSMWorld::Columns::ColumnId_MinorSkill5] = CSMWorld::UniversalId::Type_Skill; types[CSMWorld::Columns::ColumnId_Model] = CSMWorld::UniversalId::Type_Mesh; + types[CSMWorld::Columns::ColumnId_OpenSound] = CSMWorld::UniversalId::Type_Sound; + types[CSMWorld::Columns::ColumnId_OriginalCreature] = CSMWorld::UniversalId::Type_Referenceable; types[CSMWorld::Columns::ColumnId_Owner] = CSMWorld::UniversalId::Type_Referenceable; types[CSMWorld::Columns::ColumnId_OwnerGlobal] = CSMWorld::UniversalId::Type_Global; types[CSMWorld::Columns::ColumnId_Particle] = CSMWorld::UniversalId::Type_Texture; + types[CSMWorld::Columns::ColumnId_PartRefMale] = CSMWorld::UniversalId::Type_BodyPart; + types[CSMWorld::Columns::ColumnId_PartRefFemale] = CSMWorld::UniversalId::Type_BodyPart; types[CSMWorld::Columns::ColumnId_PcFaction] = CSMWorld::UniversalId::Type_Faction; types[CSMWorld::Columns::ColumnId_Race] = CSMWorld::UniversalId::Type_Race; types[CSMWorld::Columns::ColumnId_ReferenceableId] = CSMWorld::UniversalId::Type_Referenceable; diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index 3e7c2cb972..f485137032 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -64,7 +64,9 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager) // Columns with QLineEdit editor static const CSMWorld::ColumnBase::Display sIdCompletionColumns[] = { + CSMWorld::ColumnBase::Display_Cell, CSMWorld::ColumnBase::Display_Class, + CSMWorld::ColumnBase::Display_Creature, CSMWorld::ColumnBase::Display_Faction, CSMWorld::ColumnBase::Display_String, CSMWorld::ColumnBase::Display_GlobalVariable, @@ -72,15 +74,20 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager) CSMWorld::ColumnBase::Display_Mesh, CSMWorld::ColumnBase::Display_Miscellaneous, CSMWorld::ColumnBase::Display_Music, - CSMWorld::ColumnBase::Display_None, + CSMWorld::ColumnBase::Display_None, // Inplace editing (Table SubView) creates QLineEdit using Display_None + CSMWorld::ColumnBase::Display_Npc, CSMWorld::ColumnBase::Display_Race, + CSMWorld::ColumnBase::Display_Referenceable, CSMWorld::ColumnBase::Display_Region, CSMWorld::ColumnBase::Display_Script, CSMWorld::ColumnBase::Display_Skill, CSMWorld::ColumnBase::Display_Sound, CSMWorld::ColumnBase::Display_SoundRes, + CSMWorld::ColumnBase::Display_Static, + CSMWorld::ColumnBase::Display_String, CSMWorld::ColumnBase::Display_Texture, - CSMWorld::ColumnBase::Display_Video + CSMWorld::ColumnBase::Display_Video, + CSMWorld::ColumnBase::Display_Weapon }; for (std::size_t i = 0; i < sizeof(sIdCompletionColumns) / sizeof(CSMWorld::ColumnBase::Display); ++i) From 9e405b69fa74e429c23b4039365957dbdf1bc82d Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Sun, 31 May 2015 16:43:28 +0300 Subject: [PATCH 096/119] Create the custom completer popup to avoid the problem with the wrong height of the default popup --- apps/opencs/CMakeLists.txt | 2 +- .../model/world/idcompletionmanager.cpp | 7 +++++ apps/opencs/view/widget/completerpopup.cpp | 28 +++++++++++++++++++ apps/opencs/view/widget/completerpopup.hpp | 17 +++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 apps/opencs/view/widget/completerpopup.cpp create mode 100644 apps/opencs/view/widget/completerpopup.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index efbe77ccb7..37d13223a7 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -74,7 +74,7 @@ opencs_units_noqt (view/world opencs_units (view/widget scenetoolbar scenetool scenetoolmode pushbutton scenetooltoggle scenetoolrun modebutton - scenetooltoggle2 + scenetooltoggle2 completerpopup ) opencs_units (view/render diff --git a/apps/opencs/model/world/idcompletionmanager.cpp b/apps/opencs/model/world/idcompletionmanager.cpp index c9e135c834..c483a9fb54 100644 --- a/apps/opencs/model/world/idcompletionmanager.cpp +++ b/apps/opencs/model/world/idcompletionmanager.cpp @@ -4,6 +4,8 @@ #include +#include "../../view/widget/completerpopup.hpp" + #include "data.hpp" #include "idtablebase.hpp" @@ -121,6 +123,11 @@ void CSMWorld::IdCompletionManager::generateCompleters(CSMWorld::Data &data) // The completion role must be Qt::DisplayRole to get the ID values from the model completer->setCompletionRole(Qt::DisplayRole); completer->setCaseSensitivity(Qt::CaseInsensitive); + + QAbstractItemView *popup = new CSVWidget::CompleterPopup(); + completer->setPopup(popup); // The completer takes ownership of the popup + completer->setMaxVisibleItems(10); + mCompleters[current->first] = completer; } } diff --git a/apps/opencs/view/widget/completerpopup.cpp b/apps/opencs/view/widget/completerpopup.cpp new file mode 100644 index 0000000000..ad50b76e6e --- /dev/null +++ b/apps/opencs/view/widget/completerpopup.cpp @@ -0,0 +1,28 @@ +#include "completerpopup.hpp" + +CSVWidget::CompleterPopup::CompleterPopup(QWidget *parent) + : QListView(parent) +{ + setEditTriggers(QAbstractItemView::NoEditTriggers); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setSelectionBehavior(QAbstractItemView::SelectRows); + setSelectionMode(QAbstractItemView::SingleSelection); +} + +int CSVWidget::CompleterPopup::sizeHintForRow(int row) const +{ + if (model() == NULL) + { + return -1; + } + if (row < 0 || row >= model()->rowCount()) + { + return -1; + } + + ensurePolished(); + QModelIndex index = model()->index(row, modelColumn()); + QStyleOptionViewItem option = viewOptions(); + QAbstractItemDelegate *delegate = itemDelegate(index); + return delegate->sizeHint(option, index).height(); +} \ No newline at end of file diff --git a/apps/opencs/view/widget/completerpopup.hpp b/apps/opencs/view/widget/completerpopup.hpp new file mode 100644 index 0000000000..92731ab508 --- /dev/null +++ b/apps/opencs/view/widget/completerpopup.hpp @@ -0,0 +1,17 @@ +#ifndef CSV_WIDGET_COMPLETERPOPUP_HPP +#define CSV_WIDGET_COMPLETERPOPUP_HPP + +#include + +namespace CSVWidget +{ + class CompleterPopup : public QListView + { + public: + CompleterPopup(QWidget *parent = 0); + + virtual int sizeHintForRow(int row) const; + }; +} + +#endif \ No newline at end of file From e636101725c8fe214bf18bfdab455ed81cfd3d67 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Sun, 31 May 2015 18:18:49 +0300 Subject: [PATCH 097/119] Add missing new lines at the ends of files --- apps/opencs/model/doc/document.cpp | 2 +- apps/opencs/model/world/idcompletionmanager.cpp | 2 +- apps/opencs/model/world/idcompletionmanager.hpp | 2 +- apps/opencs/view/widget/completerpopup.cpp | 2 +- apps/opencs/view/widget/completerpopup.hpp | 2 +- apps/opencs/view/world/idcompletiondelegate.cpp | 2 +- apps/opencs/view/world/idcompletiondelegate.hpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index 1e3d1c59b2..18a4f48787 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -2493,4 +2493,4 @@ boost::shared_ptr CSMDoc::Document::getPhysics () CSMWorld::IdCompletionManager &CSMDoc::Document::getIdCompletionManager() { return mIdCompletionManager; -} \ No newline at end of file +} diff --git a/apps/opencs/model/world/idcompletionmanager.cpp b/apps/opencs/model/world/idcompletionmanager.cpp index c483a9fb54..ff5ec6b4bd 100644 --- a/apps/opencs/model/world/idcompletionmanager.cpp +++ b/apps/opencs/model/world/idcompletionmanager.cpp @@ -132,4 +132,4 @@ void CSMWorld::IdCompletionManager::generateCompleters(CSMWorld::Data &data) } } } -} \ No newline at end of file +} diff --git a/apps/opencs/model/world/idcompletionmanager.hpp b/apps/opencs/model/world/idcompletionmanager.hpp index 725cfa3312..fff9868eaf 100644 --- a/apps/opencs/model/world/idcompletionmanager.hpp +++ b/apps/opencs/model/world/idcompletionmanager.hpp @@ -35,4 +35,4 @@ namespace CSMWorld }; } -#endif \ No newline at end of file +#endif diff --git a/apps/opencs/view/widget/completerpopup.cpp b/apps/opencs/view/widget/completerpopup.cpp index ad50b76e6e..5777325c83 100644 --- a/apps/opencs/view/widget/completerpopup.cpp +++ b/apps/opencs/view/widget/completerpopup.cpp @@ -25,4 +25,4 @@ int CSVWidget::CompleterPopup::sizeHintForRow(int row) const QStyleOptionViewItem option = viewOptions(); QAbstractItemDelegate *delegate = itemDelegate(index); return delegate->sizeHint(option, index).height(); -} \ No newline at end of file +} diff --git a/apps/opencs/view/widget/completerpopup.hpp b/apps/opencs/view/widget/completerpopup.hpp index 92731ab508..6857064b8f 100644 --- a/apps/opencs/view/widget/completerpopup.hpp +++ b/apps/opencs/view/widget/completerpopup.hpp @@ -14,4 +14,4 @@ namespace CSVWidget }; } -#endif \ No newline at end of file +#endif diff --git a/apps/opencs/view/world/idcompletiondelegate.cpp b/apps/opencs/view/world/idcompletiondelegate.cpp index 0f309054b7..33e1282d4c 100644 --- a/apps/opencs/view/world/idcompletiondelegate.cpp +++ b/apps/opencs/view/world/idcompletiondelegate.cpp @@ -38,4 +38,4 @@ CSVWorld::CommandDelegate *CSVWorld::IdCompletionDelegateFactory::makeDelegate(C QObject *parent) const { return new IdCompletionDelegate(dispatcher, document, parent); -} \ No newline at end of file +} diff --git a/apps/opencs/view/world/idcompletiondelegate.hpp b/apps/opencs/view/world/idcompletiondelegate.hpp index 11ecc1cb9b..979c10c343 100644 --- a/apps/opencs/view/world/idcompletiondelegate.hpp +++ b/apps/opencs/view/world/idcompletiondelegate.hpp @@ -33,4 +33,4 @@ namespace CSVWorld }; } -#endif \ No newline at end of file +#endif From dbe61115b2086fdee2649972d171db5a93c30793 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Sun, 31 May 2015 18:22:43 +0300 Subject: [PATCH 098/119] Fix the mistyping header guard in the idcompletiondelegate.hpp --- apps/opencs/view/world/idcompletiondelegate.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/view/world/idcompletiondelegate.hpp b/apps/opencs/view/world/idcompletiondelegate.hpp index 979c10c343..d2ac6874f6 100644 --- a/apps/opencs/view/world/idcompletiondelegate.hpp +++ b/apps/opencs/view/world/idcompletiondelegate.hpp @@ -1,5 +1,5 @@ -#ifndef CSV_WORLD_IDCOMPLETIONMANAGER_HPP -#define CSV_WORLD_IDCOMPLETIONMANAGER_HPP +#ifndef CSV_WORLD_IDCOMPLETIONDELEGATE_HPP +#define CSV_WORLD_IDCOMPLETIONDELEGATE_HPP #include "util.hpp" From 5dc6cdeb99907385c7ca9cf513aa46f251595e8b Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Mon, 1 Jun 2015 01:14:11 +0300 Subject: [PATCH 099/119] Scroll to the top of the topic list when dialog is started --- apps/openmw/mwgui/dialogue.cpp | 2 ++ components/widgets/list.cpp | 4 ++++ components/widgets/list.hpp | 2 ++ 3 files changed, 8 insertions(+) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 692cea952d..48b9be17db 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -364,6 +364,7 @@ namespace MWGui bool sameActor = (mPtr == actor); mPtr = actor; mTopicsList->setEnabled(true); + mTopicsList->scrollToFirstItem(); setTitle(npcName); clearChoices(); @@ -455,6 +456,7 @@ namespace MWGui mKeywordSearch.seed(Misc::StringUtils::lowerCase(*it), intptr_t(t)); } mTopicsList->adjustSize(); + mTopicsList->scrollToFirstItem(); updateHistory(); } diff --git a/components/widgets/list.cpp b/components/widgets/list.cpp index 5a79de3d1a..e1d80f0226 100644 --- a/components/widgets/list.cpp +++ b/components/widgets/list.cpp @@ -157,4 +157,8 @@ namespace Gui return mScrollView->findWidget (getName() + "_item_" + name)->castType(); } + void MWList::scrollToFirstItem() + { + mScrollView->setViewOffset(MyGUI::IntPoint(0, 0)); + } } diff --git a/components/widgets/list.hpp b/components/widgets/list.hpp index 72c8a733c1..1c24af6a4c 100644 --- a/components/widgets/list.hpp +++ b/components/widgets/list.hpp @@ -46,6 +46,8 @@ namespace Gui MyGUI::Button* getItemWidget(const std::string& name); ///< get widget for an item name, useful to set up tooltip + void scrollToFirstItem(); + virtual void setPropertyOverride(const std::string& _key, const std::string& _value); protected: From 5350ce59efec0beee86f0637e5f6412631e31b79 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Mon, 1 Jun 2015 22:42:41 +0300 Subject: [PATCH 100/119] MWList doesn't scroll to the very bottom when it's shown for first time --- components/widgets/list.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/widgets/list.cpp b/components/widgets/list.cpp index e1d80f0226..535a3cad3f 100644 --- a/components/widgets/list.cpp +++ b/components/widgets/list.cpp @@ -48,7 +48,7 @@ namespace Gui const int _scrollBarWidth = 20; // fetch this from skin? const int scrollBarWidth = scrollbarShown ? _scrollBarWidth : 0; const int spacing = 3; - size_t viewPosition = -mScrollView->getViewOffset().top; + int viewPosition = mScrollView->getViewOffset().top; while (mScrollView->getChildCount()) { @@ -99,10 +99,10 @@ namespace Gui if (!scrollbarShown && mItemHeight > mClient->getSize().height) redraw(true); - size_t viewRange = mScrollView->getCanvasSize().height; + int viewRange = mScrollView->getCanvasSize().height; if(viewPosition > viewRange) viewPosition = viewRange; - mScrollView->setViewOffset(MyGUI::IntPoint(0, viewPosition * -1)); + mScrollView->setViewOffset(MyGUI::IntPoint(0, viewPosition)); } void MWList::setPropertyOverride(const std::string &_key, const std::string &_value) From 959fe3eb8773be66219575ae161e625f03536f69 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Mon, 1 Jun 2015 23:49:40 +0300 Subject: [PATCH 101/119] Reset the scrollbar position in the topic list when DialogueWindow is closed --- apps/openmw/mwgui/dialogue.cpp | 5 +++-- components/widgets/list.cpp | 2 +- components/widgets/list.hpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 48b9be17db..0cb0475c91 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -291,7 +291,10 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu); } else + { MWBase::Environment::get().getDialogueManager()->goodbyeSelected(); + mTopicsList->scrollToTop(); + } } void DialogueWindow::onWindowResize(MyGUI::Window* _sender) @@ -364,7 +367,6 @@ namespace MWGui bool sameActor = (mPtr == actor); mPtr = actor; mTopicsList->setEnabled(true); - mTopicsList->scrollToFirstItem(); setTitle(npcName); clearChoices(); @@ -456,7 +458,6 @@ namespace MWGui mKeywordSearch.seed(Misc::StringUtils::lowerCase(*it), intptr_t(t)); } mTopicsList->adjustSize(); - mTopicsList->scrollToFirstItem(); updateHistory(); } diff --git a/components/widgets/list.cpp b/components/widgets/list.cpp index 535a3cad3f..db4092b3f8 100644 --- a/components/widgets/list.cpp +++ b/components/widgets/list.cpp @@ -157,7 +157,7 @@ namespace Gui return mScrollView->findWidget (getName() + "_item_" + name)->castType(); } - void MWList::scrollToFirstItem() + void MWList::scrollToTop() { mScrollView->setViewOffset(MyGUI::IntPoint(0, 0)); } diff --git a/components/widgets/list.hpp b/components/widgets/list.hpp index 1c24af6a4c..3efe1ff756 100644 --- a/components/widgets/list.hpp +++ b/components/widgets/list.hpp @@ -46,7 +46,7 @@ namespace Gui MyGUI::Button* getItemWidget(const std::string& name); ///< get widget for an item name, useful to set up tooltip - void scrollToFirstItem(); + void scrollToTop(); virtual void setPropertyOverride(const std::string& _key, const std::string& _value); From 2c4025ec72dfd021a9252536c2385672b74e39a5 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Tue, 2 Jun 2015 00:26:31 +0300 Subject: [PATCH 102/119] Rename the method isCompleterExistFor() to hasCompleterFor() --- apps/opencs/model/world/idcompletionmanager.cpp | 4 ++-- apps/opencs/model/world/idcompletionmanager.hpp | 2 +- apps/opencs/view/world/idcompletiondelegate.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/world/idcompletionmanager.cpp b/apps/opencs/model/world/idcompletionmanager.cpp index ff5ec6b4bd..6736e94771 100644 --- a/apps/opencs/model/world/idcompletionmanager.cpp +++ b/apps/opencs/model/world/idcompletionmanager.cpp @@ -89,14 +89,14 @@ CSMWorld::IdCompletionManager::IdCompletionManager(CSMWorld::Data &data) generateCompleters(data); } -bool CSMWorld::IdCompletionManager::isCompleterExistFor(CSMWorld::Columns::ColumnId id) const +bool CSMWorld::IdCompletionManager::hasCompleterFor(CSMWorld::Columns::ColumnId id) const { return mCompleters.find(id) != mCompleters.end(); } boost::shared_ptr CSMWorld::IdCompletionManager::getCompleter(CSMWorld::Columns::ColumnId id) { - if (!isCompleterExistFor(id)) + if (!hasCompleterFor(id)) { throw std::logic_error("This column doesn't have an ID completer"); } diff --git a/apps/opencs/model/world/idcompletionmanager.hpp b/apps/opencs/model/world/idcompletionmanager.hpp index fff9868eaf..ee75ddf248 100644 --- a/apps/opencs/model/world/idcompletionmanager.hpp +++ b/apps/opencs/model/world/idcompletionmanager.hpp @@ -30,7 +30,7 @@ namespace CSMWorld public: IdCompletionManager(CSMWorld::Data &data); - bool isCompleterExistFor(CSMWorld::Columns::ColumnId id) const; + bool hasCompleterFor(CSMWorld::Columns::ColumnId id) const; boost::shared_ptr getCompleter(CSMWorld::Columns::ColumnId id); }; } diff --git a/apps/opencs/view/world/idcompletiondelegate.cpp b/apps/opencs/view/world/idcompletiondelegate.cpp index 33e1282d4c..2a1e97f4bd 100644 --- a/apps/opencs/view/world/idcompletiondelegate.cpp +++ b/apps/opencs/view/world/idcompletiondelegate.cpp @@ -26,7 +26,7 @@ QWidget *CSVWorld::IdCompletionDelegate::createEditor(QWidget *parent, QWidget *editor = CSVWorld::CommandDelegate::createEditor(parent, option, index, display); QLineEdit *lineEditor = qobject_cast(editor); - if (lineEditor != NULL && completionManager.isCompleterExistFor(columnId)) + if (lineEditor != NULL && completionManager.hasCompleterFor(columnId)) { lineEditor->setCompleter(completionManager.getCompleter(columnId).get()); } From 6cb221f8d09cce21ccdba5cae6e3fac0f0e49b1b Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Tue, 2 Jun 2015 11:55:09 +0300 Subject: [PATCH 103/119] Some minor changes to MWList --- components/widgets/list.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/widgets/list.cpp b/components/widgets/list.cpp index db4092b3f8..df7e7d61d2 100644 --- a/components/widgets/list.cpp +++ b/components/widgets/list.cpp @@ -48,7 +48,7 @@ namespace Gui const int _scrollBarWidth = 20; // fetch this from skin? const int scrollBarWidth = scrollbarShown ? _scrollBarWidth : 0; const int spacing = 3; - int viewPosition = mScrollView->getViewOffset().top; + int viewPosition = -mScrollView->getViewOffset().top; while (mScrollView->getChildCount()) { @@ -102,7 +102,7 @@ namespace Gui int viewRange = mScrollView->getCanvasSize().height; if(viewPosition > viewRange) viewPosition = viewRange; - mScrollView->setViewOffset(MyGUI::IntPoint(0, viewPosition)); + mScrollView->setViewOffset(MyGUI::IntPoint(0, -viewPosition)); } void MWList::setPropertyOverride(const std::string &_key, const std::string &_value) From ee2763f2d4286bd63e15a72aa96424763146a5f4 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 2 Jun 2015 14:43:38 +0200 Subject: [PATCH 104/119] Allow 5th parameter for PlaceAtMe (numeric value, ignored) (Fixes #2591) --- components/compiler/extensions0.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/compiler/extensions0.cpp b/components/compiler/extensions0.cpp index c56ee2ffb5..a16e653c3a 100644 --- a/components/compiler/extensions0.cpp +++ b/components/compiler/extensions0.cpp @@ -531,7 +531,7 @@ namespace Compiler extensions.registerInstruction("placeitemcell","ccffff",opcodePlaceItemCell); extensions.registerInstruction("placeitem","cffff",opcodePlaceItem); extensions.registerInstruction("placeatpc","clfl",opcodePlaceAtPc); - extensions.registerInstruction("placeatme","clfl",opcodePlaceAtMe,opcodePlaceAtMeExplicit); + extensions.registerInstruction("placeatme","clflX",opcodePlaceAtMe,opcodePlaceAtMeExplicit); extensions.registerInstruction("modscale","f",opcodeModScale,opcodeModScaleExplicit); extensions.registerInstruction("rotate","cf",opcodeRotate,opcodeRotateExplicit); extensions.registerInstruction("rotateworld","cf",opcodeRotateWorld,opcodeRotateWorldExplicit); From f84c36b500b09300d49382cdcf4de90449aa32db Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Wed, 3 Jun 2015 00:00:39 +0300 Subject: [PATCH 105/119] CommandDelegate: extract a display type from a model if it isn't specified --- apps/opencs/model/world/idtable.cpp | 3 +++ apps/opencs/model/world/idtree.cpp | 3 +++ apps/opencs/view/world/util.cpp | 8 +++++++- apps/opencs/view/world/util.hpp | 2 ++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/world/idtable.cpp b/apps/opencs/model/world/idtable.cpp index bde6412ece..8ca19f7e96 100644 --- a/apps/opencs/model/world/idtable.cpp +++ b/apps/opencs/model/world/idtable.cpp @@ -33,6 +33,9 @@ QVariant CSMWorld::IdTable::data (const QModelIndex & index, int role) const if (index.row() < 0 || index.column() < 0) return QVariant(); + if (role==ColumnBase::Role_Display) + return QVariant(mIdCollection->getColumn(index.column()).mDisplayType); + if (role==ColumnBase::Role_ColumnId) return QVariant (getColumnId (index.column())); diff --git a/apps/opencs/model/world/idtree.cpp b/apps/opencs/model/world/idtree.cpp index a9ec2c4cd6..a3dbae4655 100644 --- a/apps/opencs/model/world/idtree.cpp +++ b/apps/opencs/model/world/idtree.cpp @@ -40,6 +40,9 @@ QVariant CSMWorld::IdTree::data (const QModelIndex & index, int role) const std::pair parentAddress(unfoldIndexAddress(index.internalId())); const NestableColumn *parentColumn = mNestedCollection->getNestableColumn(parentAddress.second); + if (role == ColumnBase::Role_Display) + return parentColumn->nestedColumn(index.column()).mColumnId; + if (role == ColumnBase::Role_ColumnId) return parentColumn->nestedColumn(index.column()).mColumnId; diff --git a/apps/opencs/view/world/util.cpp b/apps/opencs/view/world/util.cpp index 5452214ef4..3be875ffd7 100644 --- a/apps/opencs/view/world/util.cpp +++ b/apps/opencs/view/world/util.cpp @@ -111,6 +111,12 @@ CSMDoc::Document& CSVWorld::CommandDelegate::getDocument() const return mDocument; } +CSMWorld::ColumnBase::Display CSVWorld::CommandDelegate::getDisplayTypeFromIndex(const QModelIndex &index) const +{ + int rawDisplay = index.data(CSMWorld::ColumnBase::Role_Display).toInt(); + return static_cast(rawDisplay); +} + void CSVWorld::CommandDelegate::setModelDataImp (QWidget *editor, QAbstractItemModel *model, const QModelIndex& index) const { @@ -146,7 +152,7 @@ void CSVWorld::CommandDelegate::setModelData (QWidget *editor, QAbstractItemMode QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleOptionViewItem& option, const QModelIndex& index) const { - return createEditor (parent, option, index, CSMWorld::ColumnBase::Display_None); + return createEditor (parent, option, index, getDisplayTypeFromIndex(index)); } QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleOptionViewItem& option, diff --git a/apps/opencs/view/world/util.hpp b/apps/opencs/view/world/util.hpp index a12e6ae369..8355e971cb 100644 --- a/apps/opencs/view/world/util.hpp +++ b/apps/opencs/view/world/util.hpp @@ -124,6 +124,8 @@ namespace CSVWorld CSMDoc::Document& getDocument() const; + CSMWorld::ColumnBase::Display getDisplayTypeFromIndex(const QModelIndex &index) const; + virtual void setModelDataImp (QWidget *editor, QAbstractItemModel *model, const QModelIndex& index) const; From 4e759370def736689dfc3acc4f64a4aa5d77ad6b Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Wed, 3 Jun 2015 00:02:53 +0300 Subject: [PATCH 106/119] Change Display_String to the proper display type where appropriate --- apps/opencs/model/world/columnbase.cpp | 2 ++ apps/opencs/model/world/columnbase.hpp | 2 ++ apps/opencs/model/world/columnimp.hpp | 21 ++++++++++++-------- apps/opencs/model/world/data.cpp | 8 ++++---- apps/opencs/model/world/refidcollection.cpp | 22 ++++++++++----------- 5 files changed, 32 insertions(+), 23 deletions(-) diff --git a/apps/opencs/model/world/columnbase.cpp b/apps/opencs/model/world/columnbase.cpp index 3d13538c03..9385038757 100644 --- a/apps/opencs/model/world/columnbase.cpp +++ b/apps/opencs/model/world/columnbase.cpp @@ -65,6 +65,8 @@ bool CSMWorld::ColumnBase::isId (Display display) Display_JournalInfo, Display_Scene, Display_GlobalVariable, + Display_BodyPart, + Display_Enchantment, Display_Script, Display_Mesh, diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index bf8378e37b..789823d5cd 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -74,6 +74,8 @@ namespace CSMWorld Display_JournalInfo, Display_Scene, Display_GlobalVariable, + Display_BodyPart, + Display_Enchantment, //CONCRETE TYPES ENDS HERE Display_Integer, diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index 6b496e0ca7..8758d924b0 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -709,7 +709,7 @@ namespace CSMWorld struct SleepListColumn : public Column { SleepListColumn() - : Column (Columns::ColumnId_SleepEncounter, ColumnBase::Display_String) + : Column (Columns::ColumnId_SleepEncounter, ColumnBase::Display_CreatureLevelledList) {} virtual QVariant get (const Record& record) const @@ -735,7 +735,7 @@ namespace CSMWorld template struct TextureColumn : public Column { - TextureColumn() : Column (Columns::ColumnId_Texture, ColumnBase::Display_String) {} + TextureColumn() : Column (Columns::ColumnId_Texture, ColumnBase::Display_Texture) {} virtual QVariant get (const Record& record) const { @@ -1269,7 +1269,7 @@ namespace CSMWorld template struct TrapColumn : public Column { - TrapColumn() : Column (Columns::ColumnId_Trap, ColumnBase::Display_String) {} + TrapColumn() : Column (Columns::ColumnId_Trap, ColumnBase::Display_Spell) {} virtual QVariant get (const Record& record) const { @@ -1294,7 +1294,7 @@ namespace CSMWorld template struct FilterColumn : public Column { - FilterColumn() : Column (Columns::ColumnId_Filter, ColumnBase::Display_String) {} + FilterColumn() : Column (Columns::ColumnId_Filter, ColumnBase::Display_Filter) {} virtual QVariant get (const Record& record) const { @@ -1497,7 +1497,10 @@ namespace CSMWorld template struct TopicColumn : public Column { - TopicColumn (bool journal) : Column (journal ? Columns::ColumnId_Journal : Columns::ColumnId_Topic, ColumnBase::Display_String) {} + TopicColumn (bool journal) + : Column (journal ? Columns::ColumnId_Journal : Columns::ColumnId_Topic, + journal ? ColumnBase::Display_Journal : ColumnBase::Display_Topic) + {} virtual QVariant get (const Record& record) const { @@ -1527,7 +1530,7 @@ namespace CSMWorld template struct ActorColumn : public Column { - ActorColumn() : Column (Columns::ColumnId_Actor, ColumnBase::Display_String) {} + ActorColumn() : Column (Columns::ColumnId_Actor, ColumnBase::Display_Npc) {} virtual QVariant get (const Record& record) const { @@ -1830,7 +1833,7 @@ namespace CSMWorld template struct ModelColumn : public Column { - ModelColumn() : Column (Columns::ColumnId_Model, ColumnBase::Display_String) {} + ModelColumn() : Column (Columns::ColumnId_Model, ColumnBase::Display_Mesh) {} virtual QVariant get (const Record& record) const { @@ -2158,7 +2161,9 @@ namespace CSMWorld struct EffectTextureColumn : public Column { EffectTextureColumn (Columns::ColumnId columnId) - : Column (columnId, ColumnBase::Display_Texture) + : Column (columnId, + columnId == Columns::ColumnId_Particle ? ColumnBase::Display_Texture + : ColumnBase::Display_Icon) { assert (this->mColumnId==Columns::ColumnId_Icon || this->mColumnId==Columns::ColumnId_Particle); diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index c27c068f10..529c8f88f9 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -115,7 +115,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc index = mFactions.getColumns()-1; mFactions.addAdapter (std::make_pair(&mFactions.getColumn(index), new FactionReactionsAdapter ())); mFactions.getNestableColumn(index)->addColumn( - new NestedChildColumn (Columns::ColumnId_Faction, ColumnBase::Display_String)); + new NestedChildColumn (Columns::ColumnId_Faction, ColumnBase::Display_Faction)); mFactions.getNestableColumn(index)->addColumn( new NestedChildColumn (Columns::ColumnId_FactionReaction, ColumnBase::Display_Integer)); @@ -135,7 +135,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc index = mRaces.getColumns()-1; mRaces.addAdapter (std::make_pair(&mRaces.getColumn(index), new SpellListAdapter ())); mRaces.getNestableColumn(index)->addColumn( - new NestedChildColumn (Columns::ColumnId_SpellId, ColumnBase::Display_String)); + new NestedChildColumn (Columns::ColumnId_SpellId, ColumnBase::Display_Spell)); // Race attributes mRaces.addColumn (new NestedParentColumn (Columns::ColumnId_RaceAttributes)); index = mRaces.getColumns()-1; @@ -180,7 +180,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc index = mRegions.getColumns()-1; mRegions.addAdapter (std::make_pair(&mRegions.getColumn(index), new RegionSoundListAdapter ())); mRegions.getNestableColumn(index)->addColumn( - new NestedChildColumn (Columns::ColumnId_SoundName, ColumnBase::Display_String)); + new NestedChildColumn (Columns::ColumnId_SoundName, ColumnBase::Display_Sound)); mRegions.getNestableColumn(index)->addColumn( new NestedChildColumn (Columns::ColumnId_SoundChance, ColumnBase::Display_Integer)); @@ -196,7 +196,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mBirthsigns.addAdapter (std::make_pair(&mBirthsigns.getColumn(index), new SpellListAdapter ())); mBirthsigns.getNestableColumn(index)->addColumn( - new NestedChildColumn (Columns::ColumnId_SpellId, ColumnBase::Display_String)); + new NestedChildColumn (Columns::ColumnId_SpellId, ColumnBase::Display_Spell)); mSpells.addColumn (new StringIdColumn); mSpells.addColumn (new RecordStateColumn); diff --git a/apps/opencs/model/world/refidcollection.cpp b/apps/opencs/model/world/refidcollection.cpp index cda19c87bb..5495926b46 100644 --- a/apps/opencs/model/world/refidcollection.cpp +++ b/apps/opencs/model/world/refidcollection.cpp @@ -99,7 +99,7 @@ CSMWorld::RefIdCollection::RefIdCollection() EnchantableColumns enchantableColumns (inventoryColumns); - mColumns.push_back (RefIdColumn (Columns::ColumnId_Enchantment, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_Enchantment, ColumnBase::Display_Enchantment)); enchantableColumns.mEnchantment = &mColumns.back(); mColumns.push_back (RefIdColumn (Columns::ColumnId_EnchantmentPoints, ColumnBase::Display_Integer)); enchantableColumns.mEnchantmentPoints = &mColumns.back(); @@ -135,7 +135,7 @@ CSMWorld::RefIdCollection::RefIdCollection() new NestedInventoryRefIdAdapter (UniversalId::Type_Creature))); mNestedAdapters.push_back (std::make_pair(&mColumns.back(), inventoryMap)); mColumns.back().addColumn( - new RefIdColumn (Columns::ColumnId_InventoryItemId, CSMWorld::ColumnBase::Display_String)); + new RefIdColumn (Columns::ColumnId_InventoryItemId, CSMWorld::ColumnBase::Display_Referenceable)); mColumns.back().addColumn( new RefIdColumn (Columns::ColumnId_ItemCount, CSMWorld::ColumnBase::Display_Integer)); @@ -150,7 +150,7 @@ CSMWorld::RefIdCollection::RefIdCollection() new NestedSpellRefIdAdapter (UniversalId::Type_Creature))); mNestedAdapters.push_back (std::make_pair(&mColumns.back(), spellsMap)); mColumns.back().addColumn( - new RefIdColumn (Columns::ColumnId_SpellId, CSMWorld::ColumnBase::Display_String)); + new RefIdColumn (Columns::ColumnId_SpellId, CSMWorld::ColumnBase::Display_Spell)); // Nested table mColumns.push_back(RefIdColumn (Columns::ColumnId_NpcDestinations, @@ -163,7 +163,7 @@ CSMWorld::RefIdCollection::RefIdCollection() new NestedTravelRefIdAdapter (UniversalId::Type_Creature))); mNestedAdapters.push_back (std::make_pair(&mColumns.back(), destMap)); mColumns.back().addColumn( - new RefIdColumn (Columns::ColumnId_DestinationCell, CSMWorld::ColumnBase::Display_String)); + new RefIdColumn (Columns::ColumnId_DestinationCell, CSMWorld::ColumnBase::Display_Cell)); mColumns.back().addColumn( new RefIdColumn (Columns::ColumnId_PosX, CSMWorld::ColumnBase::Display_Float)); mColumns.back().addColumn( @@ -289,7 +289,7 @@ CSMWorld::RefIdCollection::RefIdCollection() new NestedInventoryRefIdAdapter (UniversalId::Type_Container))); mNestedAdapters.push_back (std::make_pair(&mColumns.back(), contMap)); mColumns.back().addColumn( - new RefIdColumn (Columns::ColumnId_InventoryItemId, CSMWorld::ColumnBase::Display_String)); + new RefIdColumn (Columns::ColumnId_InventoryItemId, CSMWorld::ColumnBase::Display_Referenceable)); mColumns.back().addColumn( new RefIdColumn (Columns::ColumnId_ItemCount, CSMWorld::ColumnBase::Display_Integer)); @@ -301,7 +301,7 @@ CSMWorld::RefIdCollection::RefIdCollection() creatureColumns.mSoul = &mColumns.back(); mColumns.push_back (RefIdColumn (Columns::ColumnId_Scale, ColumnBase::Display_Float)); creatureColumns.mScale = &mColumns.back(); - mColumns.push_back (RefIdColumn (Columns::ColumnId_OriginalCreature, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_OriginalCreature, ColumnBase::Display_Creature)); creatureColumns.mOriginal = &mColumns.back(); mColumns.push_back ( RefIdColumn (Columns::ColumnId_CombatState, ColumnBase::Display_Integer)); @@ -409,10 +409,10 @@ CSMWorld::RefIdCollection::RefIdCollection() mColumns.push_back (RefIdColumn (Columns::ColumnId_Faction, ColumnBase::Display_Faction)); npcColumns.mFaction = &mColumns.back(); - mColumns.push_back (RefIdColumn (Columns::Columnid_Hair, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::Columnid_Hair, ColumnBase::Display_BodyPart)); npcColumns.mHair = &mColumns.back(); - mColumns.push_back (RefIdColumn (Columns::ColumnId_Head, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_Head, ColumnBase::Display_BodyPart)); npcColumns.mHead = &mColumns.back(); mColumns.push_back (RefIdColumn (Columns::ColumnId_Female, ColumnBase::Display_Boolean)); @@ -539,9 +539,9 @@ CSMWorld::RefIdCollection::RefIdCollection() mColumns.back().addColumn( new RefIdColumn (Columns::ColumnId_PartRefType, CSMWorld::ColumnBase::Display_PartRefType)); mColumns.back().addColumn( - new RefIdColumn (Columns::ColumnId_PartRefMale, CSMWorld::ColumnBase::Display_String)); + new RefIdColumn (Columns::ColumnId_PartRefMale, CSMWorld::ColumnBase::Display_BodyPart)); mColumns.back().addColumn( - new RefIdColumn (Columns::ColumnId_PartRefFemale, CSMWorld::ColumnBase::Display_String)); + new RefIdColumn (Columns::ColumnId_PartRefFemale, CSMWorld::ColumnBase::Display_BodyPart)); LevListColumns levListColumns (baseColumns); @@ -556,7 +556,7 @@ CSMWorld::RefIdCollection::RefIdCollection() new NestedLevListRefIdAdapter (UniversalId::Type_ItemLevelledList))); mNestedAdapters.push_back (std::make_pair(&mColumns.back(), levListMap)); mColumns.back().addColumn( - new RefIdColumn (Columns::ColumnId_LevelledItemId, CSMWorld::ColumnBase::Display_String)); + new RefIdColumn (Columns::ColumnId_LevelledItemId, CSMWorld::ColumnBase::Display_Referenceable)); mColumns.back().addColumn( new RefIdColumn (Columns::ColumnId_LevelledItemLevel, CSMWorld::ColumnBase::Display_Integer)); From b25cc6bc556ff688fcf5becd4d71c3551f5681af Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Wed, 3 Jun 2015 12:01:13 +0300 Subject: [PATCH 107/119] IdCompletionManager uses Display type instread of ColumnId for creating completers --- .../model/world/idcompletionmanager.cpp | 117 +++++++----------- .../model/world/idcompletionmanager.hpp | 17 +-- apps/opencs/view/doc/viewmanager.cpp | 38 ++---- .../view/world/idcompletiondelegate.cpp | 16 ++- 4 files changed, 70 insertions(+), 118 deletions(-) diff --git a/apps/opencs/model/world/idcompletionmanager.cpp b/apps/opencs/model/world/idcompletionmanager.cpp index 6736e94771..b59987cba2 100644 --- a/apps/opencs/model/world/idcompletionmanager.cpp +++ b/apps/opencs/model/world/idcompletionmanager.cpp @@ -11,102 +11,77 @@ namespace { - std::map generateModelTypes() + std::map generateModelTypes() { - std::map types; + std::map types; - types[CSMWorld::Columns::ColumnId_Actor] = CSMWorld::UniversalId::Type_Referenceable; - types[CSMWorld::Columns::ColumnId_AreaObject] = CSMWorld::UniversalId::Type_Referenceable; - types[CSMWorld::Columns::ColumnId_AreaSound] = CSMWorld::UniversalId::Type_Sound; - types[CSMWorld::Columns::ColumnId_BoltObject] = CSMWorld::UniversalId::Type_Referenceable; - types[CSMWorld::Columns::ColumnId_BoltSound] = CSMWorld::UniversalId::Type_Sound; - types[CSMWorld::Columns::ColumnId_CastingObject] = CSMWorld::UniversalId::Type_Referenceable; - types[CSMWorld::Columns::ColumnId_CastingSound] = CSMWorld::UniversalId::Type_Sound; - types[CSMWorld::Columns::ColumnId_Cell] = CSMWorld::UniversalId::Type_Cell; - types[CSMWorld::Columns::ColumnId_Class] = CSMWorld::UniversalId::Type_Class; - types[CSMWorld::Columns::ColumnId_CloseSound] = CSMWorld::UniversalId::Type_Sound; - types[CSMWorld::Columns::ColumnId_Creature] = CSMWorld::UniversalId::Type_Referenceable; - types[CSMWorld::Columns::ColumnId_DestinationCell] = CSMWorld::UniversalId::Type_Cell; - types[CSMWorld::Columns::ColumnId_Enchantment] = CSMWorld::UniversalId::Type_Enchantment; - types[CSMWorld::Columns::ColumnId_Faction] = CSMWorld::UniversalId::Type_Faction; - types[CSMWorld::Columns::Columnid_Hair] = CSMWorld::UniversalId::Type_BodyPart; - types[CSMWorld::Columns::ColumnId_Head] = CSMWorld::UniversalId::Type_BodyPart; - types[CSMWorld::Columns::ColumnId_HitObject] = CSMWorld::UniversalId::Type_Referenceable; - types[CSMWorld::Columns::ColumnId_HitSound] = CSMWorld::UniversalId::Type_Sound; - types[CSMWorld::Columns::ColumnId_Icon] = CSMWorld::UniversalId::Type_Icon; - types[CSMWorld::Columns::ColumnId_InventoryItemId] = CSMWorld::UniversalId::Type_Referenceable; - types[CSMWorld::Columns::ColumnId_Key] = CSMWorld::UniversalId::Type_Referenceable; - types[CSMWorld::Columns::ColumnId_LevelledItemId] = CSMWorld::UniversalId::Type_Referenceable; - types[CSMWorld::Columns::ColumnId_MajorSkill1] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_MajorSkill2] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_MajorSkill3] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_MajorSkill4] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_MajorSkill5] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_MinorSkill1] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_MinorSkill2] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_MinorSkill3] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_MinorSkill4] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_MinorSkill5] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_Model] = CSMWorld::UniversalId::Type_Mesh; - types[CSMWorld::Columns::ColumnId_OpenSound] = CSMWorld::UniversalId::Type_Sound; - types[CSMWorld::Columns::ColumnId_OriginalCreature] = CSMWorld::UniversalId::Type_Referenceable; - types[CSMWorld::Columns::ColumnId_Owner] = CSMWorld::UniversalId::Type_Referenceable; - types[CSMWorld::Columns::ColumnId_OwnerGlobal] = CSMWorld::UniversalId::Type_Global; - types[CSMWorld::Columns::ColumnId_Particle] = CSMWorld::UniversalId::Type_Texture; - types[CSMWorld::Columns::ColumnId_PartRefMale] = CSMWorld::UniversalId::Type_BodyPart; - types[CSMWorld::Columns::ColumnId_PartRefFemale] = CSMWorld::UniversalId::Type_BodyPart; - types[CSMWorld::Columns::ColumnId_PcFaction] = CSMWorld::UniversalId::Type_Faction; - types[CSMWorld::Columns::ColumnId_Race] = CSMWorld::UniversalId::Type_Race; - types[CSMWorld::Columns::ColumnId_ReferenceableId] = CSMWorld::UniversalId::Type_Referenceable; - types[CSMWorld::Columns::ColumnId_Region] = CSMWorld::UniversalId::Type_Region; - types[CSMWorld::Columns::ColumnId_Skill1] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_Skill2] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_Skill3] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_Skill4] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_Skill5] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_Skill6] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_Skill7] = CSMWorld::UniversalId::Type_Skill; - types[CSMWorld::Columns::ColumnId_SleepEncounter] = CSMWorld::UniversalId::Type_Referenceable; - types[CSMWorld::Columns::ColumnId_Soul] = CSMWorld::UniversalId::Type_Referenceable; - types[CSMWorld::Columns::ColumnId_Sound] = CSMWorld::UniversalId::Type_Sound; - types[CSMWorld::Columns::ColumnId_SoundFile] = CSMWorld::UniversalId::Type_SoundRes; - types[CSMWorld::Columns::ColumnId_SoundName] = CSMWorld::UniversalId::Type_Sound; - types[CSMWorld::Columns::ColumnId_SpellId] = CSMWorld::UniversalId::Type_Spell; - types[CSMWorld::Columns::ColumnId_Script] = CSMWorld::UniversalId::Type_Script; - types[CSMWorld::Columns::ColumnId_TeleportCell] = CSMWorld::UniversalId::Type_Cell; - types[CSMWorld::Columns::ColumnId_Texture] = CSMWorld::UniversalId::Type_Texture; - types[CSMWorld::Columns::ColumnId_Trap] = CSMWorld::UniversalId::Type_Spell; + types[CSMWorld::ColumnBase::Display_BodyPart ] = CSMWorld::UniversalId::Type_BodyPart; + types[CSMWorld::ColumnBase::Display_Cell ] = CSMWorld::UniversalId::Type_Cell; + types[CSMWorld::ColumnBase::Display_Class ] = CSMWorld::UniversalId::Type_Class; + types[CSMWorld::ColumnBase::Display_CreatureLevelledList] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::ColumnBase::Display_Creature ] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::ColumnBase::Display_Enchantment ] = CSMWorld::UniversalId::Type_Enchantment; + types[CSMWorld::ColumnBase::Display_Faction ] = CSMWorld::UniversalId::Type_Faction; + types[CSMWorld::ColumnBase::Display_GlobalVariable ] = CSMWorld::UniversalId::Type_Global; + types[CSMWorld::ColumnBase::Display_Icon ] = CSMWorld::UniversalId::Type_Icon; + types[CSMWorld::ColumnBase::Display_Mesh ] = CSMWorld::UniversalId::Type_Mesh; + types[CSMWorld::ColumnBase::Display_Miscellaneous ] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::ColumnBase::Display_Npc ] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::ColumnBase::Display_Race ] = CSMWorld::UniversalId::Type_Race; + types[CSMWorld::ColumnBase::Display_Region ] = CSMWorld::UniversalId::Type_Region; + types[CSMWorld::ColumnBase::Display_Referenceable ] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::ColumnBase::Display_Script ] = CSMWorld::UniversalId::Type_Script; + types[CSMWorld::ColumnBase::Display_Skill ] = CSMWorld::UniversalId::Type_Skill; + types[CSMWorld::ColumnBase::Display_Sound ] = CSMWorld::UniversalId::Type_Sound; + types[CSMWorld::ColumnBase::Display_SoundRes ] = CSMWorld::UniversalId::Type_SoundRes; + types[CSMWorld::ColumnBase::Display_Spell ] = CSMWorld::UniversalId::Type_Spell; + types[CSMWorld::ColumnBase::Display_Static ] = CSMWorld::UniversalId::Type_Referenceable; + types[CSMWorld::ColumnBase::Display_Texture ] = CSMWorld::UniversalId::Type_Texture; + types[CSMWorld::ColumnBase::Display_Weapon ] = CSMWorld::UniversalId::Type_Referenceable; return types; } + + typedef std::map::const_iterator ModelTypeConstIterator; } -const std::map +const std::map CSMWorld::IdCompletionManager::sCompleterModelTypes = generateModelTypes(); +std::vector CSMWorld::IdCompletionManager::getDisplayTypes() +{ + std::vector types; + ModelTypeConstIterator current = sCompleterModelTypes.begin(); + ModelTypeConstIterator end = sCompleterModelTypes.end(); + for (; current != end; ++current) + { + types.push_back(current->first); + } + return types; +} + CSMWorld::IdCompletionManager::IdCompletionManager(CSMWorld::Data &data) { generateCompleters(data); } -bool CSMWorld::IdCompletionManager::hasCompleterFor(CSMWorld::Columns::ColumnId id) const +bool CSMWorld::IdCompletionManager::hasCompleterFor(CSMWorld::ColumnBase::Display display) const { - return mCompleters.find(id) != mCompleters.end(); + return mCompleters.find(display) != mCompleters.end(); } -boost::shared_ptr CSMWorld::IdCompletionManager::getCompleter(CSMWorld::Columns::ColumnId id) +boost::shared_ptr CSMWorld::IdCompletionManager::getCompleter(CSMWorld::ColumnBase::Display display) { - if (!hasCompleterFor(id)) + if (!hasCompleterFor(display)) { throw std::logic_error("This column doesn't have an ID completer"); } - return mCompleters[id]; + return mCompleters[display]; } void CSMWorld::IdCompletionManager::generateCompleters(CSMWorld::Data &data) { - typedef std::map::const_iterator ModelTypeConstIterator; - ModelTypeConstIterator current = sCompleterModelTypes.begin(); ModelTypeConstIterator end = sCompleterModelTypes.end(); for (; current != end; ++current) diff --git a/apps/opencs/model/world/idcompletionmanager.hpp b/apps/opencs/model/world/idcompletionmanager.hpp index ee75ddf248..7944e6777e 100644 --- a/apps/opencs/model/world/idcompletionmanager.hpp +++ b/apps/opencs/model/world/idcompletionmanager.hpp @@ -1,11 +1,12 @@ #ifndef CSM_WORLD_IDCOMPLETIONMANAGER_HPP #define CSM_WORLD_IDCOMPLETIONMANAGER_HPP +#include #include #include -#include "columns.hpp" +#include "columnbase.hpp" #include "universalid.hpp" class QCompleter; @@ -17,21 +18,23 @@ namespace CSMWorld /// \brief Creates and stores all ID completers class IdCompletionManager { - static const std::map sCompleterModelTypes; + static const std::map sCompleterModelTypes; - std::map > mCompleters; + std::map > mCompleters; // Don't allow copying IdCompletionManager(const IdCompletionManager &); IdCompletionManager &operator = (const IdCompletionManager &); - void generateCompleters(CSMWorld::Data &data); + void generateCompleters(Data &data); public: - IdCompletionManager(CSMWorld::Data &data); + static std::vector getDisplayTypes(); - bool hasCompleterFor(CSMWorld::Columns::ColumnId id) const; - boost::shared_ptr getCompleter(CSMWorld::Columns::ColumnId id); + IdCompletionManager(Data &data); + + bool hasCompleterFor(ColumnBase::Display display) const; + boost::shared_ptr getCompleter(ColumnBase::Display display); }; } diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index f485137032..b2f681df17 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -1,6 +1,7 @@ #include "viewmanager.hpp" +#include #include #include @@ -10,6 +11,7 @@ #include "../../model/doc/document.hpp" #include "../../model/world/columns.hpp" #include "../../model/world/universalid.hpp" +#include "../../model/world/idcompletionmanager.hpp" #include "../world/util.hpp" #include "../world/enumdelegate.hpp" @@ -61,38 +63,12 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager) mDelegateFactories->add (CSMWorld::ColumnBase::Display_RefRecordType, new CSVWorld::IdTypeDelegateFactory()); - // Columns with QLineEdit editor - static const CSMWorld::ColumnBase::Display sIdCompletionColumns[] = + std::vector idCompletionColumns = CSMWorld::IdCompletionManager::getDisplayTypes(); + for (std::vector::const_iterator current = idCompletionColumns.begin(); + current != idCompletionColumns.end(); + ++current) { - CSMWorld::ColumnBase::Display_Cell, - CSMWorld::ColumnBase::Display_Class, - CSMWorld::ColumnBase::Display_Creature, - CSMWorld::ColumnBase::Display_Faction, - CSMWorld::ColumnBase::Display_String, - CSMWorld::ColumnBase::Display_GlobalVariable, - CSMWorld::ColumnBase::Display_Icon, - CSMWorld::ColumnBase::Display_Mesh, - CSMWorld::ColumnBase::Display_Miscellaneous, - CSMWorld::ColumnBase::Display_Music, - CSMWorld::ColumnBase::Display_None, // Inplace editing (Table SubView) creates QLineEdit using Display_None - CSMWorld::ColumnBase::Display_Npc, - CSMWorld::ColumnBase::Display_Race, - CSMWorld::ColumnBase::Display_Referenceable, - CSMWorld::ColumnBase::Display_Region, - CSMWorld::ColumnBase::Display_Script, - CSMWorld::ColumnBase::Display_Skill, - CSMWorld::ColumnBase::Display_Sound, - CSMWorld::ColumnBase::Display_SoundRes, - CSMWorld::ColumnBase::Display_Static, - CSMWorld::ColumnBase::Display_String, - CSMWorld::ColumnBase::Display_Texture, - CSMWorld::ColumnBase::Display_Video, - CSMWorld::ColumnBase::Display_Weapon - }; - - for (std::size_t i = 0; i < sizeof(sIdCompletionColumns) / sizeof(CSMWorld::ColumnBase::Display); ++i) - { - mDelegateFactories->add(sIdCompletionColumns[i], new CSVWorld::IdCompletionDelegateFactory()); + mDelegateFactories->add(*current, new CSVWorld::IdCompletionDelegateFactory()); } struct Mapping diff --git a/apps/opencs/view/world/idcompletiondelegate.cpp b/apps/opencs/view/world/idcompletiondelegate.cpp index 2a1e97f4bd..056026471b 100644 --- a/apps/opencs/view/world/idcompletiondelegate.cpp +++ b/apps/opencs/view/world/idcompletiondelegate.cpp @@ -12,7 +12,7 @@ QWidget *CSVWorld::IdCompletionDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { - return createEditor(parent, option, index, CSMWorld::ColumnBase::Display_None); + return createEditor(parent, option, index, getDisplayTypeFromIndex(index)); } QWidget *CSVWorld::IdCompletionDelegate::createEditor(QWidget *parent, @@ -20,16 +20,14 @@ QWidget *CSVWorld::IdCompletionDelegate::createEditor(QWidget *parent, const QModelIndex &index, CSMWorld::ColumnBase::Display display) const { - int columnIdData = index.data(CSMWorld::ColumnBase::Role_ColumnId).toInt(); - CSMWorld::Columns::ColumnId columnId = static_cast(columnIdData); - CSMWorld::IdCompletionManager &completionManager = getDocument().getIdCompletionManager(); - - QWidget *editor = CSVWorld::CommandDelegate::createEditor(parent, option, index, display); - QLineEdit *lineEditor = qobject_cast(editor); - if (lineEditor != NULL && completionManager.hasCompleterFor(columnId)) + if (!index.data(Qt::EditRole).isValid() && !index.data(Qt::DisplayRole).isValid()) { - lineEditor->setCompleter(completionManager.getCompleter(columnId).get()); + return NULL; } + + CSMWorld::IdCompletionManager &completionManager = getDocument().getIdCompletionManager(); + DropLineEdit *editor = new DropLineEdit(parent); + editor->setCompleter(completionManager.getCompleter(display).get()); return editor; } From bd46ddcf47c3a50943a14ea2772dac9e8ef247f8 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Wed, 3 Jun 2015 15:51:34 +0300 Subject: [PATCH 108/119] Correct the return type in IdTree::data() for Display_Role --- apps/opencs/model/world/idtree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/world/idtree.cpp b/apps/opencs/model/world/idtree.cpp index a3dbae4655..1e81d6ac2f 100644 --- a/apps/opencs/model/world/idtree.cpp +++ b/apps/opencs/model/world/idtree.cpp @@ -41,7 +41,7 @@ QVariant CSMWorld::IdTree::data (const QModelIndex & index, int role) const const NestableColumn *parentColumn = mNestedCollection->getNestableColumn(parentAddress.second); if (role == ColumnBase::Role_Display) - return parentColumn->nestedColumn(index.column()).mColumnId; + return parentColumn->nestedColumn(index.column()).mDisplayType; if (role == ColumnBase::Role_ColumnId) return parentColumn->nestedColumn(index.column()).mColumnId; From c40987338d93c6121997630f539ba7e9138540a3 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Thu, 4 Jun 2015 23:09:40 +0300 Subject: [PATCH 109/119] Scrollbars don't save their positions between openings --- apps/openmw/mwgui/alchemywindow.cpp | 1 + apps/openmw/mwgui/companionwindow.cpp | 1 + apps/openmw/mwgui/container.cpp | 1 + apps/openmw/mwgui/itemselection.cpp | 1 + apps/openmw/mwgui/itemview.cpp | 5 +++++ apps/openmw/mwgui/itemview.hpp | 2 ++ apps/openmw/mwgui/merchantrepair.cpp | 2 ++ apps/openmw/mwgui/quickkeysmenu.cpp | 1 + apps/openmw/mwgui/recharge.cpp | 2 ++ apps/openmw/mwgui/repair.cpp | 2 ++ apps/openmw/mwgui/settingswindow.cpp | 17 +++++++++++++++++ apps/openmw/mwgui/settingswindow.hpp | 5 +++++ apps/openmw/mwgui/spellcreationdialog.cpp | 1 + apps/openmw/mwgui/spellview.cpp | 4 ++++ apps/openmw/mwgui/spellview.hpp | 2 ++ apps/openmw/mwgui/tradewindow.cpp | 1 + 16 files changed, 48 insertions(+) diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index a54744370c..768ad82e43 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -130,6 +130,7 @@ namespace MWGui mSortModel = new SortFilterItemModel(model); mSortModel->setFilter(SortFilterItemModel::Filter_OnlyIngredients); mItemView->setModel (mSortModel); + mItemView->resetScrollBars(); mNameEdit->setCaption(""); diff --git a/apps/openmw/mwgui/companionwindow.cpp b/apps/openmw/mwgui/companionwindow.cpp index 4433f9ef8c..69b6aa9f98 100644 --- a/apps/openmw/mwgui/companionwindow.cpp +++ b/apps/openmw/mwgui/companionwindow.cpp @@ -114,6 +114,7 @@ void CompanionWindow::open(const MWWorld::Ptr& npc) mModel = new CompanionItemModel(npc); mSortModel = new SortFilterItemModel(mModel); mItemView->setModel(mSortModel); + mItemView->resetScrollBars(); setTitle(npc.getClass().getName(npc)); } diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 1317e1e253..76e9cbb5b6 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -151,6 +151,7 @@ namespace MWGui mSortModel = new SortFilterItemModel(mModel); mItemView->setModel (mSortModel); + mItemView->resetScrollBars(); MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mCloseButton); diff --git a/apps/openmw/mwgui/itemselection.cpp b/apps/openmw/mwgui/itemselection.cpp index 916f133607..095f392b73 100644 --- a/apps/openmw/mwgui/itemselection.cpp +++ b/apps/openmw/mwgui/itemselection.cpp @@ -39,6 +39,7 @@ namespace MWGui mModel = new InventoryItemModel(container); mSortModel = new SortFilterItemModel(mModel); mItemView->setModel(mSortModel); + mItemView->resetScrollBars(); } void ItemSelectionDialog::setCategory(int category) diff --git a/apps/openmw/mwgui/itemview.cpp b/apps/openmw/mwgui/itemview.cpp index aade232d27..c5320a2be4 100644 --- a/apps/openmw/mwgui/itemview.cpp +++ b/apps/openmw/mwgui/itemview.cpp @@ -128,6 +128,11 @@ void ItemView::update() layoutWidgets(); } +void ItemView::resetScrollBars() +{ + mScrollView->setViewOffset(MyGUI::IntPoint(0, 0)); +} + void ItemView::onSelectedItem(MyGUI::Widget *sender) { ItemModel::ModelIndex index = (*sender->getUserData >()).first; diff --git a/apps/openmw/mwgui/itemview.hpp b/apps/openmw/mwgui/itemview.hpp index 9aeba67520..f87a48aa60 100644 --- a/apps/openmw/mwgui/itemview.hpp +++ b/apps/openmw/mwgui/itemview.hpp @@ -30,6 +30,8 @@ namespace MWGui void update(); + void resetScrollBars(); + private: virtual void initialiseOverride(); diff --git a/apps/openmw/mwgui/merchantrepair.cpp b/apps/openmw/mwgui/merchantrepair.cpp index 4407bf9277..862b719d48 100644 --- a/apps/openmw/mwgui/merchantrepair.cpp +++ b/apps/openmw/mwgui/merchantrepair.cpp @@ -114,6 +114,8 @@ void MerchantRepair::onMouseWheel(MyGUI::Widget* _sender, int _rel) void MerchantRepair::open() { center(); + // Reset scrollbars + mList->setViewOffset(MyGUI::IntPoint(0, 0)); } void MerchantRepair::exit() diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 834c156f92..685c7d45c1 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -548,6 +548,7 @@ namespace MWGui WindowModal::open(); mMagicList->setModel(new SpellModel(MWBase::Environment::get().getWorld()->getPlayerPtr())); + mMagicList->resetScrollbars(); } void MagicSelectionDialog::onModelIndexSelected(SpellModel::ModelIndex index) diff --git a/apps/openmw/mwgui/recharge.cpp b/apps/openmw/mwgui/recharge.cpp index a0e5991b46..b7280565b7 100644 --- a/apps/openmw/mwgui/recharge.cpp +++ b/apps/openmw/mwgui/recharge.cpp @@ -44,6 +44,8 @@ Recharge::Recharge() void Recharge::open() { center(); + // Reset scrollbars + mView->setViewOffset(MyGUI::IntPoint(0, 0)); } void Recharge::exit() diff --git a/apps/openmw/mwgui/repair.cpp b/apps/openmw/mwgui/repair.cpp index 9f26923d44..534226aebd 100644 --- a/apps/openmw/mwgui/repair.cpp +++ b/apps/openmw/mwgui/repair.cpp @@ -36,6 +36,8 @@ Repair::Repair() void Repair::open() { center(); + // Reset scrollbars + mRepairView->setViewOffset(MyGUI::IntPoint(0, 0)); } void Repair::exit() diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index d895a28ea7..6991bb2946 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -170,6 +171,7 @@ namespace MWGui setTitle("#{sOptions}"); + getWidget(mSettingsTab, "SettingsTab"); getWidget(mOkButton, "OkButton"); getWidget(mResolutionList, "ResolutionList"); getWidget(mFullscreenButton, "FullscreenButton"); @@ -208,6 +210,7 @@ namespace MWGui mMainWidget->castType()->eventWindowChangeCoord += MyGUI::newDelegate(this, &SettingsWindow::onWindowResize); + mSettingsTab->eventTabChangeSelect += MyGUI::newDelegate(this, &SettingsWindow::onTabChanged); mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked); mShaderModeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onShaderModeToggled); mTextureFilteringButton->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onTextureFilteringChanged); @@ -275,6 +278,11 @@ namespace MWGui mControllerSwitch->setStateSelected(false); } + void SettingsWindow::onTabChanged(MyGUI::TabControl* /*_sender*/, size_t /*index*/) + { + resetScrollbars(); + } + void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender) { exit(); @@ -480,6 +488,7 @@ namespace MWGui mKeyboardSwitch->setStateSelected(true); mControllerSwitch->setStateSelected(false); updateControlsBox(); + resetScrollbars(); } void SettingsWindow::onControllerSwitchClicked(MyGUI::Widget* _sender) @@ -490,6 +499,7 @@ namespace MWGui mKeyboardSwitch->setStateSelected(false); mControllerSwitch->setStateSelected(true); updateControlsBox(); + resetScrollbars(); } void SettingsWindow::updateControlsBox() @@ -584,6 +594,7 @@ namespace MWGui void SettingsWindow::open() { updateControlsBox (); + resetScrollbars(); } void SettingsWindow::exit() @@ -595,4 +606,10 @@ namespace MWGui { updateControlsBox(); } + + void SettingsWindow::resetScrollbars() + { + mResolutionList->setScrollPosition(0); + mControlsBox->setViewOffset(MyGUI::IntPoint(0, 0)); + } } diff --git a/apps/openmw/mwgui/settingswindow.hpp b/apps/openmw/mwgui/settingswindow.hpp index 1b970b8de5..8910960b24 100644 --- a/apps/openmw/mwgui/settingswindow.hpp +++ b/apps/openmw/mwgui/settingswindow.hpp @@ -22,6 +22,7 @@ namespace MWGui void updateControlsBox(); protected: + MyGUI::TabControl* mSettingsTab; MyGUI::Button* mOkButton; // graphics @@ -50,6 +51,7 @@ namespace MWGui MyGUI::Button* mControllerSwitch; bool mKeyboardMode; //if true, setting up the keyboard. Otherwise, it's controller + void onTabChanged(MyGUI::TabControl* _sender, size_t index); void onOkButtonClicked(MyGUI::Widget* _sender); void onFpsToggled(MyGUI::Widget* _sender); void onTextureFilteringChanged(MyGUI::ComboBox* _sender, size_t pos); @@ -74,6 +76,9 @@ namespace MWGui void apply(); void configureWidgets(MyGUI::Widget* widget); + + private: + void resetScrollbars(); }; } diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 1c670838f4..a492ea7aaf 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -551,6 +551,7 @@ namespace MWGui ++i; } mAvailableEffectsList->adjustSize (); + mAvailableEffectsList->scrollToTop(); for (std::vector::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it) { diff --git a/apps/openmw/mwgui/spellview.cpp b/apps/openmw/mwgui/spellview.cpp index 6d86b4a23a..af6ff00a53 100644 --- a/apps/openmw/mwgui/spellview.cpp +++ b/apps/openmw/mwgui/spellview.cpp @@ -311,4 +311,8 @@ namespace MWGui mScrollView->setViewOffset(MyGUI::IntPoint(0, static_cast(mScrollView->getViewOffset().top + _rel*0.3f))); } + void SpellView::resetScrollbars() + { + mScrollView->setViewOffset(MyGUI::IntPoint(0, 0)); + } } diff --git a/apps/openmw/mwgui/spellview.hpp b/apps/openmw/mwgui/spellview.hpp index 7af1bda7a7..0f0b8a7d25 100644 --- a/apps/openmw/mwgui/spellview.hpp +++ b/apps/openmw/mwgui/spellview.hpp @@ -51,6 +51,8 @@ namespace MWGui virtual void setSize(const MyGUI::IntSize& _value); virtual void setCoord(const MyGUI::IntCoord& _value); + void resetScrollbars(); + private: MyGUI::ScrollView* mScrollView; diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index aecfce98d0..bdcf28bf20 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -136,6 +136,7 @@ namespace MWGui mTradeModel = new TradeItemModel(new ContainerItemModel(itemSources, worldItems), mPtr); mSortModel = new SortFilterItemModel(mTradeModel); mItemView->setModel (mSortModel); + mItemView->resetScrollBars(); updateLabels(); From 5c37079f0c06d1837da2b3d6e3f3763d709550dc Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 5 Jun 2015 12:19:21 +1000 Subject: [PATCH 110/119] Include only the columns that are visible for sorting. Should resolve Bug #2611. --- apps/opencs/model/world/idtableproxymodel.cpp | 12 ++++++++++++ apps/opencs/model/world/idtableproxymodel.hpp | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/idtableproxymodel.cpp b/apps/opencs/model/world/idtableproxymodel.cpp index 987d274620..3697b055fe 100644 --- a/apps/opencs/model/world/idtableproxymodel.cpp +++ b/apps/opencs/model/world/idtableproxymodel.cpp @@ -21,6 +21,18 @@ void CSMWorld::IdTableProxyModel::updateColumnMap() } } +bool CSMWorld::IdTableProxyModel::filterAcceptsColumn (int sourceColumn, const QModelIndex& sourceParent) + const +{ + int flags = + sourceModel()->headerData (sourceColumn, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt(); + + if (flags & CSMWorld::ColumnBase::Flag_Table) + return true; + else + return false; +} + bool CSMWorld::IdTableProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const { diff --git a/apps/opencs/model/world/idtableproxymodel.hpp b/apps/opencs/model/world/idtableproxymodel.hpp index 8683c2b9e5..89480f2881 100644 --- a/apps/opencs/model/world/idtableproxymodel.hpp +++ b/apps/opencs/model/world/idtableproxymodel.hpp @@ -24,8 +24,6 @@ namespace CSMWorld void updateColumnMap(); - bool filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const; - public: IdTableProxyModel (QObject *parent = 0); @@ -39,6 +37,10 @@ namespace CSMWorld protected: bool lessThan(const QModelIndex &left, const QModelIndex &right) const; + + virtual bool filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const; + + virtual bool filterAcceptsColumn (int sourceColumn, const QModelIndex& sourceParent) const; }; } From 58e2d3711f0c6fad58218d7fc6f1914324763068 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Fri, 5 Jun 2015 22:00:02 +0300 Subject: [PATCH 111/119] Reset Console editbox before command execution --- apps/openmw/mwgui/console.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 4eb9a271c1..62eeca0120 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -294,10 +294,9 @@ namespace MWGui mCommandHistory.push_back(cm); mCurrent = mCommandHistory.end(); mEditString.clear(); + mCommandLine->setCaption(""); execute (cm); - - mCommandLine->setCaption(""); } std::string Console::complete( std::string input, std::vector &matches ) From d2293867ba0914993866275e173880c9f079c08a Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Fri, 5 Jun 2015 22:44:06 +0300 Subject: [PATCH 112/119] Add the explanation to Console::acceptCommand() --- apps/openmw/mwgui/console.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 62eeca0120..a1f564ffaa 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -294,6 +294,10 @@ namespace MWGui mCommandHistory.push_back(cm); mCurrent = mCommandHistory.end(); mEditString.clear(); + + // Reset the command line before the command execution. + // It prevents re-triggering the acceptCommand() event during + // the actual command execution. mCommandLine->setCaption(""); execute (cm); From 49512a2b57fe2f0eb420ee37b1210c596556161a Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Fri, 5 Jun 2015 22:57:35 +0300 Subject: [PATCH 113/119] Correct the explanation for the Console::acceptCommand() --- apps/openmw/mwgui/console.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index a1f564ffaa..083dd32b0a 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -296,8 +296,8 @@ namespace MWGui mEditString.clear(); // Reset the command line before the command execution. - // It prevents re-triggering the acceptCommand() event during - // the actual command execution. + // It prevents the re-triggering of the acceptCommand() event for the same command + // during the actual command execution mCommandLine->setCaption(""); execute (cm); From 15fe5d88e2b3c7d172a28bd453b3e0d5f89295aa Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 6 Jun 2015 20:35:55 +1000 Subject: [PATCH 114/119] Allow comments (lines starting with # character) and blank lines in openmw.cfg. Should resolve Feature #2535. - controlled via a checkbox in launcher settings --- apps/launcher/maindialog.cpp | 21 ++++- apps/launcher/settingspage.cpp | 8 ++ components/config/gamesettings.cpp | 128 +++++++++++++++++++++++++++++ components/config/gamesettings.hpp | 2 + files/ui/settingspage.ui | 10 +++ 5 files changed, 166 insertions(+), 3 deletions(-) diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index fd36993bfb..27d37dbf03 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -490,7 +490,16 @@ bool Launcher::MainDialog::writeSettings() // Game settings QFile file(userPath + QString("openmw.cfg")); - if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) { + QIODevice::OpenMode mode(0); + bool keepComments = mLauncherSettings.value(QString("Settings/keep-comments"), QString("true")) + == QLatin1String("true"); + + if (keepComments) + mode = QIODevice::ReadWrite | QIODevice::Text; + else + mode = QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate; + + if (!file.open(mode)) { // File cannot be opened or created QMessageBox msgBox; msgBox.setWindowTitle(tr("Error writing OpenMW configuration file")); @@ -504,9 +513,15 @@ bool Launcher::MainDialog::writeSettings() } QTextStream stream(&file); - stream.setCodec(QTextCodec::codecForName("UTF-8")); - mGameSettings.writeFile(stream); + if (keepComments) + mGameSettings.writeFileWithComments(file); + else + { + stream.setCodec(QTextCodec::codecForName("UTF-8")); + mGameSettings.writeFile(stream); + } + file.close(); // Graphics settings diff --git a/apps/launcher/settingspage.cpp b/apps/launcher/settingspage.cpp index 843b513914..bc8ffe6180 100644 --- a/apps/launcher/settingspage.cpp +++ b/apps/launcher/settingspage.cpp @@ -260,6 +260,10 @@ void Launcher::SettingsPage::saveSettings() } else { mGameSettings.setValue(QLatin1String("encoding"), QLatin1String("win1252")); } + + QString keepComments(saveCommentsCheckBox->isChecked() ? "true" : "false"); + + mLauncherSettings.setValue(QLatin1String("Settings/keep-comments"), keepComments); } bool Launcher::SettingsPage::loadSettings() @@ -271,5 +275,9 @@ bool Launcher::SettingsPage::loadSettings() if (index != -1) languageComboBox->setCurrentIndex(index); + QString keepComments(mLauncherSettings.value(QLatin1String("Settings/keep-comments"))); + + saveCommentsCheckBox->setChecked(keepComments == "true"); + return true; } diff --git a/components/config/gamesettings.cpp b/components/config/gamesettings.cpp index 0481235c78..51c7883ad2 100644 --- a/components/config/gamesettings.cpp +++ b/components/config/gamesettings.cpp @@ -1,6 +1,7 @@ #include "gamesettings.hpp" #include "launchersettings.hpp" +#include #include #include #include @@ -173,6 +174,133 @@ bool Config::GameSettings::writeFile(QTextStream &stream) return true; } +// Policy: +// +// - Always ignore a line beginning with '#' or empty lines +// +// - If a line in file exists with matching key and first part of value (before ',', +// '\n', etc) also matches, then replace the line with that of mUserSettings. +// - else remove line (maybe replace the line with '#' in front instead?) +// +// - If there is no corresponding line in file, add at the end +// +bool Config::GameSettings::writeFileWithComments(QFile &file) +{ + QTextStream stream(&file); + stream.setCodec(QTextCodec::codecForName("UTF-8")); + + // slurp + std::vector fileCopy; + QString line = stream.readLine(); + while (!line.isNull()) + { + fileCopy.push_back(line); + line = stream.readLine(); + } + stream.seek(0); + + // empty file, no comments to keep + if (fileCopy.empty()) + return writeFile(stream); + + // Temp copy of settings to save, but with the keys appended with the first part of the value + // + // ATTENTION! + // + // A hack to avoid looping through each line, makes use of the fact that fallbacks values + // are comma separated. + QMap userSettingsCopy; + QRegExp settingRegex("^([^=]+)\\s*=\\s*([^,]+)(.*)$"); + QString settingLine; + QMap::const_iterator settingsIter = mUserSettings.begin(); + for (; settingsIter != mUserSettings.end(); ++settingsIter) + { + settingLine = settingsIter.key()+"="+settingsIter.value(); + if (settingRegex.indexIn(settingLine) != -1) + { + userSettingsCopy[settingRegex.cap(1)+"="+settingRegex.cap(2)] = + (settingRegex.captureCount() < 3) ? "" : settingRegex.cap(3); + } + } + + QString keyVal; + for (std::vector::iterator iter = fileCopy.begin(); iter != fileCopy.end(); ++iter) + { + // skip empty or comment lines + if ((*iter).isEmpty() || (*iter).startsWith("#")) + continue; + + // look for a key in the line + if (settingRegex.indexIn(*iter) == -1 || settingRegex.captureCount() < 2) + { + // no key or first part of value found in line, replace with a null string which + // will be remved later + *iter = QString(); + continue; + } + + // look for a matching key in user settings + keyVal = settingRegex.cap(1)+"="+settingRegex.cap(2); + QMap::iterator it = userSettingsCopy.find(keyVal); + if (it == userSettingsCopy.end()) + { + // no such key+valStart, replace with a null string which will be remved later + *iter = QString(); + } + else + { + *iter = QString(it.key()+it.value()); + userSettingsCopy.erase(it); + } + } + + // write the new config file + QString key; + QString value; + for (std::vector::iterator iter = fileCopy.begin(); iter != fileCopy.end(); ++iter) + { + if ((*iter).isNull()) + continue; + + if ((*iter).isEmpty() || (*iter).startsWith("#")) + stream << *iter << "\n"; + + if (settingRegex.indexIn(*iter) == -1 || settingRegex.captureCount() < 2) + continue; + + // Quote paths with spaces + key = settingRegex.cap(1); + value = settingRegex.cap(2)+settingRegex.cap(3); + if (key == QLatin1String("data") + || key == QLatin1String("data-local") + || key == QLatin1String("resources")) + { + if (value.contains(QChar(' '))) + { + value.remove(QChar('\"')); // Remove quotes + + stream << key << "=\"" << value << "\"\n"; + continue; + } + } + stream << key << "=" << value << "\n"; + } + + if (!userSettingsCopy.empty()) + { + stream << "# new entries" << "\n"; + QMap::const_iterator it = userSettingsCopy.begin(); + for (; it != userSettingsCopy.end(); ++it) + { + stream << it.key() << it.value() << "\n"; + } + } + + file.resize(file.pos()); + + return true; +} + bool Config::GameSettings::hasMaster() { bool result = false; diff --git a/components/config/gamesettings.hpp b/components/config/gamesettings.hpp index cc5033f351..35614113f4 100644 --- a/components/config/gamesettings.hpp +++ b/components/config/gamesettings.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -66,6 +67,7 @@ namespace Config bool readUserFile(QTextStream &stream); bool writeFile(QTextStream &stream); + bool writeFileWithComments(QFile &file); void setContentList(const QStringList& fileNames); QStringList getContentList() const; diff --git a/files/ui/settingspage.ui b/files/ui/settingspage.ui index 7f5e4a7de8..f38ba764c3 100644 --- a/files/ui/settingspage.ui +++ b/files/ui/settingspage.ui @@ -40,6 +40,16 @@ + + + + Keep comments in openmw.cfg + + + false + + + From d63b01dde3ebe251d9dafd157ca1104bcf413db9 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Sat, 6 Jun 2015 15:41:25 +0300 Subject: [PATCH 115/119] Checkboxes in the table view use a combobox editor --- apps/opencs/view/world/util.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/world/util.cpp b/apps/opencs/view/world/util.cpp index 3be875ffd7..e1d165a24f 100644 --- a/apps/opencs/view/world/util.cpp +++ b/apps/opencs/view/world/util.cpp @@ -152,7 +152,17 @@ void CSVWorld::CommandDelegate::setModelData (QWidget *editor, QAbstractItemMode QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleOptionViewItem& option, const QModelIndex& index) const { - return createEditor (parent, option, index, getDisplayTypeFromIndex(index)); + CSMWorld::ColumnBase::Display display = getDisplayTypeFromIndex(index); + + // This createEditor() method is called implicitly from tables. + // For boolean values in tables use the default editor (combobox). + // Checkboxes is looking ugly in the table view. + // TODO: Find a better solution? + if (display == CSMWorld::ColumnBase::Display_Boolean) + { + return QStyledItemDelegate::createEditor(parent, option, index); + } + return createEditor (parent, option, index, display); } QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleOptionViewItem& option, From 4902c6679210dee8b5158d05d99b072c2f06a494 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 7 Jun 2015 07:21:15 +1000 Subject: [PATCH 116/119] Allow space characters in front of comments. --- components/config/gamesettings.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/components/config/gamesettings.cpp b/components/config/gamesettings.cpp index 51c7883ad2..1215f08509 100644 --- a/components/config/gamesettings.cpp +++ b/components/config/gamesettings.cpp @@ -180,7 +180,7 @@ bool Config::GameSettings::writeFile(QTextStream &stream) // // - If a line in file exists with matching key and first part of value (before ',', // '\n', etc) also matches, then replace the line with that of mUserSettings. -// - else remove line (maybe replace the line with '#' in front instead?) +// - else remove line (TODO: maybe replace the line with '#' in front instead?) // // - If there is no corresponding line in file, add at the end // @@ -224,10 +224,10 @@ bool Config::GameSettings::writeFileWithComments(QFile &file) } QString keyVal; - for (std::vector::iterator iter = fileCopy.begin(); iter != fileCopy.end(); ++iter) + for (std::vector::iterator iter = fileCopy.begin(); iter != fileCopy.end(); ++iter) { // skip empty or comment lines - if ((*iter).isEmpty() || (*iter).startsWith("#")) + if ((*iter).isEmpty() || (*iter).contains(QRegExp("^\\s*#"))) continue; // look for a key in the line @@ -257,12 +257,14 @@ bool Config::GameSettings::writeFileWithComments(QFile &file) // write the new config file QString key; QString value; - for (std::vector::iterator iter = fileCopy.begin(); iter != fileCopy.end(); ++iter) + for (std::vector::iterator iter = fileCopy.begin(); iter != fileCopy.end(); ++iter) { if ((*iter).isNull()) continue; - if ((*iter).isEmpty() || (*iter).startsWith("#")) + // Below is based on readFile() code, if that changes corresponding change may be + // required (for example duplicates may be inserted if the rules don't match) + if ((*iter).isEmpty() || (*iter).contains(QRegExp("^\\s*#"))) stream << *iter << "\n"; if (settingRegex.indexIn(*iter) == -1 || settingRegex.captureCount() < 2) From a439f49c4db32a340826ae9b77c940ca59e79e5f Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 7 Jun 2015 07:38:52 +1000 Subject: [PATCH 117/119] Fix loop where there was a potential for double entry. --- components/config/gamesettings.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/config/gamesettings.cpp b/components/config/gamesettings.cpp index 1215f08509..2b3a8ba4bf 100644 --- a/components/config/gamesettings.cpp +++ b/components/config/gamesettings.cpp @@ -265,7 +265,10 @@ bool Config::GameSettings::writeFileWithComments(QFile &file) // Below is based on readFile() code, if that changes corresponding change may be // required (for example duplicates may be inserted if the rules don't match) if ((*iter).isEmpty() || (*iter).contains(QRegExp("^\\s*#"))) + { stream << *iter << "\n"; + continue; + } if (settingRegex.indexIn(*iter) == -1 || settingRegex.captureCount() < 2) continue; From d3b7cf44d391ba9624f28070e68784352e6f514d Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 7 Jun 2015 13:29:45 +1000 Subject: [PATCH 118/119] Remove user preference setting option. --- apps/launcher/maindialog.cpp | 22 +++------------------- apps/launcher/settingspage.cpp | 8 -------- files/ui/settingspage.ui | 10 ---------- 3 files changed, 3 insertions(+), 37 deletions(-) diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index 27d37dbf03..2f7a9db332 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -490,16 +490,7 @@ bool Launcher::MainDialog::writeSettings() // Game settings QFile file(userPath + QString("openmw.cfg")); - QIODevice::OpenMode mode(0); - bool keepComments = mLauncherSettings.value(QString("Settings/keep-comments"), QString("true")) - == QLatin1String("true"); - - if (keepComments) - mode = QIODevice::ReadWrite | QIODevice::Text; - else - mode = QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate; - - if (!file.open(mode)) { + if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { // File cannot be opened or created QMessageBox msgBox; msgBox.setWindowTitle(tr("Error writing OpenMW configuration file")); @@ -512,16 +503,8 @@ bool Launcher::MainDialog::writeSettings() return false; } - QTextStream stream(&file); - - if (keepComments) - mGameSettings.writeFileWithComments(file); - else - { - stream.setCodec(QTextCodec::codecForName("UTF-8")); - mGameSettings.writeFile(stream); - } + mGameSettings.writeFileWithComments(file); file.close(); // Graphics settings @@ -540,6 +523,7 @@ bool Launcher::MainDialog::writeSettings() return false; } + QTextStream stream(&file); stream.setDevice(&file); stream.setCodec(QTextCodec::codecForName("UTF-8")); diff --git a/apps/launcher/settingspage.cpp b/apps/launcher/settingspage.cpp index bc8ffe6180..843b513914 100644 --- a/apps/launcher/settingspage.cpp +++ b/apps/launcher/settingspage.cpp @@ -260,10 +260,6 @@ void Launcher::SettingsPage::saveSettings() } else { mGameSettings.setValue(QLatin1String("encoding"), QLatin1String("win1252")); } - - QString keepComments(saveCommentsCheckBox->isChecked() ? "true" : "false"); - - mLauncherSettings.setValue(QLatin1String("Settings/keep-comments"), keepComments); } bool Launcher::SettingsPage::loadSettings() @@ -275,9 +271,5 @@ bool Launcher::SettingsPage::loadSettings() if (index != -1) languageComboBox->setCurrentIndex(index); - QString keepComments(mLauncherSettings.value(QLatin1String("Settings/keep-comments"))); - - saveCommentsCheckBox->setChecked(keepComments == "true"); - return true; } diff --git a/files/ui/settingspage.ui b/files/ui/settingspage.ui index f38ba764c3..7f5e4a7de8 100644 --- a/files/ui/settingspage.ui +++ b/files/ui/settingspage.ui @@ -40,16 +40,6 @@ - - - - Keep comments in openmw.cfg - - - false - - - From 893ad11be109ab1a4e249c1d091092ff5cdfb9fe Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 8 Jun 2015 08:04:18 +1000 Subject: [PATCH 119/119] Fix missing columns in tables. Should resolve Bug #2624. - Using Flag_Table in filterAcceptsColumn() does not work. - Workaround by not allowing nested columns in sorting and filtering. --- apps/opencs/model/world/idtableproxymodel.cpp | 20 ++++++++----------- apps/opencs/model/world/idtableproxymodel.hpp | 2 -- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/apps/opencs/model/world/idtableproxymodel.cpp b/apps/opencs/model/world/idtableproxymodel.cpp index 3697b055fe..d8932d2057 100644 --- a/apps/opencs/model/world/idtableproxymodel.cpp +++ b/apps/opencs/model/world/idtableproxymodel.cpp @@ -21,21 +21,17 @@ void CSMWorld::IdTableProxyModel::updateColumnMap() } } -bool CSMWorld::IdTableProxyModel::filterAcceptsColumn (int sourceColumn, const QModelIndex& sourceParent) - const -{ - int flags = - sourceModel()->headerData (sourceColumn, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt(); - - if (flags & CSMWorld::ColumnBase::Flag_Table) - return true; - else - return false; -} - bool CSMWorld::IdTableProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const { + // It is not possible to use filterAcceptsColumn() and check for + // sourceModel()->headerData (sourceColumn, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags) + // because the sourceColumn parameter excludes the hidden columns, i.e. wrong columns can + // be rejected. Workaround by disallowing tree branches (nested columns), which are not meant + // to be visible, from the filter. + if (sourceParent.isValid()) + return false; + if (!mFilter) return true; diff --git a/apps/opencs/model/world/idtableproxymodel.hpp b/apps/opencs/model/world/idtableproxymodel.hpp index 89480f2881..d2a2405291 100644 --- a/apps/opencs/model/world/idtableproxymodel.hpp +++ b/apps/opencs/model/world/idtableproxymodel.hpp @@ -39,8 +39,6 @@ namespace CSMWorld bool lessThan(const QModelIndex &left, const QModelIndex &right) const; virtual bool filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const; - - virtual bool filterAcceptsColumn (int sourceColumn, const QModelIndex& sourceParent) const; }; }