Rope: Add a script function to set fixed rope ends

rope
Armin Burgmeier 2012-05-05 21:24:20 +02:00
parent 002d64108d
commit 2c82a66083
3 changed files with 20 additions and 1 deletions

View File

@ -337,7 +337,7 @@ C4Rope::C4Rope(C4PropList* Prototype, C4Object* first_obj, C4Object* second_obj,
if(Graphics->Type != C4DefGraphics::TYPE_Bitmap)
throw C4RopeError("Can only use bitmap as rope graphics");
Front = new C4RopeElement(first_obj, true);
Front = new C4RopeElement(first_obj, false);
Back = new C4RopeElement(second_obj, false);
const C4Real m(Fix1); // TODO: This should be a property

View File

@ -84,6 +84,11 @@ public:
C4Real GetBackAutoSegmentation() const { return BackAutoSegmentation; }
void SetFrontAutoSegmentation(C4Real max) { FrontAutoSegmentation = max; }
void SetBackAutoSegmentation(C4Real max) { BackAutoSegmentation = max; }
bool GetFrontFixed() const { return Front->Fixed; }
bool GetBackFixed() const { return Back->Fixed; }
void SetFrontFixed(bool fixed) { Front->Fixed = fixed; }
void SetBackFixed(bool fixed) { Back->Fixed = fixed; }
private:
C4Real GetL(const C4RopeElement* prev, const C4RopeElement* next) const;

View File

@ -46,6 +46,18 @@ static C4Void FnSetBackAutoSegmentation(C4AulContext* Context, int max)
return C4Void();
}
static C4Void FnSetFrontFixed(C4AulContext* Context, bool fixed)
{
static_cast<C4Rope*>(Context->Def)->SetFrontFixed(fixed);
return C4Void();
}
static C4Void FnSetBackFixed(C4AulContext* Context, bool fixed)
{
static_cast<C4Rope*>(Context->Def)->SetBackFixed(fixed);
return C4Void();
}
C4RopeAul::C4RopeAul():
RopeDef(NULL)
{
@ -69,5 +81,7 @@ void C4RopeAul::InitFunctionMap(C4AulScriptEngine* pEngine)
::AddFunc(this, "GetBack", FnGetBack);
::AddFunc(this, "SetFrontAutoSegmentation", FnSetFrontAutoSegmentation);
::AddFunc(this, "SetBackAutoSegmentation", FnSetBackAutoSegmentation);
::AddFunc(this, "SetFrontFixed", FnSetFrontFixed);
::AddFunc(this, "SetBackFixed", FnSetBackFixed);
RopeDef->Freeze();
}