Exemplo n.º 1
0
        /// <summary>
        /// Update the status
        /// </summary>
        public void Update()
        {
            Dictionary <string, dynamic> t = MtaShared.GetDictionaryFromTable(MtaClient.DxGetStatus(), "System.String", "System.Dynamic");

            TestMode                          = (TestMode)Enum.Parse(typeof(TestMode), t["TestMode"]);
            VideoCardName                     = (string)t["VideoCardName"];
            VideoCardRAM                      = (int)t["VideoCardRAM"];
            VideoCardPSVersion                = (string)t["VideoCardPSVersion"];
            VideoCardNumRenderTargets         = (int)t["VideoCardNumRenderTargets"];
            VideoCardMaxAnisotropy            = (int)t["VideoCardMaxAnisotropy"];
            VideoMemoryFreeForMTA             = (int)t["VideoMemoryFreeForMTA"];
            VideoMemoryUsedByFonts            = (int)t["VideoMemoryUsedByFonts"];
            VideoMemoryUsedByTextures         = (int)t["VideoMemoryUsedByTextures"];
            VideoMemoryUsedByRenderTargets    = (int)t["VideoMemoryUsedByRenderTargets"];
            SettingWindowed                   = (bool)t["SettingWindowed"];
            SettingFullScreenStyle            = (int)t["SettingFullScreenStyle"];
            SettingFXQuality                  = (int)t["SettingFXQuality"];
            SettingDrawDistance               = (int)t["SettingDrawDistance"];
            SettingVolumetricShadows          = (bool)t["SettingVolumetricShadows"];
            SettingStreamingVideoMemoryForGTA = (int)t["SettingStreamingVideoMemoryForGTA"];
            SettingAnisotropicFiltering       = (int)t["SettingAnisotropicFiltering"];
            SettingAntiAliasing               = (int)t["SettingAntiAliasing"];
            SettingHeatHaze                   = (bool)t["SettingHeatHaze"];
            SettingGrassEffect                = (bool)t["SettingGrassEffect"];
            Setting32BitColor                 = (bool)t["Setting32BitColor"];
            SettingHUDMatchAspectRatio        = (bool)t["SettingHUDMatchAspectRatio"];
            SettingAspectRatio                = (string)t["SettingAspectRatio"];
            SettingFOV                        = (int)t["SettingFOV"];
            SettingHighDetailVehicles         = (bool)t["SettingHighDetailVehicles"];
            AllowScreenUpload                 = (bool)t["AllowScreenUpload"];
            DepthBufferFormat                 = (string)t["DepthBufferFormat"];
            UsingDepthBuffer                  = (bool)t["UsingDepthBuffer"];
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a shader from file or raw data
        /// </summary>
        public Shader(string filePathOrRaw, float priority = 0, float maxDistance = 0, bool layered = false, ShaderElementType shaderElementType = ShaderElementType.All)
        {
            Tuple <MtaElement, string> result = MtaClient.DxCreateShader(filePathOrRaw, priority, maxDistance, layered, shaderElementType.ToString().ToLower());

            materialElement = result.Item1;
            TechniqueName   = result.Item2;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Load the col file into memory
 /// </summary>
 public void Load()
 {
     if (this.col != null)
     {
         return;
     }
     this.col = MtaClient.EngineLoadCOL(this.filepath);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Draw this line
 /// </summary>
 public virtual bool Draw()
 {
     if (Visible)
     {
         return(MtaClient.DxDrawLine3D(StartPosition.X, StartPosition.Y, StartPosition.Z, EndPosition.X, EndPosition.Y, EndPosition.Z, Color.Hex, Width, PostGUI));
     }
     return(false);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Draw this line
 /// </summary>
 public virtual bool Draw(RootElement source, OnRenderEventArgs eventArgs)
 {
     if (Visible)
     {
         return(MtaClient.DxDrawLine3D(StartPosition.X, StartPosition.Y, StartPosition.Z, EndPosition.X, EndPosition.Y, EndPosition.Z, Color.Hex, Width, PostGUI));
     }
     return(false);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Loads the TXD file into memory
 /// </summary>
 /// <param name="filteringEnabled"></param>
 public void Load(bool filteringEnabled = true)
 {
     if (this.txd != null)
     {
         return;
     }
     this.txd = MtaClient.EngineLoadTXD(this.filepath, filteringEnabled);
 }
Exemplo n.º 7
0
        /// <summary>
        /// This function returns the minimum and maximum relative coordinates of an element's bounding box.
        /// </summary>
        public static Tuple <Vector3, Vector3> GetBoundingBox(this PhysicalElement e)
        {
            Tuple <float, float, float, float, float, float> result = MtaClient.GetElementBoundingBox(e.MTAElement);
            Vector3 min = new Vector3(result.Item1, result.Item2, result.Item3);
            Vector3 max = new Vector3(result.Item4, result.Item5, result.Item6);

            return(new Tuple <Vector3, Vector3>(min, max));
        }
Exemplo n.º 8
0
 /// <summary>
 /// Loads the DFF file into memory
 /// </summary>
 public void Load()
 {
     if (this.dff != null)
     {
         return;
     }
     this.dff = MtaClient.EngineLoadDFF(this.filepath);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Remove a grid row
 /// </summary>
 public bool RemoveRow(GridRow row)
 {
     if (MtaClient.GuiGridListRemoveRow(element, row.ID))
     {
         rows.Remove(row.ID);
         return(true);
     }
     return(false);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Remove a grid column
 /// </summary>
 public bool RemoveColumn(GridColumn column)
 {
     if (MtaClient.GuiGridListRemoveColumn(element, column.ID))
     {
         columns.Remove(column.ID);
         return(true);
     }
     return(false);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Remove a specific item from the combo box
 /// </summary>
 public bool RemoveItem(ComboBoxItem item)
 {
     if (MtaClient.GuiComboBoxRemoveItem(element, item.ID))
     {
         items.Remove(item.ID);
         return(true);
     }
     return(false);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Applies the model to the game
        /// </summary>
        /// <param name="model"></param>
        /// <param name="supportsAlpha"></param>
        public void ApplyTo(int model, bool supportsAlpha = false)
        {
            if (this.dff == null)
            {
                throw new Exception(string.Format("DFF file {0} has not yet been loaded", this.filepath));
            }

            MtaClient.EngineReplaceModel(this.dff, model, supportsAlpha);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Applies the collision in the game
        /// </summary>
        /// <param name="model"></param>
        public void ApplyTo(int model)
        {
            if (this.col == null)
            {
                throw new Exception(string.Format("COL file {0} has not yet been loaded", this.filepath));
            }

            MtaClient.EngineReplaceCOL(this.col, model);
        }
Exemplo n.º 14
0
        /// <summary>
        /// This function sets the color of a single pixel for pixels contained in a string. Converts format to plain
        /// </summary>
        public bool SetPixelColor(Vector2 coordinate, Color color)
        {
            if (Format != ImageFormat.plain)
            {
                pixels = Convert(ImageFormat.plain);
            }

            return(MtaClient.DxSetPixelColor(pixels, (int)coordinate.X, (int)coordinate.Y, color.R, color.G, color.B, color.A));
        }
Exemplo n.º 15
0
        /// <summary>
        /// Applies the TXD to the game
        /// </summary>
        /// <param name="model"></param>
        public void ApplyTo(int model)
        {
            if (this.txd == null)
            {
                throw new Exception(string.Format("TXD file {0} has not yet been loaded", this.filepath));
            }

            MtaClient.EngineImportTXD(this.txd, model);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Binds a key to a method
        /// </summary>
        /// <param name="player"></param>
        /// <param name="key"></param>
        /// <param name="state"></param>
        /// <param name="handler"></param>
        /// <returns></returns>
        public static bool BindKey(string key, KeyState state, Action <string, KeyState> handler)
        {
            Action <string, string> rawClosure = (string command, string state) =>
            {
                handler(command, (KeyState)Enum.Parse(typeof(KeyState), state, true));
            };

            closures[handler] = rawClosure;
            return(MtaClient.BindKey(key, state.ToString().ToLower(), rawClosure));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Retrieve the full camera matrix
        /// </summary>
        public Tuple <Vector3, Vector3, float, float> GetFullCameraMatrix()
        {
            Tuple <float, float, float, float, float, float, float, float> result = MtaClient.GetCameraMatrix();
            Vector3 position = new Vector3(result.Item1, result.Item2, result.Item3);
            Vector3 rotation = new Vector3(result.Item4, result.Item5, result.Item6);
            float   roll     = result.Item7;
            float   yaw      = result.Rest;

            return(new Tuple <Vector3, Vector3, float, float>(position, rotation, roll, yaw));
        }
Exemplo n.º 18
0
 /// <summary>
 /// Unbinds a key from a method
 /// </summary>
 /// <param name="player"></param>
 /// <param name="key"></param>
 /// <param name="state"></param>
 /// <param name="handler"></param>
 /// <returns></returns>
 public static bool UnbindKey(string key, KeyState state, Action <string, KeyState> handler)
 {
     if (closures.ContainsKey(handler))
     {
         bool result = MtaClient.UnbindKey(key, state.ToString().ToLower(), closures[handler]);
         closures.Remove(handler);
         return(result);
     }
     return(false);
 }
Exemplo n.º 19
0
        /// <summary>
        /// This function gets the fast fourier transform data for an audio stream which is an array of floats representing the current audio frame.
        /// </summary>
        public float[] GetFftData(int iSamples = 512, int iBands = 0)
        {
            Dictionary <int, float> raw = MtaShared.GetDictionaryFromTable(MtaClient.GetSoundFFTData(element, iSamples, iBands), "System.Int32", "System.Single");

            float[] fftData = new float[raw.Count];
            foreach (KeyValuePair <int, float> pair in raw)
            {
                fftData[pair.Key] = pair.Value;
            }
            return(fftData);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Draw this material line
 /// </summary>
 public override bool Draw(RootElement source, OnRenderEventArgs eventArgs)
 {
     if (FaceToward == Vector3.Zero)
     {
         return(MtaClient.DxDrawMaterialLine3D(StartPosition.X, StartPosition.Y, StartPosition.Z, EndPosition.X, EndPosition.Y, EndPosition.Z, Material?.MaterialElement, Width, Color.Hex, PostGUI));
     }
     else
     {
         return(MtaClient.DxDrawMaterialLine3D(StartPosition.X, StartPosition.Y, StartPosition.Z, EndPosition.X, EndPosition.Y, EndPosition.Z, Material?.MaterialElement, Width, Color.Hex, PostGUI, FaceToward.X, FaceToward.Y, FaceToward.Z));
     }
 }
Exemplo n.º 21
0
 public bool Draw(RootElement source, OnRenderEventArgs eventArgs)
 {
     if (useCustomFont)
     {
         return(MtaClient.DxDrawText(Content, Position.X, Position.Y, BottomRight.X, BottomRight.Y, Color.Hex, Scale.X, Scale.Y, CustomFont.MTAFont, HorizontalAlignment.ToString().ToLower(), VerticalAlignment.ToString().ToLower(), Clip, WordBreak, PostGUI, ColorCoded, SubPixelPositioning, Rotation, RotationOrigin.X, RotationOrigin.Y));
     }
     else
     {
         return(MtaClient.DxDrawText(Content, Position.X, Position.Y, BottomRight.X, BottomRight.Y, Color.Hex, Scale.X, Scale.Y, StandardFont.ToString().ToLower(), HorizontalAlignment.ToString().ToLower(), VerticalAlignment.ToString().ToLower(), Clip, WordBreak, PostGUI, ColorCoded, SubPixelPositioning, Rotation, RotationOrigin.X, RotationOrigin.Y));
     }
 }
Exemplo n.º 22
0
 public override bool Draw(RootElement source, OnRenderEventArgs eventArgs)
 {
     if (usePath)
     {
         return(MtaClient.DxDrawImageSection(Position.X, Position.Y, Dimensions.X, Dimensions.Y, SectionTopLeft.X, SectionTopLeft.Y, SectionDimensions.X, SectionDimensions.Y, FilePath, Rotation, RotationCenter.X, RotationCenter.Y, Color.Hex, PostGUI));
     }
     else
     {
         return(MtaClient.DxDrawImageSection(Position.X, Position.Y, Dimensions.X, Dimensions.Y, SectionTopLeft.X, SectionTopLeft.Y, SectionDimensions.X, SectionDimensions.Y, Material?.MaterialElement, Rotation, RotationCenter.X, RotationCenter.Y, Color.Hex, PostGUI));
     }
 }
 /// <summary>
 /// Draw this line
 /// </summary>
 public override bool Draw()
 {
     if (FaceToward == Vector3.Zero)
     {
         return(MtaClient.DxDrawMaterialSectionLine3D(StartPosition.X, StartPosition.Y, StartPosition.Z, EndPosition.X, EndPosition.Y, EndPosition.Z, UV.X, UV.Y, UVDimensions.X, UVDimensions.Y, Material?.MaterialElement, Width, Color.Hex, PostGUI));
     }
     else
     {
         return(MtaClient.DxDrawMaterialSectionLine3D(StartPosition.X, StartPosition.Y, StartPosition.Z, EndPosition.X, EndPosition.Y, EndPosition.Z, UV.X, UV.Y, UVDimensions.X, UVDimensions.Y, Material?.MaterialElement, Width, Color.Hex, PostGUI, FaceToward.X, FaceToward.Y, FaceToward.Z));
     }
 }
Exemplo n.º 24
0
 /// <summary>
 /// Set a named parameter to compound values
 /// </summary>
 public bool SetValue(string parameterName, params dynamic[] values)
 {
     /*
      * [[
      *  do
      *          return SlipeMtaDefinitions.MtaClient.DxSetShaderValue(this.materialElement, parameterName, unpack(values))
      *  end
      * ]]
      */
     return(MtaClient.DxSetShaderValue(materialElement, parameterName, values));
 }
Exemplo n.º 25
0
 public virtual bool Draw(RootElement source, OnRenderEventArgs eventArgs)
 {
     if (usePath)
     {
         return(MtaClient.DxDrawImage(Position.X, Position.Y, Dimensions.X, Dimensions.Y, FilePath, Rotation, RotationCenter.X, RotationCenter.Y, Color.Hex));
     }
     else
     {
         return(MtaClient.DxDrawImage(Position.X, Position.Y, Dimensions.X, Dimensions.Y, Material?.MaterialElement, Rotation, RotationCenter.X, RotationCenter.Y, Color.Hex));
     }
 }
Exemplo n.º 26
0
        public static bool DrawPrimitive(PrimitiveType primitiveType, List <Vertice> vertices, bool postGui = false)
        {
            List <Vector2> vectors = new List <Vector2>();
            List <int>     colors  = new List <int>();

            foreach (Vertice vertice in vertices)
            {
                vectors.Add(vertice.Position);
                colors.Add(vertice.Color.Hex);
            }

            return(MtaClient.DxDrawPrimitive(primitiveType.ToString().ToLower(), postGui, vertices.Count, vectors, colors));
        }
Exemplo n.º 27
0
        /// <summary>
        /// This function gets the color of a single pixel from pixels contained in a string.
        /// </summary>
        public Color GetPixelColor(Vector2 coordinate)
        {
            string p = pixels;

            if (Format != ImageFormat.plain)
            {
                p = Convert(ImageFormat.plain);
            }

            Tuple <int, int, int, int> result = MtaClient.DxGetPixelColor(p, (int)coordinate.X, (int)coordinate.Y);

            return(new Color((byte)result.Item1, (byte)result.Item2, (byte)result.Item3, (byte)result.Item4));
        }
Exemplo n.º 28
0
        private static bool DrawMaterialPrimitiveWithMaterial(PrimitiveType primitiveType, dynamic pathOrMaterial, List <Vertice> vertices, bool postGui = false)
        {
            List <Vector2> vectors  = new List <Vector2>();
            List <int>     colors   = new List <int>();
            List <Vector2> topLefts = new List <Vector2>();

            foreach (Vertice vertice in vertices)
            {
                vectors.Add(vertice.Position);
                colors.Add(vertice.Color.Hex);
                topLefts.Add(vertice.TopLeft);
            }

            return(MtaClient.DxDrawMaterialPrimitive(primitiveType.ToString().ToLower(), pathOrMaterial, postGui, vertices.Count, vectors, colors, topLefts));
        }
Exemplo n.º 29
0
        /// <summary>
        /// Create an empty texture
        /// </summary>
        public Texture(Vector2 dimensions, TextureFormat textureFormat = TextureFormat.Argb, TextureEdge textureEdge = TextureEdge.Wrap, TextureType textureType = TextureType.TwoDimensional, int depth = 1)
        {
            string textureTypeString = "cube";

            if (textureType == TextureType.TwoDimensional)
            {
                textureTypeString = "2d";
            }
            else if (textureType == TextureType.ThreeDimensional)
            {
                textureTypeString = "3d";
            }

            materialElement = MtaClient.DxCreateTexture((int)dimensions.X, (int)dimensions.Y, textureFormat.ToString().ToLower(), textureEdge.ToString().ToLower(), textureTypeString, depth);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Get a list of all classes of a specific element
        /// </summary>
        public List <T> GetByType <T>(Element startAt, bool streamedIn = false) where T : Element
        {
            List <T> elements = new List <T>();

            if (!defaultElementTypeNames.ContainsKey(typeof(T)))
            {
                return(elements);
            }

            List <dynamic> mtaElements = MtaShared.GetListFromTable(MtaClient.GetElementsByType(defaultElementTypeNames[typeof(T)], startAt?.MTAElement, streamedIn), "element");

            foreach (dynamic mtaElement in mtaElements)
            {
                T element = GetElement <T>(mtaElement);
                if (element != null)
                {
                    elements.Add(element);
                }
            }

            return(elements);
        }