mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-02 03:45:34 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
dc54bd5a5f
12 changed files with 211 additions and 46 deletions
|
@ -95,6 +95,7 @@ opencs_units (view/settings
|
||||||
booleanview
|
booleanview
|
||||||
textview
|
textview
|
||||||
listview
|
listview
|
||||||
|
rangeview
|
||||||
resizeablestackedwidget
|
resizeablestackedwidget
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -12,15 +12,14 @@ CSMSettings::Setting::Setting(SettingType typ, const QString &settingName,
|
||||||
{
|
{
|
||||||
buildDefaultSetting();
|
buildDefaultSetting();
|
||||||
|
|
||||||
int vType = static_cast <int> (typ);
|
int settingType = static_cast <int> (typ);
|
||||||
|
|
||||||
if ((vType % 2) == 0)
|
//even-numbered setting types are multi-valued
|
||||||
setProperty (Property_IsMultiValue,
|
if ((settingType % 2) == 0)
|
||||||
QVariant(true).toString());
|
setProperty (Property_IsMultiValue, QVariant(true).toString());
|
||||||
else
|
|
||||||
vType--;
|
|
||||||
|
|
||||||
setProperty (Property_ViewType, QVariant (vType / 2).toString());
|
//view type is related to setting type by an order of magnitude
|
||||||
|
setProperty (Property_ViewType, QVariant (settingType / 10).toString());
|
||||||
setProperty (Property_Page, pageName);
|
setProperty (Property_Page, pageName);
|
||||||
setProperty (Property_Name, settingName);
|
setProperty (Property_Name, settingName);
|
||||||
setProperty (Property_DeclaredValues, values);
|
setProperty (Property_DeclaredValues, values);
|
||||||
|
@ -267,9 +266,9 @@ void CSMSettings::Setting::setProperty (SettingProperty prop,
|
||||||
|
|
||||||
QDataStream &operator <<(QDataStream &stream, const CSMSettings::Setting& setting)
|
QDataStream &operator <<(QDataStream &stream, const CSMSettings::Setting& setting)
|
||||||
{
|
{
|
||||||
stream << setting.properties();
|
// stream << setting.properties();
|
||||||
|
|
||||||
stream << setting.proxies();
|
// stream << setting.proxies();
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,14 +47,27 @@ namespace CSMSettings
|
||||||
|
|
||||||
enum SettingType
|
enum SettingType
|
||||||
{
|
{
|
||||||
Type_MultiBool = 0,
|
/*
|
||||||
Type_SingleBool = 1,
|
* 0 - 9 - Boolean widgets
|
||||||
Type_MultiList = 2,
|
* 10-19 - List widgets
|
||||||
Type_SingleList = 3,
|
* 21-29 - Range widgets
|
||||||
Type_MultiRange = 4,
|
* 31-39 - Text widgets
|
||||||
Type_SingleRange = 5,
|
*
|
||||||
Type_MultiText = 6,
|
* Each range corresponds to a View_Type enum by a factor of 10.
|
||||||
Type_SingleText = 7
|
*
|
||||||
|
* Even-numbered values are single-value widgets
|
||||||
|
* Odd-numbered values are multi-valued widgets
|
||||||
|
*/
|
||||||
|
|
||||||
|
Type_CheckBox = 0,
|
||||||
|
Type_RadioButton = 1,
|
||||||
|
Type_ListView = 10,
|
||||||
|
Type_ComboBox = 11,
|
||||||
|
Type_SpinBox = 21,
|
||||||
|
Type_Slider = 23,
|
||||||
|
Type_Dial = 24,
|
||||||
|
Type_TextArea = 30,
|
||||||
|
Type_LineEdit = 31
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MergeMethod
|
enum MergeMethod
|
||||||
|
|
|
@ -47,8 +47,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
{
|
{
|
||||||
QString section = "Window Size";
|
QString section = "Window Size";
|
||||||
{
|
{
|
||||||
Setting *width = createSetting (Type_SingleText, section, "Width");
|
Setting *width = createSetting (Type_LineEdit, section, "Width");
|
||||||
Setting *height = createSetting (Type_SingleText, section, "Height");
|
Setting *height = createSetting (Type_LineEdit, section, "Height");
|
||||||
|
|
||||||
width->setWidgetWidth (5);
|
width->setWidgetWidth (5);
|
||||||
height->setWidgetWidth (5);
|
height->setWidgetWidth (5);
|
||||||
|
@ -65,7 +65,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
/*
|
/*
|
||||||
*Create the proxy setting for predefined values
|
*Create the proxy setting for predefined values
|
||||||
*/
|
*/
|
||||||
Setting *preDefined = createSetting (Type_SingleList, section,
|
Setting *preDefined = createSetting (Type_ComboBox, section,
|
||||||
"Pre-Defined",
|
"Pre-Defined",
|
||||||
QStringList()
|
QStringList()
|
||||||
<< "640 x 480"
|
<< "640 x 480"
|
||||||
|
@ -94,11 +94,11 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
QStringList values = QStringList()
|
QStringList values = QStringList()
|
||||||
<< defaultValue << "Icon Only" << "Text Only";
|
<< defaultValue << "Icon Only" << "Text Only";
|
||||||
|
|
||||||
Setting *rsd = createSetting (Type_SingleBool,
|
Setting *rsd = createSetting (Type_RadioButton,
|
||||||
section, "Record Status Display",
|
section, "Record Status Display",
|
||||||
values);
|
values);
|
||||||
|
|
||||||
Setting *ritd = createSetting (Type_SingleBool,
|
Setting *ritd = createSetting (Type_RadioButton,
|
||||||
section, "Referenceable ID Type Display",
|
section, "Referenceable ID Type Display",
|
||||||
values);
|
values);
|
||||||
|
|
||||||
|
@ -110,24 +110,24 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
{
|
{
|
||||||
//create three setting objects, specifying the basic widget type,
|
//create three setting objects, specifying the basic widget type,
|
||||||
//the setting view name, the page name, and the default value
|
//the setting view name, the page name, and the default value
|
||||||
Setting *masterBoolean = createSetting (Type_SingleBool, section,
|
Setting *masterBoolean = createSetting (Type_RadioButton, section,
|
||||||
"Master Proxy",
|
"Master Proxy",
|
||||||
QStringList()
|
QStringList()
|
||||||
<< "Profile One" << "Profile Two"
|
<< "Profile One" << "Profile Two"
|
||||||
<< "Profile Three" << "Profile Four"
|
<< "Profile Three" << "Profile Four"
|
||||||
);
|
);
|
||||||
|
|
||||||
Setting *slaveBoolean = createSetting (Type_MultiBool, section,
|
Setting *slaveBoolean = createSetting (Type_CheckBox, section,
|
||||||
"Proxy Checkboxes",
|
"Proxy Checkboxes",
|
||||||
QStringList() << "One" << "Two"
|
QStringList() << "One" << "Two"
|
||||||
<< "Three" << "Four" << "Five"
|
<< "Three" << "Four" << "Five"
|
||||||
);
|
);
|
||||||
|
|
||||||
Setting *slaveSingleText = createSetting (Type_SingleText, section,
|
Setting *slaveSingleText = createSetting (Type_LineEdit, section,
|
||||||
"Proxy TextBox 1"
|
"Proxy TextBox 1"
|
||||||
);
|
);
|
||||||
|
|
||||||
Setting *slaveMultiText = createSetting (Type_SingleText, section,
|
Setting *slaveMultiText = createSetting (Type_LineEdit, section,
|
||||||
"ProxyTextBox 2"
|
"ProxyTextBox 2"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef CSVSETTINGS_BOOLEANVIEW_HPP
|
#ifndef CSVSETTINGS_BOOLEANVIEW_HPP
|
||||||
#define CSVSETTINGS_BOOELANVIEW_HPP
|
#define CSVSETTINGS_BOOLEANVIEW_HPP
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QAbstractButton>
|
#include <QAbstractButton>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "booleanview.hpp"
|
#include "booleanview.hpp"
|
||||||
#include "textview.hpp"
|
#include "textview.hpp"
|
||||||
#include "listview.hpp"
|
#include "listview.hpp"
|
||||||
|
#include "rangeview.hpp"
|
||||||
|
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/settings/usersettings.hpp"
|
||||||
#include "../../model/settings/connector.hpp"
|
#include "../../model/settings/connector.hpp"
|
||||||
|
@ -85,4 +86,5 @@ void CSVSettings::Page::buildFactories()
|
||||||
mViewFactories[ViewType_Boolean] = new BooleanViewFactory (this);
|
mViewFactories[ViewType_Boolean] = new BooleanViewFactory (this);
|
||||||
mViewFactories[ViewType_Text] = new TextViewFactory (this);
|
mViewFactories[ViewType_Text] = new TextViewFactory (this);
|
||||||
mViewFactories[ViewType_List] = new ListViewFactory (this);
|
mViewFactories[ViewType_List] = new ListViewFactory (this);
|
||||||
|
mViewFactories[ViewType_Range] = new RangeViewFactory (this);
|
||||||
}
|
}
|
||||||
|
|
94
apps/opencs/view/settings/rangeview.cpp
Normal file
94
apps/opencs/view/settings/rangeview.cpp
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QRadioButton>
|
||||||
|
#include <QGroupBox>
|
||||||
|
|
||||||
|
#include <QAbstractButton>
|
||||||
|
|
||||||
|
#include "rangeview.hpp"
|
||||||
|
#include "../../model/settings/setting.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
CSVSettings::RangeView::RangeView (CSMSettings::Setting *setting,
|
||||||
|
Page *parent)
|
||||||
|
: View (setting, parent)
|
||||||
|
{
|
||||||
|
foreach (const QString &value, setting->declaredValues())
|
||||||
|
{
|
||||||
|
QAbstractButton *button = 0;
|
||||||
|
|
||||||
|
if (isMultiValue())
|
||||||
|
button = new QCheckBox (value, this);
|
||||||
|
else
|
||||||
|
button = new QRadioButton (value, this);
|
||||||
|
|
||||||
|
connect (button, SIGNAL (clicked (bool)),
|
||||||
|
this, SLOT (slotToggled (bool)));
|
||||||
|
|
||||||
|
button->setObjectName (value);
|
||||||
|
|
||||||
|
addWidget (button);
|
||||||
|
|
||||||
|
mButtons[value] = button;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVSettings::RangeView::slotToggled (bool state)
|
||||||
|
{
|
||||||
|
//test only for true to avoid multiple selection updates with radiobuttons
|
||||||
|
if (!isMultiValue() && !state)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QStringList values;
|
||||||
|
|
||||||
|
foreach (QString key, mButtons.keys())
|
||||||
|
{
|
||||||
|
if (mButtons.value(key)->isChecked())
|
||||||
|
values.append (key);
|
||||||
|
}
|
||||||
|
setSelectedValues (values, false);
|
||||||
|
|
||||||
|
View::updateView();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVSettings::RangeView::updateView (bool signalUpdate) const
|
||||||
|
{
|
||||||
|
|
||||||
|
QStringList values = selectedValues();
|
||||||
|
|
||||||
|
foreach (const QString &buttonName, mButtons.keys())
|
||||||
|
{
|
||||||
|
QAbstractButton *button = mButtons[buttonName];
|
||||||
|
|
||||||
|
//if the value is not found in the list, the widget is checked false
|
||||||
|
bool buttonValue = values.contains(buttonName);
|
||||||
|
|
||||||
|
//skip if the butotn value will not change
|
||||||
|
if (button->isChecked() == buttonValue)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//disable autoexclusive if it's enabled and we're setting
|
||||||
|
//the button value to false
|
||||||
|
bool switchExclusive = (!buttonValue && button->autoExclusive());
|
||||||
|
|
||||||
|
if (switchExclusive)
|
||||||
|
button->setAutoExclusive (false);
|
||||||
|
|
||||||
|
button->setChecked (buttonValue);
|
||||||
|
|
||||||
|
if (switchExclusive)
|
||||||
|
button->setAutoExclusive(true);
|
||||||
|
}
|
||||||
|
View::updateView (signalUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVSettings::RangeView *CSVSettings::RangeViewFactory::createView
|
||||||
|
(CSMSettings::Setting *setting,
|
||||||
|
Page *parent)
|
||||||
|
{
|
||||||
|
return new RangeView (setting, parent);
|
||||||
|
}
|
44
apps/opencs/view/settings/rangeview.hpp
Normal file
44
apps/opencs/view/settings/rangeview.hpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#ifndef CSVSETTINGS_RANGEVIEW_HPP
|
||||||
|
#define CSVSETTINGS_RANGEVIEW_HPP
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QAbstractButton>
|
||||||
|
|
||||||
|
#include "view.hpp"
|
||||||
|
#include "../../model/settings/support.hpp"
|
||||||
|
|
||||||
|
class QStringListModel;
|
||||||
|
|
||||||
|
namespace CSVSettings
|
||||||
|
{
|
||||||
|
class RangeView : public View
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
QMap <QString, QAbstractButton *> mButtons;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit RangeView (CSMSettings::Setting *setting,
|
||||||
|
Page *parent);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void updateView (bool signalUpdate = true) const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotToggled (bool state);
|
||||||
|
};
|
||||||
|
|
||||||
|
class RangeViewFactory : public QObject, public IViewFactory
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit RangeViewFactory (QWidget *parent = 0)
|
||||||
|
: QObject (parent)
|
||||||
|
{}
|
||||||
|
|
||||||
|
RangeView *createView (CSMSettings::Setting *setting,
|
||||||
|
Page *parent);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // CSVSETTINGS_RANGEVIEW_HPP
|
|
@ -1,6 +1,7 @@
|
||||||
#include "aiwander.hpp"
|
#include "aiwander.hpp"
|
||||||
|
|
||||||
#include <OgreVector3.h>
|
#include <OgreVector3.h>
|
||||||
|
#include <OgreSceneNode.h>
|
||||||
|
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
@ -211,7 +212,7 @@ namespace MWMechanics
|
||||||
// Reduce the turning animation glitch by using a *HUGE* value of
|
// Reduce the turning animation glitch by using a *HUGE* value of
|
||||||
// epsilon... TODO: a proper fix might be in either the physics or the
|
// epsilon... TODO: a proper fix might be in either the physics or the
|
||||||
// animation subsystem
|
// animation subsystem
|
||||||
if (zTurn(actor, Ogre::Degree(mTargetAngle), Ogre::Degree(12)))
|
if (zTurn(actor, Ogre::Degree(mTargetAngle), Ogre::Degree(5)))
|
||||||
mRotate = false;
|
mRotate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,18 +334,7 @@ namespace MWMechanics
|
||||||
if(mChooseAction)
|
if(mChooseAction)
|
||||||
{
|
{
|
||||||
mPlayedIdle = 0;
|
mPlayedIdle = 0;
|
||||||
unsigned short idleRoll = 0;
|
getRandomIdle(); // NOTE: sets mPlayedIdle with a random selection
|
||||||
|
|
||||||
for(unsigned int counter = 0; counter < mIdle.size(); counter++)
|
|
||||||
{
|
|
||||||
unsigned short idleChance = mIdleChanceMultiplier * mIdle[counter];
|
|
||||||
unsigned short randSelect = (int)(rand() / ((double)RAND_MAX + 1) * int(100 / mIdleChanceMultiplier));
|
|
||||||
if(randSelect < idleChance && randSelect > idleRoll)
|
|
||||||
{
|
|
||||||
mPlayedIdle = counter+2;
|
|
||||||
idleRoll = randSelect;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!mPlayedIdle && mDistance)
|
if(!mPlayedIdle && mDistance)
|
||||||
{
|
{
|
||||||
|
@ -395,6 +385,8 @@ namespace MWMechanics
|
||||||
mMoveNow = false;
|
mMoveNow = false;
|
||||||
mWalking = false;
|
mWalking = false;
|
||||||
mObstacleCheck.clear();
|
mObstacleCheck.clear();
|
||||||
|
mIdleNow = true;
|
||||||
|
getRandomIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mRotate)
|
if(!mRotate)
|
||||||
|
@ -402,11 +394,11 @@ namespace MWMechanics
|
||||||
Ogre::Vector3 dir = playerPos - actorPos;
|
Ogre::Vector3 dir = playerPos - actorPos;
|
||||||
float length = dir.length();
|
float length = dir.length();
|
||||||
|
|
||||||
// FIXME: horrible hack
|
|
||||||
float faceAngle = Ogre::Radian(Ogre::Math::ACos(dir.y / length) *
|
float faceAngle = Ogre::Radian(Ogre::Math::ACos(dir.y / length) *
|
||||||
((Ogre::Math::ASin(dir.x / length).valueRadians()>0)?1.0:-1.0)).valueDegrees();
|
((Ogre::Math::ASin(dir.x / length).valueRadians()>0)?1.0:-1.0)).valueDegrees();
|
||||||
|
float actorAngle = actor.getRefData().getBaseNode()->getOrientation().getRoll().valueDegrees();
|
||||||
// an attempt at reducing the turning animation glitch
|
// an attempt at reducing the turning animation glitch
|
||||||
if(abs(faceAngle) > 10)
|
if(abs(abs(faceAngle) - abs(actorAngle)) >= 5) // TODO: is there a better way?
|
||||||
{
|
{
|
||||||
mTargetAngle = faceAngle;
|
mTargetAngle = faceAngle;
|
||||||
mRotate = true;
|
mRotate = true;
|
||||||
|
@ -432,7 +424,8 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if idle animation finished
|
// Check if idle animation finished
|
||||||
if(!checkIdle(actor, mPlayedIdle))
|
// FIXME: don't stay forever
|
||||||
|
if(!checkIdle(actor, mPlayedIdle) && playerDistSqr > helloDistance*helloDistance)
|
||||||
{
|
{
|
||||||
mPlayedIdle = 0;
|
mPlayedIdle = 0;
|
||||||
mIdleNow = false;
|
mIdleNow = false;
|
||||||
|
@ -586,5 +579,21 @@ namespace MWMechanics
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AiWander::getRandomIdle()
|
||||||
|
{
|
||||||
|
unsigned short idleRoll = 0;
|
||||||
|
|
||||||
|
for(unsigned int counter = 0; counter < mIdle.size(); counter++)
|
||||||
|
{
|
||||||
|
unsigned short idleChance = mIdleChanceMultiplier * mIdle[counter];
|
||||||
|
unsigned short randSelect = (int)(rand() / ((double)RAND_MAX + 1) * int(100 / mIdleChanceMultiplier));
|
||||||
|
if(randSelect < idleChance && randSelect > idleRoll)
|
||||||
|
{
|
||||||
|
mPlayedIdle = counter+2;
|
||||||
|
idleRoll = randSelect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace MWMechanics
|
||||||
void stopWalking(const MWWorld::Ptr& actor);
|
void stopWalking(const MWWorld::Ptr& actor);
|
||||||
void playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect);
|
void playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect);
|
||||||
bool checkIdle(const MWWorld::Ptr& actor, unsigned short idleSelect);
|
bool checkIdle(const MWWorld::Ptr& actor, unsigned short idleSelect);
|
||||||
|
void getRandomIdle();
|
||||||
|
|
||||||
int mDistance; // how far the actor can wander from the spawn point
|
int mDistance; // how far the actor can wander from the spawn point
|
||||||
int mDuration;
|
int mDuration;
|
||||||
|
|
|
@ -856,7 +856,8 @@ namespace MWMechanics
|
||||||
// Find an actor who witnessed the crime
|
// Find an actor who witnessed the crime
|
||||||
for (std::vector<MWWorld::Ptr>::iterator it = neighbors.begin(); it != neighbors.end(); ++it)
|
for (std::vector<MWWorld::Ptr>::iterator it = neighbors.begin(); it != neighbors.end(); ++it)
|
||||||
{
|
{
|
||||||
if (*it == ptr) continue; // not the player
|
if ( *it == ptr
|
||||||
|
|| !it->getClass().isNpc()) continue; // not the player and is an NPC
|
||||||
|
|
||||||
// Was the crime seen?
|
// Was the crime seen?
|
||||||
if ( ( MWBase::Environment::get().getWorld()->getLOS(ptr, *it) && awarenessCheck(ptr, *it) ) ||
|
if ( ( MWBase::Environment::get().getWorld()->getLOS(ptr, *it) && awarenessCheck(ptr, *it) ) ||
|
||||||
|
@ -872,7 +873,8 @@ namespace MWMechanics
|
||||||
// Tell everyone, including yourself
|
// Tell everyone, including yourself
|
||||||
for (std::vector<MWWorld::Ptr>::iterator it1 = neighbors.begin(); it1 != neighbors.end(); ++it1)
|
for (std::vector<MWWorld::Ptr>::iterator it1 = neighbors.begin(); it1 != neighbors.end(); ++it1)
|
||||||
{
|
{
|
||||||
if (*it1 == ptr) continue; // not the player
|
if ( *it == ptr
|
||||||
|
|| !it->getClass().isNpc()) continue; // not the player and is an NPC
|
||||||
|
|
||||||
// TODO: Add more messages
|
// TODO: Add more messages
|
||||||
if (type == OT_Theft)
|
if (type == OT_Theft)
|
||||||
|
|
Loading…
Reference in a new issue