mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-27 19:10:52 +00:00
Merge with develop
This commit is contained in:
parent
7ef20878fa
commit
752f45f25b
5 changed files with 92 additions and 4 deletions
|
@ -1415,6 +1415,14 @@
|
|||
posparent="show_clock_12h"
|
||||
x="0"
|
||||
y="-12" />
|
||||
<instance template="tgcw_checkbox"
|
||||
id="radar_use_camera"
|
||||
text="uiRadarUseCamera"
|
||||
tooltip="uittRadarUseCamera"
|
||||
posref="BL TL"
|
||||
posparent="show_reticle"
|
||||
x="0"
|
||||
y="-12" />
|
||||
</group>
|
||||
<ctrl style="skin_scroll"
|
||||
id="sb_hud"
|
||||
|
@ -3273,6 +3281,11 @@
|
|||
widget="boolbut"
|
||||
link="UI:SAVE:SHOW_RETICLE"
|
||||
realtime="true" />
|
||||
<param ui="hud:radar_use_camera:c"
|
||||
type="db"
|
||||
widget="boolbut"
|
||||
link="UI:SAVE:RADAR:USE_CAMERA"
|
||||
realtime="true" />
|
||||
<param ui="alpha_colors:col_day:c"
|
||||
type="db"
|
||||
widget="colbut"
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "game_share/inventories.h"
|
||||
#include "game_share/animal_type.h"
|
||||
|
||||
extern NL3D::UCamera MainCam;
|
||||
extern CEntityManager EntitiesMngr;
|
||||
extern CContinentManager ContinentMngr;
|
||||
CCompassDialogsManager * CCompassDialogsManager::_Instance = NULL;
|
||||
|
@ -129,11 +130,24 @@ CGroupCompas::CGroupCompas(const TCtorParam ¶m)
|
|||
_LastDynamicTargetPos = 0xFFFFFFFF;
|
||||
_SavedTargetValid = false;
|
||||
_TargetSetOnce = false;
|
||||
|
||||
CCDBNodeLeaf *pRC = CDBManager::getInstance()->getDbProp("UI:SAVE:RADAR:USE_CAMERA");
|
||||
if (pRC)
|
||||
{
|
||||
ICDBNode::CTextId textId;
|
||||
pRC->addObserver( &_UseCameraObs, textId);
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
CGroupCompas::~CGroupCompas()
|
||||
{
|
||||
CCDBNodeLeaf *pRC = CDBManager::getInstance()->getDbProp("UI:SAVE:RADAR:USE_CAMERA");
|
||||
if (pRC)
|
||||
{
|
||||
ICDBNode::CTextId textId;
|
||||
pRC->removeObserver( &_UseCameraObs, textId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -225,12 +239,37 @@ void CGroupCompas::draw()
|
|||
{
|
||||
if ((uint) _Target.getType() >= CCompassTarget::NumTypes) return;
|
||||
CInterfaceManager *im = CInterfaceManager::getInstance();
|
||||
|
||||
if (_RadarView && _UseCameraObs._changed)
|
||||
{
|
||||
_UseCameraObs._changed = false;
|
||||
_RadarView->setUseCamera(_UseCameraObs._useCamera);
|
||||
}
|
||||
|
||||
//
|
||||
const NLMISC::CVectorD &userPosD = UserEntity->pos();
|
||||
NLMISC::CVector userPos((float) userPosD.x, (float) userPosD.y, (float) userPosD.z);
|
||||
NLMISC::CVector2f targetPos(0.f, 0.f);
|
||||
// if a position tracker is provided, use it
|
||||
CCompassTarget displayedTarget = _Target;
|
||||
float myAngle;
|
||||
|
||||
if (_UseCameraObs._useCamera)
|
||||
{
|
||||
CVector projectedFront = MainCam.getMatrix().getJ();
|
||||
if (projectedFront.norm() <= 0.01f)
|
||||
{
|
||||
projectedFront = MainCam.getMatrix().getK();
|
||||
projectedFront.z = 0.f;
|
||||
}
|
||||
CVector cam = projectedFront.normed();
|
||||
myAngle = (float)atan2(cam.y, cam.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
const CVector &front = UserEntity->front();
|
||||
myAngle = (float)atan2 (front.y, front.x);
|
||||
}
|
||||
|
||||
switch(_Target.getType())
|
||||
{
|
||||
|
@ -332,8 +371,6 @@ void CGroupCompas::draw()
|
|||
_ArrowShape->getShape().getMaterial(0).setDiffuse(color);
|
||||
|
||||
// Set angle
|
||||
const CVector &front = UserEntity->front();
|
||||
float myAngle = (float)atan2 (front.y, front.x);
|
||||
float deltaX = targetPos.x - userPos.x;
|
||||
float deltaY = targetPos.y - userPos.y;
|
||||
float targetAngle = (float)atan2 (deltaY, deltaX);
|
||||
|
@ -496,6 +533,13 @@ bool CGroupCompas::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
|
|||
return true;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CGroupCompas::CDBUseCameraObs::update( NLMISC::ICDBNode *node)
|
||||
{
|
||||
_changed = true;
|
||||
_useCamera = ((CCDBNodeLeaf*)node)->getValueBool();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
bool buildCompassTargetFromTeamMember(CCompassTarget &ct, uint teamMemberId)
|
||||
{
|
||||
|
|
|
@ -132,6 +132,17 @@ private:
|
|||
uint32 _RadarPos;
|
||||
|
||||
NLMISC::CVector2f getNorthPos(const NLMISC::CVector2f &userPos) const;
|
||||
|
||||
class CDBUseCameraObs : public NLMISC::ICDBNode::IPropertyObserver
|
||||
{
|
||||
public:
|
||||
CDBUseCameraObs():_useCamera(false),_changed(false)
|
||||
{ }
|
||||
virtual void update( NLMISC::ICDBNode *node);
|
||||
bool _useCamera;
|
||||
bool _changed;
|
||||
};
|
||||
CDBUseCameraObs _UseCameraObs;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,6 +35,8 @@ using namespace std;
|
|||
using namespace NLMISC;
|
||||
using namespace NL3D;
|
||||
|
||||
extern NL3D::UCamera MainCam;
|
||||
|
||||
NLMISC_REGISTER_OBJECT(CViewBase, CViewRadar, std::string, "radar");
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -127,10 +129,25 @@ void CViewRadar::draw ()
|
|||
CEntityCL *user = EntitiesMngr.entity(0);
|
||||
if (user == NULL) return;
|
||||
|
||||
float angle;
|
||||
CVectorD xyzRef = user->pos();
|
||||
const CVector dir = user->front();
|
||||
if (_UseCamera)
|
||||
{
|
||||
CVector projectedFront = MainCam.getMatrix().getJ();
|
||||
if (projectedFront.norm() <= 0.01f)
|
||||
{
|
||||
projectedFront = MainCam.getMatrix().getK();
|
||||
projectedFront.z = 0.f;
|
||||
}
|
||||
CVector cam = projectedFront.normed();
|
||||
angle = (float)(atan2(cam.y, cam.x) - (Pi / 2.0));
|
||||
}
|
||||
else
|
||||
{
|
||||
const CVector dir = user->front();
|
||||
angle = (float)(atan2(dir.y, dir.x) - (Pi / 2.0));
|
||||
}
|
||||
|
||||
float angle = (float)(atan2(dir.y, dir.x) - (Pi / 2.0));
|
||||
CMatrix mat;
|
||||
mat.identity();
|
||||
// Scale to transform from world to interface screen
|
||||
|
|
|
@ -62,9 +62,12 @@ public:
|
|||
void setWorldSize(float f) { _WorldSize = f; }
|
||||
float getWorldSize() const { return (float)_WorldSize; }
|
||||
|
||||
void setUseCamera(bool b) { _UseCamera = b; }
|
||||
|
||||
protected:
|
||||
|
||||
double _WorldSize;
|
||||
bool _UseCamera;
|
||||
|
||||
struct CRadarSpotDesc
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue