mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 16:15:31 +00:00
String setting to CSMPrefs, part of dehardcoding animation files
This commit is contained in:
parent
d3c865d909
commit
95272e0f14
5 changed files with 141 additions and 1 deletions
|
@ -116,7 +116,7 @@ opencs_units (view/prefs
|
||||||
|
|
||||||
opencs_units (model/prefs
|
opencs_units (model/prefs
|
||||||
state setting intsetting doublesetting boolsetting enumsetting coloursetting shortcut
|
state setting intsetting doublesetting boolsetting enumsetting coloursetting shortcut
|
||||||
shortcuteventhandler shortcutmanager shortcutsetting modifiersetting
|
shortcuteventhandler shortcutmanager shortcutsetting modifiersetting stringsetting
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (model/prefs
|
opencs_units_noqt (model/prefs
|
||||||
|
|
|
@ -421,6 +421,35 @@ void CSMPrefs::State::declare()
|
||||||
declareSubcategory ("Script Editor");
|
declareSubcategory ("Script Editor");
|
||||||
declareShortcut ("script-editor-comment", "Comment Selection", QKeySequence());
|
declareShortcut ("script-editor-comment", "Comment Selection", QKeySequence());
|
||||||
declareShortcut ("script-editor-uncomment", "Uncomment Selection", QKeySequence());
|
declareShortcut ("script-editor-uncomment", "Uncomment Selection", QKeySequence());
|
||||||
|
|
||||||
|
declareCategory ("Models");
|
||||||
|
declareString ("baseanim", "3rd person base model with textkeys-data", "meshes/openmwdude.dae").
|
||||||
|
setTooltip("3rd person base model with textkeys-data");
|
||||||
|
|
||||||
|
/*# 3rd person base model with textkeys-data
|
||||||
|
baseanim = meshes/base_anim.nif
|
||||||
|
|
||||||
|
# 1st person base animation model that looks also for corresponding kf-file
|
||||||
|
xbaseanim1st = meshes/xbase_anim.1st.nif
|
||||||
|
|
||||||
|
# 3rd person beast race base model with textkeys-data
|
||||||
|
baseanimkna = meshes/base_animkna.nif
|
||||||
|
|
||||||
|
# 1st person beast race base animation model
|
||||||
|
baseanimkna1st = meshes/base_animkna.1st.nif
|
||||||
|
|
||||||
|
# 3rd person female base model with textkeys-data
|
||||||
|
baseanimfemale = meshes/base_anim_female.nif
|
||||||
|
|
||||||
|
# 1st person female base model with textkeys-data
|
||||||
|
baseanimfemale1st = meshes/base_anim_female.1st.nif
|
||||||
|
|
||||||
|
# 3rd person werewolf skin
|
||||||
|
wolfskin = meshes/wolf/skin.nif
|
||||||
|
|
||||||
|
# 1st person werewolf skin
|
||||||
|
wolfskin1st = meshes/wolf/skin.1st.nif*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::State::declareCategory (const std::string& key)
|
void CSMPrefs::State::declareCategory (const std::string& key)
|
||||||
|
@ -557,6 +586,24 @@ CSMPrefs::ShortcutSetting& CSMPrefs::State::declareShortcut (const std::string&
|
||||||
return *setting;
|
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,
|
CSMPrefs::ModifierSetting& CSMPrefs::State::declareModifier(const std::string& key, const std::string& label,
|
||||||
int default_)
|
int default_)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "category.hpp"
|
#include "category.hpp"
|
||||||
#include "setting.hpp"
|
#include "setting.hpp"
|
||||||
#include "enumsetting.hpp"
|
#include "enumsetting.hpp"
|
||||||
|
#include "stringsetting.hpp"
|
||||||
#include "shortcutmanager.hpp"
|
#include "shortcutmanager.hpp"
|
||||||
|
|
||||||
class QColor;
|
class QColor;
|
||||||
|
@ -78,6 +79,8 @@ namespace CSMPrefs
|
||||||
ShortcutSetting& declareShortcut (const std::string& key, const std::string& label,
|
ShortcutSetting& declareShortcut (const std::string& key, const std::string& label,
|
||||||
const QKeySequence& default_);
|
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_);
|
ModifierSetting& declareModifier(const std::string& key, const std::string& label, int modifier_);
|
||||||
|
|
||||||
void declareSeparator();
|
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 <QTextEdit>
|
||||||
|
#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 QTextEdit (QString::fromUtf8 (mDefault.c_str()), parent);
|
||||||
|
|
||||||
|
if (!mTooltip.empty())
|
||||||
|
{
|
||||||
|
QString tooltip = QString::fromUtf8 (mTooltip.c_str());
|
||||||
|
mWidget->setToolTip (tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
connect (mWidget, SIGNAL (textChanged (std::string)), this, SLOT (textChanged (std::string)));
|
||||||
|
|
||||||
|
return std::make_pair (static_cast<QWidget *> (nullptr), mWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMPrefs::StringSetting::updateWidget()
|
||||||
|
{
|
||||||
|
if (mWidget)
|
||||||
|
{
|
||||||
|
//mWidget->setValue(getValues().getString(getKey(), getParent()->getKey()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMPrefs::StringSetting::textChanged (std::string text)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
QMutexLocker lock (getMutex());
|
||||||
|
getValues().setString (getKey(), getParent()->getKey(), text);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 QTextEdit;
|
||||||
|
|
||||||
|
namespace CSMPrefs
|
||||||
|
{
|
||||||
|
class StringSetting : public Setting
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
std::string mTooltip;
|
||||||
|
std::string mDefault;
|
||||||
|
QTextEdit* 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 (std::string text);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue