/// <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"]; }
/// <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; }
/// <summary> /// Load the col file into memory /// </summary> public void Load() { if (this.col != null) { return; } this.col = MtaClient.EngineLoadCOL(this.filepath); }
/// <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); }
/// <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); }
/// <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); }
/// <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)); }
/// <summary> /// Loads the DFF file into memory /// </summary> public void Load() { if (this.dff != null) { return; } this.dff = MtaClient.EngineLoadDFF(this.filepath); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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)); }
/// <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); }
/// <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)); }
/// <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)); }
/// <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); }
/// <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); }
/// <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)); } }
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)); } }
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)); } }
/// <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)); }
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)); } }
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)); }
/// <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)); }
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)); }
/// <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); }
/// <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); }