Merge remote-tracking branch 'scrawl/master'

openmw-30
Marc Zinnschlag 11 years ago
commit 3abe4c1f16

@ -305,6 +305,10 @@ namespace MWBase
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress) = 0;
virtual void readRecord (ESM::ESMReader& reader, int32_t type) = 0;
virtual int countSavedGameRecords() const = 0;
/// Does the current stack of GUI-windows permit saving?
virtual bool isSavingAllowed() const = 0;
};
}

@ -196,6 +196,16 @@ namespace MWGui
bitmapFile->read(&textureData[0], width*height*4);
bitmapFile->close();
std::string resourceName;
if (name.size() >= 5 && Misc::StringUtils::ciEqual(name.substr(0, 5), "magic"))
resourceName = "Magic Cards";
else if (name.size() >= 7 && Misc::StringUtils::ciEqual(name.substr(0, 7), "century"))
resourceName = "Century Gothic";
else if (name.size() >= 7 && Misc::StringUtils::ciEqual(name.substr(0, 7), "daedric"))
resourceName = "Daedric";
else
return; // no point in loading it, since there is no way of using additional fonts
std::string textureName = name;
Ogre::Image image;
image.loadDynamicImage(&textureData[0], width, height, Ogre::PF_BYTE_RGBA);
@ -208,18 +218,11 @@ namespace MWGui
// Register the font with MyGUI
MyGUI::ResourceManualFont* font = static_cast<MyGUI::ResourceManualFont*>(
MyGUI::FactoryManager::getInstance().createObject("Resource", "ResourceManualFont"));
// We need to emulate loading from XML because the data members are private as of mygui 3.2.0
MyGUI::xml::Document xmlDocument;
MyGUI::xml::ElementPtr root = xmlDocument.createRoot("ResourceManualFont");
if (name.size() >= 5 && Misc::StringUtils::ciEqual(name.substr(0, 5), "magic"))
root->addAttribute("name", "Magic Cards");
else if (name.size() >= 7 && Misc::StringUtils::ciEqual(name.substr(0, 7), "century"))
root->addAttribute("name", "Century Gothic");
else if (name.size() >= 7 && Misc::StringUtils::ciEqual(name.substr(0, 7), "daedric"))
root->addAttribute("name", "Daedric");
else
return; // no point in loading it, since there is no way of using additional fonts
root->addAttribute("name", resourceName);
MyGUI::xml::ElementPtr defaultHeight = root->createChild("Property");
defaultHeight->addAttribute("key", "DefaultHeight");
@ -285,6 +288,7 @@ namespace MWGui
font->deserialization(root, MyGUI::Version(3,2,0));
MyGUI::ResourceManager::getInstance().removeByName(font->getResourceName());
MyGUI::ResourceManager::getInstance().addResource(font);
}

@ -35,7 +35,7 @@ namespace MWGui
, mTrading(false)
, mLastXSize(0)
, mLastYSize(0)
, mPreview(MWBase::Environment::get().getWorld ()->getPlayerPtr())
, mPreview(new MWRender::InventoryPreview(MWBase::Environment::get().getWorld ()->getPlayerPtr()))
, mPreviewDirty(true)
, mDragAndDrop(dragAndDrop)
, mSelectedItem(-1)
@ -91,8 +91,8 @@ namespace MWGui
mTradeModel = new TradeItemModel(new InventoryItemModel(mPtr), MWWorld::Ptr());
mSortModel = new SortFilterItemModel(mTradeModel);
mItemView->setModel(mSortModel);
mPreview = MWRender::InventoryPreview(mPtr);
mPreview.setup();
mPreview.reset(new MWRender::InventoryPreview(mPtr));
mPreview->setup();
}
void InventoryWindow::setGuiMode(GuiMode mode)
@ -444,7 +444,7 @@ namespace MWGui
MWWorld::Ptr InventoryWindow::getAvatarSelectedItem(int x, int y)
{
int slot = mPreview.getSlotSelected (x, y);
int slot = mPreview->getSlotSelected (x, y);
if (slot == -1)
return MWWorld::Ptr();
@ -493,7 +493,7 @@ namespace MWGui
mPreviewDirty = false;
MyGUI::IntSize size = mAvatarImage->getSize();
mPreview.update (size.width, size.height);
mPreview->update (size.width, size.height);
mAvatarImage->setImageTexture("CharacterPreview");
mAvatarImage->setImageCoord(MyGUI::IntCoord(0, 0, std::min(512, size.width), std::min(1024, size.height)));

@ -34,7 +34,7 @@ namespace MWGui
MWWorld::Ptr getAvatarSelectedItem(int x, int y);
void rebuildAvatar() {
mPreview.rebuild();
mPreview->rebuild();
}
TradeItemModel* getTradeModel();
@ -81,7 +81,7 @@ namespace MWGui
int mLastXSize;
int mLastYSize;
MWRender::InventoryPreview mPreview;
std::auto_ptr<MWRender::InventoryPreview> mPreview;
bool mTrading;

@ -170,7 +170,8 @@ namespace MWGui
buttons.push_back("loadgame");
if (state==MWBase::StateManager::State_Running &&
MWBase::Environment::get().getWorld()->getGlobalInt ("chargenstate")==-1)
MWBase::Environment::get().getWorld()->getGlobalInt ("chargenstate")==-1 &&
MWBase::Environment::get().getWindowManager()->isSavingAllowed())
buttons.push_back("savegame");
buttons.push_back("options");

@ -2,6 +2,8 @@
#include <boost/lexical_cast.hpp>
#include <components/esm/quickkeys.hpp>
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/class.hpp"
@ -55,6 +57,14 @@ namespace MWGui
}
}
void QuickKeysMenu::clear()
{
for (int i=0; i<10; ++i)
{
unassign(mQuickKeyButtons[i], i);
}
}
QuickKeysMenu::~QuickKeysMenu()
{
delete mAssignDialog;
@ -154,8 +164,6 @@ namespace MWGui
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 += MWWorld::Class::get(item).getInventoryIcon(item);
@ -165,7 +173,8 @@ namespace MWGui
image->setImageTexture (path);
image->setNeedMouseFocus (false);
mItemSelectionDialog->setVisible(false);
if (mItemSelectionDialog)
mItemSelectionDialog->setVisible(false);
}
void QuickKeysMenu::onAssignItemCancel()
@ -198,7 +207,8 @@ namespace MWGui
image->setImageTexture (path);
image->setNeedMouseFocus (false);
mMagicSelectionDialog->setVisible(false);
if (mMagicSelectionDialog)
mMagicSelectionDialog->setVisible(false);
}
void QuickKeysMenu::onAssignMagic (const std::string& spellId)
@ -239,7 +249,8 @@ namespace MWGui
image->setImageTexture (path);
image->setNeedMouseFocus (false);
mMagicSelectionDialog->setVisible(false);
if (mMagicSelectionDialog)
mMagicSelectionDialog->setVisible(false);
}
void QuickKeysMenu::onAssignMagicCancel ()
@ -374,6 +385,110 @@ namespace MWGui
center();
}
void QuickKeysMenu::write(ESM::ESMWriter &writer)
{
writer.startRecord(ESM::REC_KEYS);
ESM::QuickKeys keys;
for (int i=0; i<10; ++i)
{
MyGUI::Button* button = mQuickKeyButtons[i];
int type = *button->getUserData<QuickKeyType>();
ESM::QuickKeys::QuickKey key;
key.mType = type;
switch (type)
{
case Type_Unassigned:
break;
case Type_Item:
case Type_MagicItem:
{
MWWorld::Ptr item = *button->getChildAt(0)->getUserData<MWWorld::Ptr>();
key.mId = item.getCellRef().mRefID;
break;
}
case Type_Magic:
std::string spellId = button->getChildAt(0)->getUserString("Spell");
key.mId = spellId;
break;
}
keys.mKeys.push_back(key);
}
keys.save(writer);
writer.endRecord(ESM::REC_KEYS);
}
void QuickKeysMenu::readRecord(ESM::ESMReader &reader, int32_t type)
{
if (type != ESM::REC_KEYS)
return;
ESM::QuickKeys keys;
keys.load(reader);
int i=0;
for (std::vector<ESM::QuickKeys::QuickKey>::const_iterator it = keys.mKeys.begin(); it != keys.mKeys.end(); ++it)
{
if (i >= 10)
return;
mSelectedIndex = i;
int keyType = it->mType;
std::string id = it->mId;
MyGUI::Button* button = mQuickKeyButtons[i];
switch (keyType)
{
case Type_Magic:
onAssignMagic(id);
break;
case Type_Item:
case Type_MagicItem:
{
// Find the item by id
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
MWWorld::Ptr item;
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
{
if (Misc::StringUtils::ciEqual(it->getCellRef().mRefID, id))
{
if (item.isEmpty() ||
// Prefer the stack with the lowest remaining uses
(it->getCellRef().mCharge != -1 && (item.getCellRef().mCharge == -1 || it->getCellRef().mCharge < item.getCellRef().mCharge) ))
{
item = *it;
}
}
}
if (item.isEmpty())
unassign(button, i);
else
{
if (keyType == Type_Item)
onAssignItem(item);
else if (keyType == Type_MagicItem)
onAssignMagicItem(item);
}
break;
}
case Type_Unassigned:
unassign(button, i);
break;
}
++i;
}
}
// ---------------------------------------------------------------------------------------------------------

@ -41,6 +41,11 @@ namespace MWGui
};
void write (ESM::ESMWriter& writer);
void readRecord (ESM::ESMReader& reader, int32_t type);
void clear();
private:
MyGUI::EditBox* mInstructionLabel;
MyGUI::Button* mOkButton;

@ -17,6 +17,8 @@ namespace MWGui
void checkReferenceAvailable(); ///< closes the window, if the MW-reference has become unavailable
void resetReference() { mPtr = MWWorld::Ptr(); mCurrentPlayerCell = NULL; }
protected:
virtual void onReferenceUnavailable() = 0; ///< called when reference has become unavailable

@ -53,7 +53,7 @@ namespace MWGui
{
onSlotSelected(sender, pos);
if (MyGUI::InputManager::getInstance().isShiftPressed())
if (pos != MyGUI::ITEM_NONE && MyGUI::InputManager::getInstance().isShiftPressed())
{
ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog();
dialog->open("#{sMessage3}");
@ -206,6 +206,13 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage65}");
return;
}
}
setVisible(false);
MWBase::Environment::get().getWindowManager()->removeGuiMode (MWGui::GM_MainMenu);
if (mSaving)
{
MWBase::Environment::get().getStateManager()->saveGame (mSaveNameEdit->getCaption(), mCurrentSlot);
}
else
@ -213,12 +220,9 @@ namespace MWGui
if (mCurrentCharacter && mCurrentSlot)
{
MWBase::Environment::get().getStateManager()->loadGame (mCurrentCharacter, mCurrentSlot);
MWBase::Environment::get().getWindowManager()->removeGuiMode (MWGui::GM_MainMenu);
}
}
setVisible(false);
if (MWBase::Environment::get().getStateManager()->getState()==
MWBase::StateManager::State_NoGame)
{

@ -475,7 +475,7 @@ namespace MWGui
text += std::string("#DDC79E") + faction->mName;
if (expelled.find(it->first) != expelled.end())
text += "\n#{sExpelled}";
text += "\n#BF9959#{sExpelled}";
else
{
text += std::string("\n#BF9959") + faction->mRanks[it->second];

@ -1405,16 +1405,49 @@ namespace MWGui
void WindowManager::clear()
{
mMap->clear();
mQuickKeysMenu->clear();
mTrainingWindow->resetReference();
mDialogueWindow->resetReference();
mTradeWindow->resetReference();
mSpellBuyingWindow->resetReference();
mSpellCreationDialog->resetReference();
mEnchantingDialog->resetReference();
mContainerWindow->resetReference();
mCompanionWindow->resetReference();
mConsole->resetReference();
mGuiModes.clear();
updateVisible();
}
void WindowManager::write(ESM::ESMWriter &writer, Loading::Listener& progress)
{
mMap->write(writer, progress);
mQuickKeysMenu->write(writer);
progress.increaseProgress();
}
void WindowManager::readRecord(ESM::ESMReader &reader, int32_t type)
{
mMap->readRecord(reader, type);
if (type == ESM::REC_GMAP)
mMap->readRecord(reader, type);
else if (type == ESM::REC_KEYS)
mQuickKeysMenu->readRecord(reader, type);
}
int WindowManager::countSavedGameRecords() const
{
return 1 // Global map
+ 1; // QuickKeysMenu
}
bool WindowManager::isSavingAllowed() const
{
return !MyGUI::InputManager::getInstance().isModalAny()
// TODO: remove this, once we have properly serialized the state of open windows
&& (!isGuiMode() || (mGuiModes.size() == 1 && getMode() == GM_MainMenu));
}
void WindowManager::playVideo(const std::string &name, bool allowSkipping)

@ -293,6 +293,10 @@ namespace MWGui
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress);
virtual void readRecord (ESM::ESMReader& reader, int32_t type);
virtual int countSavedGameRecords() const;
/// Does the current stack of GUI-windows permit saving?
virtual bool isSavingAllowed() const;
private:
bool mConsoleOnlyScripts;

@ -489,12 +489,13 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
mIdleState = CharState_Idle;
}
refreshCurrentAnims(mIdleState, mMovementState, true);
if(mDeathState != CharState_None)
{
playRandomDeath(1.0f);
}
else
refreshCurrentAnims(mIdleState, mMovementState, true);
}
CharacterController::~CharacterController()

@ -34,6 +34,10 @@ namespace MWRender
virtual void rebuild();
private:
CharacterPreview(const CharacterPreview&);
CharacterPreview& operator=(const CharacterPreview&);
protected:
virtual bool renderHeadOnly() { return false; }

@ -28,7 +28,9 @@ RippleSimulation::RippleSimulation(Ogre::SceneManager* mainSceneManager)
mRippleAreaLength(1000),
mImpulseSize(20),
mTexelOffset(0,0),
mFirstUpdate(true)
mFirstUpdate(true),
mRectangle(NULL),
mImpulse(NULL)
{
Ogre::AxisAlignedBox aabInf;
aabInf.setInfinite();
@ -105,6 +107,7 @@ RippleSimulation::RippleSimulation(Ogre::SceneManager* mainSceneManager)
RippleSimulation::~RippleSimulation()
{
delete mRectangle;
delete mImpulse;
Ogre::Root::getSingleton().destroySceneManager(mSceneMgr);
}

@ -201,7 +201,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
+MWBase::Environment::get().getWorld()->countSavedGameRecords()
+MWBase::Environment::get().getScriptManager()->getGlobalScripts().countSavedGameRecords()
+MWBase::Environment::get().getDialogueManager()->countSavedGameRecords()
+1; // global map
+MWBase::Environment::get().getWindowManager()->countSavedGameRecords();
writer.setRecordCount (recordCount);
writer.save (stream);
@ -235,8 +235,9 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
void MWState::StateManager::quickSave (std::string name)
{
if (mState!=State_Running ||
MWBase::Environment::get().getWorld()->getGlobalInt ("chargenstate")!=-1) // char gen
if (!(mState==State_Running &&
MWBase::Environment::get().getWorld()->getGlobalInt ("chargenstate")==-1 // char gen
&& MWBase::Environment::get().getWindowManager()->isSavingAllowed()))
{
//You can not save your game right now
MWBase::Environment::get().getWindowManager()->messageBox("#{sSaveGameDenied}");
@ -323,7 +324,7 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl
break;
case ESM::REC_GMAP:
case ESM::REC_KEYS:
MWBase::Environment::get().getWindowManager()->readRecord(reader, n.val);
break;

@ -231,6 +231,8 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr
{
CellStore *cell;
MWBase::Environment::get().getWorld()->getLocalScripts().add(script, item);
if(&(MWWorld::Class::get (player).getContainerStore (player)) == this)
{
cell = 0; // Items in player's inventory have cell set to 0, so their scripts will never be removed
@ -243,7 +245,6 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr
item.mCell = cell;
item.mContainerStore = 0;
MWBase::Environment::get().getWorld()->getLocalScripts().add(script, item);
}
return it;

@ -45,7 +45,7 @@ add_component_dir (esm
loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat
loadweap records aipackage effectlist spelllist variant variantimp loadtes3 cellref filter
savedgame journalentry queststate locals globalscript player objectstate cellid cellstate globalmap lightstate inventorystate containerstate npcstate creaturestate dialoguestate statstate
npcstats creaturestats weatherstate
npcstats creaturestats weatherstate quickkeys
)
add_component_dir (misc

@ -34,6 +34,12 @@ struct Position
};
#pragma pack(pop)
template <int a, int b, int c, int d>
struct FourCC
{
static const unsigned int value = (((((d << 8) | c) << 8) | b) << 8) | a;
};
enum RecNameInts
{
// format 0 / legacy
@ -93,6 +99,7 @@ enum RecNameInts
REC_GMAP = 0x50414d47,
REC_DIAS = 0x53414944,
REC_WTHR = 0x52485457,
REC_KEYS = FourCC<'K','E','Y','S'>::value,
// format 1
REC_FILT = 0x544C4946

@ -0,0 +1,43 @@
#include "quickkeys.hpp"
#include "esmwriter.hpp"
#include "esmreader.hpp"
namespace ESM
{
void QuickKeys::load(ESMReader &esm)
{
while (esm.isNextSub("KEY_"))
{
esm.getSubHeader();
int keyType;
esm.getHNT(keyType, "TYPE");
std::string id;
id = esm.getHNString("ID__");
QuickKey key;
key.mType = keyType;
key.mId = id;
mKeys.push_back(key);
}
}
void QuickKeys::save(ESMWriter &esm) const
{
const std::string recKey = "KEY_";
for (std::vector<QuickKey>::const_iterator it = mKeys.begin(); it != mKeys.end(); ++it)
{
esm.startSubRecord(recKey);
esm.writeHNT("TYPE", it->mType);
esm.writeHNString("ID__", it->mId);
esm.endRecord(recKey);
}
}
}

@ -0,0 +1,28 @@
#ifndef OPENMW_COMPONENTS_ESM_QUICKKEYS_H
#define OPENMW_COMPONENTS_ESM_QUICKKEYS_H
#include <vector>
#include <string>
namespace ESM
{
class ESMReader;
class ESMWriter;
struct QuickKeys
{
struct QuickKey
{
int mType;
std::string mId; // Spell or Item ID
};
std::vector<QuickKey> mKeys;
void load (ESMReader &esm);
void save (ESMWriter &esm) const;
};
}
#endif

@ -62,6 +62,7 @@ namespace OgreInit
OgreInit::~OgreInit()
{
delete mRoot;
delete Ogre::LogManager::getSingletonPtr();
std::vector<Ogre::ParticleEmitterFactory*>::iterator ei;
for(ei = mEmitterFactories.begin();ei != mEmitterFactories.end();++ei)

@ -337,6 +337,8 @@ namespace Terrain
it->mTarget->loadLayers(*it);
}
delete data;
mRootNode->loadMaterials();
mLayerLoadPending = false;

@ -49,22 +49,6 @@
<BasisSkin type="SimpleText" offset="0 0 16 16" align="Stretch"/>
</Skin>
<Skin name="DaedricText" size="16 16">
<Property key="FontName" value="daedric36"/>
<Property key="FontHeight" value="36"/>
<Property key="TextAlign" value="Default"/>
<Property key="TextColour" value="1 1 1"/>
<BasisSkin type="SimpleText" offset="0 0 16 16" align="Stretch"/>
</Skin>
<Skin name="DaedricText_orig" size="16 16">
<Property key="FontName" value="daedric_orig36"/>
<Property key="FontHeight" value="36"/>
<Property key="TextAlign" value="Default"/>
<Property key="TextColour" value="1 1 1"/>
<BasisSkin type="SimpleText" offset="0 0 16 16" align="Stretch"/>
</Skin>
<Skin name="MW_StatNameC" size="200 18">
<Child type="TextBoxC" skin="SandText" offset="0 0 200 18" align="Left HStretch" name="StatName"/>
</Skin>

Loading…
Cancel
Save