mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-10 01:09:34 +00:00
Fusion
This commit is contained in:
commit
66a34ace54
20 changed files with 1973 additions and 531 deletions
|
@ -191,6 +191,7 @@ namespace NLGUI
|
|||
int luaGetLineFromId(CLuaState &ls);
|
||||
int luaIsSeparator(CLuaState &ls);
|
||||
int luaAddLine(CLuaState &ls);
|
||||
int luaAddIconLine(CLuaState &ls);
|
||||
int luaAddLineAtIndex(CLuaState &ls);
|
||||
int luaAddSeparator(CLuaState &ls);
|
||||
int luaAddSeparatorAtIndex(CLuaState &ls);
|
||||
|
@ -210,6 +211,7 @@ namespace NLGUI
|
|||
REFLECT_LUA_METHOD("addSubMenu", luaAddSubMenu);
|
||||
REFLECT_LUA_METHOD("isSeparator", luaIsSeparator);
|
||||
REFLECT_LUA_METHOD("addLine", luaAddLine); // name, ah, ah_params, id
|
||||
REFLECT_LUA_METHOD("addIconLine", luaAddIconLine); // name, ah, ah_params, id, texture
|
||||
REFLECT_LUA_METHOD("addLineAtIndex", luaAddLineAtIndex); // index, name, ah, ah_params, id
|
||||
REFLECT_LUA_METHOD("addSeparator", luaAddSeparator);
|
||||
REFLECT_LUA_METHOD("addSeparatorAtIndex", luaAddSeparatorAtIndex);
|
||||
|
@ -278,6 +280,7 @@ namespace NLGUI
|
|||
*/
|
||||
CGroupSubMenu *cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup = NULL) const;
|
||||
void initOptions(CInterfaceGroup *parent);
|
||||
CViewBitmap *createIcon(CInterfaceElement *parentPos, const std::string &texture);
|
||||
CViewBitmap *createCheckBox(bool checked);
|
||||
CViewBitmap *createRightArrow(CInterfaceElement *parentPos, bool center);
|
||||
};
|
||||
|
|
|
@ -38,14 +38,17 @@ namespace NLGUI
|
|||
|
||||
void resetPointerPos ();
|
||||
void setPointerDown (bool pd);
|
||||
void setPointerMiddleDown (bool pd);
|
||||
void setPointerRightDown (bool pd);
|
||||
void setPointerDownString (const std::string &s);
|
||||
|
||||
void getPointerPos (sint32 &x, sint32 &y);
|
||||
void getPointerDispPos (sint32 &x, sint32 &y);
|
||||
|
||||
void getPointerOldPos (sint32 &x, sint32 &y);
|
||||
void getPointerDownPos (sint32 &x, sint32 &y);
|
||||
bool getPointerDown ();
|
||||
bool getPointerDown (sint32 &x, sint32 &y);
|
||||
bool getPointerMiddleDown (sint32 &x, sint32 &y);
|
||||
bool getPointerRightDown (sint32 &x, sint32 &y);
|
||||
std::string getPointerDownString ();
|
||||
bool getPointerDrag ();
|
||||
|
||||
|
@ -70,6 +73,12 @@ namespace NLGUI
|
|||
bool _PointerDown; // Is the pointer down ?
|
||||
sint32 _PointerDownX; // Pointer down position
|
||||
sint32 _PointerDownY;
|
||||
bool _PointerMiddleDown; // Is the middle pointer down ?
|
||||
sint32 _PointerMiddleDownX; // Pointer middle down position
|
||||
sint32 _PointerMiddleDownY;
|
||||
bool _PointerRightDown; // Is the right pointer down ?
|
||||
sint32 _PointerRightDownX; // Pointer right down position
|
||||
sint32 _PointerRightDownY;
|
||||
std::string _PointerDownString; // What is under the pointer at the down position
|
||||
bool _PointerDrag; // Is the pointer down and we have moved ?
|
||||
bool _PointerVisible; // Is the pointer visible or hidden ?
|
||||
|
|
|
@ -2014,7 +2014,6 @@ namespace NLGUI
|
|||
it = styles.find("background-image");
|
||||
if (it != styles.end())
|
||||
{
|
||||
nlinfo("found background-image %s", it->second.c_str());
|
||||
string image = (*it).second;
|
||||
string::size_type texExt = toLower(image).find("url(");
|
||||
// Url image
|
||||
|
|
|
@ -384,6 +384,22 @@ namespace NLGUI
|
|||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CViewBitmap *CGroupSubMenu::createIcon(CInterfaceElement *parentPos, const string &texture)
|
||||
{
|
||||
// Add an icon to the line
|
||||
CViewBitmap *pVB = new CViewBitmap(CViewBase::TCtorParam());
|
||||
pVB->setSerializable( false );
|
||||
pVB->setParent (this);
|
||||
pVB->setParentPos (parentPos);
|
||||
pVB->setParentPosRef (Hotspot_ML);
|
||||
pVB->setPosRef (Hotspot_MR);
|
||||
pVB->setTexture(texture);
|
||||
pVB->setModulateGlobalColor(false);
|
||||
pVB->setX (-2);
|
||||
addView (pVB);
|
||||
return pVB;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CViewBitmap *CGroupSubMenu::createCheckBox(bool checked)
|
||||
|
@ -1229,13 +1245,22 @@ namespace NLGUI
|
|||
pV->setCheckBox(checkBox);
|
||||
}
|
||||
|
||||
CViewBitmap *icon = NULL;
|
||||
if (!texture.empty())
|
||||
{
|
||||
if (_GroupList->getNumChildren() == 1)
|
||||
pV->setX(20);
|
||||
icon = createIcon(pV, texture);
|
||||
}
|
||||
|
||||
|
||||
tmp.ViewText = pV;
|
||||
tmp.Separator = NULL;
|
||||
tmp.AHName = ah;
|
||||
tmp.AHParams = params;
|
||||
tmp.Cond = cond;
|
||||
tmp.CheckBox = checkBox;
|
||||
tmp.RightArrow = NULL;
|
||||
tmp.RightArrow = icon;
|
||||
if (id.empty())
|
||||
tmp.Id = NLMISC::toString (_Lines.size());
|
||||
else
|
||||
|
@ -1776,6 +1801,22 @@ namespace NLGUI
|
|||
return 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
int CGroupSubMenu::luaAddIconLine(CLuaState &ls)
|
||||
{
|
||||
const char *funcName = "addIconLine";
|
||||
CLuaIHM::checkArgCount(ls, funcName, 5);
|
||||
CLuaIHM::checkArgTypeUCString(ls, funcName, 1);
|
||||
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
|
||||
CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING);
|
||||
CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING);
|
||||
CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING);
|
||||
ucstring arg1;
|
||||
nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1));
|
||||
addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
int CGroupSubMenu::luaAddLineAtIndex(CLuaState &ls)
|
||||
{
|
||||
|
|
|
@ -80,16 +80,39 @@ namespace NLGUI
|
|||
{
|
||||
_PointerDown = pd;
|
||||
|
||||
if (_PointerDown == true)
|
||||
if (_PointerDown)
|
||||
{
|
||||
_PointerDownX = _PointerX;
|
||||
_PointerDownY = _PointerY;
|
||||
}
|
||||
|
||||
if (_PointerDown == false)
|
||||
else
|
||||
_PointerDrag = false;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::setPointerMiddleDown (bool pd)
|
||||
{
|
||||
_PointerMiddleDown = pd;
|
||||
|
||||
if (_PointerMiddleDown)
|
||||
{
|
||||
_PointerMiddleDownX = _PointerX;
|
||||
_PointerMiddleDownY = _PointerY;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::setPointerRightDown (bool pd)
|
||||
{
|
||||
_PointerRightDown = pd;
|
||||
|
||||
if (_PointerRightDown)
|
||||
{
|
||||
_PointerRightDownX = _PointerX;
|
||||
_PointerRightDownY = _PointerY;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::setPointerDownString (const std::string &s)
|
||||
{
|
||||
|
@ -120,16 +143,30 @@ namespace NLGUI
|
|||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y)
|
||||
bool CViewPointerBase::getPointerDown (sint32 &x, sint32 &y)
|
||||
{
|
||||
x = _PointerDownX;
|
||||
y = _PointerDownY;
|
||||
|
||||
return _PointerDown;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
bool CViewPointerBase::getPointerDown ()
|
||||
bool CViewPointerBase::getPointerMiddleDown (sint32 &x, sint32 &y)
|
||||
{
|
||||
return _PointerDown;
|
||||
x = _PointerMiddleDownX;
|
||||
y = _PointerMiddleDownY;
|
||||
|
||||
return _PointerMiddleDown;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
bool CViewPointerBase::getPointerRightDown (sint32 &x, sint32 &y)
|
||||
{
|
||||
x = _PointerRightDownX;
|
||||
y = _PointerRightDownY;
|
||||
|
||||
return _PointerRightDown;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -1048,7 +1048,7 @@ void CClientConfig::setValues()
|
|||
|
||||
/////////////////////////
|
||||
// NEW PATCHING SYSTEM //
|
||||
READ_BOOL_DEV(PatchWanted)
|
||||
READ_BOOL_FV(PatchWanted)
|
||||
|
||||
#ifdef RZ_USE_CUSTOM_PATCH_SERVER
|
||||
READ_STRING_FV(PatchUrl)
|
||||
|
|
|
@ -59,6 +59,7 @@ CContextualCursor ContextCur;
|
|||
CLFECOMMON::TCLEntityId SlotUnderCursor;
|
||||
uint32 MissionId = 0;
|
||||
uint32 MissionRingId = 0;
|
||||
sint32 InstanceId = 0;
|
||||
UInstance selectedInstance;
|
||||
const UInstance noSelectedInstance;
|
||||
string selectedInstanceURL;
|
||||
|
@ -89,6 +90,7 @@ void contextExtractRM (bool rightClick, bool dblClick);
|
|||
void contextMission (bool rightClick, bool dblClick);
|
||||
void contextWebPage (bool rightClick, bool dblClick);
|
||||
void contextWebIG (bool rightClick, bool dblClick);
|
||||
void contextARKitect (bool rightClick, bool dblClick);
|
||||
void contextRingMission (bool rightClick, bool dblClick);
|
||||
void contextOutpost (bool rightClick, bool dblClick);
|
||||
void contextBuildTotem (bool rightClick, bool dblClick);
|
||||
|
@ -127,6 +129,7 @@ void initContextualCursor()
|
|||
ContextCur.add(true, "MISSION", string(""), 0.0f, checkUnderCursor, contextMission);
|
||||
ContextCur.add(true, "WEB PAGE", string(""), 0.0f, checkUnderCursor, contextWebPage);
|
||||
ContextCur.add(true, "WEBIG", string(""), 0.0f, checkUnderCursor, contextWebIG);
|
||||
ContextCur.add(false, "ARKITECT", string("curs_pick.tga"), 0.0f, checkUnderCursor, contextARKitect);
|
||||
ContextCur.add(true, "OUTPOST", string(""), 0.0f, checkUnderCursor, contextOutpost);
|
||||
ContextCur.add(true, "RING MISSION", string(""), 0.0f, checkUnderCursor, contextRingMission);
|
||||
ContextCur.add(true, "BUILD_TOTEM", string("uimGcmChooseBuilding"), 0.0f, checkUnderCursor, contextBuildTotem);
|
||||
|
@ -530,10 +533,10 @@ void checkUnderCursor()
|
|||
}
|
||||
else
|
||||
{
|
||||
CShapeInstanceReference instref = EntitiesMngr.getShapeInstanceUnderPos(cursX, cursY);
|
||||
sint32 instance_idx;
|
||||
CShapeInstanceReference instref = EntitiesMngr.getShapeInstanceUnderPos(cursX, cursY, instance_idx);
|
||||
|
||||
bool cleanSelectedInstance = EntitiesMngr.instancesRemoved();
|
||||
if (cleanSelectedInstance)
|
||||
if (EntitiesMngr.instancesRemoved())
|
||||
selectedInstance = noSelectedInstance;
|
||||
|
||||
UInstance instance = instref.Instance;
|
||||
|
@ -556,9 +559,16 @@ void checkUnderCursor()
|
|||
selectedInstance.getMaterial(j).setShininess( 1000.0f );
|
||||
}
|
||||
}
|
||||
if (!instref.ContextText.empty())
|
||||
|
||||
selectedInstanceURL = instref.ContextURL;
|
||||
if (instref.ContextText.empty())
|
||||
{
|
||||
InstanceId = instance_idx;
|
||||
if(ContextCur.context("ARKITECT", 0.f, ucstring()))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedInstanceURL = instref.ContextURL;
|
||||
ucstring contextText;
|
||||
contextText.fromUtf8(instref.ContextText);
|
||||
if(ContextCur.context("WEBIG", 0.f, contextText))
|
||||
|
@ -879,6 +889,8 @@ void contextWebPage(bool rightClick, bool dblClick)
|
|||
//-----------------------------------------------
|
||||
void contextWebIG(bool rightClick, bool dblClick)
|
||||
{
|
||||
if(rightClick)
|
||||
return;
|
||||
CInterfaceManager *IM = CInterfaceManager::getInstance();
|
||||
CInterfaceElement *pGC = CWidgetManager::getInstance()->getElementFromId("ui:interface:bot_chat_object");
|
||||
CInterface3DShape *el= dynamic_cast<CInterface3DShape*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:bot_chat_object:scene3d:object_1"));
|
||||
|
@ -900,6 +912,24 @@ void contextWebIG(bool rightClick, bool dblClick)
|
|||
}
|
||||
}// contextWebIG //
|
||||
|
||||
//-----------------------------------------------
|
||||
// contextARKitect :
|
||||
//-----------------------------------------------
|
||||
void contextARKitect(bool rightClick, bool dblClick)
|
||||
{
|
||||
string header;
|
||||
if (rightClick)
|
||||
{
|
||||
header = toString("rightClick = true\nSelectedInstanceId = %u\n", InstanceId);
|
||||
} else {
|
||||
header = toString("rightClick = false\nSelectedInstanceId = %u\n", InstanceId);
|
||||
}
|
||||
|
||||
CLuaManager::getInstance().executeLuaScript(string(header)+selectedInstanceURL, true);
|
||||
|
||||
}// contextARKitect //
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// contextOutpost
|
||||
//-----------------------------------------------
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "interface_v3/people_interraction.h"
|
||||
#include "interface_v3/bar_manager.h"
|
||||
#include "interface_v3/group_compas.h"
|
||||
#include "misc.h"
|
||||
// 3D
|
||||
#include "nel/3d/quad_tree.h"
|
||||
// Interface 3D
|
||||
|
@ -65,11 +66,13 @@
|
|||
#include "player_r2_cl.h"
|
||||
#include "r2/editor.h"
|
||||
|
||||
|
||||
///////////
|
||||
// USING //
|
||||
///////////
|
||||
using namespace NLMISC;
|
||||
using namespace NL3D;
|
||||
using namespace NLPACS;
|
||||
using namespace std;
|
||||
|
||||
#ifdef DEBUG_NEW
|
||||
|
@ -403,6 +406,7 @@ CEntityManager::CEntityManager()
|
|||
_NbPlayer = 0;
|
||||
_NbChar = 0;
|
||||
_LastEntityUnderPos= NULL;
|
||||
_LastRemovedInstance = -1;
|
||||
}// CEntityManager //
|
||||
|
||||
//-----------------------------------------------
|
||||
|
@ -525,22 +529,181 @@ void CEntityManager::reinit()
|
|||
initialize(_NbMaxEntity);
|
||||
}
|
||||
|
||||
CShapeInstanceReference CEntityManager::createInstance(const string& shape, const CVector &pos, const string& text, const string& url, bool bbox_active)
|
||||
CShapeInstanceReference CEntityManager::createInstance(const string& shape, const CVector &pos, const string& text, const string& url, bool haveCollisions, sint32& idx)
|
||||
{
|
||||
idx = -1;
|
||||
CShapeInstanceReference nullinstref(UInstance(), string(""), string(""));
|
||||
if (!Scene) return nullinstref;
|
||||
|
||||
UInstance instance = Scene->createInstance(shape);
|
||||
if (text.empty())
|
||||
bbox_active = false;
|
||||
CShapeInstanceReference instref = CShapeInstanceReference(instance, text, url, bbox_active);
|
||||
|
||||
if(!instance.empty())
|
||||
{
|
||||
_ShapeInstances.push_back(instref);
|
||||
UMovePrimitive *primitive = NULL;
|
||||
|
||||
if (PACS && haveCollisions)
|
||||
{
|
||||
primitive = PACS->addCollisionablePrimitive(dynamicWI, 1);
|
||||
primitive->setDontSnapToGround(false);
|
||||
}
|
||||
|
||||
// Put instance in last deleted position if found
|
||||
if (_LastRemovedInstance != -1)
|
||||
{
|
||||
idx = _LastRemovedInstance;
|
||||
_ShapeInstances[idx].Instance = instance;
|
||||
_ShapeInstances[idx].Primitive = primitive;
|
||||
_ShapeInstances[idx].ContextText = text;
|
||||
_ShapeInstances[idx].ContextURL = url;
|
||||
_ShapeInstances[idx].BboxActive = !text.empty() || !url.empty();
|
||||
_ShapeInstances[idx].Deleted = false;
|
||||
|
||||
_LastRemovedInstance = _ShapeInstances[idx].LastDeleted;
|
||||
_ShapeInstances[idx].LastDeleted = -1;
|
||||
return _ShapeInstances[idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
CShapeInstanceReference instref = CShapeInstanceReference(instance, text, url, !text.empty() || !url.empty());
|
||||
instref.Primitive = primitive;
|
||||
idx = _ShapeInstances.size();
|
||||
_ShapeInstances.push_back(instref);
|
||||
return instref;
|
||||
}
|
||||
}
|
||||
return instref;
|
||||
return nullinstref;
|
||||
}
|
||||
|
||||
bool CEntityManager::deleteInstance(uint32 idx)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size())
|
||||
return false;
|
||||
|
||||
if (!_ShapeInstances[idx].Instance.empty())
|
||||
Scene->deleteInstance(_ShapeInstances[idx].Instance);
|
||||
UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
|
||||
if (primitive)
|
||||
{
|
||||
PACS->removePrimitive(primitive);
|
||||
}
|
||||
|
||||
if (!_ShapeInstances[idx].Deleted)
|
||||
{
|
||||
_ShapeInstances[idx].Primitive = NULL;
|
||||
_ShapeInstances[idx].Deleted = true;
|
||||
_ShapeInstances[idx].LastDeleted = _LastRemovedInstance;
|
||||
_LastRemovedInstance = idx;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CVector CEntityManager::getInstancePos(uint32 idx)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return CVector(0,0,0);
|
||||
|
||||
UInstance instance = _ShapeInstances[idx].Instance;
|
||||
if(instance.empty())
|
||||
return CVector(0,0,0);
|
||||
|
||||
return instance.getPos();
|
||||
}
|
||||
|
||||
bool CEntityManager::setInstancePos(uint32 idx, CVector pos)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return false;
|
||||
|
||||
UInstance instance = _ShapeInstances[idx].Instance;
|
||||
if(instance.empty())
|
||||
return false;
|
||||
|
||||
UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
|
||||
if (primitive)
|
||||
{
|
||||
primitive->setGlobalPosition(_ShapeInstances[idx].PrimRelativePos + pos, dynamicWI);
|
||||
}
|
||||
|
||||
instance.setPos(pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
CVector CEntityManager::getInstanceRot(uint32 idx)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return CVector(0,0,0);
|
||||
|
||||
UInstance instance = _ShapeInstances[idx].Instance;
|
||||
if(instance.empty())
|
||||
return CVector(0,0,0);
|
||||
|
||||
return instance.getRotEuler();
|
||||
}
|
||||
|
||||
bool CEntityManager::setInstanceRot(uint32 idx, CVector rot)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return false;
|
||||
|
||||
UInstance instance = _ShapeInstances[idx].Instance;
|
||||
if(instance.empty())
|
||||
return false;
|
||||
|
||||
instance.setRotEuler(rot);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CVector CEntityManager::getInstanceScale(uint32 idx)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return CVector(0,0,0);
|
||||
|
||||
UInstance instance = _ShapeInstances[idx].Instance;
|
||||
if(instance.empty())
|
||||
return CVector(0,0,0);
|
||||
|
||||
return instance.getScale();
|
||||
}
|
||||
|
||||
CVector CEntityManager::getInstanceColPos(uint32 idx)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return CVector(0,0,0);
|
||||
|
||||
return _ShapeInstances[idx].PrimRelativePos;
|
||||
}
|
||||
|
||||
CVector CEntityManager::getInstanceColScale(uint32 idx)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return CVector(0,0,0);
|
||||
|
||||
UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
|
||||
if (!primitive)
|
||||
return CVector(0,0,0);
|
||||
|
||||
float width, depth;
|
||||
primitive->getSize(width, depth);
|
||||
float height = primitive->getHeight();
|
||||
|
||||
return CVector(width, depth, height);
|
||||
}
|
||||
|
||||
double CEntityManager::getInstanceColOrient(uint32 idx)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return 0.f;
|
||||
|
||||
UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
|
||||
if (!primitive)
|
||||
return 0.f;
|
||||
|
||||
return primitive->getOrientation(dynamicWI);
|
||||
}
|
||||
|
||||
|
||||
bool CEntityManager::removeInstances()
|
||||
{
|
||||
if (!Scene) return false;
|
||||
|
@ -549,9 +712,16 @@ bool CEntityManager::removeInstances()
|
|||
{
|
||||
if (!_ShapeInstances[i].Instance.empty())
|
||||
Scene->deleteInstance(_ShapeInstances[i].Instance);
|
||||
|
||||
UMovePrimitive *primitive = _ShapeInstances[i].Primitive;
|
||||
if (primitive)
|
||||
{
|
||||
PACS->removePrimitive(primitive);
|
||||
}
|
||||
}
|
||||
_ShapeInstances.clear();
|
||||
_InstancesRemoved = true;
|
||||
_LastRemovedInstance = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -562,10 +732,163 @@ bool CEntityManager::instancesRemoved()
|
|||
return instRemoved;
|
||||
}
|
||||
|
||||
CShapeInstanceReference CEntityManager::getShapeInstanceUnderPos(float x, float y)
|
||||
|
||||
|
||||
bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const vector<string> &values) {
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return false;
|
||||
|
||||
UInstance instance = _ShapeInstances[idx].Instance;
|
||||
if(instance.empty())
|
||||
return false;
|
||||
|
||||
UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
|
||||
|
||||
for (uint32 i=0; i < keys.size(); i++)
|
||||
{
|
||||
string param = keys[i];
|
||||
if (param == "transparency")
|
||||
{
|
||||
uint t;
|
||||
if( fromString( values[i], t ) ) {
|
||||
t = max(0, min((int)t, 255));
|
||||
makeInstanceTransparent(instance, t, t == 255);
|
||||
}
|
||||
}
|
||||
else if (param == "colorize")
|
||||
{
|
||||
CRGBA c;
|
||||
if( fromString( values[i], c ) )
|
||||
{
|
||||
for(uint j=0;j<instance.getNumMaterials();j++)
|
||||
{
|
||||
instance.getMaterial(j).setShininess( 1000.0f );
|
||||
instance.getMaterial(j).setEmissive(c);
|
||||
instance.getMaterial(j).setDiffuse(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (param == "texture")
|
||||
{
|
||||
if (!values[i].empty())
|
||||
{
|
||||
for(uint j=0;j<instance.getNumMaterials();j++)
|
||||
{
|
||||
sint numStages = instance.getMaterial(j).getLastTextureStage() + 1;
|
||||
for(sint l = 0; l < numStages; l++)
|
||||
{
|
||||
if (instance.getMaterial(j).isTextureFile((uint) l))
|
||||
instance.getMaterial(j).setTextureFileName(values[i], (uint) l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (param == "scale x" || param == "scale y" || param == "scale z")
|
||||
{
|
||||
float v;
|
||||
CVector scale = instance.getScale();
|
||||
|
||||
if( getRelativeFloatFromString( values[i], v ) ) {
|
||||
updateVector(param, scale, v, true);
|
||||
} else {
|
||||
updateVector(param, scale, v, false);
|
||||
}
|
||||
instance.setScale(scale);
|
||||
}
|
||||
|
||||
// Primitive colissions setups
|
||||
|
||||
if (!primitive) continue;
|
||||
|
||||
if (param == "col size x" || param == "col size y" || param == "col size z")
|
||||
{
|
||||
float width, depth;
|
||||
primitive->getSize(width, depth);
|
||||
float height = primitive->getHeight();
|
||||
|
||||
CVector size = CVector(width, depth, height);
|
||||
float v;
|
||||
if( getRelativeFloatFromString( values[i], v ) ) {
|
||||
updateVector(param, size, v, true);
|
||||
} else {
|
||||
updateVector(param, size, v, false);
|
||||
}
|
||||
primitive->setSize(size.x, size.y);
|
||||
primitive->setHeight(size.z);
|
||||
}
|
||||
else if (param == "col pos x" || param == "col pos y" || param == "col pos z")
|
||||
{
|
||||
CVector pos = instance.getPos();
|
||||
float v;
|
||||
|
||||
if( getRelativeFloatFromString( values[i], v ) ) {
|
||||
updateVector(param, _ShapeInstances[idx].PrimRelativePos, v, false);
|
||||
} else {
|
||||
if (param == "col pos x")
|
||||
_ShapeInstances[idx].PrimRelativePos.x = v - pos.x;
|
||||
if (param == "col pos y")
|
||||
_ShapeInstances[idx].PrimRelativePos.y = v - pos.y;
|
||||
if (param == "col pos z")
|
||||
_ShapeInstances[idx].PrimRelativePos.z = v - pos.z;
|
||||
}
|
||||
primitive->setGlobalPosition(pos + _ShapeInstances[idx].PrimRelativePos, dynamicWI);
|
||||
}
|
||||
else if (param == "col orientation")
|
||||
{
|
||||
double orient = primitive->getOrientation(dynamicWI);
|
||||
double v = 0.f;
|
||||
|
||||
if (values[i].empty())
|
||||
continue;
|
||||
|
||||
if (values[i][0] == '+')
|
||||
{
|
||||
fromString(values[i].substr(1), v);
|
||||
orient += v;
|
||||
}
|
||||
else
|
||||
{
|
||||
fromString(values[i], v);
|
||||
orient = v;
|
||||
}
|
||||
|
||||
primitive->setOrientation(orient, dynamicWI);
|
||||
}
|
||||
else if (param == "col mask player")
|
||||
{
|
||||
bool active;
|
||||
fromString(values[i], active);
|
||||
UMovePrimitive::TCollisionMask mask=primitive->getCollisionMask();
|
||||
if (active)
|
||||
primitive->setCollisionMask(mask|MaskColPlayer);
|
||||
else
|
||||
primitive->setCollisionMask(mask&~MaskColPlayer);
|
||||
}
|
||||
else if (param == "col mask door")
|
||||
{
|
||||
bool active;
|
||||
fromString(values[i], active);
|
||||
UMovePrimitive::TCollisionMask mask=primitive->getCollisionMask();
|
||||
if (active)
|
||||
primitive->setCollisionMask(mask|MaskColDoor);
|
||||
else
|
||||
primitive->setCollisionMask(mask&~MaskColDoor);
|
||||
}
|
||||
else if (param == "col obstacle")
|
||||
{
|
||||
bool active;
|
||||
fromString(values[i], active);
|
||||
primitive->setObstacle(active);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CShapeInstanceReference CEntityManager::getShapeInstanceUnderPos(float x, float y, sint32 &idx)
|
||||
{
|
||||
CShapeInstanceReference selectedInstance(UInstance(), string(""), string(""));
|
||||
_LastInstanceUnderPos= NULL;
|
||||
idx = -1;
|
||||
|
||||
// If not initialised, return
|
||||
if (_ShapeInstances.empty())
|
||||
|
@ -586,29 +909,40 @@ CShapeInstanceReference CEntityManager::getShapeInstanceUnderPos(float x, float
|
|||
float bestDist = 255;
|
||||
for(uint i=0; i<_ShapeInstances.size(); i++)
|
||||
{
|
||||
if (_ShapeInstances[i].BboxActive)
|
||||
if (!_ShapeInstances[i].Deleted && _ShapeInstances[i].BboxActive)
|
||||
{
|
||||
H_AUTO(RZ_Client_GEUP_box_intersect)
|
||||
|
||||
// if intersect the bbox
|
||||
NLMISC::CAABBox bbox;
|
||||
//= _ShapeInstances[i].SelectionBox;
|
||||
_ShapeInstances[i].Instance.getShapeAABBox(bbox);
|
||||
if (bbox.getCenter() == CVector::Null)
|
||||
{
|
||||
bbox.setMinMax(CVector(-0.3f, -0.3f, -0.3f)+_ShapeInstances[i].Instance.getPos(), CVector(0.3f, 0.3f, 0.3f)+_ShapeInstances[i].Instance.getPos());
|
||||
}
|
||||
else
|
||||
{
|
||||
bbox.setMinMax((bbox.getMin()*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos(), (bbox.getMax()*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos());
|
||||
}
|
||||
if(bbox.intersect(pos, pos+dir*15.0f))
|
||||
{
|
||||
float dist = (bbox.getCenter()-pos).norm();
|
||||
if (dist < bestDist)
|
||||
if(!_ShapeInstances[i].Instance.empty()) {
|
||||
_ShapeInstances[i].Instance.getShapeAABBox(bbox);
|
||||
CVector bbox_min;
|
||||
CVector bbox_max;
|
||||
|
||||
if (bbox.getCenter() == CVector::Null)
|
||||
{
|
||||
selectedInstance = _ShapeInstances[i];
|
||||
bestDist = dist;
|
||||
bbox_min = CVector(-0.5f, -0.5f, -0.5f);
|
||||
bbox_max = CVector(-0.5f, -0.5f, -0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
bbox_min = bbox.getMin();
|
||||
bbox_max = bbox.getMax();
|
||||
}
|
||||
|
||||
bbox.setMinMax((bbox_min*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos(), (bbox_max*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos());
|
||||
|
||||
if(bbox.intersect(pos, pos+dir*100.0f))
|
||||
{
|
||||
float dist = (bbox.getCenter()-pos).norm();
|
||||
if (dist < bestDist)
|
||||
{
|
||||
selectedInstance = _ShapeInstances[i];
|
||||
bestDist = dist;
|
||||
idx = (sint32)i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,12 +101,24 @@ public:
|
|||
ContextText = text;
|
||||
ContextURL = url;
|
||||
BboxActive = bbox_active;
|
||||
Deleted = false;
|
||||
LastDeleted = -1;
|
||||
Primitive = NULL;
|
||||
PrimSize = CVector(1.f, 1.f, 1.f);
|
||||
PrimHeight = 1.f;
|
||||
PrimRelativePos = CVector(0.f, 0.f, 0.f);
|
||||
}
|
||||
|
||||
NL3D::UInstance Instance;
|
||||
NLPACS::UMovePrimitive *Primitive;
|
||||
CVector PrimSize;
|
||||
float PrimHeight;
|
||||
CVector PrimRelativePos;
|
||||
string ContextText;
|
||||
string ContextURL;
|
||||
bool BboxActive;
|
||||
bool Deleted;
|
||||
sint32 LastDeleted;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -132,6 +144,7 @@ private:
|
|||
|
||||
/// Shapes Instances caches
|
||||
std::vector<CShapeInstanceReference> _ShapeInstances;
|
||||
sint32 _LastRemovedInstance;
|
||||
bool _InstancesRemoved;
|
||||
|
||||
typedef struct
|
||||
|
@ -213,10 +226,20 @@ public:
|
|||
void reinit();
|
||||
|
||||
|
||||
CShapeInstanceReference createInstance(const string& shape, const CVector &pos, const string &text, const string &url, bool active=true);
|
||||
CShapeInstanceReference createInstance(const string& shape, const CVector &pos, const string &text, const string &url, bool haveCollisions, sint32 &idx);
|
||||
bool deleteInstance(uint32 idx);
|
||||
bool removeInstances();
|
||||
CVector getInstancePos(uint32 idx);
|
||||
bool setInstancePos(uint32 idx, CVector pos);
|
||||
CVector getInstanceRot(uint32 idx);
|
||||
CVector getInstanceScale(uint32 idx);
|
||||
CVector getInstanceColPos(uint32 idx);
|
||||
CVector getInstanceColScale(uint32 idx);
|
||||
double getInstanceColOrient(uint32 idx);
|
||||
bool setInstanceRot(uint32 idx, CVector pos);
|
||||
bool instancesRemoved();
|
||||
CShapeInstanceReference getShapeInstanceUnderPos(float x, float y);
|
||||
bool setupInstance(uint32 idx, const std::vector<std::string> &keys, const std::vector<std::string> &values);
|
||||
CShapeInstanceReference getShapeInstanceUnderPos(float x, float y, sint32 &idx);
|
||||
|
||||
/**
|
||||
* Create an entity according to the slot and the form.
|
||||
|
|
|
@ -271,6 +271,15 @@ void HandleSystemCursorCapture(const CEvent &event)
|
|||
{
|
||||
CEventMouseDown &em = (CEventMouseDown &) event;
|
||||
DownMouseButtons |= em.Button & (leftButton | middleButton | rightButton);
|
||||
|
||||
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
|
||||
if (cursor)
|
||||
{
|
||||
cursor->setPointerDown(em.Button == leftButton);
|
||||
cursor->setPointerMiddleDown(em.Button == middleButton);
|
||||
cursor->setPointerRightDown(em.Button == rightButton);
|
||||
}
|
||||
|
||||
Driver->setCapture(true);
|
||||
}
|
||||
|
||||
|
@ -281,6 +290,13 @@ void HandleSystemCursorCapture(const CEvent &event)
|
|||
DownMouseButtons &= ~(em.Button & (leftButton | middleButton | rightButton));
|
||||
if (DownMouseButtons == 0)
|
||||
{
|
||||
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
|
||||
if (cursor)
|
||||
{
|
||||
cursor->setPointerDown(false);
|
||||
cursor->setPointerMiddleDown(false);
|
||||
cursor->setPointerRightDown(false);
|
||||
}
|
||||
Driver->setCapture(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ extern bool Render;
|
|||
extern bool WantProfiling; // Do we want a CPU profile?
|
||||
extern bool WantProfilingVBLock; // Do we want a VBLock profile?
|
||||
extern bool PACSBorders;
|
||||
extern bool ARKPACSBorders;
|
||||
extern bool DebugClusters;
|
||||
extern bool SoundBox;
|
||||
extern uint8 ShowInfos;
|
||||
|
@ -92,6 +93,16 @@ REGISTER_ACTION_HANDLER (CAHDisplayInfos, "display_infos");
|
|||
* *
|
||||
***********************************************************************************************************/
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class CAHToggleARKPACSBorders : public IActionHandler
|
||||
{
|
||||
virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
|
||||
{
|
||||
ARKPACSBorders = !ARKPACSBorders;
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CAHToggleARKPACSBorders, "ark_pacs_borders");
|
||||
|
||||
#if !FINAL_VERSION
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class CAHProfile : public IActionHandler
|
||||
|
|
|
@ -2537,7 +2537,6 @@ class CAHAddShape : public IActionHandler
|
|||
}
|
||||
|
||||
bool have_shapes = true;
|
||||
bool first_shape = true;
|
||||
while(have_shapes)
|
||||
{
|
||||
string shape;
|
||||
|
@ -2554,8 +2553,8 @@ class CAHAddShape : public IActionHandler
|
|||
have_shapes = false;
|
||||
}
|
||||
|
||||
|
||||
CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector((float)x, (float)y, (float)z), c, u, first_shape);
|
||||
sint32 idx;
|
||||
CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector((float)x, (float)y, (float)z), c, u, false, idx);
|
||||
UInstance instance = instref.Instance;
|
||||
|
||||
if(!instance.empty())
|
||||
|
@ -2575,7 +2574,7 @@ class CAHAddShape : public IActionHandler
|
|||
instance.getMaterial(j).setShininess( 1000.0f );
|
||||
}
|
||||
|
||||
if (!texture_name.empty() && first_shape)
|
||||
if (!texture_name.empty())
|
||||
{
|
||||
sint numStages = instance.getMaterial(j).getLastTextureStage() + 1;
|
||||
for(sint l = 0; l < numStages; l++)
|
||||
|
@ -2588,8 +2587,6 @@ class CAHAddShape : public IActionHandler
|
|||
}
|
||||
}
|
||||
|
||||
first_shape = false;
|
||||
|
||||
if (transparency.empty())
|
||||
::makeInstanceTransparent(instance, 255, false);
|
||||
else
|
||||
|
@ -2622,6 +2619,9 @@ class CAHAddShape : public IActionHandler
|
|||
instance.setPos(CVector((float)x, (float)y, (float)z));
|
||||
instance.setRotQuat(dir.getRot());
|
||||
}
|
||||
|
||||
instance.setTransformMode(UTransformable::RotEuler);
|
||||
|
||||
// if the shape is a particle system, additionnal parameters are user params
|
||||
UParticleSystemInstance psi;
|
||||
psi.cast (instance);
|
||||
|
@ -2654,6 +2654,7 @@ class CAHAddShape : public IActionHandler
|
|||
};
|
||||
REGISTER_ACTION_HANDLER (CAHAddShape, "add_shape");
|
||||
|
||||
|
||||
class CAHRemoveShapes : public IActionHandler
|
||||
{
|
||||
virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -106,6 +106,16 @@ private:
|
|||
static int getCompleteIslands(CLuaState &ls);
|
||||
static int getIslandId(CLuaState &ls);//TEMP
|
||||
|
||||
static int addShape(CLuaState &ls);
|
||||
static int moveShape(CLuaState &ls);
|
||||
static int rotateShape(CLuaState &ls);
|
||||
static int getShapePos(CLuaState &ls);
|
||||
static int getShapeScale(CLuaState &ls);
|
||||
static int getShapeRot(CLuaState &ls);
|
||||
static int getShapeColPos(CLuaState &ls);
|
||||
static int getShapeColScale(CLuaState &ls);
|
||||
static int getShapeColOrient(CLuaState &ls);
|
||||
static int deleteShape(CLuaState &ls);
|
||||
|
||||
///////////////////////////// Standard Lua stuff ends here //////////////////////////////////////////////
|
||||
|
||||
|
@ -202,6 +212,14 @@ private:
|
|||
static sint getCharacterSheetRegionLevel(const std::string &sheet);
|
||||
static std::string getRegionByAlias(uint32 alias);
|
||||
static sint getGroundZ(uint32 x, sint32 y);
|
||||
static int getGroundAtMouse(CLuaState &ls);
|
||||
static int getMousePos(CLuaState &ls);
|
||||
static int getMouseDown(CLuaState &ls);
|
||||
static int getMouseMiddleDown(CLuaState &ls);
|
||||
static int getMouseRightDown(CLuaState &ls);
|
||||
static int getShapeIdAt(CLuaState &ls);
|
||||
static int setupShape(CLuaState &ls);
|
||||
static void setMouseCursor(const std::string texture);
|
||||
// open the window to do a tell to 'player', if 'msg' is not empty, then the message will be sent immediatly
|
||||
// else, current command of the chat window will be replaced with tell 'player'
|
||||
static void tell(const ucstring &player, const ucstring &msg);
|
||||
|
|
|
@ -274,6 +274,7 @@ CTimedFXManager::TDebugDisplayMode ShowTimedFXMode = CTimedFXManager::NoText;
|
|||
|
||||
// DEBUG
|
||||
bool PACSBorders = false;
|
||||
bool ARKPACSBorders = false;
|
||||
bool DebugClusters = false;
|
||||
CVector LastDebugClusterCameraThirdPersonStart= CVector::Null;
|
||||
CVector LastDebugClusterCameraThirdPersonEnd= CVector::Null;
|
||||
|
@ -1796,6 +1797,12 @@ bool mainLoop()
|
|||
displayPACSPrimitive();
|
||||
}
|
||||
|
||||
// Display PACS borders only (for ARK).
|
||||
if (ARKPACSBorders)
|
||||
{
|
||||
displayPACSPrimitive();
|
||||
}
|
||||
|
||||
// display Sound box
|
||||
if (SoundBox)
|
||||
{
|
||||
|
@ -2505,6 +2512,8 @@ bool mainLoop()
|
|||
|
||||
// R2ED enabled ?
|
||||
R2::getEditor().autoConfigInit(IsInRingSession);
|
||||
if (!IsInRingSession)
|
||||
R2::getEditor().registerLuaFunc();
|
||||
|
||||
CurrSeason = computeCurrSeason();
|
||||
|
||||
|
|
|
@ -1507,3 +1507,44 @@ bool getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<st
|
|||
|
||||
return nFoundStringMode > -1;
|
||||
}
|
||||
|
||||
// Get float value from string. Return true if the value is relatif ( src = "+15.5" for example )
|
||||
bool getRelativeFloatFromString(const std::string src, float &dst)
|
||||
{
|
||||
dst = 0;
|
||||
if (src.empty())
|
||||
return false;
|
||||
|
||||
if (src[0] == '+')
|
||||
return fromString(src.substr(1), dst);
|
||||
else
|
||||
fromString(src, dst);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool updateVector(const string part, CVector &dst, float value, bool add /* = false */)
|
||||
{
|
||||
string p = part;
|
||||
if (part.size() > 1)
|
||||
p = part.substr(part.size()-1, 1);
|
||||
|
||||
if (add)
|
||||
{
|
||||
if (p == "x")
|
||||
dst.x += value;
|
||||
else if (p == "y")
|
||||
dst.y += value;
|
||||
else if (p == "z")
|
||||
dst.z += value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p == "x")
|
||||
dst.x = value;
|
||||
else if (p == "y")
|
||||
dst.y = value;
|
||||
else if (p == "z")
|
||||
dst.z = value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,6 +168,9 @@ std::string getStringCategory(const ucstring &src, ucstring &dest, bool alwaysAd
|
|||
// Get the category from the string (src="&SYS&Who are you?" and dest="Who are you?" and return "SYS"), if no category, return ""
|
||||
std::string getStringCategoryIfAny(const ucstring &src, ucstring &dest);
|
||||
|
||||
bool getRelativeFloatFromString(const std::string src, float &dst);
|
||||
bool updateVector(const std::string part, NLMISC::CVector &dst, float value, bool add = false);
|
||||
|
||||
// Number of shortcut
|
||||
#define RYZOM_MAX_SHORTCUT 20
|
||||
|
||||
|
|
|
@ -893,6 +893,7 @@ public:
|
|||
static NLMISC::CCDBNodeLeaf *getPlotItemSheetDBLeaf(uint index);
|
||||
static bool getIsStartingScenario() { return _IsStartingScenario; }
|
||||
bool isClearingContent() const { return _ClearingContent; }
|
||||
void registerLuaFunc();
|
||||
|
||||
private:
|
||||
void initPlotItems();
|
||||
|
@ -925,7 +926,7 @@ private:
|
|||
void initObjectProjectionMetatable();
|
||||
void registerDisplayers();
|
||||
void registerTools();
|
||||
void registerLuaFunc();
|
||||
|
||||
// add a C++ method in the environement
|
||||
void registerEnvMethod(const char *name, TLuaWrappedFunction func);
|
||||
void registerEnvFunction(const char *name, TLuaWrappedFunction func);
|
||||
|
|
|
@ -165,6 +165,47 @@ void CTool::getMousePos(sint32 &x, sint32 &y)
|
|||
cursor->getPointerPos(x, y);
|
||||
}
|
||||
|
||||
// ***************************************************************
|
||||
void CTool::getMouseDown(bool &down, sint32 &x, sint32 &y)
|
||||
{
|
||||
down = false;
|
||||
//H_AUTO(R2_CTool_getMousePos)
|
||||
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
|
||||
if(cursor == NULL)
|
||||
{
|
||||
x = y = -1;
|
||||
return;
|
||||
}
|
||||
down = cursor->getPointerDown(x, y);
|
||||
}
|
||||
|
||||
// ***************************************************************
|
||||
void CTool::getMouseMiddleDown(bool &down, sint32 &x, sint32 &y)
|
||||
{
|
||||
//H_AUTO(R2_CTool_getMousePos)
|
||||
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
|
||||
if(cursor == NULL)
|
||||
{
|
||||
x = y = -1;
|
||||
return;
|
||||
}
|
||||
down = cursor->getPointerMiddleDown(x, y);
|
||||
}
|
||||
|
||||
// ***************************************************************
|
||||
void CTool::getMouseRightDown(bool &down, sint32 &x, sint32 &y)
|
||||
{
|
||||
//H_AUTO(R2_CTool_getMousePos)
|
||||
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
|
||||
if(cursor == NULL)
|
||||
{
|
||||
x = y = -1;
|
||||
return;
|
||||
}
|
||||
down = cursor->getPointerRightDown(x, y);
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************
|
||||
sint32 CTool::getMouseX()
|
||||
{
|
||||
|
@ -446,13 +487,16 @@ bool CTool::computeNearestValidSurfaceFromHeightMap(float x, float y, NLMISC::CV
|
|||
|
||||
sint mapX = (sint) (x - islandDesc->XMin);
|
||||
sint mapY = (sint) (y - islandDesc->YMin);
|
||||
|
||||
if (mapX < 0 || mapY < 0 || mapX >= (islandDesc->XMax - islandDesc->XMin) || mapY >= (islandDesc->YMax - islandDesc->YMin)) return false;
|
||||
sint hmZ = heightMap(mapX, mapY);
|
||||
if (hmZ >= 0x7ffe) return false; // not an accessible pos
|
||||
|
||||
if (!isIslandValidPos(heightMap, *islandDesc, x + 0.5f, y) ||
|
||||
!isIslandValidPos(heightMap, *islandDesc, x - 0.5f, y) ||
|
||||
!isIslandValidPos(heightMap, *islandDesc, x, y + 0.5f) ||
|
||||
!isIslandValidPos(heightMap, *islandDesc, x, y - 0.5f)) return false;
|
||||
|
||||
float z = 1.f + 2.f * hmZ;
|
||||
// this is a possibly valid position
|
||||
// compute nearest surface from here, and see if not far from the intersection
|
||||
|
@ -471,6 +515,7 @@ bool CTool::computeNearestValidSurfaceFromHeightMap(float x, float y, NLMISC::CV
|
|||
inter1Found = inter1Found && normal1.z >= minAngleSin;
|
||||
inter2Found = inter2Found && normal2.z >= minAngleSin;
|
||||
if (!inter1Found && !inter2Found) return false;
|
||||
|
||||
if (inter1Found && inter2Found)
|
||||
{
|
||||
// because z in heightmap in usually a 'ceil' of real height, tends to favor surface below
|
||||
|
@ -901,5 +946,4 @@ NLMISC::CRGBA CTool::getInvalidPosColor()
|
|||
|
||||
}
|
||||
|
||||
|
||||
} // R2
|
||||
|
|
|
@ -213,6 +213,12 @@ public:
|
|||
static CInterfaceManager &getUI();
|
||||
// Get mouse position
|
||||
static void getMousePos(sint32 &x, sint32 &y) ;
|
||||
// Get if mouse are clicked down and position of last down click
|
||||
static void getMouseDown(bool &down, sint32 &x, sint32 &y);
|
||||
// Get if mouse are middle clicked down and position of last down click
|
||||
static void getMouseMiddleDown(bool &down, sint32 &x, sint32 &y);
|
||||
// Get if mouse are right clicked down and position of last down click
|
||||
static void getMouseRightDown(bool &down, sint32 &x, sint32 &y);
|
||||
// Get mouse x position
|
||||
static sint32 getMouseX();
|
||||
// Get mouse y position
|
||||
|
|
Loading…
Reference in a new issue