Пример #1
0
        /// <summary>
        /// Creates a new Font by loading a specifically formatted image.
        /// <para>In versions prior to 0.9.0, LÖVE expects ISO 8859-1 encoding for the glyphs string.</para>
        /// <para>	This function can be slow if it is called repeatedly, such as from Scene.Update. If you need to use a specific resource often, create it once and store it somewhere it can be reused!</para>
        /// </summary>
        /// <param name="filename">The filepath to the image file.</param>
        /// <param name="glyphs">A string of the characters in the image in order from left to right.</param>
        /// <param name="extraspacing">Additional spacing (positive or negative) to apply to each glyph in the Font.</param>
        /// <returns></returns>
        public static Font NewImageFont(string filename, string glyphs, int extraspacing = 0)
        {
            var imageData       = Resource.NewImageData(filename);
            var glyphsBytes     = DllTool.GetNullTailUTF8Bytes(glyphs);
            var rasterizerImage = Font.NewImageRasterizer(imageData, glyphsBytes, extraspacing);

            return(Graphics.NewFont(rasterizerImage));
        }
Пример #2
0
        public static Shader NewShader(string vertexCodeStr, string pixelCodeStr)
        {
            bool gles = IsOpenGLES();

            IntPtr out_shader = IntPtr.Zero;
            string vertexCode, pixelCode;

            Love2dGraphicsShaderBoot.shaderCodeToGLSL(gles, vertexCodeStr, pixelCodeStr, out vertexCode, out pixelCode);
            Love2dDll.wrap_love_dll_graphics_newShader(DllTool.GetNullTailUTF8Bytes(vertexCode), DllTool.GetNullTailUTF8Bytes(pixelCode), out out_shader);
            return(LoveObject.NewObject <Shader>(out_shader));
        }
Пример #3
0
 /// <summary>
 /// Sets the write directory for your game. Note that you can only set the name of the folder to store your files in, not the location.
 /// </summary>
 /// <param name="path">The new identity that will be used as write directory.</param>
 /// <param name="append">Whether the identity directory will be searched when reading a filepath before or after the game's source directory and any currently.
 /// TRUE: results in searching source before searching save directory; FALSE: results in searching game save directory before searching source directorymounted archives.</param>
 public static void SetIdentity(string path, bool append = false)
 {
     SetIdentity(DllTool.GetNullTailUTF8Bytes(path), append);
 }
Пример #4
0
 /// <summary>
 /// <para>Returns a table with the names of files and subdirectories in the specified path. The array is not sorted in any way; the order is undefined.</para>
 /// <para>If the path passed to the function exists in the game and the save directory, it will list the files and directories from both places.</para>
 /// </summary>
 /// <param name="dir">The directory.</param>
 /// <returns></returns>
 public static string[] GetDirectoryItems(string dir)
 {
     return(GetDirectoryItems(DllTool.GetNullTailUTF8Bytes(dir)));
 }
Пример #5
0
 /// <summary>
 /// Gets information about the specified file or directory.
 /// </summary>
 /// <param name="path">The file or directory path to check.</param>
 /// <returns></returns>
 public static FileInfo GetInfo(string path)
 {
     return(GetInfo(DllTool.GetNullTailUTF8Bytes(path)));
 }
Пример #6
0
        /// <summary>
        /// Creates a new FileData object.
        /// </summary>
        /// <param name="contents">The contents of the file.</param>
        /// <param name="filename">The name of the file.</param>
        /// <returns></returns>
        public static FileData NewFileData(byte[] contents, string filename)
        {
            IntPtr out_file;

            Love2dDll.wrap_love_dll_filesystem_newFileData_content(contents, contents.Length, DllTool.GetNullTailUTF8Bytes(filename), out out_file);
            return(LoveObject.NewObject <FileData>(out_file));
        }
Пример #7
0
 /// <summary>
 /// execuate lua code with given file path.
 /// </summary>
 /// <param name="luaCode">file path to execuate</param>
 public static void DoFile(string filepath)
 {
     Love2dDll.wrap_love_dll_luasupport_doFile(DllTool.GetNullTailUTF8Bytes(filepath));
 }
Пример #8
0
 public static bool Unmount(string archive)
 {
     return(Unmount(DllTool.GetNullTailUTF8Bytes(archive)));
 }
Пример #9
0
 public static void _SetRequirePath(string paths)
 {
     _SetRequirePath(DllTool.GetNullTailUTF8Bytes(paths));
 }
Пример #10
0
 /// <summary>
 /// Sends one or more boolean values to a special (uniform) variable inside the shader.
 /// </summary>
 /// <param name="name">Name of the boolean to send to the shader.</param>
 /// <param name="valueArray">Boolean to send to store in the uniform variable.</param>
 public void SendBooleans(string name, params bool[] valueArray)
 {
     SendBooleans(DllTool.GetNullTailUTF8Bytes(name), valueArray);
 }
Пример #11
0
 /// <summary>
 /// WARNNING: incorrect use of this function can carsh program.
 /// <para> params of valueArray.Length should equals columns * rows * count </para>
 /// </summary>
 /// <param name="name">uniform variable name</param>
 /// <param name="valueArray">each float consistute matrix array</param>
 /// <param name="columns">matrix columns</param>
 /// <param name="rows">matrix rows</param>
 /// <param name="count">matrix count</param>
 public void SendMatrix(string name, float[] valueArray, int columns, int rows, int count)
 {
     SendMatrix(DllTool.GetNullTailUTF8Bytes(name), valueArray, columns, rows, count);
 }
Пример #12
0
 /// <summary>
 /// Creates a new FileData object.
 /// </summary>
 /// <param name="contents">The contents of the file.</param>
 /// <param name="filename">The name of the file.</param>
 /// <returns></returns>
 public static FileData NewFileData(byte[] contents, string filename)
 {
     return(NewFileData(contents, DllTool.GetNullTailUTF8Bytes(filename)));
 }
Пример #13
0
 /// <summary>
 /// Sends one or more int values to a special (uniform) variable inside the shader.
 /// </summary>
 /// <param name="name">Name of the int to send to the shader.</param>
 /// <param name="valueArray">Int to send to store in the uniform variable.</param>
 public void SendInts(string name, params int[] valueArray)
 {
     SendInts(DllTool.GetNullTailUTF8Bytes(name), valueArray);
 }
Пример #14
0
 /// <summary>
 /// Sends one or more colors to a special (extern / uniform) vec3 or vec4 variable inside the shader. The color components must be in the range of [0, 1]. The colors are gamma-corrected if global gamma-correction is enabled.
 /// </summary>
 /// <param name="name">The name of the color extern variable to send to in the shader.</param>
 /// <param name="valueArray">A array with red, green, blue, and alpha color components in the range of [0, 1] to send to the extern as a vector.</param>
 public void SendColors(string name, params Vector4[] valueArray)
 {
     SendColors(DllTool.GetNullTailUTF8Bytes(name), valueArray);
 }
Пример #15
0
 /// <summary>
 /// Displays a simple message box with a single 'OK' button.
 /// <para>	This function will pause all execution of the main thread until the user has clicked a button to exit the message box. Calling the function from a different thread may cause love to crash.</para>
 /// </summary>
 /// <param name="title">The title of the message box.</param>
 /// <param name="message">The text inside the message box.</param>
 /// <param name="msgbox_type">The type of the message box.</param>
 /// <param name="attachToWindow">Whether the message box should be attached to the love window or free-floating.</param>
 /// <returns>Whether the message box was successfully displayed.</returns>
 public static bool ShowMessageBox(string title, string message, MessageBoxType msgbox_type = MessageBoxType.Info, bool attachToWindow = true)
 {
     return(ShowMessageBox(DllTool.GetNullTailUTF8Bytes(title), DllTool.GetNullTailUTF8Bytes(message), msgbox_type, attachToWindow));
 }
Пример #16
0
 /// <summary>
 /// Sets the window title.
 /// <para>Constantly updating the window title can lead to issues on some systems and therefore is discouraged.</para>
 /// </summary>
 /// <param name="titleStr">The new window title.</param>
 public static void SetTitle(string titleStr)
 {
     SetTitle(DllTool.GetNullTailUTF8Bytes(titleStr));
 }
Пример #17
0
 /// <summary>
 /// Sets the source of the game, where the code is present. This function can only be called once, and is normally automatically done by LÖVE.
 /// </summary>
 /// <param name="path">Absolute path to the game's source folder.</param>
 public static void SetSource(string path)
 {
     SetSource(DllTool.GetNullTailUTF8Bytes(path));
 }
Пример #18
0
 /// <summary>
 /// Creates a new GlyphData.
 /// </summary>
 /// <param name="rasterizer">The Rasterizer containing the font.</param>
 /// <param name="glyph">The character code of the glyph.</param>
 /// <returns></returns>
 public GlyphData NewGlyphData(Rasterizer rasterizer, string glyph)
 {
     return(NewGlyphData(rasterizer, DllTool.GetNullTailUTF8Bytes(glyph)));
 }
Пример #19
0
 /// <summary>
 /// Mounts a zip file or folder in the game's save directory for reading. It is also possible to mount love.filesystem.getSourceBaseDirectory if the game is in fused mode.
 /// </summary>
 /// <param name="archive">The folder or zip file in the game's save directory to mount.</param>
 /// <param name="mountpoint">The new path the archive will be mounted to.</param>
 /// <param name="appendToPath">Whether the archive will be searched when reading a filepath before or after already-mounted archives. This includes the game's source and save directories.</param>
 /// <returns></returns>
 public static bool Mount(string archive, string mountpoint, bool appendToPath = false)
 {
     return(Mount(DllTool.GetNullTailUTF8Bytes(archive), DllTool.GetNullTailUTF8Bytes(mountpoint), appendToPath));
 }
Пример #20
0
 public bool HasGlyphs(string str)
 {
     return(HasGlyphs(DllTool.GetNullTailUTF8Bytes(str)));
 }
Пример #21
0
 /// <summary>
 /// Initializes FileSystem, will be called internally, so should not be used explictly.
 /// </summary>
 /// <param name="args"></param>
 /// <returns></returns>
 public static bool Init(string args)
 {
     return(Init(DllTool.GetNullTailUTF8Bytes(args)));
 }
Пример #22
0
 public static long _GetLastModified(string filename)
 {
     return(_GetLastModified(DllTool.GetNullTailUTF8Bytes(filename)));
 }
Пример #23
0
 public GlyphData GetGlyphData(string str)
 {
     return(GetGlyphData(DllTool.GetNullTailUTF8Bytes(str)));
 }
Пример #24
0
 /// <summary>
 /// Sends one or more texture to a special (uniform) variable inside the shader.
 /// </summary>
 /// <param name="name">Name of the Texture to send to the shader.(UTF8 byte array)</param>
 /// <param name="texture">Texture (Image or Canvas) to send to the uniform variable.</param>
 public void SendTexture(string name, Texture texture)
 {
     SendTexture(DllTool.GetNullTailUTF8Bytes(name), texture);
 }
Пример #25
0
 /// <summary>
 ///  File which is created when a user drags and drops an actual file onto the
 ///  LOVE game. Uses C's stdio. Filenames are system-dependent full paths.
 /// </summary>
 /// <param name="filename">The filename of the file.</param>
 /// <param name="fmode_type">The mode to open the file in.</param>
 public static File NewDroppedFile(string filename, FileMode fmode_type = FileMode.Read)
 {
     Love2dDll.wrap_love_dll_filesystem_newDroppedFile(DllTool.GetNullTailUTF8Bytes(filename), (int)fmode_type, out IntPtr out_file);
     return(LoveObject.NewObject <File>(out_file));
 }
Пример #26
0
 public void AttachAttribute(string name, Mesh mesh)
 {
     AttachAttribute(DllTool.GetNullTailUTF8Bytes(name), mesh);
 }
Пример #27
0
 /// <summary>
 /// execuate lua code.
 /// </summary>
 /// <param name="luaCode">lua code to execuate</param>
 public static void DoString(string luaCode)
 {
     Love2dDll.wrap_love_dll_luasupport_doString(DllTool.GetNullTailUTF8Bytes(luaCode));
 }
Пример #28
0
 public void SetState(string state)
 {
     SetState(DllTool.GetNullTailUTF8Bytes(state));
 }
Пример #29
0
 public static void PushString(string str)
 {
     Love2dDll.wrap_love_dll_luasupport_pushString(DllTool.GetNullTailUTF8Bytes(str));
 }
Пример #30
0
 /// <summary>
 /// Encodes the ImageData and optionally writes it to the save directory.
 /// </summary>
 /// <param name="format_type">The format to encode the image as.</param>
 /// <param name="filename">The filename to write the file to. If null, no file will be written but the FileData will still be returned.</param>
 /// <returns></returns>
 public FileData Encode(ImageFormat format, string filename = null)
 {
     return(Encode(format, filename != null, DllTool.GetNullTailUTF8Bytes(filename)));
 }