mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 07:23:52 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
b969986cff
186 changed files with 3116 additions and 1633 deletions
|
@ -90,13 +90,13 @@ endif(UNIX AND NOT APPLE)
|
|||
# Location of morrowind data files
|
||||
if (APPLE)
|
||||
set(MORROWIND_DATA_FILES "./data" CACHE PATH "location of Morrowind data files")
|
||||
set(MORROWIND_RESOURCE_FILES "./resources" CACHE PATH "location of OpenMW resources files")
|
||||
set(OPENMW_RESOURCE_FILES "./resources" CACHE PATH "location of OpenMW resources files")
|
||||
elseif(UNIX)
|
||||
set(MORROWIND_DATA_FILES "/usr/share/games/openmw/data/" CACHE PATH "location of Morrowind data files")
|
||||
set(MORROWIND_RESOURCE_FILES "/usr/share/games/openmw/resources/" CACHE PATH "location of OpenMW resources files")
|
||||
set(MORROWIND_DATA_FILES "${CMAKE_INSTALL_PREFIX}/share/games/openmw/data/" CACHE PATH "location of Morrowind data files")
|
||||
set(OPENMW_RESOURCE_FILES "${CMAKE_INSTALL_PREFIX}/share/games/openmw/resources/" CACHE PATH "location of OpenMW resources files")
|
||||
else()
|
||||
set(MORROWIND_DATA_FILES "data" CACHE PATH "location of Morrowind data files")
|
||||
set(MORROWIND_RESOURCE_FILES "resources" CACHE PATH "location of OpenMW resources files")
|
||||
set(OPENMW_RESOURCE_FILES "resources" CACHE PATH "location of OpenMW resources files")
|
||||
endif(APPLE)
|
||||
|
||||
if (WIN32)
|
||||
|
@ -239,16 +239,40 @@ find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
|||
find_package(SDL2 REQUIRED)
|
||||
find_package(OpenAL REQUIRED)
|
||||
find_package(Bullet REQUIRED)
|
||||
IF(OGRE_STATIC)
|
||||
find_package(Cg)
|
||||
IF(WIN32)
|
||||
set(OGRE_PLUGIN_INCLUDE_DIRS ${OGRE_Plugin_CgProgramManager_INCLUDE_DIRS} ${OGRE_Plugin_OctreeSceneManager_INCLUDE_DIRS} ${OGRE_Plugin_ParticleFX_INCLUDE_DIRS} ${OGRE_RenderSystem_Direct3D9_INCLUDE_DIRS} ${OGRE_RenderSystem_GL_INCLUDE_DIRS})
|
||||
ELSE(WIN32)
|
||||
set(OGRE_PLUGIN_INCLUDE_DIRS ${OGRE_Plugin_CgProgramManager_INCLUDE_DIRS} ${OGRE_Plugin_OctreeSceneManager_INCLUDE_DIRS} ${OGRE_Plugin_ParticleFX_INCLUDE_DIRS} ${OGRE_RenderSystem_GL_INCLUDE_DIRS})
|
||||
ENDIF(WIN32)
|
||||
ENDIF(OGRE_STATIC)
|
||||
|
||||
set(OGRE_PLUGIN_INCLUDE_DIRS "")
|
||||
set(OGRE_STATIC_PLUGINS "")
|
||||
|
||||
macro(add_static_ogre_plugin PLUGIN)
|
||||
if(OGRE_${PLUGIN}_FOUND)
|
||||
# strip RenderSystem_ or Plugin_ prefix from plugin name
|
||||
string(REPLACE "RenderSystem_" "" PLUGIN_TEMP ${PLUGIN})
|
||||
string(REPLACE "Plugin_" "" PLUGIN_NAME ${PLUGIN_TEMP})
|
||||
add_definitions(-DENABLE_PLUGIN_${PLUGIN_NAME})
|
||||
|
||||
list(APPEND OGRE_PLUGIN_INCLUDE_DIRS ${OGRE_${PLUGIN}_INCLUDE_DIRS})
|
||||
list(APPEND OGRE_STATIC_PLUGINS ${OGRE_${PLUGIN}_LIBRARIES})
|
||||
endif(OGRE_${PLUGIN}_FOUND)
|
||||
endmacro(add_static_ogre_plugin)
|
||||
|
||||
if(OGRE_STATIC)
|
||||
# set up OGRE_PLUGIN_INCLUDE_DIRS and OGRE_STATIC_PLUGINS
|
||||
add_static_ogre_plugin(Plugin_OctreeSceneManager)
|
||||
add_static_ogre_plugin(Plugin_ParticleFX)
|
||||
find_package(Cg)
|
||||
if(Cg_FOUND)
|
||||
add_static_ogre_plugin(Plugin_CgProgramManager)
|
||||
list(APPEND OGRE_STATIC_PLUGINS ${Cg_LIBRARIES})
|
||||
endif(Cg_FOUND)
|
||||
|
||||
add_static_ogre_plugin(RenderSystem_GL)
|
||||
if(WIN32)
|
||||
add_static_ogre_plugin(RenderSystem_Direct3D9)
|
||||
endif(WIN32)
|
||||
endif(OGRE_STATIC)
|
||||
|
||||
include_directories("."
|
||||
${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OGRE_INCLUDE_DIR}/OGRE ${OGRE_PLUGIN_INCLUDE_DIRS}
|
||||
${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OGRE_INCLUDE_DIR}/OGRE ${OGRE_INCLUDE_DIRS} ${OGRE_PLUGIN_INCLUDE_DIRS}
|
||||
${SDL2_INCLUDE_DIR}
|
||||
${Boost_INCLUDE_DIR}
|
||||
${PLATFORM_INCLUDE_DIR}
|
||||
|
@ -260,6 +284,10 @@ include_directories("."
|
|||
|
||||
link_directories(${SDL2_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR} ${MYGUI_LIB_DIR})
|
||||
|
||||
if(MYGUI_STATIC)
|
||||
add_definitions(-DMYGUI_STATIC)
|
||||
endif (MYGUI_STATIC)
|
||||
|
||||
if (APPLE)
|
||||
# List used Ogre plugins
|
||||
SET(USED_OGRE_PLUGINS ${OGRE_RenderSystem_GL_LIBRARY_REL}
|
||||
|
|
|
@ -94,15 +94,6 @@ if(NOT WIN32)
|
|||
endif(NOT WIN32)
|
||||
|
||||
# Main executable
|
||||
IF(OGRE_STATIC)
|
||||
IF(WIN32)
|
||||
ADD_DEFINITIONS(-DENABLE_PLUGIN_Direct3D9 -DENABLE_PLUGIN_GL)
|
||||
set(OGRE_STATIC_PLUGINS ${OGRE_RenderSystem_Direct3D9_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES})
|
||||
ELSE(WIN32)
|
||||
ADD_DEFINITIONS(-DENABLE_PLUGIN_GL)
|
||||
set(OGRE_STATIC_PLUGINS ${OGRE_RenderSystem_GL_LIBRARIES})
|
||||
ENDIF(WIN32)
|
||||
ENDIF(OGRE_STATIC)
|
||||
add_executable(omwlauncher
|
||||
${GUI_TYPE}
|
||||
${LAUNCHER}
|
||||
|
@ -116,7 +107,7 @@ target_link_libraries(omwlauncher
|
|||
${Boost_LIBRARIES}
|
||||
${OGRE_LIBRARIES}
|
||||
${OGRE_STATIC_PLUGINS}
|
||||
${SDL2_LIBRARY}
|
||||
${SDL2_LIBRARY_ONLY}
|
||||
${QT_LIBRARIES}
|
||||
components
|
||||
)
|
||||
|
|
|
@ -192,6 +192,7 @@ endif(APPLE)
|
|||
|
||||
target_link_libraries(opencs
|
||||
${OGRE_LIBRARIES}
|
||||
${OGRE_STATIC_PLUGINS}
|
||||
${SHINY_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
${QT_LIBRARIES}
|
||||
|
|
|
@ -65,7 +65,11 @@ CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& proje
|
|||
|
||||
appendStage (new WriteRefIdCollectionStage (mDocument, mState));
|
||||
|
||||
appendStage (new CollectionReferencesStage (mDocument, mState));
|
||||
|
||||
appendStage (new WriteCellCollectionStage (mDocument, mState));
|
||||
|
||||
// close file and clean up
|
||||
appendStage (new CloseSaveStage (mState));
|
||||
|
||||
appendStage (new FinalSavingStage (mDocument, mState));
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include <components/esm/loaddial.hpp>
|
||||
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
||||
#include "../world/infocollection.hpp"
|
||||
|
||||
#include "document.hpp"
|
||||
|
@ -216,6 +218,143 @@ void CSMDoc::WriteFilterStage::perform (int stage, Messages& messages)
|
|||
}
|
||||
|
||||
|
||||
CSMDoc::CollectionReferencesStage::CollectionReferencesStage (Document& document,
|
||||
SavingState& state)
|
||||
: mDocument (document), mState (state)
|
||||
{}
|
||||
|
||||
int CSMDoc::CollectionReferencesStage::setup()
|
||||
{
|
||||
mState.getSubRecords().clear();
|
||||
|
||||
int size = mDocument.getData().getReferences().getSize();
|
||||
|
||||
int steps = size/100;
|
||||
if (size%100) ++steps;
|
||||
|
||||
return steps;
|
||||
}
|
||||
|
||||
void CSMDoc::CollectionReferencesStage::perform (int stage, Messages& messages)
|
||||
{
|
||||
int size = mDocument.getData().getReferences().getSize();
|
||||
|
||||
for (int i=stage*100; i<stage*100+100 && i<size; ++i)
|
||||
{
|
||||
const CSMWorld::Record<CSMWorld::CellRef>& record =
|
||||
mDocument.getData().getReferences().getRecord (i);
|
||||
|
||||
if (record.mState==CSMWorld::RecordBase::State_Deleted ||
|
||||
record.mState==CSMWorld::RecordBase::State_Modified ||
|
||||
record.mState==CSMWorld::RecordBase::State_ModifiedOnly)
|
||||
{
|
||||
mState.getSubRecords()[Misc::StringUtils::lowerCase (record.get().mCell)]
|
||||
.push_back (i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CSMDoc::WriteCellCollectionStage::WriteCellCollectionStage (Document& document,
|
||||
SavingState& state)
|
||||
: mDocument (document), mState (state)
|
||||
{}
|
||||
|
||||
int CSMDoc::WriteCellCollectionStage::setup()
|
||||
{
|
||||
return mDocument.getData().getCells().getSize();
|
||||
}
|
||||
|
||||
void CSMDoc::WriteCellCollectionStage::perform (int stage, Messages& messages)
|
||||
{
|
||||
const CSMWorld::Record<CSMWorld::Cell>& cell =
|
||||
mDocument.getData().getCells().getRecord (stage);
|
||||
|
||||
std::map<std::string, std::vector<int> >::const_iterator references =
|
||||
mState.getSubRecords().find (Misc::StringUtils::lowerCase (cell.get().mId));
|
||||
|
||||
if (cell.mState==CSMWorld::RecordBase::State_Modified ||
|
||||
cell.mState==CSMWorld::RecordBase::State_ModifiedOnly ||
|
||||
references!=mState.getSubRecords().end())
|
||||
{
|
||||
bool interior = cell.get().mId.substr (0, 1)!="#";
|
||||
|
||||
// write cell data
|
||||
mState.getWriter().startRecord (cell.mModified.sRecordId);
|
||||
|
||||
mState.getWriter().writeHNOCString ("NAME", cell.get().mName);
|
||||
|
||||
ESM::Cell cell2 = cell.get();
|
||||
|
||||
if (interior)
|
||||
cell2.mData.mFlags |= ESM::Cell::Interior;
|
||||
else
|
||||
{
|
||||
cell2.mData.mFlags &= ~ESM::Cell::Interior;
|
||||
|
||||
std::istringstream stream (cell.get().mId.c_str());
|
||||
char ignore;
|
||||
stream >> ignore >> cell2.mData.mX >> cell2.mData.mY;
|
||||
}
|
||||
cell2.save (mState.getWriter());
|
||||
|
||||
// write references
|
||||
if (references!=mState.getSubRecords().end())
|
||||
{
|
||||
// first pass: find highest RefNum
|
||||
int lastRefNum = -1;
|
||||
|
||||
for (std::vector<int>::const_iterator iter (references->second.begin());
|
||||
iter!=references->second.end(); ++iter)
|
||||
{
|
||||
const CSMWorld::Record<CSMWorld::CellRef>& ref =
|
||||
mDocument.getData().getReferences().getRecord (*iter);
|
||||
|
||||
if (ref.get().mRefNum.mContentFile==0 && ref.get().mRefNum.mIndex>lastRefNum)
|
||||
lastRefNum = ref.get().mRefNum.mIndex;
|
||||
}
|
||||
|
||||
// second pass: write
|
||||
for (std::vector<int>::const_iterator iter (references->second.begin());
|
||||
iter!=references->second.end(); ++iter)
|
||||
{
|
||||
const CSMWorld::Record<CSMWorld::CellRef>& ref =
|
||||
mDocument.getData().getReferences().getRecord (*iter);
|
||||
|
||||
if (ref.mState==CSMWorld::RecordBase::State_Modified ||
|
||||
ref.mState==CSMWorld::RecordBase::State_ModifiedOnly)
|
||||
{
|
||||
if (ref.get().mRefNum.mContentFile==-2)
|
||||
{
|
||||
if (lastRefNum>=0xffffff)
|
||||
throw std::runtime_error (
|
||||
"RefNums exhausted in cell: " + cell.get().mId);
|
||||
|
||||
ESM::CellRef ref2 = ref.get();
|
||||
ref2.mRefNum.mContentFile = 0;
|
||||
ref2.mRefNum.mIndex = ++lastRefNum;
|
||||
|
||||
ref2.save (mState.getWriter());
|
||||
}
|
||||
else
|
||||
ref.get().save (mState.getWriter());
|
||||
}
|
||||
else if (ref.mState==CSMWorld::RecordBase::State_Deleted)
|
||||
{
|
||||
/// \todo write record with delete flag
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mState.getWriter().endRecord (cell.mModified.sRecordId);
|
||||
}
|
||||
else if (cell.mState==CSMWorld::RecordBase::State_Deleted)
|
||||
{
|
||||
/// \todo write record with delete flag
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CSMDoc::CloseSaveStage::CloseSaveStage (SavingState& state)
|
||||
: mState (state)
|
||||
{}
|
||||
|
|
|
@ -163,8 +163,40 @@ namespace CSMDoc
|
|||
|
||||
virtual void perform (int stage, Messages& messages);
|
||||
///< Messages resulting from this stage will be appended to \a messages.
|
||||
|
||||
};
|
||||
|
||||
class CollectionReferencesStage : public Stage
|
||||
{
|
||||
Document& mDocument;
|
||||
SavingState& mState;
|
||||
|
||||
public:
|
||||
|
||||
CollectionReferencesStage (Document& document, SavingState& state);
|
||||
|
||||
virtual int setup();
|
||||
///< \return number of steps
|
||||
|
||||
virtual void perform (int stage, Messages& messages);
|
||||
///< Messages resulting from this stage will be appended to \a messages.
|
||||
};
|
||||
|
||||
class WriteCellCollectionStage : public Stage
|
||||
{
|
||||
Document& mDocument;
|
||||
SavingState& mState;
|
||||
|
||||
public:
|
||||
|
||||
WriteCellCollectionStage (Document& document, SavingState& state);
|
||||
|
||||
virtual int setup();
|
||||
///< \return number of steps
|
||||
|
||||
virtual void perform (int stage, Messages& messages);
|
||||
///< Messages resulting from this stage will be appended to \a messages.
|
||||
};
|
||||
|
||||
class CloseSaveStage : public Stage
|
||||
{
|
||||
|
|
|
@ -25,6 +25,8 @@ void CSMDoc::SavingState::start (Document& document, bool project)
|
|||
|
||||
mStream.clear();
|
||||
|
||||
mSubRecords.clear();
|
||||
|
||||
if (project)
|
||||
mPath = mProjectPath;
|
||||
else
|
||||
|
@ -61,3 +63,8 @@ bool CSMDoc::SavingState::isProjectFile() const
|
|||
{
|
||||
return mProjectFile;
|
||||
}
|
||||
|
||||
std::map<std::string, std::vector<int> >& CSMDoc::SavingState::getSubRecords()
|
||||
{
|
||||
return mSubRecords;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define CSM_DOC_SAVINGSTATE_H
|
||||
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
@ -25,6 +26,7 @@ namespace CSMDoc
|
|||
ESM::ESMWriter mWriter;
|
||||
boost::filesystem::path mProjectPath;
|
||||
bool mProjectFile;
|
||||
std::map<std::string, std::vector<int> > mSubRecords; // record ID, list of subrecords
|
||||
|
||||
public:
|
||||
|
||||
|
@ -46,6 +48,8 @@ namespace CSMDoc
|
|||
|
||||
bool isProjectFile() const;
|
||||
///< Currently saving project file? (instead of content file)
|
||||
|
||||
std::map<std::string, std::vector<int> >& getSubRecords();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -621,12 +621,6 @@ void CSMTools::ReferenceableCheckStage::npcCheck (
|
|||
}
|
||||
else
|
||||
{
|
||||
if (npc.mNpdt52.mMana < 0)
|
||||
messages.push_back (std::make_pair (id, npc.mId + " mana has negative value"));
|
||||
|
||||
if (npc.mNpdt52.mFatigue < 0)
|
||||
messages.push_back (std::make_pair (id, npc.mId + " fatigue has negative value"));
|
||||
|
||||
if (npc.mNpdt52.mAgility == 0)
|
||||
messages.push_back (std::make_pair (id, npc.mId + " agility has zero value"));
|
||||
|
||||
|
|
|
@ -18,8 +18,3 @@ void CSMWorld::Cell::load (ESM::ESMReader &esm)
|
|||
mId = stream.str();
|
||||
}
|
||||
}
|
||||
|
||||
void CSMWorld::Cell::addRef (const std::string& id)
|
||||
{
|
||||
mRefs.push_back (std::make_pair (id, false));
|
||||
}
|
|
@ -15,12 +15,9 @@ namespace CSMWorld
|
|||
struct Cell : public ESM::Cell
|
||||
{
|
||||
std::string mId;
|
||||
std::vector<std::pair<std::string, bool> > mRefs; // ID, modified
|
||||
std::vector<std::string> mDeletedRefs;
|
||||
|
||||
void load (ESM::ESMReader &esm);
|
||||
|
||||
void addRef (const std::string& id);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -489,6 +489,7 @@ int CSMWorld::Data::startLoading (const boost::filesystem::path& path, bool base
|
|||
delete mReader;
|
||||
mReader = 0;
|
||||
mDialogue = 0;
|
||||
mRefLoadCache.clear();
|
||||
|
||||
mReader = new ESM::ESMReader;
|
||||
mReader->setEncoder (&mEncoder);
|
||||
|
@ -513,6 +514,7 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Stage::Messages& messages)
|
|||
delete mReader;
|
||||
mReader = 0;
|
||||
mDialogue = 0;
|
||||
mRefLoadCache.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -534,9 +536,12 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Stage::Messages& messages)
|
|||
case ESM::REC_SPEL: mSpells.load (*mReader, mBase); break;
|
||||
|
||||
case ESM::REC_CELL:
|
||||
{
|
||||
mCells.load (*mReader, mBase);
|
||||
mRefs.load (*mReader, mCells.getSize()-1, mBase);
|
||||
std::string cellId = Misc::StringUtils::lowerCase (mCells.getId (mCells.getSize()-1));
|
||||
mRefs.load (*mReader, mCells.getSize()-1, mBase, mRefLoadCache[cellId], messages);
|
||||
break;
|
||||
}
|
||||
|
||||
case ESM::REC_ACTI: mReferenceables.load (*mReader, mBase, UniversalId::Type_Activator); break;
|
||||
case ESM::REC_ALCH: mReferenceables.load (*mReader, mBase, UniversalId::Type_Potion); break;
|
||||
|
|
|
@ -77,6 +77,7 @@ namespace CSMWorld
|
|||
const ESM::Dialogue *mDialogue; // last loaded dialogue
|
||||
bool mBase;
|
||||
bool mProject;
|
||||
std::map<std::string, std::map<ESM::RefNum, std::string> > mRefLoadCache;
|
||||
|
||||
// not implemented
|
||||
Data (const Data&);
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
|
||||
#include "ref.hpp"
|
||||
|
||||
#include "cell.hpp"
|
||||
|
||||
void CSMWorld::CellRef::load (ESM::ESMReader &esm, Cell& cell, const std::string& id)
|
||||
CSMWorld::CellRef::CellRef()
|
||||
{
|
||||
mId = id;
|
||||
mCell = cell.mId;
|
||||
mRefNum.mIndex = 0;
|
||||
|
||||
cell.addRef (mId);
|
||||
// special marker: This reference does not have a RefNum assign to it yet.
|
||||
mRefNum.mContentFile = -2;
|
||||
}
|
|
@ -3,11 +3,6 @@
|
|||
|
||||
#include <components/esm/cellref.hpp>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESMReader;
|
||||
}
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
class Cell;
|
||||
|
@ -18,8 +13,7 @@ namespace CSMWorld
|
|||
std::string mId;
|
||||
std::string mCell;
|
||||
|
||||
void load (ESM::ESMReader &esm, Cell& cell, const std::string& id);
|
||||
///< Load cell ref and register it with \a cell.
|
||||
CellRef();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,15 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
||||
#include "ref.hpp"
|
||||
#include "cell.hpp"
|
||||
#include "universalid.hpp"
|
||||
#include "record.hpp"
|
||||
|
||||
void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base)
|
||||
void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base,
|
||||
std::map<ESM::RefNum, std::string>& cache, CSMDoc::Stage::Messages& messages)
|
||||
{
|
||||
Record<Cell> cell = mCells.getRecord (cellIndex);
|
||||
|
||||
|
@ -17,19 +20,73 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
|
|||
CellRef ref;
|
||||
|
||||
bool deleted = false;
|
||||
while (cell2.getNextRef (reader, ref, deleted))
|
||||
|
||||
while (ESM::Cell::getNextRef (reader, ref, deleted))
|
||||
{
|
||||
/// \todo handle deleted and moved references
|
||||
ref.load (reader, cell2, getNewId());
|
||||
ref.mCell = cell2.mId;
|
||||
|
||||
Record<CellRef> record2;
|
||||
record2.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
|
||||
(base ? record2.mBase : record2.mModified) = ref;
|
||||
/// \todo handle moved references
|
||||
|
||||
appendRecord (record2);
|
||||
std::map<ESM::RefNum, std::string>::iterator iter = cache.find (ref.mRefNum);
|
||||
|
||||
if (deleted)
|
||||
{
|
||||
if (iter==cache.end())
|
||||
{
|
||||
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Cell,
|
||||
mCells.getId (cellIndex));
|
||||
|
||||
messages.push_back (std::make_pair (id,
|
||||
"Attempt to delete a non-existing reference"));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
int index = getIndex (iter->second);
|
||||
|
||||
Record<CellRef> record = getRecord (index);
|
||||
|
||||
if (record.mState==RecordBase::State_BaseOnly)
|
||||
{
|
||||
removeRows (index, 1);
|
||||
cache.erase (iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
record.mState = RecordBase::State_Deleted;
|
||||
setRecord (index, record);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (iter==cache.end())
|
||||
{
|
||||
// new reference
|
||||
ref.mId = getNewId();
|
||||
|
||||
Record<CellRef> record;
|
||||
record.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
|
||||
(base ? record.mBase : record.mModified) = ref;
|
||||
|
||||
appendRecord (record);
|
||||
|
||||
cache.insert (std::make_pair (ref.mRefNum, ref.mId));
|
||||
}
|
||||
else
|
||||
{
|
||||
// old reference -> merge
|
||||
ref.mId = iter->second;
|
||||
|
||||
int index = getIndex (ref.mId);
|
||||
|
||||
Record<CellRef> record = getRecord (index);
|
||||
record.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_Modified;
|
||||
(base ? record.mBase : record.mModified) = ref;
|
||||
|
||||
setRecord (index, record);
|
||||
}
|
||||
}
|
||||
|
||||
mCells.setRecord (cellIndex, cell);
|
||||
}
|
||||
|
||||
std::string CSMWorld::RefCollection::getNewId()
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#ifndef CSM_WOLRD_REFCOLLECTION_H
|
||||
#define CSM_WOLRD_REFCOLLECTION_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "../doc/stage.hpp"
|
||||
|
||||
#include "collection.hpp"
|
||||
#include "ref.hpp"
|
||||
#include "record.hpp"
|
||||
|
@ -22,7 +26,9 @@ namespace CSMWorld
|
|||
: mCells (cells), mNextId (0)
|
||||
{}
|
||||
|
||||
void load (ESM::ESMReader& reader, int cellIndex, bool base);
|
||||
void load (ESM::ESMReader& reader, int cellIndex, bool base,
|
||||
std::map<ESM::RefNum, std::string>& cache,
|
||||
CSMDoc::Stage::Messages& messages);
|
||||
///< Load a sequence of references.
|
||||
|
||||
std::string getNewId();
|
||||
|
|
|
@ -304,10 +304,17 @@ CSMWorld::RefIdCollection::RefIdCollection()
|
|||
mColumns.push_back (RefIdColumn (Columns::ColumnId_WeaponReach, ColumnBase::Display_Float));
|
||||
weaponColumns.mReach = &mColumns.back();
|
||||
|
||||
for (int i=0; i<6; ++i)
|
||||
for (int i=0; i<3; ++i)
|
||||
{
|
||||
mColumns.push_back (RefIdColumn (Columns::ColumnId_MinChop + i, ColumnBase::Display_Integer));
|
||||
weaponColumns.mChop[i] = &mColumns.back();
|
||||
const RefIdColumn **column =
|
||||
i==0 ? weaponColumns.mChop : (i==1 ? weaponColumns.mSlash : weaponColumns.mThrust);
|
||||
|
||||
for (int j=0; j<2; ++j)
|
||||
{
|
||||
mColumns.push_back (
|
||||
RefIdColumn (Columns::ColumnId_MinChop+i*2+j, ColumnBase::Display_Integer));
|
||||
column[j] = &mColumns.back();
|
||||
}
|
||||
}
|
||||
|
||||
static const struct
|
||||
|
|
|
@ -33,7 +33,7 @@ add_openmw_dir (mwgui
|
|||
merchantrepair repair soulgemdialog companionwindow bookpage journalviewmodel journalbooks
|
||||
keywordsearch itemmodel containeritemmodel inventoryitemmodel sortfilteritemmodel itemview
|
||||
tradeitemmodel companionitemmodel pickpocketitemmodel fontloader controllers savegamedialog
|
||||
recharge mode videowidget backgroundimage
|
||||
recharge mode videowidget backgroundimage itemwidget
|
||||
)
|
||||
|
||||
add_openmw_dir (mwdialogue
|
||||
|
@ -89,19 +89,6 @@ endif(WIN32)
|
|||
|
||||
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
||||
|
||||
IF(OGRE_STATIC)
|
||||
ADD_DEFINITIONS(-DENABLE_PLUGIN_OctreeSceneManager -DENABLE_PLUGIN_ParticleFX -DENABLE_PLUGIN_GL)
|
||||
set(OGRE_STATIC_PLUGINS ${OGRE_Plugin_OctreeSceneManager_LIBRARIES} ${OGRE_Plugin_ParticleFX_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES})
|
||||
IF(WIN32)
|
||||
ADD_DEFINITIONS(-DENABLE_PLUGIN_Direct3D9)
|
||||
list (APPEND OGRE_STATIC_PLUGINS ${OGRE_RenderSystem_Direct3D9_LIBRARIES})
|
||||
ENDIF(WIN32)
|
||||
IF (Cg_FOUND)
|
||||
ADD_DEFINITIONS(-DENABLE_PLUGIN_CgProgramManager)
|
||||
list (APPEND OGRE_STATIC_PLUGINS ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${Cg_LIBRARIES})
|
||||
ENDIF (Cg_FOUND)
|
||||
ENDIF(OGRE_STATIC)
|
||||
|
||||
add_executable(openmw
|
||||
${OPENMW_LIBS} ${OPENMW_LIBS_HEADER}
|
||||
${OPENMW_FILES}
|
||||
|
|
|
@ -137,6 +137,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|||
}
|
||||
|
||||
// update GUI
|
||||
MWBase::Environment::get().getWindowManager()->onFrame(frametime);
|
||||
if (MWBase::Environment::get().getStateManager()->getState()!=
|
||||
MWBase::StateManager::State_NoGame)
|
||||
{
|
||||
|
@ -145,7 +146,6 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|||
MWBase::Environment::get().getWorld()->getTriangleBatchCount(tri, batch);
|
||||
MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), tri, batch);
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->onFrame(frametime);
|
||||
MWBase::Environment::get().getWindowManager()->update();
|
||||
}
|
||||
}
|
||||
|
@ -491,10 +491,7 @@ void OMW::Engine::activate()
|
|||
|
||||
MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr);
|
||||
|
||||
boost::shared_ptr<MWWorld::Action> action =
|
||||
ptr.getClass().activate (ptr, MWBase::Environment::get().getWorld()->getPlayerPtr());
|
||||
|
||||
interpreterContext.activate (ptr, action);
|
||||
interpreterContext.activate (ptr);
|
||||
|
||||
std::string script = ptr.getClass().getScript (ptr);
|
||||
|
||||
|
@ -508,7 +505,7 @@ void OMW::Engine::activate()
|
|||
|
||||
if (!interpreterContext.hasActivationBeenHandled())
|
||||
{
|
||||
interpreterContext.executeActivation();
|
||||
interpreterContext.executeActivation(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,8 @@ namespace MWBase
|
|||
|
||||
virtual void persuade (int type) = 0;
|
||||
virtual int getTemporaryDispositionChange () const = 0;
|
||||
|
||||
/// @note This change is temporary and gets discarded when dialogue ends.
|
||||
virtual void applyDispositionChange (int delta) = 0;
|
||||
|
||||
virtual int countSavedGameRecords() const = 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef GAME_MWSTATE_STATEMANAGER_H
|
||||
#define GAME_MWSTATE_STATEMANAGER_H
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
namespace MWState
|
||||
|
@ -24,7 +24,7 @@ namespace MWBase
|
|||
State_Running
|
||||
};
|
||||
|
||||
typedef std::vector<MWState::Character>::const_iterator CharacterIterator;
|
||||
typedef std::list<MWState::Character>::const_iterator CharacterIterator;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ namespace MWGui
|
|||
class InventoryWindow;
|
||||
class ContainerWindow;
|
||||
class DialogueWindow;
|
||||
class WindowModal;
|
||||
|
||||
enum ShowInDialogueMode {
|
||||
ShowInDialogueMode_IfPossible,
|
||||
|
@ -234,14 +235,19 @@ namespace MWBase
|
|||
|
||||
virtual void addVisitedLocation(const std::string& name, int x, int y) = 0;
|
||||
|
||||
/// Hides dialog and schedules dialog to be deleted.
|
||||
virtual void removeDialog(OEngine::GUI::Layout* dialog) = 0;
|
||||
///< Hides dialog and schedules dialog to be deleted.
|
||||
|
||||
///Gracefully attempts to exit the topmost GUI mode
|
||||
/** No guarentee of actually closing the window **/
|
||||
virtual void exitCurrentGuiMode() = 0;
|
||||
|
||||
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>(), enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible) = 0;
|
||||
virtual void staticMessageBox(const std::string& message) = 0;
|
||||
virtual void removeStaticMessageBox() = 0;
|
||||
|
||||
/// returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
||||
virtual int readPressedButton() = 0;
|
||||
///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
||||
|
||||
virtual void onFrame (float frameDuration) = 0;
|
||||
|
||||
|
@ -309,6 +315,19 @@ namespace MWBase
|
|||
|
||||
/// Does the current stack of GUI-windows permit saving?
|
||||
virtual bool isSavingAllowed() const = 0;
|
||||
|
||||
/// Returns the current Modal
|
||||
/** Used to send exit command to active Modal when Esc is pressed **/
|
||||
virtual MWGui::WindowModal* getCurrentModal() const = 0;
|
||||
|
||||
/// Sets the current Modal
|
||||
/** Used to send exit command to active Modal when Esc is pressed **/
|
||||
virtual void addCurrentModal(MWGui::WindowModal* input) = 0;
|
||||
|
||||
/// Removes the top Modal
|
||||
/** Used when one Modal adds another Modal
|
||||
\param input Pointer to the current modal, to ensure proper modal is removed **/
|
||||
virtual void removeCurrentModal(MWGui::WindowModal* input) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -50,9 +50,9 @@ namespace MWClass
|
|||
void Light::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
const std::string model = getModel(ptr);
|
||||
if(!model.empty()) {
|
||||
renderingInterface.getObjects().insertModel(ptr, model);
|
||||
}
|
||||
|
||||
// Insert even if model is empty, so that the light is added
|
||||
renderingInterface.getObjects().insertModel(ptr, model);
|
||||
}
|
||||
|
||||
void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||
|
|
|
@ -64,6 +64,9 @@ namespace MWClass
|
|||
|
||||
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
|
||||
///< Return item max health or throw an exception, if class does not have item health
|
||||
|
||||
virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const { return true; }
|
||||
///< \return Item health data available? (default implementation: false)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -680,7 +680,7 @@ namespace MWClass
|
|||
else
|
||||
getCreatureStats(ptr).setHitRecovery(true); // Is this supposed to always occur?
|
||||
|
||||
if(ishealth)
|
||||
if(ishealth && !attacker.isEmpty()) // Don't use armor mitigation for fall damage
|
||||
{
|
||||
// Hit percentages:
|
||||
// cuirass = 30%
|
||||
|
|
|
@ -64,6 +64,9 @@ namespace MWClass
|
|||
|
||||
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
|
||||
///< Return item max health or throw an exception, if class does not have item health
|
||||
|
||||
virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const { return true; }
|
||||
///< \return Item health data available? (default implementation: false)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -560,17 +560,7 @@ namespace MWDialogue
|
|||
|
||||
void DialogueManager::applyDispositionChange(int delta)
|
||||
{
|
||||
int oldTemp = mTemporaryDispositionChange;
|
||||
mTemporaryDispositionChange += delta;
|
||||
// don't allow increasing beyond 100 or decreasing below 0
|
||||
int curDisp = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mActor);
|
||||
if (curDisp + mTemporaryDispositionChange < 0)
|
||||
mTemporaryDispositionChange = -curDisp;
|
||||
else if (curDisp + mTemporaryDispositionChange > 100)
|
||||
mTemporaryDispositionChange = 100 - curDisp;
|
||||
|
||||
int diff = mTemporaryDispositionChange - oldTemp;
|
||||
mPermanentDispositionChange += diff;
|
||||
}
|
||||
|
||||
bool DialogueManager::checkServiceRefused()
|
||||
|
|
|
@ -84,6 +84,8 @@ namespace MWDialogue
|
|||
|
||||
virtual void persuade (int type);
|
||||
virtual int getTemporaryDispositionChange () const;
|
||||
|
||||
/// @note This change is temporary and gets discarded when dialogue ends.
|
||||
virtual void applyDispositionChange (int delta);
|
||||
|
||||
virtual int countSavedGameRecords() const;
|
||||
|
|
|
@ -13,20 +13,7 @@
|
|||
#include "inventoryitemmodel.hpp"
|
||||
#include "sortfilteritemmodel.hpp"
|
||||
#include "itemview.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
std::string getIconPath(MWWorld::Ptr ptr)
|
||||
{
|
||||
std::string path = std::string("icons\\");
|
||||
path += ptr.getClass().getInventoryIcon(ptr);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -66,10 +53,7 @@ namespace MWGui
|
|||
|
||||
void AlchemyWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
mAlchemy.clear();
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Alchemy);
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Inventory);
|
||||
exit();
|
||||
}
|
||||
|
||||
void AlchemyWindow::onCreateButtonClicked(MyGUI::Widget* _sender)
|
||||
|
@ -152,13 +136,19 @@ namespace MWGui
|
|||
{
|
||||
mApparatus.at (index)->setUserString ("ToolTipType", "ItemPtr");
|
||||
mApparatus.at (index)->setUserData (*iter);
|
||||
mApparatus.at (index)->setImageTexture (getIconPath (*iter));
|
||||
mApparatus.at (index)->setItem(*iter);
|
||||
}
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void AlchemyWindow::exit() {
|
||||
mAlchemy.clear();
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Alchemy);
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Inventory);
|
||||
}
|
||||
|
||||
void AlchemyWindow::onIngredientSelected(MyGUI::Widget* _sender)
|
||||
{
|
||||
removeIngredient(_sender);
|
||||
|
@ -186,7 +176,7 @@ namespace MWGui
|
|||
MWMechanics::Alchemy::TIngredientsIterator it = mAlchemy.beginIngredients ();
|
||||
for (int i=0; i<4; ++i)
|
||||
{
|
||||
MyGUI::ImageBox* ingredient = mIngredients[i];
|
||||
ItemWidget* ingredient = mIngredients[i];
|
||||
|
||||
MWWorld::Ptr item;
|
||||
if (it != mAlchemy.endIngredients ())
|
||||
|
@ -201,15 +191,15 @@ namespace MWGui
|
|||
if (ingredient->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(ingredient->getChildAt(0));
|
||||
|
||||
ingredient->setImageTexture("");
|
||||
ingredient->clearUserStrings ();
|
||||
|
||||
ingredient->setItem(item);
|
||||
|
||||
if (item.isEmpty ())
|
||||
continue;
|
||||
|
||||
ingredient->setUserString("ToolTipType", "ItemPtr");
|
||||
ingredient->setUserData(item);
|
||||
ingredient->setImageTexture(getIconPath(item));
|
||||
|
||||
MyGUI::TextBox* text = ingredient->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label"));
|
||||
text->setTextAlign(MyGUI::Align::Right);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
namespace MWGui
|
||||
{
|
||||
class ItemView;
|
||||
class ItemWidget;
|
||||
class SortFilterItemModel;
|
||||
|
||||
class AlchemyWindow : public WindowBase
|
||||
|
@ -19,6 +20,7 @@ namespace MWGui
|
|||
AlchemyWindow();
|
||||
|
||||
virtual void open();
|
||||
virtual void exit();
|
||||
|
||||
private:
|
||||
ItemView* mItemView;
|
||||
|
@ -43,8 +45,8 @@ namespace MWGui
|
|||
|
||||
MWMechanics::Alchemy mAlchemy;
|
||||
|
||||
std::vector<MyGUI::ImageBox *> mApparatus;
|
||||
std::vector<MyGUI::ImageBox *> mIngredients;
|
||||
std::vector<ItemWidget*> mApparatus;
|
||||
std::vector<ItemWidget*> mIngredients;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -114,6 +114,14 @@ namespace MWGui
|
|||
setTakeButtonShow(true);
|
||||
}
|
||||
|
||||
void BookWindow::exit()
|
||||
{
|
||||
// no 3d sounds because the object could be in a container.
|
||||
MWBase::Environment::get().getSoundManager()->playSound ("book close", 1.0, 1.0);
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Book);
|
||||
}
|
||||
|
||||
void BookWindow::setTakeButtonShow(bool show)
|
||||
{
|
||||
mTakeButtonShow = show;
|
||||
|
@ -128,10 +136,7 @@ namespace MWGui
|
|||
|
||||
void BookWindow::onCloseButtonClicked (MyGUI::Widget* sender)
|
||||
{
|
||||
// no 3d sounds because the object could be in a container.
|
||||
MWBase::Environment::get().getSoundManager()->playSound ("book close", 1.0, 1.0);
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Book);
|
||||
exit();
|
||||
}
|
||||
|
||||
void BookWindow::onTakeButtonClicked (MyGUI::Widget* sender)
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace MWGui
|
|||
public:
|
||||
BookWindow();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
void open(MWWorld::Ptr book);
|
||||
void setTakeButtonShow(bool show);
|
||||
void nextPage();
|
||||
|
|
|
@ -718,6 +718,11 @@ namespace MWGui
|
|||
}
|
||||
|
||||
void SelectSpecializationDialog::onCancelClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
void SelectSpecializationDialog::exit()
|
||||
{
|
||||
eventCancel();
|
||||
}
|
||||
|
@ -764,6 +769,11 @@ namespace MWGui
|
|||
}
|
||||
|
||||
void SelectAttributeDialog::onCancelClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
void SelectAttributeDialog::exit()
|
||||
{
|
||||
eventCancel();
|
||||
}
|
||||
|
@ -855,6 +865,11 @@ namespace MWGui
|
|||
}
|
||||
|
||||
void SelectSkillDialog::onCancelClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
void SelectSkillDialog::exit()
|
||||
{
|
||||
eventCancel();
|
||||
}
|
||||
|
|
|
@ -136,6 +136,8 @@ namespace MWGui
|
|||
SelectSpecializationDialog();
|
||||
~SelectSpecializationDialog();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
ESM::Class::Specialization getSpecializationId() const { return mSpecializationId; }
|
||||
|
||||
// Events
|
||||
|
@ -167,6 +169,8 @@ namespace MWGui
|
|||
SelectAttributeDialog();
|
||||
~SelectAttributeDialog();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
ESM::Attribute::AttributeID getAttributeId() const { return mAttributeId; }
|
||||
|
||||
// Events
|
||||
|
@ -196,6 +200,8 @@ namespace MWGui
|
|||
SelectSkillDialog();
|
||||
~SelectSkillDialog();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
ESM::Skill::SkillEnum getSkillId() const { return mSkillId; }
|
||||
|
||||
// Events
|
||||
|
|
|
@ -118,6 +118,11 @@ void CompanionWindow::updateEncumbranceBar()
|
|||
}
|
||||
|
||||
void CompanionWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
void CompanionWindow::exit()
|
||||
{
|
||||
if (mPtr.getTypeName() == typeid(ESM::NPC).name() && mPtr.getClass().getNpcStats(mPtr).getProfit() < 0)
|
||||
{
|
||||
|
|
|
@ -18,6 +18,8 @@ namespace MWGui
|
|||
public:
|
||||
CompanionWindow(DragAndDrop* dragAndDrop, MessageBoxManager* manager);
|
||||
|
||||
virtual void exit();
|
||||
|
||||
void open(const MWWorld::Ptr& npc);
|
||||
void onFrame ();
|
||||
|
||||
|
|
|
@ -28,13 +28,18 @@ namespace MWGui
|
|||
center();
|
||||
}
|
||||
|
||||
void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
|
||||
void ConfirmationDialog::exit()
|
||||
{
|
||||
eventCancelClicked();
|
||||
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
void ConfirmationDialog::onOkButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
eventOkClicked();
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace MWGui
|
|||
public:
|
||||
ConfirmationDialog();
|
||||
void open(const std::string& message);
|
||||
virtual void exit();
|
||||
|
||||
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace MWGui
|
|||
}
|
||||
catch (const std::exception& error)
|
||||
{
|
||||
printError (std::string ("An exception has been thrown: ") + error.what());
|
||||
printError (std::string ("Error: ") + error.what());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -143,6 +143,11 @@ namespace MWGui
|
|||
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(NULL);
|
||||
}
|
||||
|
||||
void Console::exit()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Console);
|
||||
}
|
||||
|
||||
void Console::setFont(const std::string &fntName)
|
||||
{
|
||||
mHistory->setFontName(fntName);
|
||||
|
@ -190,7 +195,7 @@ namespace MWGui
|
|||
}
|
||||
catch (const std::exception& error)
|
||||
{
|
||||
printError (std::string ("An exception has been thrown: ") + error.what());
|
||||
printError (std::string ("Error: ") + error.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,86 +21,83 @@
|
|||
|
||||
namespace MWGui
|
||||
{
|
||||
class Console : public WindowBase, private Compiler::ErrorHandler, public ReferenceInterface
|
||||
{
|
||||
private:
|
||||
class Console : public WindowBase, private Compiler::ErrorHandler, public ReferenceInterface
|
||||
{
|
||||
public:
|
||||
/// Set the implicit object for script execution
|
||||
void setSelectedObject(const MWWorld::Ptr& object);
|
||||
|
||||
Compiler::Extensions mExtensions;
|
||||
MWScript::CompilerContext mCompilerContext;
|
||||
std::vector<std::string> mNames;
|
||||
bool mConsoleOnlyScripts;
|
||||
MyGUI::EditBox* mCommandLine;
|
||||
MyGUI::EditBox* mHistory;
|
||||
|
||||
bool compile (const std::string& cmd, Compiler::Output& output);
|
||||
typedef std::list<std::string> StringList;
|
||||
|
||||
/// Report error to the user.
|
||||
virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type);
|
||||
// History of previous entered commands
|
||||
StringList mCommandHistory;
|
||||
StringList::iterator mCurrent;
|
||||
std::string mEditString;
|
||||
|
||||
/// Report a file related error
|
||||
virtual void report (const std::string& message, Type type);
|
||||
Console(int w, int h, bool consoleOnlyScripts);
|
||||
|
||||
void listNames();
|
||||
///< Write all valid identifiers and keywords into mNames and sort them.
|
||||
/// \note If mNames is not empty, this function is a no-op.
|
||||
/// \note The list may contain duplicates (if a name is a keyword and an identifier at the same
|
||||
/// time).
|
||||
virtual void open();
|
||||
virtual void close();
|
||||
|
||||
public:
|
||||
virtual void exit();
|
||||
|
||||
void setSelectedObject(const MWWorld::Ptr& object);
|
||||
///< Set the implicit object for script execution
|
||||
void setFont(const std::string &fntName);
|
||||
|
||||
protected:
|
||||
void onResChange(int width, int height);
|
||||
|
||||
virtual void onReferenceUnavailable();
|
||||
void clearHistory();
|
||||
|
||||
// Print a message to the console. Messages may contain color
|
||||
// code, eg. "#FFFFFF this is white".
|
||||
void print(const std::string &msg);
|
||||
|
||||
public:
|
||||
MyGUI::EditBox* mCommandLine;
|
||||
MyGUI::EditBox* mHistory;
|
||||
// These are pre-colored versions that you should use.
|
||||
|
||||
typedef std::list<std::string> StringList;
|
||||
/// Output from successful console command
|
||||
void printOK(const std::string &msg);
|
||||
|
||||
// History of previous entered commands
|
||||
StringList mCommandHistory;
|
||||
StringList::iterator mCurrent;
|
||||
std::string mEditString;
|
||||
/// Error message
|
||||
void printError(const std::string &msg);
|
||||
|
||||
Console(int w, int h, bool consoleOnlyScripts);
|
||||
void execute (const std::string& command);
|
||||
|
||||
virtual void open();
|
||||
virtual void close();
|
||||
void executeFile (const std::string& path);
|
||||
|
||||
void setFont(const std::string &fntName);
|
||||
protected:
|
||||
|
||||
void onResChange(int width, int height);
|
||||
virtual void onReferenceUnavailable();
|
||||
|
||||
void clearHistory();
|
||||
private:
|
||||
|
||||
// Print a message to the console. Messages may contain color
|
||||
// code, eg. "#FFFFFF this is white".
|
||||
void print(const std::string &msg);
|
||||
void keyPress(MyGUI::Widget* _sender,
|
||||
MyGUI::KeyCode key,
|
||||
MyGUI::Char _char);
|
||||
|
||||
// These are pre-colored versions that you should use.
|
||||
void acceptCommand(MyGUI::EditBox* _sender);
|
||||
|
||||
/// Output from successful console command
|
||||
void printOK(const std::string &msg);
|
||||
std::string complete( std::string input, std::vector<std::string> &matches );
|
||||
|
||||
/// Error message
|
||||
void printError(const std::string &msg);
|
||||
Compiler::Extensions mExtensions;
|
||||
MWScript::CompilerContext mCompilerContext;
|
||||
std::vector<std::string> mNames;
|
||||
bool mConsoleOnlyScripts;
|
||||
|
||||
void execute (const std::string& command);
|
||||
bool compile (const std::string& cmd, Compiler::Output& output);
|
||||
|
||||
void executeFile (const std::string& path);
|
||||
/// Report error to the user.
|
||||
virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type);
|
||||
|
||||
private:
|
||||
/// Report a file related error
|
||||
virtual void report (const std::string& message, Type type);
|
||||
|
||||
void keyPress(MyGUI::Widget* _sender,
|
||||
MyGUI::KeyCode key,
|
||||
MyGUI::Char _char);
|
||||
|
||||
void acceptCommand(MyGUI::EditBox* _sender);
|
||||
|
||||
std::string complete( std::string input, std::vector<std::string> &matches );
|
||||
/// Write all valid identifiers and keywords into mNames and sort them.
|
||||
/// \note If mNames is not empty, this function is a no-op.
|
||||
/// \note The list may contain duplicates (if a name is a keyword and an identifier at the same
|
||||
/// time).
|
||||
void listNames();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "inventorywindow.hpp"
|
||||
|
||||
#include "itemview.hpp"
|
||||
#include "itemwidget.hpp"
|
||||
#include "inventoryitemmodel.hpp"
|
||||
#include "sortfilteritemmodel.hpp"
|
||||
#include "pickpocketitemmodel.hpp"
|
||||
|
@ -46,22 +47,15 @@ namespace MWGui
|
|||
mSourceSortModel->addDragItem(mItem.mBase, count);
|
||||
}
|
||||
|
||||
std::string path = std::string("icons\\");
|
||||
path += mItem.mBase.getClass().getInventoryIcon(mItem.mBase);
|
||||
MyGUI::ImageBox* baseWidget = mDragAndDropWidget->createWidget<MyGUI::ImageBox>
|
||||
("ImageBox", MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
|
||||
ItemWidget* baseWidget = mDragAndDropWidget->createWidget<ItemWidget>
|
||||
("MW_ItemIcon", MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
|
||||
mDraggedWidget = baseWidget;
|
||||
MyGUI::ImageBox* image = baseWidget->createWidget<MyGUI::ImageBox>("ImageBox",
|
||||
MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||
size_t pos = path.rfind(".");
|
||||
if (pos != std::string::npos)
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture(path);
|
||||
image->setNeedMouseFocus(false);
|
||||
baseWidget->setItem(mItem.mBase);
|
||||
baseWidget->setNeedMouseFocus(false);
|
||||
|
||||
// text widget that shows item count
|
||||
MyGUI::TextBox* text = image->createWidget<MyGUI::TextBox>("SandBrightText",
|
||||
// TODO: move to ItemWidget
|
||||
MyGUI::TextBox* text = baseWidget->createWidget<MyGUI::TextBox>("SandBrightText",
|
||||
MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label"));
|
||||
text->setTextAlign(MyGUI::Align::Right);
|
||||
text->setNeedMouseFocus(false);
|
||||
|
@ -263,7 +257,7 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
|
||||
void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
|
||||
void ContainerWindow::exit()
|
||||
{
|
||||
if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop)
|
||||
{
|
||||
|
@ -271,6 +265,11 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
|
||||
void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
void ContainerWindow::onTakeAllButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop)
|
||||
|
|
|
@ -54,6 +54,8 @@ namespace MWGui
|
|||
void open(const MWWorld::Ptr& container, bool loot=false);
|
||||
virtual void close();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
private:
|
||||
DragAndDrop* mDragAndDrop;
|
||||
|
||||
|
|
|
@ -49,7 +49,12 @@ namespace MWGui
|
|||
mItemEdit->setCaption(boost::lexical_cast<std::string>(maxCount));
|
||||
}
|
||||
|
||||
void CountDialog::cancel()
|
||||
void CountDialog::cancel() //Keeping this here as I don't know if anything else relies on it.
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
void CountDialog::exit()
|
||||
{
|
||||
setVisible(false);
|
||||
}
|
||||
|
@ -65,16 +70,16 @@ namespace MWGui
|
|||
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
// essentially duplicating what the OK button does if user presses
|
||||
// Enter key
|
||||
void CountDialog::onEnterKeyPressed(MyGUI::EditBox* _sender)
|
||||
{
|
||||
eventOkClicked(NULL, mSlider->getScrollPosition()+1);
|
||||
|
||||
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
void CountDialog::onEditTextChange(MyGUI::EditBox* _sender)
|
||||
{
|
||||
if (_sender->getCaption() == "")
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace MWGui
|
|||
CountDialog();
|
||||
void open(const std::string& item, const std::string& message, const int maxCount);
|
||||
void cancel();
|
||||
virtual void exit();
|
||||
|
||||
typedef MyGUI::delegates::CMultiDelegate2<MyGUI::Widget*, int> EventHandle_WidgetInt;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace MWGui
|
|||
|
||||
void PersuasionDialog::onCancel(MyGUI::Widget *sender)
|
||||
{
|
||||
setVisible(false);
|
||||
exit();
|
||||
}
|
||||
|
||||
void PersuasionDialog::onPersuade(MyGUI::Widget *sender)
|
||||
|
@ -87,6 +87,11 @@ namespace MWGui
|
|||
mGoldLabel->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(playerGold));
|
||||
}
|
||||
|
||||
void PersuasionDialog::exit()
|
||||
{
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------
|
||||
|
||||
Response::Response(const std::string &text, const std::string &title)
|
||||
|
@ -264,6 +269,14 @@ namespace MWGui
|
|||
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize);
|
||||
}
|
||||
|
||||
void DialogueWindow::exit()
|
||||
{
|
||||
if ((!mEnabled || MWBase::Environment::get().getDialogueManager()->isInChoice())
|
||||
&& !mGoodbye)
|
||||
return;
|
||||
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
|
||||
}
|
||||
|
||||
void DialogueWindow::onWindowResize(MyGUI::Window* _sender)
|
||||
{
|
||||
mTopicsList->adjustSize();
|
||||
|
@ -281,9 +294,7 @@ namespace MWGui
|
|||
|
||||
void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
if (!mEnabled || MWBase::Environment::get().getDialogueManager()->isInChoice())
|
||||
return;
|
||||
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
|
||||
exit();
|
||||
}
|
||||
|
||||
void DialogueWindow::onSelectTopic(const std::string& topic, int id)
|
||||
|
@ -504,6 +515,15 @@ namespace MWGui
|
|||
// no scrollbar
|
||||
onScrollbarMoved(mScrollBar, 0);
|
||||
}
|
||||
|
||||
MyGUI::Button* byeButton;
|
||||
getWidget(byeButton, "ByeButton");
|
||||
if(MWBase::Environment::get().getDialogueManager()->isInChoice() && !mGoodbye) {
|
||||
byeButton->setEnabled(false);
|
||||
}
|
||||
else {
|
||||
byeButton->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void DialogueWindow::notifyLinkClicked (TypesetBook::InteractiveId link)
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace MWGui
|
|||
PersuasionDialog();
|
||||
|
||||
virtual void open();
|
||||
virtual void exit();
|
||||
|
||||
private:
|
||||
MyGUI::Button* mCancelButton;
|
||||
|
@ -103,6 +104,8 @@ namespace MWGui
|
|||
public:
|
||||
DialogueWindow();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
// Events
|
||||
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "itemselection.hpp"
|
||||
#include "container.hpp"
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
#include "sortfilteritemmodel.hpp"
|
||||
|
||||
|
@ -57,8 +58,50 @@ namespace MWGui
|
|||
void EnchantingDialog::open()
|
||||
{
|
||||
center();
|
||||
onRemoveItem(NULL);
|
||||
onRemoveSoul(NULL);
|
||||
|
||||
setSoulGem(MWWorld::Ptr());
|
||||
setItem(MWWorld::Ptr());
|
||||
}
|
||||
|
||||
void EnchantingDialog::setSoulGem(const MWWorld::Ptr &gem)
|
||||
{
|
||||
if (gem.isEmpty())
|
||||
{
|
||||
mSoulBox->setItem(MWWorld::Ptr());
|
||||
mSoulBox->clearUserStrings();
|
||||
mEnchanting.setSoulGem(MWWorld::Ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
mSoulBox->setItem(gem);
|
||||
mSoulBox->setUserString ("ToolTipType", "ItemPtr");
|
||||
mSoulBox->setUserData(gem);
|
||||
mEnchanting.setSoulGem(gem);
|
||||
}
|
||||
updateLabels();
|
||||
}
|
||||
|
||||
void EnchantingDialog::setItem(const MWWorld::Ptr &item)
|
||||
{
|
||||
if (item.isEmpty())
|
||||
{
|
||||
mItemBox->setItem(MWWorld::Ptr());
|
||||
mItemBox->clearUserStrings();
|
||||
mEnchanting.setOldItem(MWWorld::Ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
mItemBox->setItem(item);
|
||||
mItemBox->setUserString ("ToolTipType", "ItemPtr");
|
||||
mItemBox->setUserData(item);
|
||||
mEnchanting.setOldItem(item);
|
||||
}
|
||||
updateLabels();
|
||||
}
|
||||
|
||||
void EnchantingDialog::exit()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Enchanting);
|
||||
}
|
||||
|
||||
void EnchantingDialog::updateLabels()
|
||||
|
@ -117,16 +160,7 @@ namespace MWGui
|
|||
startEditing();
|
||||
mEnchanting.setSoulGem(soulgem);
|
||||
|
||||
MyGUI::ImageBox* image = mSoulBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += soulgem.getClass().getInventoryIcon(soulgem);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture (path);
|
||||
image->setUserString ("ToolTipType", "ItemPtr");
|
||||
image->setUserData(soulgem);
|
||||
image->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onRemoveSoul);
|
||||
setSoulGem(soulgem);
|
||||
|
||||
mPrice->setVisible(false);
|
||||
mPriceText->setVisible(false);
|
||||
|
@ -141,51 +175,36 @@ namespace MWGui
|
|||
|
||||
void EnchantingDialog::onCancelButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Enchanting);
|
||||
exit();
|
||||
}
|
||||
|
||||
void EnchantingDialog::onSelectItem(MyGUI::Widget *sender)
|
||||
{
|
||||
delete mItemSelectionDialog;
|
||||
mItemSelectionDialog = new ItemSelectionDialog("#{sEnchantItems}");
|
||||
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &EnchantingDialog::onItemSelected);
|
||||
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &EnchantingDialog::onItemCancel);
|
||||
mItemSelectionDialog->setVisible(true);
|
||||
mItemSelectionDialog->openContainer(MWBase::Environment::get().getWorld()->getPlayerPtr());
|
||||
mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyEnchantable);
|
||||
if (mEnchanting.getOldItem().isEmpty())
|
||||
{
|
||||
delete mItemSelectionDialog;
|
||||
mItemSelectionDialog = new ItemSelectionDialog("#{sEnchantItems}");
|
||||
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &EnchantingDialog::onItemSelected);
|
||||
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &EnchantingDialog::onItemCancel);
|
||||
mItemSelectionDialog->setVisible(true);
|
||||
mItemSelectionDialog->openContainer(MWBase::Environment::get().getWorld()->getPlayerPtr());
|
||||
mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyEnchantable);
|
||||
}
|
||||
else
|
||||
{
|
||||
setItem(MWWorld::Ptr());
|
||||
}
|
||||
}
|
||||
|
||||
void EnchantingDialog::onItemSelected(MWWorld::Ptr item)
|
||||
{
|
||||
mItemSelectionDialog->setVisible(false);
|
||||
|
||||
while (mItemBox->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (mItemBox->getChildAt(0));
|
||||
|
||||
MyGUI::ImageBox* image = mItemBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += item.getClass().getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture (path);
|
||||
image->setUserString ("ToolTipType", "ItemPtr");
|
||||
image->setUserData(item);
|
||||
image->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onRemoveItem);
|
||||
|
||||
mEnchanting.setOldItem(item);
|
||||
setItem(item);
|
||||
mEnchanting.nextCastStyle();
|
||||
updateLabels();
|
||||
}
|
||||
|
||||
void EnchantingDialog::onRemoveItem(MyGUI::Widget *sender)
|
||||
{
|
||||
while (mItemBox->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (mItemBox->getChildAt(0));
|
||||
mEnchanting.setOldItem(MWWorld::Ptr());
|
||||
updateLabels();
|
||||
}
|
||||
|
||||
void EnchantingDialog::onItemCancel()
|
||||
{
|
||||
mItemSelectionDialog->setVisible(false);
|
||||
|
@ -202,28 +221,7 @@ namespace MWGui
|
|||
return;
|
||||
}
|
||||
|
||||
while (mSoulBox->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (mSoulBox->getChildAt(0));
|
||||
|
||||
MyGUI::ImageBox* image = mSoulBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += item.getClass().getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture (path);
|
||||
image->setUserString ("ToolTipType", "ItemPtr");
|
||||
image->setUserData(item);
|
||||
image->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onRemoveSoul);
|
||||
updateLabels();
|
||||
}
|
||||
|
||||
void EnchantingDialog::onRemoveSoul(MyGUI::Widget *sender)
|
||||
{
|
||||
while (mSoulBox->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (mSoulBox->getChildAt(0));
|
||||
mEnchanting.setSoulGem(MWWorld::Ptr());
|
||||
updateLabels();
|
||||
setSoulGem(item);
|
||||
}
|
||||
|
||||
void EnchantingDialog::onSoulCancel()
|
||||
|
@ -233,15 +231,22 @@ namespace MWGui
|
|||
|
||||
void EnchantingDialog::onSelectSoul(MyGUI::Widget *sender)
|
||||
{
|
||||
delete mItemSelectionDialog;
|
||||
mItemSelectionDialog = new ItemSelectionDialog("#{sSoulGemsWithSouls}");
|
||||
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &EnchantingDialog::onSoulSelected);
|
||||
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &EnchantingDialog::onSoulCancel);
|
||||
mItemSelectionDialog->setVisible(true);
|
||||
mItemSelectionDialog->openContainer(MWBase::Environment::get().getWorld()->getPlayerPtr());
|
||||
mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyChargedSoulstones);
|
||||
if (mEnchanting.getGem().isEmpty())
|
||||
{
|
||||
delete mItemSelectionDialog;
|
||||
mItemSelectionDialog = new ItemSelectionDialog("#{sSoulGemsWithSouls}");
|
||||
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &EnchantingDialog::onSoulSelected);
|
||||
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &EnchantingDialog::onSoulCancel);
|
||||
mItemSelectionDialog->setVisible(true);
|
||||
mItemSelectionDialog->openContainer(MWBase::Environment::get().getWorld()->getPlayerPtr());
|
||||
mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyChargedSoulstones);
|
||||
|
||||
//MWBase::Environment::get().getWindowManager()->messageBox("#{sInventorySelectNoSoul}");
|
||||
//MWBase::Environment::get().getWindowManager()->messageBox("#{sInventorySelectNoSoul}");
|
||||
}
|
||||
else
|
||||
{
|
||||
setSoulGem(MWWorld::Ptr());
|
||||
}
|
||||
}
|
||||
|
||||
void EnchantingDialog::notifyEffectsChanged ()
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace MWGui
|
|||
{
|
||||
|
||||
class ItemSelectionDialog;
|
||||
class ItemWidget;
|
||||
|
||||
class EnchantingDialog : public WindowBase, public ReferenceInterface, public EffectEditorBase
|
||||
{
|
||||
|
@ -19,6 +20,12 @@ namespace MWGui
|
|||
virtual ~EnchantingDialog();
|
||||
|
||||
virtual void open();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
void setSoulGem (const MWWorld::Ptr& gem);
|
||||
void setItem (const MWWorld::Ptr& item);
|
||||
|
||||
void startEnchanting(MWWorld::Ptr actor);
|
||||
void startSelfEnchanting(MWWorld::Ptr soulgem);
|
||||
|
||||
|
@ -29,8 +36,6 @@ namespace MWGui
|
|||
void onCancelButtonClicked(MyGUI::Widget* sender);
|
||||
void onSelectItem (MyGUI::Widget* sender);
|
||||
void onSelectSoul (MyGUI::Widget* sender);
|
||||
void onRemoveItem (MyGUI::Widget* sender);
|
||||
void onRemoveSoul (MyGUI::Widget* sender);
|
||||
|
||||
void onItemSelected(MWWorld::Ptr item);
|
||||
void onItemCancel();
|
||||
|
@ -43,8 +48,8 @@ namespace MWGui
|
|||
ItemSelectionDialog* mItemSelectionDialog;
|
||||
|
||||
MyGUI::Button* mCancelButton;
|
||||
MyGUI::ImageBox* mItemBox;
|
||||
MyGUI::ImageBox* mSoulBox;
|
||||
ItemWidget* mItemBox;
|
||||
ItemWidget* mSoulBox;
|
||||
|
||||
MyGUI::Button* mTypeButton;
|
||||
MyGUI::Button* mBuyButton;
|
||||
|
|
|
@ -64,10 +64,15 @@ namespace
|
|||
return unicode;
|
||||
}
|
||||
|
||||
// getUtf8, aka the worst function ever written.
|
||||
// This includes various hacks for dealing with Morrowind's .fnt files that are *mostly*
|
||||
// in the expected win12XX encoding, but also have randomly swapped characters sometimes.
|
||||
// Looks like the Morrowind developers found standard encodings too boring and threw in some twists for fun.
|
||||
std::string getUtf8 (unsigned char c, ToUTF8::Utf8Encoder& encoder, ToUTF8::FromType encoding)
|
||||
{
|
||||
if (encoding == ToUTF8::WINDOWS_1250)
|
||||
{
|
||||
// Hacks for polish font
|
||||
unsigned char win1250;
|
||||
std::map<unsigned char, unsigned char> conv;
|
||||
conv[0x80] = 0xc6;
|
||||
|
@ -101,7 +106,8 @@ namespace
|
|||
conv[0xa3] = 0xbf;
|
||||
conv[0xa4] = 0x0; // not contained in win1250
|
||||
conv[0xe1] = 0x8c;
|
||||
conv[0xe1] = 0x8c;
|
||||
// Can't remember if this was supposed to read 0xe2, or is it just an extraneous copypaste?
|
||||
//conv[0xe1] = 0x8c;
|
||||
conv[0xe3] = 0x0; // not contained in win1250
|
||||
conv[0xf5] = 0x0; // not contained in win1250
|
||||
|
||||
|
@ -252,6 +258,21 @@ namespace MWGui
|
|||
code->addAttribute("bearing", MyGUI::utility::toString(data[i].kerning) + " "
|
||||
+ MyGUI::utility::toString((fontSize-data[i].ascent)));
|
||||
|
||||
// More hacks! The french game uses U+2019, which is nowhere to be found in
|
||||
// the CP437 encoding of the font. Fall back to 39 (regular apostrophe)
|
||||
if (i == 39 && mEncoding == ToUTF8::CP437)
|
||||
{
|
||||
MyGUI::xml::ElementPtr code = codes->createChild("Code");
|
||||
code->addAttribute("index", 0x2019);
|
||||
code->addAttribute("coord", MyGUI::utility::toString(x1) + " "
|
||||
+ MyGUI::utility::toString(y1) + " "
|
||||
+ MyGUI::utility::toString(w) + " "
|
||||
+ MyGUI::utility::toString(h));
|
||||
code->addAttribute("advance", data[i].width);
|
||||
code->addAttribute("bearing", MyGUI::utility::toString(data[i].kerning) + " "
|
||||
+ MyGUI::utility::toString((fontSize-data[i].ascent)));
|
||||
}
|
||||
|
||||
// ASCII vertical bar, use this as text input cursor
|
||||
if (i == 124)
|
||||
{
|
||||
|
@ -265,18 +286,30 @@ namespace MWGui
|
|||
cursorCode->addAttribute("bearing", MyGUI::utility::toString(data[i].kerning) + " "
|
||||
+ MyGUI::utility::toString((fontSize-data[i].ascent)));
|
||||
}
|
||||
|
||||
// Question mark, use for NotDefined marker (used for glyphs not existing in the font)
|
||||
if (i == 63)
|
||||
{
|
||||
MyGUI::xml::ElementPtr cursorCode = codes->createChild("Code");
|
||||
cursorCode->addAttribute("index", MyGUI::FontCodeType::NotDefined);
|
||||
cursorCode->addAttribute("coord", MyGUI::utility::toString(x1) + " "
|
||||
+ MyGUI::utility::toString(y1) + " "
|
||||
+ MyGUI::utility::toString(w) + " "
|
||||
+ MyGUI::utility::toString(h));
|
||||
cursorCode->addAttribute("advance", data[i].width);
|
||||
cursorCode->addAttribute("bearing", MyGUI::utility::toString(data[i].kerning) + " "
|
||||
+ MyGUI::utility::toString((fontSize-data[i].ascent)));
|
||||
}
|
||||
}
|
||||
|
||||
// These are required as well, but the fonts don't provide them
|
||||
for (int i=0; i<3; ++i)
|
||||
for (int i=0; i<2; ++i)
|
||||
{
|
||||
MyGUI::FontCodeType::Enum type;
|
||||
if(i == 0)
|
||||
type = MyGUI::FontCodeType::Selected;
|
||||
else if (i == 1)
|
||||
type = MyGUI::FontCodeType::SelectedBack;
|
||||
else if (i == 2)
|
||||
type = MyGUI::FontCodeType::NotDefined;
|
||||
|
||||
MyGUI::xml::ElementPtr cursorCode = codes->createChild("Code");
|
||||
cursorCode->addAttribute("index", type);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "container.hpp"
|
||||
|
||||
#include "itemmodel.hpp"
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -423,9 +424,6 @@ namespace MWGui
|
|||
mSpellStatus->setProgressRange(100);
|
||||
mSpellStatus->setProgressPosition(successChancePercent);
|
||||
|
||||
if (mSpellImage->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0));
|
||||
|
||||
mSpellBox->setUserString("ToolTipType", "Spell");
|
||||
mSpellBox->setUserString("Spell", spellId);
|
||||
|
||||
|
@ -438,7 +436,9 @@ namespace MWGui
|
|||
icon.insert(slashPos+1, "b_");
|
||||
icon = std::string("icons\\") + icon;
|
||||
Widgets::fixTexturePath(icon);
|
||||
mSpellImage->setImageTexture(icon);
|
||||
|
||||
mSpellImage->setItem(MWWorld::Ptr());
|
||||
mSpellImage->setIcon(icon);
|
||||
}
|
||||
|
||||
void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent)
|
||||
|
@ -455,21 +455,10 @@ namespace MWGui
|
|||
mSpellStatus->setProgressRange(100);
|
||||
mSpellStatus->setProgressPosition(chargePercent);
|
||||
|
||||
if (mSpellImage->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0));
|
||||
|
||||
mSpellBox->setUserString("ToolTipType", "ItemPtr");
|
||||
mSpellBox->setUserData(item);
|
||||
|
||||
mSpellImage->setImageTexture("textures\\menu_icon_magic_mini.dds");
|
||||
MyGUI::ImageBox* itemBox = mSpellImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1)
|
||||
, MyGUI::Align::Stretch);
|
||||
|
||||
std::string path = std::string("icons\\");
|
||||
path+=item.getClass().getInventoryIcon(item);
|
||||
Widgets::fixTexturePath(path);
|
||||
itemBox->setImageTexture(path);
|
||||
itemBox->setNeedMouseFocus(false);
|
||||
mSpellImage->setItem(item);
|
||||
}
|
||||
|
||||
void HUD::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent)
|
||||
|
@ -489,23 +478,7 @@ namespace MWGui
|
|||
mWeapStatus->setProgressRange(100);
|
||||
mWeapStatus->setProgressPosition(durabilityPercent);
|
||||
|
||||
if (mWeapImage->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(mWeapImage->getChildAt(0));
|
||||
|
||||
std::string path = std::string("icons\\");
|
||||
path+=item.getClass().getInventoryIcon(item);
|
||||
Widgets::fixTexturePath(path);
|
||||
|
||||
if (item.getClass().getEnchantment(item) != "")
|
||||
{
|
||||
mWeapImage->setImageTexture("textures\\menu_icon_magic_mini.dds");
|
||||
MyGUI::ImageBox* itemBox = mWeapImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1)
|
||||
, MyGUI::Align::Stretch);
|
||||
itemBox->setImageTexture(path);
|
||||
itemBox->setNeedMouseFocus(false);
|
||||
}
|
||||
else
|
||||
mWeapImage->setImageTexture(path);
|
||||
mWeapImage->setItem(item);
|
||||
}
|
||||
|
||||
void HUD::unsetSelectedSpell()
|
||||
|
@ -519,11 +492,9 @@ namespace MWGui
|
|||
mWeaponSpellBox->setVisible(true);
|
||||
}
|
||||
|
||||
if (mSpellImage->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0));
|
||||
mSpellStatus->setProgressRange(100);
|
||||
mSpellStatus->setProgressPosition(0);
|
||||
mSpellImage->setImageTexture("");
|
||||
mSpellImage->setItem(MWWorld::Ptr());
|
||||
mSpellBox->clearUserStrings();
|
||||
}
|
||||
|
||||
|
@ -538,17 +509,17 @@ namespace MWGui
|
|||
mWeaponSpellBox->setVisible(true);
|
||||
}
|
||||
|
||||
if (mWeapImage->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(mWeapImage->getChildAt(0));
|
||||
mWeapStatus->setProgressRange(100);
|
||||
mWeapStatus->setProgressPosition(0);
|
||||
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
|
||||
mWeapImage->setItem(MWWorld::Ptr());
|
||||
if (player.getClass().getNpcStats(player).isWerewolf())
|
||||
mWeapImage->setImageTexture("icons\\k\\tx_werewolf_hand.dds");
|
||||
mWeapImage->setIcon("icons\\k\\tx_werewolf_hand.dds");
|
||||
else
|
||||
mWeapImage->setImageTexture("icons\\k\\stealth_handtohand.dds");
|
||||
mWeapImage->setIcon("icons\\k\\stealth_handtohand.dds");
|
||||
|
||||
mWeapBox->clearUserStrings();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace MWGui
|
|||
{
|
||||
class DragAndDrop;
|
||||
class SpellIcons;
|
||||
class ItemWidget;
|
||||
|
||||
class HUD : public OEngine::GUI::Layout, public LocalMapBase
|
||||
{
|
||||
|
@ -63,7 +64,7 @@ namespace MWGui
|
|||
MyGUI::ProgressBar *mHealth, *mMagicka, *mStamina, *mEnemyHealth, *mDrowning;
|
||||
MyGUI::Widget* mHealthFrame;
|
||||
MyGUI::Widget *mWeapBox, *mSpellBox, *mSneakBox;
|
||||
MyGUI::ImageBox *mWeapImage, *mSpellImage;
|
||||
ItemWidget *mWeapImage, *mSpellImage;
|
||||
MyGUI::ProgressBar *mWeapStatus, *mSpellStatus;
|
||||
MyGUI::Widget *mEffectBox, *mMinimapBox;
|
||||
MyGUI::Button* mMinimapButton;
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace MWGui
|
|||
for (size_t i=0; i<mSourceModel->getItemCount(); ++i)
|
||||
{
|
||||
const ItemStack& item = mSourceModel->getItem(i);
|
||||
if (item == itemToSearch)
|
||||
if (item.mBase == itemToSearch.mBase)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
@ -112,7 +112,7 @@ namespace MWGui
|
|||
for (size_t i=0; i<getItemCount(); ++i)
|
||||
{
|
||||
const ItemStack& item = getItem(i);
|
||||
if (item == itemToSearch)
|
||||
if (item.mBase == itemToSearch.mBase)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
|
|
@ -26,6 +26,11 @@ namespace MWGui
|
|||
center();
|
||||
}
|
||||
|
||||
void ItemSelectionDialog::exit()
|
||||
{
|
||||
eventDialogCanceled();
|
||||
}
|
||||
|
||||
void ItemSelectionDialog::openContainer(const MWWorld::Ptr& container)
|
||||
{
|
||||
mModel = new InventoryItemModel(container);
|
||||
|
@ -53,7 +58,7 @@ namespace MWGui
|
|||
|
||||
void ItemSelectionDialog::onCancelButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
eventDialogCanceled();
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace MWGui
|
|||
public:
|
||||
ItemSelectionDialog(const std::string& label);
|
||||
|
||||
virtual void exit();
|
||||
|
||||
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||
typedef MyGUI::delegates::CMultiDelegate1<MWWorld::Ptr> EventHandle_Item;
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include "itemmodel.hpp"
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -80,53 +81,24 @@ void ItemView::update()
|
|||
const ItemStack& item = mModel->getItem(i);
|
||||
|
||||
/// \todo performance improvement: don't create/destroy all the widgets everytime the container window changes size, only reposition them
|
||||
std::string path = std::string("icons\\");
|
||||
path += item.mBase.getClass().getInventoryIcon(item.mBase);
|
||||
|
||||
// background widget (for the "equipped" frame and magic item background image)
|
||||
bool isMagic = (item.mFlags & ItemStack::Flag_Enchanted);
|
||||
MyGUI::ImageBox* backgroundWidget = dragArea->createWidget<MyGUI::ImageBox>("ImageBox",
|
||||
ItemWidget* itemWidget = dragArea->createWidget<ItemWidget>("MW_ItemIcon",
|
||||
MyGUI::IntCoord(x, y, 42, 42), MyGUI::Align::Default);
|
||||
backgroundWidget->setUserString("ToolTipType", "ItemModelIndex");
|
||||
backgroundWidget->setUserData(std::make_pair(i, mModel));
|
||||
itemWidget->setUserString("ToolTipType", "ItemModelIndex");
|
||||
itemWidget->setUserData(std::make_pair(i, mModel));
|
||||
ItemWidget::ItemState state = ItemWidget::None;
|
||||
if (item.mType == ItemStack::Type_Barter)
|
||||
state = ItemWidget::Barter;
|
||||
if (item.mType == ItemStack::Type_Equipped)
|
||||
state = ItemWidget::Equip;
|
||||
itemWidget->setItem(item.mBase, state);
|
||||
|
||||
std::string backgroundTex = "textures\\menu_icon";
|
||||
if (isMagic)
|
||||
backgroundTex += "_magic";
|
||||
if (item.mType == ItemStack::Type_Normal)
|
||||
{
|
||||
if (!isMagic)
|
||||
backgroundTex = "";
|
||||
}
|
||||
else if (item.mType == ItemStack::Type_Equipped)
|
||||
backgroundTex += "_equip";
|
||||
else if (item.mType == ItemStack::Type_Barter)
|
||||
backgroundTex += "_barter";
|
||||
|
||||
if (backgroundTex != "")
|
||||
backgroundTex += ".dds";
|
||||
|
||||
backgroundWidget->setImageTexture(backgroundTex);
|
||||
if ((item.mType == ItemStack::Type_Barter) && !isMagic)
|
||||
backgroundWidget->setProperty("ImageCoord", "2 2 42 42");
|
||||
else
|
||||
backgroundWidget->setProperty("ImageCoord", "0 0 42 42");
|
||||
backgroundWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemView::onSelectedItem);
|
||||
backgroundWidget->eventMouseWheel += MyGUI::newDelegate(this, &ItemView::onMouseWheel);
|
||||
|
||||
// image
|
||||
MyGUI::ImageBox* image = backgroundWidget->createWidget<MyGUI::ImageBox>("ImageBox",
|
||||
MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||
std::string::size_type pos = path.rfind(".");
|
||||
if(pos != std::string::npos)
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture(path);
|
||||
image->setNeedMouseFocus(false);
|
||||
itemWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemView::onSelectedItem);
|
||||
itemWidget->eventMouseWheel += MyGUI::newDelegate(this, &ItemView::onMouseWheel);
|
||||
|
||||
// text widget that shows item count
|
||||
MyGUI::TextBox* text = image->createWidget<MyGUI::TextBox>("SandBrightText",
|
||||
MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label"));
|
||||
// TODO: move to ItemWidget
|
||||
MyGUI::TextBox* text = itemWidget->createWidget<MyGUI::TextBox>("SandBrightText",
|
||||
MyGUI::IntCoord(5, 19, 32, 18), MyGUI::Align::Default, std::string("Label"));
|
||||
text->setTextAlign(MyGUI::Align::Right);
|
||||
text->setNeedMouseFocus(false);
|
||||
text->setTextShadow(true);
|
||||
|
|
105
apps/openmw/mwgui/itemwidget.cpp
Normal file
105
apps/openmw/mwgui/itemwidget.cpp
Normal file
|
@ -0,0 +1,105 @@
|
|||
#include "itemwidget.hpp"
|
||||
|
||||
#include <MyGUI_FactoryManager.h>
|
||||
#include <MyGUI_ImageBox.h>
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
ItemWidget::ItemWidget()
|
||||
: mItem(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ItemWidget::registerComponents()
|
||||
{
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<ItemWidget>("Widget");
|
||||
}
|
||||
|
||||
void ItemWidget::initialiseOverride()
|
||||
{
|
||||
assignWidget(mItem, "Item");
|
||||
if (mItem)
|
||||
mItem->setNeedMouseFocus(false);
|
||||
assignWidget(mFrame, "Frame");
|
||||
if (mFrame)
|
||||
mFrame->setNeedMouseFocus(false);
|
||||
|
||||
Base::initialiseOverride();
|
||||
}
|
||||
|
||||
void ItemWidget::setIcon(const std::string &icon)
|
||||
{
|
||||
if (mItem)
|
||||
mItem->setImageTexture(icon);
|
||||
}
|
||||
|
||||
void ItemWidget::setFrame(const std::string &frame, const MyGUI::IntCoord &coord)
|
||||
{
|
||||
if (mFrame)
|
||||
{
|
||||
mFrame->setImageTexture(frame);
|
||||
mFrame->setImageTile(MyGUI::IntSize(coord.width, coord.height)); // Why is this needed? MyGUI bug?
|
||||
mFrame->setImageCoord(coord);
|
||||
}
|
||||
}
|
||||
|
||||
void ItemWidget::setIcon(const MWWorld::Ptr &ptr)
|
||||
{
|
||||
// image
|
||||
std::string path = std::string("icons\\");
|
||||
path += ptr.getClass().getInventoryIcon(ptr);
|
||||
|
||||
std::string::size_type pos = path.rfind(".");
|
||||
if(pos != std::string::npos)
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
setIcon(path);
|
||||
}
|
||||
|
||||
|
||||
void ItemWidget::setItem(const MWWorld::Ptr &ptr, ItemState state)
|
||||
{
|
||||
if (!mItem)
|
||||
return;
|
||||
|
||||
if (ptr.isEmpty())
|
||||
{
|
||||
if (mFrame)
|
||||
mFrame->setImageTexture("");
|
||||
mItem->setImageTexture("");
|
||||
return;
|
||||
}
|
||||
|
||||
bool isMagic = !ptr.getClass().getEnchantment(ptr).empty();
|
||||
|
||||
std::string backgroundTex = "textures\\menu_icon";
|
||||
if (isMagic)
|
||||
backgroundTex += "_magic";
|
||||
if (state == None)
|
||||
{
|
||||
if (!isMagic)
|
||||
backgroundTex = "";
|
||||
}
|
||||
else if (state == Equip)
|
||||
{
|
||||
backgroundTex += "_equip";
|
||||
}
|
||||
else if (state == Barter)
|
||||
backgroundTex += "_barter";
|
||||
|
||||
if (backgroundTex != "")
|
||||
backgroundTex += ".dds";
|
||||
|
||||
if (state == Barter && !isMagic)
|
||||
setFrame(backgroundTex, MyGUI::IntCoord(2,2,42,42));
|
||||
else
|
||||
setFrame(backgroundTex, MyGUI::IntCoord(0,0,42,42));
|
||||
|
||||
setIcon(ptr);
|
||||
}
|
||||
|
||||
}
|
49
apps/openmw/mwgui/itemwidget.hpp
Normal file
49
apps/openmw/mwgui/itemwidget.hpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
#ifndef OPENMW_MWGUI_ITEMWIDGET_H
|
||||
#define OPENMW_MWGUI_ITEMWIDGET_H
|
||||
|
||||
#include <MyGUI_Widget.h>
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Ptr;
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
/// @brief A widget that shows an icon for an MWWorld::Ptr
|
||||
class ItemWidget : public MyGUI::Widget
|
||||
{
|
||||
MYGUI_RTTI_DERIVED(ItemWidget)
|
||||
public:
|
||||
ItemWidget();
|
||||
|
||||
/// Register needed components with MyGUI's factory manager
|
||||
static void registerComponents ();
|
||||
|
||||
enum ItemState
|
||||
{
|
||||
None,
|
||||
Equip,
|
||||
Barter,
|
||||
Magic
|
||||
};
|
||||
|
||||
/// \a ptr may be empty
|
||||
void setItem (const MWWorld::Ptr& ptr, ItemState state = None);
|
||||
|
||||
// Set icon and frame manually
|
||||
void setIcon (const std::string& icon);
|
||||
void setIcon (const MWWorld::Ptr& ptr);
|
||||
void setFrame (const std::string& frame, const MyGUI::IntCoord& coord);
|
||||
|
||||
private:
|
||||
virtual void initialiseOverride();
|
||||
|
||||
MyGUI::ImageBox* mItem;
|
||||
MyGUI::ImageBox* mFrame;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -148,22 +148,6 @@ namespace
|
|||
mTypesetter->lineBreak ();
|
||||
}
|
||||
};
|
||||
|
||||
struct AddQuestLink : AddContent
|
||||
{
|
||||
AddQuestLink (MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* style) :
|
||||
AddContent (typesetter, style)
|
||||
{
|
||||
}
|
||||
|
||||
void operator () (MWGui::JournalViewModel::QuestId id, MWGui::JournalViewModel::Utf8Span name)
|
||||
{
|
||||
MWGui::BookTypesetter::Style* style = mTypesetter->createHotStyle (mBodyStyle, MyGUI::Colour::Black, linkHot, linkActive, id);
|
||||
|
||||
mTypesetter->write (style, name);
|
||||
mTypesetter->lineBreak ();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
|
@ -206,7 +190,7 @@ book JournalBooks::createJournalBook ()
|
|||
BookTypesetter::Style* header = typesetter->createStyle ("", MyGUI::Colour (0.60f, 0.00f, 0.00f));
|
||||
BookTypesetter::Style* body = typesetter->createStyle ("", MyGUI::Colour::Black);
|
||||
|
||||
mModel->visitJournalEntries (0, AddJournalEntry (typesetter, body, header, true));
|
||||
mModel->visitJournalEntries ("", AddJournalEntry (typesetter, body, header, true));
|
||||
|
||||
return typesetter->complete ();
|
||||
}
|
||||
|
@ -227,16 +211,17 @@ book JournalBooks::createTopicBook (uintptr_t topicId)
|
|||
return typesetter->complete ();
|
||||
}
|
||||
|
||||
book JournalBooks::createQuestBook (uintptr_t questId)
|
||||
book JournalBooks::createQuestBook (const std::string& questName)
|
||||
{
|
||||
BookTypesetter::Ptr typesetter = createTypesetter ();
|
||||
|
||||
BookTypesetter::Style* header = typesetter->createStyle ("", MyGUI::Colour (0.60f, 0.00f, 0.00f));
|
||||
BookTypesetter::Style* body = typesetter->createStyle ("", MyGUI::Colour::Black);
|
||||
|
||||
mModel->visitQuestName (questId, AddQuestName (typesetter, header));
|
||||
AddQuestName addName (typesetter, header);
|
||||
addName(to_utf8_span(questName.c_str()));
|
||||
|
||||
mModel->visitJournalEntries (questId, AddJournalEntry (typesetter, body, header, false));
|
||||
mModel->visitJournalEntries (questName, AddJournalEntry (typesetter, body, header, false));
|
||||
|
||||
return typesetter->complete ();
|
||||
}
|
||||
|
@ -269,26 +254,6 @@ book JournalBooks::createTopicIndexBook ()
|
|||
return typesetter->complete ();
|
||||
}
|
||||
|
||||
book JournalBooks::createTopicIndexBook (char character)
|
||||
{
|
||||
BookTypesetter::Ptr typesetter = BookTypesetter::create (0x7FFFFFFF, 0x7FFFFFFF);
|
||||
BookTypesetter::Style* style = typesetter->createStyle ("", MyGUI::Colour::Black);
|
||||
|
||||
mModel->visitTopicNamesStartingWith (character, AddTopicLink (typesetter, style));
|
||||
|
||||
return typesetter->complete ();
|
||||
}
|
||||
|
||||
book JournalBooks::createQuestIndexBook (bool activeOnly)
|
||||
{
|
||||
BookTypesetter::Ptr typesetter = BookTypesetter::create (0x7FFFFFFF, 0x7FFFFFFF);
|
||||
BookTypesetter::Style* base = typesetter->createStyle ("", MyGUI::Colour::Black);
|
||||
|
||||
mModel->visitQuestNames (activeOnly, AddQuestLink (typesetter, base));
|
||||
|
||||
return typesetter->complete ();
|
||||
}
|
||||
|
||||
BookTypesetter::Ptr JournalBooks::createTypesetter ()
|
||||
{
|
||||
//TODO: determine page size from layout...
|
||||
|
|
|
@ -18,10 +18,9 @@ namespace MWGui
|
|||
Book createEmptyJournalBook ();
|
||||
Book createJournalBook ();
|
||||
Book createTopicBook (uintptr_t topicId);
|
||||
Book createQuestBook (uintptr_t questId);
|
||||
Book createTopicBook (const std::string& topicId);
|
||||
Book createQuestBook (const std::string& questName);
|
||||
Book createTopicIndexBook ();
|
||||
Book createTopicIndexBook (char character);
|
||||
Book createQuestIndexBook (bool showAll);
|
||||
|
||||
private:
|
||||
BookTypesetter::Ptr createTypesetter ();
|
||||
|
|
|
@ -195,10 +195,12 @@ struct JournalViewModelImpl : JournalViewModel
|
|||
|
||||
};
|
||||
|
||||
void visitQuestNames (bool active_only, boost::function <void (QuestId, Utf8Span)> visitor) const
|
||||
void visitQuestNames (bool active_only, boost::function <void (const std::string&)> visitor) const
|
||||
{
|
||||
MWBase::Journal * journal = MWBase::Environment::get ().getJournal ();
|
||||
|
||||
std::set<std::string> visitedQuests;
|
||||
|
||||
for (MWBase::Journal::TQuestIter i = journal->questBegin (); i != journal->questEnd (); ++i)
|
||||
{
|
||||
if (active_only && i->second.isFinished ())
|
||||
|
@ -209,7 +211,15 @@ struct JournalViewModelImpl : JournalViewModel
|
|||
// Note that even with Tribunal, some quests still don't have quest names. I'm assuming those are not supposed
|
||||
// to appear in the quest book.
|
||||
if (!quest.getName().empty())
|
||||
visitor (reinterpret_cast <QuestId> (&i->second), toUtf8Span (quest.getName()));
|
||||
{
|
||||
// Don't list the same quest name twice
|
||||
if (visitedQuests.find(quest.getName()) != visitedQuests.end())
|
||||
continue;
|
||||
|
||||
visitor (quest.getName());
|
||||
|
||||
visitedQuests.insert(quest.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,20 +268,29 @@ struct JournalViewModelImpl : JournalViewModel
|
|||
}
|
||||
};
|
||||
|
||||
void visitJournalEntries (QuestId questId, boost::function <void (JournalEntry const &)> visitor) const
|
||||
void visitJournalEntries (const std::string& questName, boost::function <void (JournalEntry const &)> visitor) const
|
||||
{
|
||||
MWBase::Journal * journal = MWBase::Environment::get().getJournal();
|
||||
|
||||
if (questId != 0)
|
||||
if (!questName.empty())
|
||||
{
|
||||
MWDialogue::Quest const * quest = reinterpret_cast <MWDialogue::Quest const *> (questId);
|
||||
std::vector<MWDialogue::Quest const*> quests;
|
||||
for (MWBase::Journal::TQuestIter questIt = journal->questBegin(); questIt != journal->questEnd(); ++questIt)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(questIt->second.getName(), questName))
|
||||
quests.push_back(&questIt->second);
|
||||
}
|
||||
|
||||
for(MWBase::Journal::TEntryIter i = journal->begin(); i != journal->end (); ++i)
|
||||
{
|
||||
for (MWDialogue::Topic::TEntryIter j = quest->begin (); j != quest->end (); ++j)
|
||||
for (std::vector<MWDialogue::Quest const*>::iterator questIt = quests.begin(); questIt != quests.end(); ++questIt)
|
||||
{
|
||||
if (i->mInfoId == j->mInfoId)
|
||||
visitor (JournalEntryImpl <MWBase::Journal::TEntryIter> (this, i));
|
||||
MWDialogue::Quest const* quest = *questIt;
|
||||
for (MWDialogue::Topic::TEntryIter j = quest->begin (); j != quest->end (); ++j)
|
||||
{
|
||||
if (i->mInfoId == j->mInfoId)
|
||||
visitor (JournalEntryImpl <MWBase::Journal::TEntryIter> (this, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +312,7 @@ struct JournalViewModelImpl : JournalViewModel
|
|||
visitor (toUtf8Span (topic.getName()));
|
||||
}
|
||||
|
||||
void visitTopicNamesStartingWith (char character, boost::function < void (TopicId , Utf8Span) > visitor) const
|
||||
void visitTopicNamesStartingWith (char character, boost::function < void (const std::string&) > visitor) const
|
||||
{
|
||||
MWBase::Journal * journal = MWBase::Environment::get().getJournal();
|
||||
|
||||
|
@ -302,7 +321,7 @@ struct JournalViewModelImpl : JournalViewModel
|
|||
if (i->first [0] != std::tolower (character, mLocale))
|
||||
continue;
|
||||
|
||||
visitor (TopicId (&i->second), toUtf8Span (i->second.getName()));
|
||||
visitor (i->second.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,17 +70,18 @@ namespace MWGui
|
|||
/// provides access to the name of the quest with the specified identifier
|
||||
virtual void visitQuestName (TopicId topicId, boost::function <void (Utf8Span)> visitor) const = 0;
|
||||
|
||||
/// walks the active and optionally completed, quests providing the quest id and name
|
||||
virtual void visitQuestNames (bool active_only, boost::function <void (QuestId, Utf8Span)> visitor) const = 0;
|
||||
/// walks the active and optionally completed, quests providing the name
|
||||
virtual void visitQuestNames (bool active_only, boost::function <void (const std::string&)> visitor) const = 0;
|
||||
|
||||
/// walks over the journal entries related to the specified quest identified by its id
|
||||
virtual void visitJournalEntries (QuestId questId, boost::function <void (JournalEntry const &)> visitor) const = 0;
|
||||
/// walks over the journal entries related to all quests with the given name
|
||||
/// If \a questName is empty, simply visits all journal entries
|
||||
virtual void visitJournalEntries (const std::string& questName, boost::function <void (JournalEntry const &)> visitor) const = 0;
|
||||
|
||||
/// provides the name of the topic specified by its id
|
||||
virtual void visitTopicName (TopicId topicId, boost::function <void (Utf8Span)> visitor) const = 0;
|
||||
|
||||
/// walks over the topics whose names start with the specified character providing the topics id and name
|
||||
virtual void visitTopicNamesStartingWith (char character, boost::function < void (TopicId , Utf8Span) > visitor) const = 0;
|
||||
/// walks over the topics whose names start with the specified character providing the topics name
|
||||
virtual void visitTopicNamesStartingWith (char character, boost::function < void (const std::string&) > visitor) const = 0;
|
||||
|
||||
/// walks over the topic entries for the topic specified by its identifier
|
||||
virtual void visitTopicEntries (TopicId topicId, boost::function <void (TopicEntry const &)> visitor) const = 0;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
#include "../mwbase/journal.hpp"
|
||||
#include "list.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
@ -19,6 +20,7 @@
|
|||
#include "imagebutton.hpp"
|
||||
#include "journalviewmodel.hpp"
|
||||
#include "journalbooks.hpp"
|
||||
#include "list.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -36,9 +38,7 @@ namespace
|
|||
static char const PageOneNum [] = "PageOneNum";
|
||||
static char const PageTwoNum [] = "PageTwoNum";
|
||||
static char const TopicsList [] = "TopicsList";
|
||||
static char const TopicsPage [] = "TopicsPage";
|
||||
static char const QuestsList [] = "QuestsList";
|
||||
static char const QuestsPage [] = "QuestsPage";
|
||||
static char const LeftBookPage [] = "LeftBookPage";
|
||||
static char const RightBookPage [] = "RightBookPage";
|
||||
static char const LeftTopicIndex [] = "LeftTopicIndex";
|
||||
|
@ -110,12 +110,17 @@ namespace
|
|||
adviseButtonClick (ShowAllBTN, &JournalWindowImpl::notifyShowAll );
|
||||
adviseButtonClick (ShowActiveBTN, &JournalWindowImpl::notifyShowActive);
|
||||
|
||||
MWGui::Widgets::MWList* list = getWidget<MWGui::Widgets::MWList>(QuestsList);
|
||||
list->eventItemSelected += MyGUI::newDelegate(this, &JournalWindowImpl::notifyQuestClicked);
|
||||
|
||||
MWGui::Widgets::MWList* topicsList = getWidget<MWGui::Widgets::MWList>(TopicsList);
|
||||
topicsList->eventItemSelected += MyGUI::newDelegate(this, &JournalWindowImpl::notifyTopicSelected);
|
||||
|
||||
{
|
||||
MWGui::BookPage::ClickCallback callback;
|
||||
|
||||
callback = boost::bind (&JournalWindowImpl::notifyTopicClicked, this, _1);
|
||||
|
||||
getPage (TopicsPage)->adviseLinkClicked (callback);
|
||||
getPage (LeftBookPage)->adviseLinkClicked (callback);
|
||||
getPage (RightBookPage)->adviseLinkClicked (callback);
|
||||
}
|
||||
|
@ -129,14 +134,6 @@ namespace
|
|||
getPage (RightTopicIndex)->adviseLinkClicked (callback);
|
||||
}
|
||||
|
||||
{
|
||||
MWGui::BookPage::ClickCallback callback;
|
||||
|
||||
callback = boost::bind (&JournalWindowImpl::notifyQuestClicked, this, _1);
|
||||
|
||||
getPage (QuestsPage)->adviseLinkClicked (callback);
|
||||
}
|
||||
|
||||
adjustButton(OptionsBTN, true);
|
||||
adjustButton(PrevPageBTN);
|
||||
adjustButton(NextPageBTN);
|
||||
|
@ -271,6 +268,10 @@ namespace
|
|||
//TODO: figure out how to make "options" page overlay book page
|
||||
// correctly, so that text may show underneath
|
||||
getPage (RightBookPage)->showPage (Book (), 0);
|
||||
|
||||
// If in quest mode, ensure the quest list is updated
|
||||
if (mQuestMode)
|
||||
notifyQuests(getWidget<MyGUI::Widget>(QuestsList));
|
||||
}
|
||||
|
||||
void pushBook (Book book, unsigned int page)
|
||||
|
@ -349,9 +350,22 @@ namespace
|
|||
setVisible (JournalBTN, true);
|
||||
}
|
||||
|
||||
void notifyQuestClicked (intptr_t questId)
|
||||
void notifyTopicSelected (const std::string& topic, int id)
|
||||
{
|
||||
Book book = createQuestBook (questId);
|
||||
const MWBase::Journal* journal = MWBase::Environment::get().getJournal();
|
||||
intptr_t topicId = 0; /// \todo get rid of intptr ids
|
||||
for(MWBase::Journal::TTopicIter i = journal->topicBegin(); i != journal->topicEnd (); ++i)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(i->first, topic))
|
||||
topicId = intptr_t (&i->second);
|
||||
}
|
||||
|
||||
notifyTopicClicked(topicId);
|
||||
}
|
||||
|
||||
void notifyQuestClicked (const std::string& name, int id)
|
||||
{
|
||||
Book book = createQuestBook (name);
|
||||
|
||||
if (mStates.size () > 1)
|
||||
replaceBook (book, 0);
|
||||
|
@ -395,7 +409,14 @@ namespace
|
|||
setVisible (RightTopicIndex, false);
|
||||
setVisible (TopicsList, true);
|
||||
|
||||
showList (TopicsList, TopicsPage, createTopicIndexBook ((char)character));
|
||||
MWGui::Widgets::MWList* list = getWidget<MWGui::Widgets::MWList>(TopicsList);
|
||||
list->clear();
|
||||
|
||||
AddNamesToList add(list);
|
||||
|
||||
mModel->visitTopicNamesStartingWith((char) character, add);
|
||||
|
||||
list->adjustSize();
|
||||
}
|
||||
|
||||
void notifyTopics(MyGUI::Widget* _sender)
|
||||
|
@ -409,9 +430,21 @@ namespace
|
|||
setVisible (ShowActiveBTN, false);
|
||||
}
|
||||
|
||||
struct AddNamesToList
|
||||
{
|
||||
AddNamesToList(MWGui::Widgets::MWList* list) : mList(list) {}
|
||||
|
||||
MWGui::Widgets::MWList* mList;
|
||||
void operator () (const std::string& name)
|
||||
{
|
||||
mList->addItem(name);
|
||||
}
|
||||
};
|
||||
|
||||
void notifyQuests(MyGUI::Widget* _sender)
|
||||
{
|
||||
mQuestMode = true;
|
||||
|
||||
setVisible (LeftTopicIndex, false);
|
||||
setVisible (RightTopicIndex, false);
|
||||
setVisible (TopicsList, false);
|
||||
|
@ -419,23 +452,26 @@ namespace
|
|||
setVisible (ShowAllBTN, !mAllQuests);
|
||||
setVisible (ShowActiveBTN, mAllQuests);
|
||||
|
||||
showList (QuestsList, QuestsPage, createQuestIndexBook (!mAllQuests));
|
||||
MWGui::Widgets::MWList* list = getWidget<MWGui::Widgets::MWList>(QuestsList);
|
||||
list->clear();
|
||||
|
||||
AddNamesToList add(list);
|
||||
|
||||
mModel->visitQuestNames(!mAllQuests, add);
|
||||
|
||||
list->adjustSize();
|
||||
}
|
||||
|
||||
void notifyShowAll(MyGUI::Widget* _sender)
|
||||
{
|
||||
mAllQuests = true;
|
||||
setVisible (ShowAllBTN, !mAllQuests);
|
||||
setVisible (ShowActiveBTN, mAllQuests);
|
||||
showList (QuestsList, QuestsPage, createQuestIndexBook (!mAllQuests));
|
||||
notifyQuests(_sender);
|
||||
}
|
||||
|
||||
void notifyShowActive(MyGUI::Widget* _sender)
|
||||
{
|
||||
mAllQuests = false;
|
||||
setVisible (ShowAllBTN, !mAllQuests);
|
||||
setVisible (ShowActiveBTN, mAllQuests);
|
||||
showList (QuestsList, QuestsPage, createQuestIndexBook (!mAllQuests));
|
||||
notifyQuests(_sender);
|
||||
}
|
||||
|
||||
void notifyCancel(MyGUI::Widget* _sender)
|
||||
|
|
|
@ -65,8 +65,10 @@ namespace MWGui
|
|||
{
|
||||
if (*it != "")
|
||||
{
|
||||
if (mListItemSkin.empty())
|
||||
throw std::runtime_error("MWList needs a ListItemSkin property");
|
||||
MyGUI::Button* button = mScrollView->createWidget<MyGUI::Button>(
|
||||
"MW_ListLine", MyGUI::IntCoord(0, mItemHeight, mScrollView->getSize().width - scrollBarWidth - 2, 24),
|
||||
mListItemSkin, MyGUI::IntCoord(0, mItemHeight, mScrollView->getSize().width - scrollBarWidth - 2, 24),
|
||||
MyGUI::Align::Left | MyGUI::Align::Top, getName() + "_item_" + (*it));
|
||||
button->setCaption((*it));
|
||||
button->getSubWidgetText()->setWordWrap(true);
|
||||
|
@ -102,6 +104,14 @@ namespace MWGui
|
|||
mScrollView->setViewOffset(MyGUI::IntPoint(0, -viewPosition));
|
||||
}
|
||||
|
||||
void MWList::setPropertyOverride(const std::string &_key, const std::string &_value)
|
||||
{
|
||||
if (_key == "ListItemSkin")
|
||||
mListItemSkin = _value;
|
||||
else
|
||||
Base::setPropertyOverride(_key, _value);
|
||||
}
|
||||
|
||||
bool MWList::hasItem(const std::string& name)
|
||||
{
|
||||
return (std::find(mItems.begin(), mItems.end(), name) != mItems.end());
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace MWGui
|
|||
|
||||
/**
|
||||
* Event: Item selected with the mouse.
|
||||
* signature: void method(std::string itemName)
|
||||
* signature: void method(std::string itemName, int index)
|
||||
*/
|
||||
EventHandle_StringInt eventItemSelected;
|
||||
|
||||
|
@ -49,6 +49,8 @@ namespace MWGui
|
|||
MyGUI::Widget* getItemWidget(const std::string& name);
|
||||
///< get widget for an item name, useful to set up tooltip
|
||||
|
||||
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
|
||||
|
||||
protected:
|
||||
void initialiseOverride();
|
||||
|
||||
|
@ -60,6 +62,7 @@ namespace MWGui
|
|||
private:
|
||||
MyGUI::ScrollView* mScrollView;
|
||||
MyGUI::Widget* mClient;
|
||||
std::string mListItemSkin;
|
||||
|
||||
std::vector<std::string> mItems;
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/statemanager.hpp"
|
||||
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
#include "../mwbase/inputmanager.hpp"
|
||||
|
@ -26,7 +27,6 @@ namespace MWGui
|
|||
, WindowBase("openmw_loading_screen.layout")
|
||||
, mLastRenderTime(0.f)
|
||||
, mLastWallpaperChangeTime(0.f)
|
||||
, mFirstLoad(true)
|
||||
, mProgress(0)
|
||||
, mVSyncWasEnabled(false)
|
||||
{
|
||||
|
@ -77,7 +77,11 @@ namespace MWGui
|
|||
mWindow->setVSyncEnabled(false);
|
||||
#endif
|
||||
|
||||
if (!mFirstLoad)
|
||||
bool showWallpaper = (MWBase::Environment::get().getStateManager()->getState()
|
||||
== MWBase::StateManager::State_NoGame);
|
||||
|
||||
|
||||
if (!showWallpaper)
|
||||
{
|
||||
mBackgroundImage->setImageTexture("");
|
||||
int width = mWindow->getWidth();
|
||||
|
@ -103,12 +107,12 @@ namespace MWGui
|
|||
|
||||
setVisible(true);
|
||||
|
||||
if (mFirstLoad)
|
||||
if (showWallpaper)
|
||||
{
|
||||
changeWallpaper();
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->pushGuiMode(mFirstLoad ? GM_LoadingWallpaper : GM_Loading);
|
||||
MWBase::Environment::get().getWindowManager()->pushGuiMode(showWallpaper ? GM_LoadingWallpaper : GM_Loading);
|
||||
}
|
||||
|
||||
void LoadingScreen::loadingOff()
|
||||
|
@ -188,11 +192,6 @@ namespace MWGui
|
|||
draw();
|
||||
}
|
||||
|
||||
void LoadingScreen::removeWallpaper()
|
||||
{
|
||||
mFirstLoad = false;
|
||||
}
|
||||
|
||||
void LoadingScreen::draw()
|
||||
{
|
||||
const float loadingScreenFps = 20.f;
|
||||
|
@ -201,7 +200,10 @@ namespace MWGui
|
|||
{
|
||||
mLastRenderTime = mTimer.getMilliseconds ();
|
||||
|
||||
if (mFirstLoad && mTimer.getMilliseconds () > mLastWallpaperChangeTime + 5000*1)
|
||||
bool showWallpaper = (MWBase::Environment::get().getStateManager()->getState()
|
||||
== MWBase::StateManager::State_NoGame);
|
||||
|
||||
if (showWallpaper && mTimer.getMilliseconds () > mLastWallpaperChangeTime + 5000*1)
|
||||
{
|
||||
mLastWallpaperChangeTime = mTimer.getMilliseconds ();
|
||||
changeWallpaper();
|
||||
|
|
|
@ -29,8 +29,6 @@ namespace MWGui
|
|||
|
||||
virtual void setVisible(bool visible);
|
||||
|
||||
virtual void removeWallpaper();
|
||||
|
||||
LoadingScreen(Ogre::SceneManager* sceneMgr, Ogre::RenderWindow* rw);
|
||||
virtual ~LoadingScreen();
|
||||
|
||||
|
@ -42,8 +40,6 @@ namespace MWGui
|
|||
void updateWindow(Ogre::RenderWindow* rw) { mWindow = rw; }
|
||||
|
||||
private:
|
||||
bool mFirstLoad;
|
||||
|
||||
Ogre::SceneManager* mSceneMgr;
|
||||
Ogre::RenderWindow* mWindow;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "mainmenu.hpp"
|
||||
|
||||
#include <OgreResourceGroupManager.h>
|
||||
|
||||
#include <components/version/version.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
@ -16,6 +18,7 @@
|
|||
#include "confirmationdialog.hpp"
|
||||
#include "imagebutton.hpp"
|
||||
#include "backgroundimage.hpp"
|
||||
#include "videowidget.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -25,6 +28,7 @@ namespace MWGui
|
|||
, mButtonBox(0), mWidth (w), mHeight (h)
|
||||
, mSaveGameDialog(NULL)
|
||||
, mBackground(NULL)
|
||||
, mVideo(NULL)
|
||||
{
|
||||
getWidget(mVersionText, "VersionText");
|
||||
std::stringstream sstream;
|
||||
|
@ -42,6 +46,8 @@ namespace MWGui
|
|||
std::string output = sstream.str();
|
||||
mVersionText->setCaption(output);
|
||||
|
||||
mHasAnimatedMenu = (Ogre::ResourceGroupManager::getSingleton().resourceExistsInAnyGroup("video\\menu_background.bik"));
|
||||
|
||||
updateMenu();
|
||||
}
|
||||
|
||||
|
@ -134,14 +140,73 @@ namespace MWGui
|
|||
|
||||
void MainMenu::showBackground(bool show)
|
||||
{
|
||||
if (show && !mBackground)
|
||||
if (mVideo && !show)
|
||||
{
|
||||
mBackground = MyGUI::Gui::getInstance().createWidgetReal<BackgroundImage>("ImageBox", 0,0,1,1,
|
||||
MyGUI::Align::Stretch, "Menu");
|
||||
mBackground->setBackgroundImage("textures\\menu_morrowind.dds");
|
||||
MyGUI::Gui::getInstance().destroyWidget(mVideoBackground);
|
||||
mVideoBackground = NULL;
|
||||
mVideo = NULL;
|
||||
}
|
||||
if (mBackground && !show)
|
||||
{
|
||||
MyGUI::Gui::getInstance().destroyWidget(mBackground);
|
||||
mBackground = NULL;
|
||||
}
|
||||
|
||||
if (!show)
|
||||
return;
|
||||
|
||||
if (mHasAnimatedMenu)
|
||||
{
|
||||
if (!mVideo)
|
||||
{
|
||||
// Use black background to correct aspect ratio
|
||||
mVideoBackground = MyGUI::Gui::getInstance().createWidgetReal<MyGUI::ImageBox>("ImageBox", 0,0,1,1,
|
||||
MyGUI::Align::Default, "Menu");
|
||||
mVideoBackground->setImageTexture("black.png");
|
||||
|
||||
mVideo = mVideoBackground->createWidget<VideoWidget>("ImageBox", 0,0,1,1,
|
||||
MyGUI::Align::Stretch, "Menu");
|
||||
|
||||
mVideo->playVideo("video\\menu_background.bik", false);
|
||||
}
|
||||
|
||||
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
int screenWidth = viewSize.width;
|
||||
int screenHeight = viewSize.height;
|
||||
mVideoBackground->setSize(screenWidth, screenHeight);
|
||||
|
||||
double imageaspect = static_cast<double>(mVideo->getVideoWidth())/mVideo->getVideoHeight();
|
||||
|
||||
int leftPadding = std::max(0.0, (screenWidth - screenHeight * imageaspect) / 2);
|
||||
int topPadding = std::max(0.0, (screenHeight - screenWidth / imageaspect) / 2);
|
||||
|
||||
mVideo->setCoord(leftPadding, topPadding,
|
||||
screenWidth - leftPadding*2, screenHeight - topPadding*2);
|
||||
|
||||
mVideo->setVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!mBackground)
|
||||
{
|
||||
mBackground = MyGUI::Gui::getInstance().createWidgetReal<BackgroundImage>("ImageBox", 0,0,1,1,
|
||||
MyGUI::Align::Stretch, "Menu");
|
||||
mBackground->setBackgroundImage("textures\\menu_morrowind.dds");
|
||||
}
|
||||
mBackground->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void MainMenu::update(float dt)
|
||||
{
|
||||
if (mVideo)
|
||||
{
|
||||
if (!mVideo->update())
|
||||
{
|
||||
// If finished playing, start again
|
||||
mVideo->playVideo("video\\menu_background.bik", 0);
|
||||
}
|
||||
}
|
||||
if (mBackground)
|
||||
mBackground->setVisible(show);
|
||||
}
|
||||
|
||||
void MainMenu::updateMenu()
|
||||
|
@ -229,7 +294,7 @@ namespace MWGui
|
|||
if (state == MWBase::StateManager::State_NoGame)
|
||||
{
|
||||
// Align with the background image
|
||||
int bottomPadding=48;
|
||||
int bottomPadding=24;
|
||||
mButtonBox->setCoord (mWidth/2 - maxwidth/2, mHeight - curH - bottomPadding, maxwidth, curH);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -9,12 +9,15 @@ namespace MWGui
|
|||
class ImageButton;
|
||||
class BackgroundImage;
|
||||
class SaveGameDialog;
|
||||
class VideoWidget;
|
||||
|
||||
class MainMenu : public OEngine::GUI::Layout
|
||||
{
|
||||
int mWidth;
|
||||
int mHeight;
|
||||
|
||||
bool mHasAnimatedMenu;
|
||||
|
||||
public:
|
||||
|
||||
MainMenu(int w, int h);
|
||||
|
@ -24,6 +27,8 @@ namespace MWGui
|
|||
|
||||
virtual void setVisible (bool visible);
|
||||
|
||||
void update(float dt);
|
||||
|
||||
private:
|
||||
|
||||
MyGUI::Widget* mButtonBox;
|
||||
|
@ -31,6 +36,9 @@ namespace MWGui
|
|||
|
||||
BackgroundImage* mBackground;
|
||||
|
||||
MyGUI::ImageBox* mVideoBackground;
|
||||
VideoWidget* mVideo; // For animated main menus
|
||||
|
||||
std::map<std::string, MWGui::ImageButton*> mButtons;
|
||||
|
||||
void onButtonClicked (MyGUI::Widget* sender);
|
||||
|
|
|
@ -110,6 +110,11 @@ void MerchantRepair::open()
|
|||
center();
|
||||
}
|
||||
|
||||
void MerchantRepair::exit()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_MerchantRepair);
|
||||
}
|
||||
|
||||
void MerchantRepair::onRepairButtonClick(MyGUI::Widget *sender)
|
||||
{
|
||||
// repair
|
||||
|
@ -128,7 +133,7 @@ void MerchantRepair::onRepairButtonClick(MyGUI::Widget *sender)
|
|||
|
||||
void MerchantRepair::onOkButtonClick(MyGUI::Widget *sender)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_MerchantRepair);
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ public:
|
|||
|
||||
virtual void open();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
void startRepair(const MWWorld::Ptr& actor);
|
||||
|
||||
private:
|
||||
|
|
|
@ -179,7 +179,6 @@ namespace MWGui
|
|||
{
|
||||
WindowModal::open();
|
||||
|
||||
int fixedWidth = 500;
|
||||
int textPadding = 10; // padding between text-widget and main-widget
|
||||
int textButtonPadding = 20; // padding between the text-widget und the button-widget
|
||||
int buttonLeftPadding = 10; // padding between the buttons if horizontal
|
||||
|
@ -232,102 +231,52 @@ namespace MWGui
|
|||
buttonsWidth += buttonLeftPadding;
|
||||
|
||||
MyGUI::IntSize mainWidgetSize;
|
||||
if(buttonsWidth < fixedWidth)
|
||||
{
|
||||
// on one line
|
||||
if(textSize.width + 2*textPadding < buttonsWidth)
|
||||
{
|
||||
mainWidgetSize.width = buttonsWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
mainWidgetSize.width = textSize.width + 3*textPadding;
|
||||
}
|
||||
mainWidgetSize.height = textSize.height + textButtonPadding + buttonHeight + buttonMainPadding;
|
||||
|
||||
MyGUI::IntPoint absPos;
|
||||
absPos.left = (gameWindowSize.width - mainWidgetSize.width)/2;
|
||||
absPos.top = (gameWindowSize.height - mainWidgetSize.height)/2;
|
||||
|
||||
mMainWidget->setPosition(absPos);
|
||||
mMainWidget->setSize(mainWidgetSize);
|
||||
|
||||
MyGUI::IntCoord messageWidgetCoord;
|
||||
messageWidgetCoord.left = (mainWidgetSize.width - textSize.width)/2;
|
||||
messageWidgetCoord.top = textPadding;
|
||||
mMessageWidget->setCoord(messageWidgetCoord);
|
||||
|
||||
mMessageWidget->setSize(textSize);
|
||||
|
||||
MyGUI::IntCoord buttonCord;
|
||||
MyGUI::IntSize buttonSize(0, buttonHeight);
|
||||
int left = (mainWidgetSize.width - buttonsWidth)/2 + buttonPadding;
|
||||
|
||||
std::vector<MyGUI::Button*>::const_iterator button;
|
||||
for(button = mButtons.begin(); button != mButtons.end(); ++button)
|
||||
{
|
||||
buttonCord.left = left;
|
||||
buttonCord.top = textSize.height + textButtonPadding;
|
||||
|
||||
buttonSize.width = (*button)->getTextSize().width + 2*buttonPadding;
|
||||
buttonSize.height = (*button)->getTextSize().height + 2*buttonPadding;
|
||||
|
||||
(*button)->setCoord(buttonCord);
|
||||
(*button)->setSize(buttonSize);
|
||||
|
||||
left += buttonSize.width + buttonLeftPadding;
|
||||
}
|
||||
// among each other
|
||||
if(biggestButtonWidth > textSize.width) {
|
||||
mainWidgetSize.width = biggestButtonWidth + buttonTopPadding;
|
||||
}
|
||||
else
|
||||
{
|
||||
// among each other
|
||||
if(biggestButtonWidth > textSize.width) {
|
||||
mainWidgetSize.width = biggestButtonWidth + buttonTopPadding;
|
||||
}
|
||||
else {
|
||||
mainWidgetSize.width = textSize.width + 3*textPadding;
|
||||
}
|
||||
|
||||
MyGUI::IntCoord buttonCord;
|
||||
MyGUI::IntSize buttonSize(0, buttonHeight);
|
||||
|
||||
int top = textButtonPadding + buttonTopPadding + textSize.height;
|
||||
|
||||
std::vector<MyGUI::Button*>::const_iterator button;
|
||||
for(button = mButtons.begin(); button != mButtons.end(); ++button)
|
||||
{
|
||||
buttonSize.width = (*button)->getTextSize().width + buttonPadding*2;
|
||||
buttonSize.height = (*button)->getTextSize().height + buttonPadding*2;
|
||||
|
||||
buttonCord.top = top;
|
||||
buttonCord.left = (mainWidgetSize.width - buttonSize.width)/2 - 5; // FIXME: -5 is not so nice :/
|
||||
|
||||
(*button)->setCoord(buttonCord);
|
||||
(*button)->setSize(buttonSize);
|
||||
|
||||
top += buttonSize.height + 2*buttonTopPadding;
|
||||
}
|
||||
|
||||
mainWidgetSize.height = top + buttonMainPadding;
|
||||
mMainWidget->setSize(mainWidgetSize);
|
||||
|
||||
MyGUI::IntPoint absPos;
|
||||
absPos.left = (gameWindowSize.width - mainWidgetSize.width)/2;
|
||||
absPos.top = (gameWindowSize.height - mainWidgetSize.height)/2;
|
||||
|
||||
mMainWidget->setPosition(absPos);
|
||||
|
||||
MyGUI::IntCoord messageWidgetCoord;
|
||||
messageWidgetCoord.left = (mainWidgetSize.width - textSize.width)/2;
|
||||
messageWidgetCoord.top = textPadding;
|
||||
messageWidgetCoord.width = textSize.width;
|
||||
messageWidgetCoord.height = textSize.height;
|
||||
mMessageWidget->setCoord(messageWidgetCoord);
|
||||
else {
|
||||
mainWidgetSize.width = textSize.width + 3*textPadding;
|
||||
}
|
||||
|
||||
MyGUI::IntCoord buttonCord;
|
||||
MyGUI::IntSize buttonSize(0, buttonHeight);
|
||||
|
||||
int top = textButtonPadding + buttonTopPadding + textSize.height;
|
||||
|
||||
std::vector<MyGUI::Button*>::const_iterator button;
|
||||
for(button = mButtons.begin(); button != mButtons.end(); ++button)
|
||||
{
|
||||
buttonSize.width = (*button)->getTextSize().width + buttonPadding*2;
|
||||
buttonSize.height = (*button)->getTextSize().height + buttonPadding*2;
|
||||
|
||||
buttonCord.top = top;
|
||||
buttonCord.left = (mainWidgetSize.width - buttonSize.width)/2 - 5; // FIXME: -5 is not so nice :/
|
||||
|
||||
(*button)->setCoord(buttonCord);
|
||||
(*button)->setSize(buttonSize);
|
||||
|
||||
top += buttonSize.height + 2*buttonTopPadding;
|
||||
}
|
||||
|
||||
mainWidgetSize.height = top + buttonMainPadding;
|
||||
mMainWidget->setSize(mainWidgetSize);
|
||||
|
||||
MyGUI::IntPoint absPos;
|
||||
absPos.left = (gameWindowSize.width - mainWidgetSize.width)/2;
|
||||
absPos.top = (gameWindowSize.height - mainWidgetSize.height)/2;
|
||||
|
||||
mMainWidget->setPosition(absPos);
|
||||
|
||||
MyGUI::IntCoord messageWidgetCoord;
|
||||
messageWidgetCoord.left = (mainWidgetSize.width - textSize.width)/2;
|
||||
messageWidgetCoord.top = textPadding;
|
||||
messageWidgetCoord.width = textSize.width;
|
||||
messageWidgetCoord.height = textSize.height;
|
||||
mMessageWidget->setCoord(messageWidgetCoord);
|
||||
|
||||
// Set key focus to "Ok" button
|
||||
std::string ok = Misc::StringUtils::lowerCase(MyGUI::LanguageManager::getInstance().replaceTags("#{sOK}"));
|
||||
std::vector<MyGUI::Button*>::const_iterator button;
|
||||
for(button = mButtons.begin(); button != mButtons.end(); ++button)
|
||||
{
|
||||
if(Misc::StringUtils::ciEqual((*button)->getCaption(), ok))
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "spellwindow.hpp"
|
||||
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -46,17 +48,24 @@ namespace MWGui
|
|||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
MyGUI::Button* button;
|
||||
ItemWidget* button;
|
||||
getWidget(button, "QuickKey" + boost::lexical_cast<std::string>(i+1));
|
||||
|
||||
button->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||
|
||||
unassign(button, i);
|
||||
|
||||
mQuickKeyButtons.push_back(button);
|
||||
|
||||
mAssigned.push_back(Type_Unassigned);
|
||||
|
||||
unassign(button, i);
|
||||
}
|
||||
}
|
||||
|
||||
void QuickKeysMenu::exit()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode (MWGui::GM_QuickKeysMenu);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::clear()
|
||||
{
|
||||
for (int i=0; i<10; ++i)
|
||||
|
@ -72,12 +81,14 @@ namespace MWGui
|
|||
delete mMagicSelectionDialog;
|
||||
}
|
||||
|
||||
void QuickKeysMenu::unassign(MyGUI::Widget* key, int index)
|
||||
void QuickKeysMenu::unassign(ItemWidget* key, int index)
|
||||
{
|
||||
while (key->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (key->getChildAt(0));
|
||||
key->clearUserStrings();
|
||||
key->setItem(MWWorld::Ptr());
|
||||
while (key->getChildCount()) // Destroy number label
|
||||
MyGUI::Gui::getInstance().destroyWidget(key->getChildAt(0));
|
||||
|
||||
key->setUserData(Type_Unassigned);
|
||||
mAssigned[index] = Type_Unassigned;
|
||||
|
||||
MyGUI::TextBox* textBox = key->createWidgetReal<MyGUI::TextBox>("SandText", MyGUI::FloatCoord(0,0,1,1), MyGUI::Align::Default);
|
||||
textBox->setTextAlign (MyGUI::Align::Center);
|
||||
|
@ -151,27 +162,16 @@ namespace MWGui
|
|||
|
||||
void QuickKeysMenu::onAssignItem(MWWorld::Ptr item)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (button->getChildAt(0));
|
||||
assert (mSelectedIndex > 0);
|
||||
ItemWidget* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount()) // Destroy number label
|
||||
MyGUI::Gui::getInstance().destroyWidget(button->getChildAt(0));
|
||||
|
||||
button->setUserData(Type_Item);
|
||||
mAssigned[mSelectedIndex] = Type_Item;
|
||||
|
||||
MyGUI::ImageBox* frame = button->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default);
|
||||
std::string backgroundTex = "textures\\menu_icon_barter.dds";
|
||||
frame->setImageTexture (backgroundTex);
|
||||
frame->setImageCoord (MyGUI::IntCoord(4, 4, 40, 40));
|
||||
frame->setUserString ("ToolTipType", "ItemPtr");
|
||||
frame->setUserData(item);
|
||||
frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += item.getClass().getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture (path);
|
||||
image->setNeedMouseFocus (false);
|
||||
button->setItem(item, ItemWidget::Barter);
|
||||
button->setUserString ("ToolTipType", "ItemPtr");
|
||||
button->setUserData(item);
|
||||
|
||||
if (mItemSelectionDialog)
|
||||
mItemSelectionDialog->setVisible(false);
|
||||
|
@ -184,28 +184,18 @@ namespace MWGui
|
|||
|
||||
void QuickKeysMenu::onAssignMagicItem (MWWorld::Ptr item)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (button->getChildAt(0));
|
||||
assert (mSelectedIndex > 0);
|
||||
ItemWidget* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount()) // Destroy number label
|
||||
MyGUI::Gui::getInstance().destroyWidget(button->getChildAt(0));
|
||||
|
||||
button->setUserData(Type_MagicItem);
|
||||
mAssigned[mSelectedIndex] = Type_MagicItem;
|
||||
|
||||
MyGUI::ImageBox* frame = button->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default);
|
||||
std::string backgroundTex = "textures\\menu_icon_select_magic_magic.dds";
|
||||
frame->setImageTexture (backgroundTex);
|
||||
frame->setImageCoord (MyGUI::IntCoord(2, 2, 40, 40));
|
||||
frame->setUserString ("ToolTipType", "ItemPtr");
|
||||
frame->setUserData(item);
|
||||
frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||
button->setFrame("textures\\menu_icon_select_magic_magic.dds", MyGUI::IntCoord(2, 2, 40, 40));
|
||||
button->setIcon(item);
|
||||
|
||||
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += item.getClass().getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture (path);
|
||||
image->setNeedMouseFocus (false);
|
||||
button->setUserString ("ToolTipType", "ItemPtr");
|
||||
button->setUserData(item);
|
||||
|
||||
if (mMagicSelectionDialog)
|
||||
mMagicSelectionDialog->setVisible(false);
|
||||
|
@ -213,21 +203,16 @@ namespace MWGui
|
|||
|
||||
void QuickKeysMenu::onAssignMagic (const std::string& spellId)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (button->getChildAt(0));
|
||||
assert (mSelectedIndex > 0);
|
||||
ItemWidget* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount()) // Destroy number label
|
||||
MyGUI::Gui::getInstance().destroyWidget(button->getChildAt(0));
|
||||
|
||||
button->setUserData(Type_Magic);
|
||||
mAssigned[mSelectedIndex] = Type_Magic;
|
||||
|
||||
MyGUI::ImageBox* frame = button->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default);
|
||||
std::string backgroundTex = "textures\\menu_icon_select_magic.dds";
|
||||
frame->setImageTexture (backgroundTex);
|
||||
frame->setImageCoord (MyGUI::IntCoord(2, 2, 40, 40));
|
||||
frame->setUserString ("ToolTipType", "Spell");
|
||||
frame->setUserString ("Spell", spellId);
|
||||
frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||
|
||||
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||
button->setItem(MWWorld::Ptr());
|
||||
button->setUserString ("ToolTipType", "Spell");
|
||||
button->setUserString ("Spell", spellId);
|
||||
|
||||
const MWWorld::ESMStore &esmStore =
|
||||
MWBase::Environment::get().getWorld()->getStore();
|
||||
|
@ -246,8 +231,8 @@ namespace MWGui
|
|||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
|
||||
image->setImageTexture (path);
|
||||
image->setNeedMouseFocus (false);
|
||||
button->setFrame("textures\\menu_icon_select_magic.dds", MyGUI::IntCoord(2, 2, 40, 40));
|
||||
button->setIcon(path);
|
||||
|
||||
if (mMagicSelectionDialog)
|
||||
mMagicSelectionDialog->setVisible(false);
|
||||
|
@ -260,16 +245,17 @@ namespace MWGui
|
|||
|
||||
void QuickKeysMenu::activateQuickKey(int index)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[index-1];
|
||||
assert (index-1 > 0);
|
||||
ItemWidget* button = mQuickKeyButtons[index-1];
|
||||
|
||||
QuickKeyType type = *button->getUserData<QuickKeyType>();
|
||||
QuickKeyType type = mAssigned[index-1];
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
||||
|
||||
if (type == Type_Item || type == Type_MagicItem)
|
||||
{
|
||||
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
||||
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
||||
// make sure the item is available
|
||||
if (item.getRefData ().getCount() < 1)
|
||||
{
|
||||
|
@ -281,7 +267,7 @@ namespace MWGui
|
|||
if (Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), id))
|
||||
{
|
||||
item = *it;
|
||||
button->getChildAt(0)->setUserData(item);
|
||||
button->setUserData(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +284,7 @@ namespace MWGui
|
|||
|
||||
if (type == Type_Magic)
|
||||
{
|
||||
std::string spellId = button->getChildAt(0)->getUserString("Spell");
|
||||
std::string spellId = button->getUserString("Spell");
|
||||
|
||||
// Make sure the player still has this spell
|
||||
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||
|
@ -310,13 +296,13 @@ namespace MWGui
|
|||
}
|
||||
else if (type == Type_Item)
|
||||
{
|
||||
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
||||
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item);
|
||||
}
|
||||
else if (type == Type_MagicItem)
|
||||
{
|
||||
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
||||
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
||||
|
||||
// retrieve ContainerStoreIterator to the item
|
||||
MWWorld::ContainerStoreIterator it = store.begin();
|
||||
|
@ -385,6 +371,11 @@ namespace MWGui
|
|||
center();
|
||||
}
|
||||
|
||||
void QuickKeysMenuAssign::exit()
|
||||
{
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::write(ESM::ESMWriter &writer)
|
||||
{
|
||||
writer.startRecord(ESM::REC_KEYS);
|
||||
|
@ -393,9 +384,9 @@ namespace MWGui
|
|||
|
||||
for (int i=0; i<10; ++i)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[i];
|
||||
ItemWidget* button = mQuickKeyButtons[i];
|
||||
|
||||
int type = *button->getUserData<QuickKeyType>();
|
||||
int type = mAssigned[i];
|
||||
|
||||
ESM::QuickKeys::QuickKey key;
|
||||
key.mType = type;
|
||||
|
@ -407,12 +398,12 @@ namespace MWGui
|
|||
case Type_Item:
|
||||
case Type_MagicItem:
|
||||
{
|
||||
MWWorld::Ptr item = *button->getChildAt(0)->getUserData<MWWorld::Ptr>();
|
||||
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
||||
key.mId = item.getCellRef().getRefId();
|
||||
break;
|
||||
}
|
||||
case Type_Magic:
|
||||
std::string spellId = button->getChildAt(0)->getUserString("Spell");
|
||||
std::string spellId = button->getUserString("Spell");
|
||||
key.mId = spellId;
|
||||
break;
|
||||
}
|
||||
|
@ -442,7 +433,7 @@ namespace MWGui
|
|||
mSelectedIndex = i;
|
||||
int keyType = it->mType;
|
||||
std::string id = it->mId;
|
||||
MyGUI::Button* button = mQuickKeyButtons[i];
|
||||
ItemWidget* button = mQuickKeyButtons[i];
|
||||
|
||||
switch (keyType)
|
||||
{
|
||||
|
@ -508,7 +499,12 @@ namespace MWGui
|
|||
|
||||
void MagicSelectionDialog::onCancelButtonClicked (MyGUI::Widget *sender)
|
||||
{
|
||||
mParent->onAssignMagicCancel ();
|
||||
exit();
|
||||
}
|
||||
|
||||
void MagicSelectionDialog::exit()
|
||||
{
|
||||
mParent->onAssignMagicCancel();
|
||||
}
|
||||
|
||||
void MagicSelectionDialog::open ()
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace MWGui
|
|||
class QuickKeysMenuAssign;
|
||||
class ItemSelectionDialog;
|
||||
class MagicSelectionDialog;
|
||||
class ItemWidget;
|
||||
|
||||
class QuickKeysMenu : public WindowBase
|
||||
{
|
||||
|
@ -18,6 +19,7 @@ namespace MWGui
|
|||
QuickKeysMenu();
|
||||
~QuickKeysMenu();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
void onItemButtonClicked(MyGUI::Widget* sender);
|
||||
void onMagicButtonClicked(MyGUI::Widget* sender);
|
||||
|
@ -50,7 +52,8 @@ namespace MWGui
|
|||
MyGUI::EditBox* mInstructionLabel;
|
||||
MyGUI::Button* mOkButton;
|
||||
|
||||
std::vector<MyGUI::Button*> mQuickKeyButtons;
|
||||
std::vector<ItemWidget*> mQuickKeyButtons;
|
||||
std::vector<QuickKeyType> mAssigned;
|
||||
|
||||
QuickKeysMenuAssign* mAssignDialog;
|
||||
ItemSelectionDialog* mItemSelectionDialog;
|
||||
|
@ -62,13 +65,14 @@ namespace MWGui
|
|||
void onQuickKeyButtonClicked(MyGUI::Widget* sender);
|
||||
void onOkButtonClicked(MyGUI::Widget* sender);
|
||||
|
||||
void unassign(MyGUI::Widget* key, int index);
|
||||
void unassign(ItemWidget* key, int index);
|
||||
};
|
||||
|
||||
class QuickKeysMenuAssign : public WindowModal
|
||||
{
|
||||
public:
|
||||
QuickKeysMenuAssign(QuickKeysMenu* parent);
|
||||
virtual void exit();
|
||||
|
||||
private:
|
||||
MyGUI::TextBox* mLabel;
|
||||
|
@ -86,6 +90,7 @@ namespace MWGui
|
|||
MagicSelectionDialog(QuickKeysMenu* parent);
|
||||
|
||||
virtual void open();
|
||||
virtual void exit();
|
||||
|
||||
private:
|
||||
MyGUI::Button* mCancelButton;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
#include "widgets.hpp"
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -38,14 +39,14 @@ void Recharge::open()
|
|||
center();
|
||||
}
|
||||
|
||||
void Recharge::exit()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Recharge);
|
||||
}
|
||||
|
||||
void Recharge::start (const MWWorld::Ptr &item)
|
||||
{
|
||||
std::string path = std::string("icons\\");
|
||||
path += item.getClass().getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
mGemIcon->setImageTexture (path);
|
||||
mGemIcon->setItem(item);
|
||||
mGemIcon->setUserString("ToolTipType", "ItemPtr");
|
||||
mGemIcon->setUserData(item);
|
||||
|
||||
|
@ -103,14 +104,9 @@ void Recharge::updateView()
|
|||
text->setNeedMouseFocus(false);
|
||||
currentY += 19;
|
||||
|
||||
MyGUI::ImageBox* icon = mView->createWidget<MyGUI::ImageBox> (
|
||||
"ImageBox", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += iter->getClass().getInventoryIcon(*iter);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
icon->setImageTexture (path);
|
||||
ItemWidget* icon = mView->createWidget<ItemWidget> (
|
||||
"MW_ItemIconSmall", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default);
|
||||
icon->setItem(*iter);
|
||||
icon->setUserString("ToolTipType", "ItemPtr");
|
||||
icon->setUserData(*iter);
|
||||
icon->eventMouseButtonClick += MyGUI::newDelegate(this, &Recharge::onItemClicked);
|
||||
|
@ -128,7 +124,7 @@ void Recharge::updateView()
|
|||
|
||||
void Recharge::onCancel(MyGUI::Widget *sender)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Recharge);
|
||||
exit();
|
||||
}
|
||||
|
||||
void Recharge::onItemClicked(MyGUI::Widget *sender)
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
namespace MWGui
|
||||
{
|
||||
|
||||
class ItemWidget;
|
||||
|
||||
class Recharge : public WindowBase
|
||||
{
|
||||
public:
|
||||
|
@ -15,6 +17,8 @@ public:
|
|||
|
||||
virtual void open();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
void start (const MWWorld::Ptr& gem);
|
||||
|
||||
protected:
|
||||
|
@ -23,7 +27,7 @@ protected:
|
|||
|
||||
MyGUI::Widget* mGemBox;
|
||||
|
||||
MyGUI::ImageBox* mGemIcon;
|
||||
ItemWidget* mGemIcon;
|
||||
|
||||
MyGUI::TextBox* mChargeLabel;
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#include "widgets.hpp"
|
||||
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
|
@ -35,16 +37,16 @@ void Repair::open()
|
|||
center();
|
||||
}
|
||||
|
||||
void Repair::exit()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Repair);
|
||||
}
|
||||
|
||||
void Repair::startRepairItem(const MWWorld::Ptr &item)
|
||||
{
|
||||
mRepair.setTool(item);
|
||||
|
||||
std::string path = std::string("icons\\");
|
||||
path += item.getClass().getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
mToolIcon->setImageTexture (path);
|
||||
mToolIcon->setItem(item);
|
||||
mToolIcon->setUserString("ToolTipType", "ItemPtr");
|
||||
mToolIcon->setUserData(item);
|
||||
|
||||
|
@ -108,14 +110,9 @@ void Repair::updateRepairView()
|
|||
text->setNeedMouseFocus(false);
|
||||
currentY += 19;
|
||||
|
||||
MyGUI::ImageBox* icon = mRepairView->createWidget<MyGUI::ImageBox> (
|
||||
"ImageBox", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += iter->getClass().getInventoryIcon(*iter);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
icon->setImageTexture (path);
|
||||
ItemWidget* icon = mRepairView->createWidget<ItemWidget> (
|
||||
"MW_ItemIconSmall", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default);
|
||||
icon->setItem(*iter);
|
||||
icon->setUserString("ToolTipType", "ItemPtr");
|
||||
icon->setUserData(*iter);
|
||||
icon->eventMouseButtonClick += MyGUI::newDelegate(this, &Repair::onRepairItem);
|
||||
|
@ -134,7 +131,7 @@ void Repair::updateRepairView()
|
|||
|
||||
void Repair::onCancel(MyGUI::Widget *sender)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Repair);
|
||||
exit();
|
||||
}
|
||||
|
||||
void Repair::onRepairItem(MyGUI::Widget *sender)
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
namespace MWGui
|
||||
{
|
||||
|
||||
class ItemWidget;
|
||||
|
||||
class Repair : public WindowBase
|
||||
{
|
||||
public:
|
||||
|
@ -15,6 +17,8 @@ public:
|
|||
|
||||
virtual void open();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
void startRepairItem (const MWWorld::Ptr& item);
|
||||
|
||||
protected:
|
||||
|
@ -23,7 +27,7 @@ protected:
|
|||
|
||||
MyGUI::Widget* mToolBox;
|
||||
|
||||
MyGUI::ImageBox* mToolIcon;
|
||||
ItemWidget* mToolIcon;
|
||||
|
||||
MyGUI::TextBox* mUsesLabel;
|
||||
MyGUI::TextBox* mQualityLabel;
|
||||
|
|
|
@ -117,7 +117,7 @@ namespace MWGui
|
|||
std::string directory =
|
||||
Misc::StringUtils::lowerCase (Settings::Manager::getString ("character", "Saves"));
|
||||
|
||||
int selectedIndex = MyGUI::ITEM_NONE;
|
||||
size_t selectedIndex = MyGUI::ITEM_NONE;
|
||||
|
||||
for (MWBase::StateManager::CharacterIterator it = mgr->characterBegin(); it != mgr->characterEnd(); ++it)
|
||||
{
|
||||
|
@ -134,9 +134,12 @@ namespace MWGui
|
|||
else
|
||||
{
|
||||
// Find the localised name for this class from the store
|
||||
const ESM::Class* class_ = MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(
|
||||
const ESM::Class* class_ = MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().search(
|
||||
it->getSignature().mPlayerClassId);
|
||||
className = class_->mName;
|
||||
if (class_)
|
||||
className = class_->mName;
|
||||
else
|
||||
className = "?"; // From an older savegame format that did not support custom classes properly.
|
||||
}
|
||||
|
||||
title << " (Level " << it->getSignature().mPlayerLevel << " " << className << ")";
|
||||
|
@ -159,6 +162,11 @@ namespace MWGui
|
|||
|
||||
}
|
||||
|
||||
void SaveGameDialog::exit()
|
||||
{
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
void SaveGameDialog::setLoadOrSave(bool load)
|
||||
{
|
||||
mSaving = !load;
|
||||
|
@ -177,7 +185,7 @@ namespace MWGui
|
|||
|
||||
void SaveGameDialog::onCancelButtonClicked(MyGUI::Widget *sender)
|
||||
{
|
||||
setVisible(false);
|
||||
exit();
|
||||
}
|
||||
|
||||
void SaveGameDialog::onConfirmationGiven()
|
||||
|
|
|
@ -19,6 +19,8 @@ namespace MWGui
|
|||
|
||||
virtual void open();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
void setLoadOrSave(bool load);
|
||||
|
||||
private:
|
||||
|
|
|
@ -67,6 +67,13 @@ namespace MWGui
|
|||
setTakeButtonShow(true);
|
||||
}
|
||||
|
||||
void ScrollWindow::exit()
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound ("scroll", 1.0, 1.0);
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Scroll);
|
||||
}
|
||||
|
||||
void ScrollWindow::setTakeButtonShow(bool show)
|
||||
{
|
||||
mTakeButtonShow = show;
|
||||
|
@ -81,9 +88,7 @@ namespace MWGui
|
|||
|
||||
void ScrollWindow::onCloseButtonClicked (MyGUI::Widget* _sender)
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound ("scroll", 1.0, 1.0);
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Scroll);
|
||||
exit();
|
||||
}
|
||||
|
||||
void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace MWGui
|
|||
ScrollWindow ();
|
||||
|
||||
void open (MWWorld::Ptr scroll);
|
||||
virtual void exit();
|
||||
void setTakeButtonShow(bool show);
|
||||
void setInventoryAllowed(bool allowed);
|
||||
|
||||
|
|
|
@ -73,17 +73,6 @@ namespace
|
|||
return (Ogre::Root::getSingleton ().getRenderSystem ()->getName ().find("OpenGL") != std::string::npos) ? "glsl" : "hlsl";
|
||||
}
|
||||
|
||||
bool cgAvailable ()
|
||||
{
|
||||
Ogre::Root::PluginInstanceList list = Ogre::Root::getSingleton ().getInstalledPlugins ();
|
||||
for (Ogre::Root::PluginInstanceList::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||
{
|
||||
if ((*it)->getName() == "Cg Program Manager")
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* checkButtonType = "CheckButton";
|
||||
const char* sliderType = "Slider";
|
||||
|
||||
|
@ -242,7 +231,7 @@ namespace MWGui
|
|||
|
||||
void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Settings);
|
||||
exit();
|
||||
}
|
||||
|
||||
void SettingsWindow::onResolutionSelected(MyGUI::ListBox* _sender, size_t index)
|
||||
|
@ -366,12 +355,7 @@ namespace MWGui
|
|||
void SettingsWindow::onShaderModeToggled(MyGUI::Widget* _sender)
|
||||
{
|
||||
std::string val = static_cast<MyGUI::Button*>(_sender)->getCaption();
|
||||
if (val == "cg")
|
||||
{
|
||||
val = hlslGlsl();
|
||||
}
|
||||
else if (cgAvailable ())
|
||||
val = "cg";
|
||||
val = hlslGlsl();
|
||||
|
||||
static_cast<MyGUI::Button*>(_sender)->setCaption(val);
|
||||
|
||||
|
@ -510,4 +494,9 @@ namespace MWGui
|
|||
{
|
||||
updateControlsBox ();
|
||||
}
|
||||
|
||||
void SettingsWindow::exit()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Settings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ namespace MWGui
|
|||
|
||||
virtual void open();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
void updateControlsBox();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -33,6 +33,11 @@ namespace MWGui
|
|||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellBuyingWindow::onCancelButtonClicked);
|
||||
}
|
||||
|
||||
void SpellBuyingWindow::exit()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_SpellBuying);
|
||||
}
|
||||
|
||||
void SpellBuyingWindow::addSpell(const std::string& spellId)
|
||||
{
|
||||
const MWWorld::ESMStore &store =
|
||||
|
@ -132,7 +137,7 @@ namespace MWGui
|
|||
|
||||
void SpellBuyingWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_SpellBuying);
|
||||
exit();
|
||||
}
|
||||
|
||||
void SpellBuyingWindow::updateLabels()
|
||||
|
|
|
@ -25,6 +25,8 @@ namespace MWGui
|
|||
|
||||
void startSpellBuying(const MWWorld::Ptr& actor);
|
||||
|
||||
virtual void exit();
|
||||
|
||||
protected:
|
||||
MyGUI::Button* mCancelButton;
|
||||
MyGUI::TextBox* mPlayerGold;
|
||||
|
|
|
@ -75,6 +75,15 @@ namespace MWGui
|
|||
center();
|
||||
}
|
||||
|
||||
void EditEffectDialog::exit()
|
||||
{
|
||||
setVisible(false);
|
||||
if(mEditing)
|
||||
eventEffectModified(mOldEffect);
|
||||
else
|
||||
eventEffectRemoved(mEffect);
|
||||
}
|
||||
|
||||
void EditEffectDialog::newEffect (const ESM::MagicEffect *effect)
|
||||
{
|
||||
setMagicEffect(effect);
|
||||
|
@ -222,11 +231,7 @@ namespace MWGui
|
|||
|
||||
void EditEffectDialog::onCancelButtonClicked (MyGUI::Widget* sender)
|
||||
{
|
||||
setVisible(false);
|
||||
if(mEditing)
|
||||
eventEffectModified(mOldEffect);
|
||||
else
|
||||
eventEffectRemoved(mEffect);
|
||||
exit();
|
||||
}
|
||||
|
||||
void EditEffectDialog::setSkill (int skill)
|
||||
|
@ -313,7 +318,7 @@ namespace MWGui
|
|||
|
||||
void SpellCreationDialog::onCancelButtonClicked (MyGUI::Widget* sender)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode (MWGui::GM_SpellCreation);
|
||||
exit();
|
||||
}
|
||||
|
||||
void SpellCreationDialog::onBuyButtonClicked (MyGUI::Widget* sender)
|
||||
|
@ -367,6 +372,11 @@ namespace MWGui
|
|||
center();
|
||||
}
|
||||
|
||||
void SpellCreationDialog::exit()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode (MWGui::GM_SpellCreation);
|
||||
}
|
||||
|
||||
void SpellCreationDialog::onReferenceUnavailable ()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Dialogue);
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace MWGui
|
|||
EditEffectDialog();
|
||||
|
||||
virtual void open();
|
||||
virtual void exit();
|
||||
|
||||
void setSkill(int skill);
|
||||
void setAttribute(int attribute);
|
||||
|
@ -127,6 +128,7 @@ namespace MWGui
|
|||
SpellCreationDialog();
|
||||
|
||||
virtual void open();
|
||||
virtual void exit();
|
||||
|
||||
void startSpellMaking(MWWorld::Ptr actor);
|
||||
|
||||
|
|
|
@ -190,6 +190,7 @@ namespace MWGui
|
|||
costChance->setNeedMouseFocus(false);
|
||||
costChance->setStateSelected(*it == MWBase::Environment::get().getWindowManager()->getSelectedSpell());
|
||||
|
||||
t->setSize(mWidth-12-costChance->getTextSize().width, t->getHeight());
|
||||
|
||||
mHeight += spellHeight;
|
||||
}
|
||||
|
@ -255,6 +256,8 @@ namespace MWGui
|
|||
if (store.getSelectedEnchantItem() != store.end())
|
||||
costCharge->setStateSelected(item == *store.getSelectedEnchantItem());
|
||||
|
||||
t->setSize(mWidth-12-costCharge->getTextSize().width, t->getHeight());
|
||||
|
||||
mHeight += spellHeight;
|
||||
}
|
||||
|
||||
|
@ -287,6 +290,8 @@ namespace MWGui
|
|||
groupWidget2->setCaptionWithReplacing(label2);
|
||||
groupWidget2->setTextAlign(MyGUI::Align::Right);
|
||||
groupWidget2->setNeedMouseFocus(false);
|
||||
|
||||
groupWidget->setSize(mWidth-8-groupWidget2->getTextSize().width, groupWidget->getHeight());
|
||||
}
|
||||
|
||||
mHeight += 24;
|
||||
|
|
|
@ -454,20 +454,30 @@ namespace MWGui
|
|||
|
||||
if (!mFactions.empty())
|
||||
{
|
||||
// Add a line separator if there are items above
|
||||
if (!mSkillWidgets.empty())
|
||||
addSeparator(coord1, coord2);
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
const MWMechanics::NpcStats &PCstats = player.getClass().getNpcStats(player);
|
||||
const std::set<std::string> &expelled = PCstats.getExpelled();
|
||||
|
||||
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sFaction", "Faction"), coord1, coord2);
|
||||
bool firstFaction=true;
|
||||
FactionList::const_iterator end = mFactions.end();
|
||||
for (FactionList::const_iterator it = mFactions.begin(); it != end; ++it)
|
||||
{
|
||||
const ESM::Faction *faction =
|
||||
store.get<ESM::Faction>().find(it->first);
|
||||
if (faction->mData.mIsHidden == 1)
|
||||
continue;
|
||||
|
||||
if (firstFaction)
|
||||
{
|
||||
// Add a line separator if there are items above
|
||||
if (!mSkillWidgets.empty())
|
||||
addSeparator(coord1, coord2);
|
||||
|
||||
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sFaction", "Faction"), coord1, coord2);
|
||||
|
||||
firstFaction = false;
|
||||
}
|
||||
|
||||
MyGUI::Widget* w = addItem(faction->mName, coord1, coord2);
|
||||
|
||||
std::string text;
|
||||
|
|
|
@ -400,7 +400,7 @@ namespace MWGui
|
|||
if (!info.effects.empty())
|
||||
{
|
||||
MyGUI::Widget* effectArea = mDynamicToolTipBox->createWidget<MyGUI::Widget>("",
|
||||
MyGUI::IntCoord(0, totalSize.height, 300, 300-totalSize.height),
|
||||
MyGUI::IntCoord(padding.left, totalSize.height, 300-padding.left, 300-totalSize.height),
|
||||
MyGUI::Align::Stretch, "ToolTipEffectArea");
|
||||
|
||||
MyGUI::IntCoord coord(0, 6, totalSize.width, 24);
|
||||
|
@ -419,7 +419,7 @@ namespace MWGui
|
|||
{
|
||||
assert(enchant);
|
||||
MyGUI::Widget* enchantArea = mDynamicToolTipBox->createWidget<MyGUI::Widget>("",
|
||||
MyGUI::IntCoord(0, totalSize.height, 300, 300-totalSize.height),
|
||||
MyGUI::IntCoord(padding.left, totalSize.height, 300-padding.left, 300-totalSize.height),
|
||||
MyGUI::Align::Stretch, "ToolTipEnchantArea");
|
||||
|
||||
MyGUI::IntCoord coord(0, 6, totalSize.width, 24);
|
||||
|
@ -512,7 +512,11 @@ namespace MWGui
|
|||
std::string ToolTips::toString(const float value)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << std::setprecision(3) << value;
|
||||
|
||||
if (value != int(value))
|
||||
stream << std::setprecision(3);
|
||||
|
||||
stream << value;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace MWGui
|
|||
bool found = false;
|
||||
for (; it != out.end(); ++it)
|
||||
{
|
||||
if (it->stacks(item))
|
||||
if (it->mBase == item.mBase)
|
||||
{
|
||||
it->mCount += item.mCount;
|
||||
found = true;
|
||||
|
@ -52,7 +52,7 @@ namespace MWGui
|
|||
bool found = false;
|
||||
for (; it != out.end(); ++it)
|
||||
{
|
||||
if (it->stacks(item))
|
||||
if (it->mBase == item.mBase)
|
||||
{
|
||||
if (it->mCount < count)
|
||||
throw std::runtime_error("Not enough borrowed items to return");
|
||||
|
@ -114,7 +114,7 @@ namespace MWGui
|
|||
size_t i=0;
|
||||
for (; i<sourceModel->getItemCount(); ++i)
|
||||
{
|
||||
if (it->stacks(sourceModel->getItem(i)))
|
||||
if (it->mBase == sourceModel->getItem(i).mBase)
|
||||
break;
|
||||
}
|
||||
if (i == sourceModel->getItemCount())
|
||||
|
@ -182,7 +182,7 @@ namespace MWGui
|
|||
std::vector<ItemStack>::iterator it = mBorrowedFromUs.begin();
|
||||
for (; it != mBorrowedFromUs.end(); ++it)
|
||||
{
|
||||
if (it->stacks(item))
|
||||
if (it->mBase == item.mBase)
|
||||
{
|
||||
if (item.mCount < it->mCount)
|
||||
throw std::runtime_error("Lent more items than present");
|
||||
|
|
|
@ -74,6 +74,8 @@ namespace MWGui
|
|||
mDecreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonPressed);
|
||||
mDecreaseButton->eventMouseButtonReleased += MyGUI::newDelegate(this, &TradeWindow::onBalanceButtonReleased);
|
||||
|
||||
mTotalBalance->eventEditTextChange += MyGUI::newDelegate(this, &TradeWindow::onBalanceEdited);
|
||||
|
||||
setCoord(400, 0, 400, 300);
|
||||
}
|
||||
|
||||
|
@ -136,6 +138,13 @@ namespace MWGui
|
|||
return mPtr.getClass().getServices(mPtr);
|
||||
}
|
||||
|
||||
void TradeWindow::exit()
|
||||
{
|
||||
mTradeModel->abort();
|
||||
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel()->abort();
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Barter);
|
||||
}
|
||||
|
||||
void TradeWindow::onItemSelected (int index)
|
||||
{
|
||||
const ItemStack& item = mSortModel->getItem(index);
|
||||
|
@ -293,6 +302,9 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
|
||||
// Is the player buying?
|
||||
bool buying = (mCurrentMerchantOffer < 0);
|
||||
|
||||
if(mCurrentBalance > mCurrentMerchantOffer)
|
||||
{
|
||||
//if npc is a creature: reject (no haggle)
|
||||
|
@ -306,7 +318,7 @@ namespace MWGui
|
|||
int a = abs(mCurrentMerchantOffer);
|
||||
int b = abs(mCurrentBalance);
|
||||
int d = 0;
|
||||
if (mCurrentBalance<0)
|
||||
if (buying)
|
||||
d = int(100 * (a - b) / a);
|
||||
else
|
||||
d = int(100 * (b - a) / a);
|
||||
|
@ -327,13 +339,13 @@ namespace MWGui
|
|||
float pcTerm = (clampedDisposition - 50 + a1 + b1 + c1) * playerStats.getFatigueTerm();
|
||||
float npcTerm = (d1 + e1 + f1) * sellerStats.getFatigueTerm();
|
||||
float x = gmst.find("fBargainOfferMulti")->getFloat() * d + gmst.find("fBargainOfferBase")->getFloat();
|
||||
if (mCurrentBalance<0)
|
||||
if (buying)
|
||||
x += abs(int(pcTerm - npcTerm));
|
||||
else
|
||||
x += abs(int(npcTerm - pcTerm));
|
||||
|
||||
int roll = std::rand()%100 + 1;
|
||||
if(roll > x) //trade refused
|
||||
if(roll > x || (mCurrentMerchantOffer < 0) != (mCurrentBalance < 0)) //trade refused
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->
|
||||
messageBox("#{sNotifyMessage9}");
|
||||
|
@ -375,9 +387,7 @@ namespace MWGui
|
|||
|
||||
void TradeWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
mTradeModel->abort();
|
||||
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel()->abort();
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Barter);
|
||||
exit();
|
||||
}
|
||||
|
||||
void TradeWindow::onMaxSaleButtonClicked(MyGUI::Widget* _sender)
|
||||
|
@ -405,6 +415,19 @@ namespace MWGui
|
|||
mBalanceButtonsState = BBS_None;
|
||||
}
|
||||
|
||||
void TradeWindow::onBalanceEdited(MyGUI::EditBox *_sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
unsigned int count = boost::lexical_cast<unsigned int>(_sender->getCaption());
|
||||
mCurrentBalance = count * (mCurrentBalance >= 0 ? 1 : -1);
|
||||
updateLabels();
|
||||
}
|
||||
catch (std::bad_cast&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void TradeWindow::onIncreaseButtonTriggered()
|
||||
{
|
||||
if(mCurrentBalance<=-1) mCurrentBalance -= 1;
|
||||
|
|
|
@ -35,6 +35,8 @@ namespace MWGui
|
|||
|
||||
int getMerchantServices();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
|
||||
private:
|
||||
ItemView* mItemView;
|
||||
|
@ -53,7 +55,7 @@ namespace MWGui
|
|||
MyGUI::Button* mIncreaseButton;
|
||||
MyGUI::Button* mDecreaseButton;
|
||||
MyGUI::TextBox* mTotalBalanceLabel;
|
||||
MyGUI::TextBox* mTotalBalance;
|
||||
MyGUI::EditBox* mTotalBalance;
|
||||
|
||||
MyGUI::Widget* mBottomPane;
|
||||
|
||||
|
@ -89,6 +91,7 @@ namespace MWGui
|
|||
void onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
||||
void onDecreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
||||
void onBalanceButtonReleased(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
||||
void onBalanceEdited(MyGUI::EditBox* _sender);
|
||||
|
||||
void onIncreaseButtonTriggered();
|
||||
void onDecreaseButtonTriggered();
|
||||
|
|
|
@ -35,6 +35,11 @@ namespace MWGui
|
|||
center();
|
||||
}
|
||||
|
||||
void TrainingWindow::exit()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Training);
|
||||
}
|
||||
|
||||
void TrainingWindow::startTraining (MWWorld::Ptr actor)
|
||||
{
|
||||
mPtr = actor;
|
||||
|
@ -107,7 +112,7 @@ namespace MWGui
|
|||
|
||||
void TrainingWindow::onCancelButtonClicked (MyGUI::Widget *sender)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Training);
|
||||
exit();
|
||||
}
|
||||
|
||||
void TrainingWindow::onTrainingSelected (MyGUI::Widget *sender)
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace MWGui
|
|||
|
||||
virtual void open();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
void startTraining(MWWorld::Ptr actor);
|
||||
|
||||
void onFrame(float dt);
|
||||
|
|
|
@ -45,6 +45,11 @@ namespace MWGui
|
|||
mSelect->getHeight());
|
||||
}
|
||||
|
||||
void TravelWindow::exit()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Travel);
|
||||
}
|
||||
|
||||
void TravelWindow::addDestination(const std::string& travelId,ESM::Position pos,bool interior)
|
||||
{
|
||||
int price = 0;
|
||||
|
@ -170,7 +175,7 @@ namespace MWGui
|
|||
|
||||
void TravelWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Travel);
|
||||
exit();
|
||||
}
|
||||
|
||||
void TravelWindow::updateLabels()
|
||||
|
|
|
@ -22,6 +22,8 @@ namespace MWGui
|
|||
public:
|
||||
TravelWindow();
|
||||
|
||||
virtual void exit();
|
||||
|
||||
void startTravel(const MWWorld::Ptr& actor);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -42,4 +42,9 @@ bool VideoWidget::update()
|
|||
return mPlayer.isPlaying();
|
||||
}
|
||||
|
||||
void VideoWidget::cleanup()
|
||||
{
|
||||
mPlayer.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@ namespace MWGui
|
|||
/// @return Is the video still playing?
|
||||
bool update();
|
||||
|
||||
/// Free video player resources (done automatically on destruction)
|
||||
void cleanup();
|
||||
|
||||
private:
|
||||
bool mAllowSkipping;
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue