mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
Merge branch 'settingstocs_csmprefs' into 'master'
Dehardcode animations in OpenMW-CS (CSMPrefs method) See merge request OpenMW/openmw!742
This commit is contained in:
commit
50db75bd13
@ -116,7 +116,7 @@ opencs_units (view/prefs
|
||||
|
||||
opencs_units (model/prefs
|
||||
state setting intsetting doublesetting boolsetting enumsetting coloursetting shortcut
|
||||
shortcuteventhandler shortcutmanager shortcutsetting modifiersetting
|
||||
shortcuteventhandler shortcutmanager shortcutsetting modifiersetting stringsetting
|
||||
)
|
||||
|
||||
opencs_units_noqt (model/prefs
|
||||
|
@ -421,6 +421,16 @@ void CSMPrefs::State::declare()
|
||||
declareSubcategory ("Script Editor");
|
||||
declareShortcut ("script-editor-comment", "Comment Selection", QKeySequence());
|
||||
declareShortcut ("script-editor-uncomment", "Uncomment Selection", QKeySequence());
|
||||
|
||||
declareCategory ("Models");
|
||||
declareString ("baseanim", "base animations", "meshes/base_anim.nif").
|
||||
setTooltip("3rd person base model with textkeys-data");
|
||||
declareString ("baseanimkna", "base animations, kna", "meshes/base_animkna.nif").
|
||||
setTooltip("3rd person beast race base model with textkeys-data");
|
||||
declareString ("baseanimfemale", "base animations, female", "meshes/base_anim_female.nif").
|
||||
setTooltip("3rd person female base model with textkeys-data");
|
||||
declareString ("wolfskin", "base animations, wolf", "meshes/wolf/skin.nif").
|
||||
setTooltip("3rd person werewolf skin");
|
||||
}
|
||||
|
||||
void CSMPrefs::State::declareCategory (const std::string& key)
|
||||
@ -557,6 +567,24 @@ CSMPrefs::ShortcutSetting& CSMPrefs::State::declareShortcut (const std::string&
|
||||
return *setting;
|
||||
}
|
||||
|
||||
CSMPrefs::StringSetting& CSMPrefs::State::declareString (const std::string& key, const std::string& label, std::string default_)
|
||||
{
|
||||
if (mCurrentCategory==mCategories.end())
|
||||
throw std::logic_error ("no category for setting");
|
||||
|
||||
setDefault (key, default_);
|
||||
|
||||
default_ = mSettings.getString (key, mCurrentCategory->second.getKey());
|
||||
|
||||
CSMPrefs::StringSetting *setting =
|
||||
new CSMPrefs::StringSetting (&mCurrentCategory->second, &mSettings, &mMutex, key, label,
|
||||
default_);
|
||||
|
||||
mCurrentCategory->second.addSetting (setting);
|
||||
|
||||
return *setting;
|
||||
}
|
||||
|
||||
CSMPrefs::ModifierSetting& CSMPrefs::State::declareModifier(const std::string& key, const std::string& label,
|
||||
int default_)
|
||||
{
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "category.hpp"
|
||||
#include "setting.hpp"
|
||||
#include "enumsetting.hpp"
|
||||
#include "stringsetting.hpp"
|
||||
#include "shortcutmanager.hpp"
|
||||
|
||||
class QColor;
|
||||
@ -78,6 +79,8 @@ namespace CSMPrefs
|
||||
ShortcutSetting& declareShortcut (const std::string& key, const std::string& label,
|
||||
const QKeySequence& default_);
|
||||
|
||||
StringSetting& declareString (const std::string& key, const std::string& label, std::string default_);
|
||||
|
||||
ModifierSetting& declareModifier(const std::string& key, const std::string& label, int modifier_);
|
||||
|
||||
void declareSeparator();
|
||||
|
54
apps/opencs/model/prefs/stringsetting.cpp
Normal file
54
apps/opencs/model/prefs/stringsetting.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
#include "stringsetting.hpp"
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QMutexLocker>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include "category.hpp"
|
||||
#include "state.hpp"
|
||||
|
||||
CSMPrefs::StringSetting::StringSetting (Category *parent, Settings::Manager *values,
|
||||
QMutex *mutex, const std::string& key, const std::string& label, std::string default_)
|
||||
: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(nullptr)
|
||||
{}
|
||||
|
||||
CSMPrefs::StringSetting& CSMPrefs::StringSetting::setTooltip (const std::string& tooltip)
|
||||
{
|
||||
mTooltip = tooltip;
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::pair<QWidget *, QWidget *> CSMPrefs::StringSetting::makeWidgets (QWidget *parent)
|
||||
{
|
||||
mWidget = new QLineEdit (QString::fromUtf8 (mDefault.c_str()), parent);
|
||||
|
||||
if (!mTooltip.empty())
|
||||
{
|
||||
QString tooltip = QString::fromUtf8 (mTooltip.c_str());
|
||||
mWidget->setToolTip (tooltip);
|
||||
}
|
||||
|
||||
connect (mWidget, SIGNAL (textChanged (QString)), this, SLOT (textChanged (QString)));
|
||||
|
||||
return std::make_pair (static_cast<QWidget *> (nullptr), mWidget);
|
||||
}
|
||||
|
||||
void CSMPrefs::StringSetting::updateWidget()
|
||||
{
|
||||
if (mWidget)
|
||||
{
|
||||
mWidget->setText(QString::fromStdString(getValues().getString(getKey(), getParent()->getKey())));
|
||||
}
|
||||
}
|
||||
|
||||
void CSMPrefs::StringSetting::textChanged (const QString& text)
|
||||
{
|
||||
{
|
||||
QMutexLocker lock (getMutex());
|
||||
getValues().setString (getKey(), getParent()->getKey(), text.toStdString());
|
||||
}
|
||||
|
||||
getParent()->getState()->update (*this);
|
||||
}
|
36
apps/opencs/model/prefs/stringsetting.hpp
Normal file
36
apps/opencs/model/prefs/stringsetting.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef CSM_PREFS_StringSetting_H
|
||||
#define CSM_PREFS_StringSetting_H
|
||||
|
||||
#include "setting.hpp"
|
||||
|
||||
class QLineEdit;
|
||||
|
||||
namespace CSMPrefs
|
||||
{
|
||||
class StringSetting : public Setting
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
std::string mTooltip;
|
||||
std::string mDefault;
|
||||
QLineEdit* mWidget;
|
||||
|
||||
public:
|
||||
|
||||
StringSetting (Category *parent, Settings::Manager *values,
|
||||
QMutex *mutex, const std::string& key, const std::string& label, std::string default_);
|
||||
|
||||
StringSetting& setTooltip (const std::string& tooltip);
|
||||
|
||||
/// Return label, input widget.
|
||||
std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent) override;
|
||||
|
||||
void updateWidget() override;
|
||||
|
||||
private slots:
|
||||
|
||||
void textChanged (const QString& text);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user