$#include "lm_pkg_anime.h"

/* tolua -o pkg_moho.cpp -H pkg_moho.h pkg_moho.lua_pkg */



/*

    This file is used to auto-generate Lua interfaces.

    If you make a change to this file, you must run the tolua command like so:

    In Terminal, go to the 'scripting' folder and type the following command:

    > python _make_pkg.py

*/




typedef int                int32;

typedef unsigned int    uint32;

typedef float            real;



module MOHO { // begin module



/**********************************************************************/

/*** Moho View ***/



class XGraphics : public LM_Graphics

{

};



class MohoView : public LM_View {

    void RefreshView();

    void DrawMe();



    int32 QualityFlags();

    void SetQualityFlags(int32 qualityFlags);

    void SetTracingImage(const char *path);

    bool IsTracingEnabled();

    void TurnTracingOn(bool b);

    bool IsTracingOn();

    bool IsStereoEnabled();

    void TurnStereoOn(bool b);

    bool IsStereoOn();



    int32 PickPoint(LM_Point where, int32 pickWidth = 3);

    void PickEdge(LM_Point where, int32 *curveID, int32 *segID, int32 pickWidth = 3);

    LM_Point PickEdgeAlongLine(LM_Point lineEnd1, LM_Point lineEnd2, int32 *curveID, int32 *segID, int32 skipMinSegID, int32 skipMaxSegID);

    MohoLayer *PickGlobalEdge(LM_Point where, int32 *curveID, int32 *segID, int32 pickWidth = 3);

    int32 PickShape(LM_Point where, int32 noHigherThan = -1, int32 pickWidth = 3);

    int32 PickBone(LM_Point where, LM_Vector2 clickVec, MohoLayer *layer, bool exact, int32 pickWidth = 3);

    void FloodSelect(LM_Point where, int32 tolerance);

    M_Shape *PickGlobalShape(LM_Point where, int32 noHigherThan = -1, int32 pickWidth = 3);

    int32 PickFace(LM_Point where, int32 pickWidth = 3);

    MohoLayer *PickGlobalLayer(LM_Point where, int32 pickWidth = 3);



    LM_Vector2 Point2Vec(LM_Point where, LM_Matrix *layerM = NULL);



    XGraphics *Graphics();

    void ResetView(int32 mode = 2);



    // These may seem weird, but the purpose is to get exactly the same behavior as the right-drag versions

    void PanDown(LM_Point where);

    void PanMoved(LM_Point where);

    void PanUp(LM_Point where);



    void ZoomDown(LM_Point where);

    void ZoomMoved(LM_Point where);

    void ZoomUp(LM_Point where);



    void RotateDown(LM_Point where);

    void RotateMoved(LM_Point where);

    void RotateUp(LM_Point where);



    void OrbitDown(LM_Point where);

    void OrbitMoved(LM_Point where);

    void OrbitUp(LM_Point where);



    void DrawPreviewShape();

};



/**********************************************************************/

/*** Miscellaneous Support Stuff ***/



#define MSG_SCRIPT_BASE @ MSG_BASE



class MouseEvent {

    MohoView    *view;



    LM_Point    pt;

    LM_Point    startPt;

    LM_Vector2    vec;

    LM_Vector2    startVec;

    bool        shiftKey;

    bool        ctrlKey;

    bool        altKey;

    real        penPressure;

    bool        doubleClick;

};



class KeyEvent {

    MohoView    *view;



    char        *key;

    int32        keyCode;

    bool        shiftKey;

    bool        ctrlKey;

    bool        altKey;

};



class InputDeviceEvent {

    MohoView    *view;

    

    LM_Message    *inputData;

    bool        shiftKey;

    bool        ctrlKey;

    bool        altKey;

};



/**********************************************************************/

/*** Font Preview View ***/



class LM_FontPreview : public LM_View {

    void SetPreviewText(const char *text);

    void SetFontName(const char *font);

    void Refresh();

};



extern LM_FontPreview *WF_FontPreview @ FontPreview(int32 width, int32 height);



/**********************************************************************/

/*** Mesh Preview View ***/



class LM_MeshPreview : public LM_View {

    M_Mesh *Mesh();

    bool CreateShape(bool filled);

    void AutoZoom();

    void Refresh();

};



extern LM_MeshPreview *WF_MeshPreview @ MeshPreview(int32 width, int32 height);



/**********************************************************************/

/*** Moho Script Interface ***/



extern void RedrawMoho @ Redraw();

extern void NewKeyframe(int32 channel);

extern const char *Localize(const char *str);



class ScriptInterface {

    int32        fFrame @ frame;

    int32        fLayerFrame @ layerFrame;

    MohoDoc        *fDoc @ document;

    MohoLayer    *fLayer @ layer;

    MohoView    *fView @ view;

    bool        fGridOn @ gridOn;

    real        fGridSize @ gridSize;



    void Quit();

    void Click();



    void SetCurFrame(int32 frame);

    void UpdateUI();

    bool IsPlaying();



    bool IsCopyable();

    void Copy(M_Mesh *mesh = NULL);

    void CopyAlternate(M_Mesh *mesh = NULL);

    bool IsPasteable();

    void Paste();

    void PasteAlternate();



    bool CheckIfLocked(MohoLayer *layer, bool showAlert);

    

    void NewKeyframe(int32 channel);

    void UpdateSelectedChannels();



    bool DisableDrawingTools();



    void SetSelLayer(MohoLayer *layer, bool multiSelect = false, bool allowDeselect = true);

    void ShowLayerInLayersPalette(MohoLayer *layer);

    MohoLayer *CreateNewLayer(int32 layerType);

    MohoLayer *DuplicateLayer(MohoLayer *layer);

    void DeleteLayer(MohoLayer *layer);

    void DeleteMultipleLayers();

    void PlaceLayerInGroup(MohoLayer *child, MohoLayer *group, bool top = true);

    void PlaceLayerBehindAnother(MohoLayer *moveLayer, MohoLayer *behindThis);

    MeshLayer *LayerAsVector(MohoLayer *layer);

    ImageLayer *LayerAsImage(MohoLayer *layer);

    GroupLayer *LayerAsGroup(MohoLayer *layer);

    BoneLayer *LayerAsBone(MohoLayer *layer);

    SwitchLayer *LayerAsSwitch(MohoLayer *layer);

    ParticleLayer *LayerAsParticle(MohoLayer *layer);

    Mesh3DLayer *LayerAs3D(MohoLayer *layer);

    AudioLayer *LayerAsAudio(MohoLayer *layer);

    NoteLayer *LayerAsNote(MohoLayer *layer);



    void EditLayerSettings();

    

    M_Mesh *Mesh();

    M_Shape *NewShapeProperties();

    void SnapToGrid(LM_Vector2 &v);

    void AddPointKeyframe(int32 frame, MohoLayer *layer = NULL, bool allSelectedKeys = false);

    int32 CreateShape(bool filled, bool behindNeighborStrokes = false, int32 frame = -1000000, bool checkForBadShapes = true, bool skipDuplicateStrokes = false, bool skipFill = false, bool skipLine = false);

    real NewShapeLineWidth();

        // The following method is deprecated, but remains for older scripts.

        // Use the new void InsertText(int32 lineOffset, InsertTextParams *textParams) method instead

    void InsertText(const char *text, const char *font, bool fill, bool stroke, bool groupTogether, bool centerH, int32 lineOffset);

    void InsertText(InsertTextParams *textParams, int32 lineOffset);

    void PickStyleProperties(M_Shape *fromShape);

    void PushStyleProperties(M_Shape *toShape);



    M_Skeleton *Skeleton();

    M_Skeleton *ParentSkeleton();

    void UpdateBonePointSelection();



    M_Mesh3D *Mesh3D();



    int32 CountAudioLayers();

    AudioLayer *GetAudioLayer(int32 id);



    // coordinate conversions

    real PixelToDoc(real pixel);

    real DocToPixel(real doc);



    int32 CountPoints();

    int32 CountSelectedPoints(bool updateCount = false);

    int32 CountCurves();

    int32 CountSelectedCurves(bool updateCount = false);

    int32 CountEdges();

    int32 CountSelectedEdges(bool updateCount = false);

    int32 CountShapes();

    int32 CountSelectedShapes(bool updateCount = false);



    int32 CountBones();

    int32 CountSelectedBones(bool updateCount = false);



    void CreateTextObject();

    void FillInFontList(LM_TextList *list);



    LM_Vector3 NoiseVector(LM_Vector3 &pos, real amp, real freq);



    void ImportEPS(const char *path);



    const char *AppDir();

    const char *UserAppDir();

    void BeginFileListing(const char *dir, bool listHiddenAndSystemFiles = true);

    const char *GetNextFile();



    MohoDoc *LoadDocument(const char *path);

    void DestroyDocument(MohoDoc *doc);

    

    void OpenPoserPalette();

    

    void FileNew();

    void FileOpen(const char *path);

    void FileSave();

    void FileSaveAs(const char *path);

    void FileImport(const char *path);

    void FileRender(const char *path); // path should end in .bmp, .jpg, .png, or .tga

};



/**********************************************************************/

/*** Script Preference Interface ***/



class ScriptPrefs {

    void SetBool(const char *key, bool value);

    bool GetBool(const char *key, bool defaultValue);



    void SetInt(const char *key, int32 value);

    int32 GetInt(const char *key, int32 defaultValue);



    void SetFloat(const char *key, real value);

    real GetFloat(const char *key, real defaultValue);



    void SetString(const char *key, const char *value);

    const char *GetString(const char *key, const char *defaultValue);

};



} // end MOHO module