private async void OnPlay(object sender, OverlayEventArgs e) { // Destroy overlay e.Overlay.Dispose(); // Un-focus overlay API.SetNuiFocus(false, false); // Position character Game.Player.Character.Position = new Vector3(0f, 0f, 71f); // Load character model while (!await Game.Player.ChangeModel(new Model(PedHash.FreemodeMale01))) { await Delay(10); } Game.Player.Character.Style.SetDefaultClothes(); // Unfreeze Game.Player.Unfreeze(); // Show HUD Screen.Hud.IsVisible = true; // Switch in API.SwitchInPlayer(API.PlayerPedId()); // Release focus hold this.started = true; }
public virtual void OnBeforeDrawingEvent(OverlayEventArgs e) { if (BeforeDrawingEvent != null) { BeforeDrawingEvent(this, e); } }
public virtual void OnAfterDrawingEvent(OverlayEventArgs e) { if (AfterDrawingEvent != null) { AfterDrawingEvent(this, e); } }
private void OnOverlay(object sender, OverlayEventArgs overlayEventArgs) { if (groups.Length > 0 && groups.Contains(overlayEventArgs.group)) return; var button = GetComponent<UIButton>(); if (button != null) { if (overlayEventArgs.activated) { cachedEnable = button.isEnabled; button.isEnabled = false; } else { button.isEnabled = cachedEnable; } } collider.enabled = !overlayEventArgs.activated; }
void MarkerClick(object sender, OverlayEventArgs e) { e.MapCommand = "window.location.replace('/Profile/User.aspx?username="******"')"; }
/// <summary> /// This function preprosses the mako layer /// </summary> /// <param name="input">The input string to parse</param> /// <param name="argument">The argument sent to the parser</param> public String Preprocess(string input, object obj, bool onlyPreprocess = false) { string argument = ""; bool inflate = false; string uri = ""; if (input == null) return ""; #region OverlayManager Experimental /**** * STOCKHOLM 2011-07-01 14:45 * * New feature: Apply custom overlays specified by individual service: * Overlay are marked with <#namespace#> where "namespace" is an special * kind of <namespace>.xml view file inside an <extension_dir>/views/ folder * */ // First gain attention by the event OverlayEventArgs args = new OverlayEventArgs(); // Create event args args.URI = uri; if (RequestOverlay != null) RequestOverlay(this, args); // if the args has retained the phase, eg. not cancelled if (!args.Cancel) { // Substitute the overlay placeholders with the views if(args.ViewFolders != null) foreach (KeyValuePair<string, string> overlay in args.ViewFolders) { using (StreamReader SR = new StreamReader(overlay.Value)) { String content = SR.ReadToEnd(); // Substitute overlay placeholders input = input.Replace("<#" + overlay.Key.Replace(".xml","") + "#>", content); SR.Close(); } } } // Remove unwanted trailings Regex a = new Regex(@"<\#[^\#]*\#>", RegexOptions.IgnoreCase); if(input != null) input = a.Replace(input, ""); #endregion this.RuntimeMachine.SetVariable("data", obj); /** * Begin normal operation * */ // Clear the output buffer Output = ""; /** * Tell the runtime machine about the argument * */ try { String[] arguments = argument.Split(':'); RuntimeMachine.SetVariable("parameter", argument.Replace(arguments[0] + ":", "").Replace(arguments[1] + ":", "")); RuntimeMachine.SetVariable("service", arguments[0]); } catch { } /** * This string defines the call-stack of the query * This is done before any other preprocessing * */ String CallStack = ""; String[] lines = input.Split('\n'); /** * Boolean indicating which parse mode the parser is in, * true = in executable text * false = in output line * */ bool parseMode = false; // Boolean indicating first line is parsing bool firstLine = true; /*** * Iterate through all lines and preprocess the page. * If page starts with an % it will be treated as an preparser code or all content * inside enclosing <? ?> * Two string builders, the first is for the current output segment and the second for the current * executable segmetn * */ StringBuilder outputCode = new StringBuilder(); StringBuilder executableSegment = new StringBuilder(); // The buffer for the final preprocessing output StringBuilder finalOutput = new StringBuilder(); // Append initial case outputCode.Append(""); // Boolean startCase. true = <? false \n% bool startCase = false; // Boolean which tells if the cursor is in the preparse or output part of the buffer (inside or outside an executable segment) bool codeMode = false; for(int i=0; i < input.Length ;i++) { // Check if at an overgoing to an code block if(codeMode) { if((startCase && (input[i] == '?' ||input[i] == '%') && input[i+1] == '>') ||( input[i] == '\n' && !startCase)) { codeMode=false; // Jump forward two times if endcase is ?> if(startCase) i++; // Get the final output string codeOutput = executableSegment.ToString(); // If in JSPython mode, convert all row breaks to ; and other syntax elements if (JSPython) { codeOutput = codeOutput.Replace("\n", ";"); /** * Convert statements * */ codeOutput = codeOutput.Replace(":", "{"); codeOutput = codeOutput.Replace("end", "}"); codeOutput = codeOutput.Replace("\nif ", "\nif("); codeOutput = codeOutput.Replace("then:", "){"); codeOutput = codeOutput.Replace("do:", "){"); codeOutput = codeOutput.Replace("endif", "}"); } codeOutput = codeOutput.Replace("lt;", "<"); codeOutput = codeOutput.Replace("lower than", "<"); codeOutput = codeOutput.Replace("lower", "<"); codeOutput = codeOutput.Replace("higher", ">"); codeOutput = codeOutput.Replace("highter than", ">"); codeOutput = codeOutput.Replace("gt;", ">"); // Append the code data to the string buffer finalOutput.Append(" "+ codeOutput + " "); // Clear outputcode buffer executableSegment = new StringBuilder(); continue; } executableSegment.Append(input[i]); } else { // If at end, summarize the string if(i == input.Length - 1) { // Append the last string outputCode.Append(input[i]); // Format output code (Replace " to ¤ and swap back on preprocessing) String OutputCode = outputCode.ToString().Replace("\"", "¤").Replace("\n", "%BR%\");\n__printx(\""); OutputCode = this.HandleToTokens(OutputCode.ToString(),'@'); finalOutput.Append("__printx(\"" + OutputCode + "\");"); } try { if ((((input[i] == '\n' || input[i] == ' ' || input[i] == '\t') && input[i + 1] == '%' && input[i + 2] != '>')) || (input[i] == '<' && input[i + 1] == '?')) { startCase = (input[i] == '<' && input[i + 1] == '?'); codeMode = true; // Convert tokens to interpretable handles String OutputCode = outputCode.ToString().Replace("\"", "¤").Replace("\n", "%BR%\");\n__printx(\""); OutputCode = this.HandleToTokens(OutputCode.ToString(), '@'); OutputCode = this.HandleToTokens(OutputCode.ToString(), '$'); finalOutput.Append("__printx(\"" + OutputCode + "\");"); // Clear the output code buffer outputCode = new StringBuilder(); // Skip two tokens forward to not include those tokens to the code buffer i += 1; continue; } } catch { continue; } outputCode.Append(input[i]); } } // if exiting in text mode, append an end of the scalar string if (!parseMode) { CallStack += "\");"; } // Run the code RuntimeMachine.RegisterFunction("__printx", (MethodBase)new printx_func(__printx).Method, this); RuntimeMachine.RegisterFunction("synchronize_data", (MethodBase)new synchronize_func(synchronize_data).Method, this); //RuntimeMachine.RegisterFunction("include", (MethodBase)new synchronize_func(include).Method, this); CallStack = finalOutput.ToString(); CallStack = CallStack.Replace("\r", ""); Regex reg = new Regex(@"\#include\(\'(.*?)\'\)"); MatchCollection collection = reg.Matches(CallStack.ToString()); foreach (Match match in collection) { String baseString =match.Captures[0].Value; String c = baseString.Substring(10, baseString.Length - 8 - 4); using (StreamReader sr = new StreamReader(c)) { String newCode = sr.ReadToEnd(); newCode = Preprocess(newCode, obj, true); CallStack = CallStack.Replace(baseString, newCode); } } if (!onlyPreprocess) { /*** * Try run the page. If there was error return ERROR: <error> message so the * handler can choose to present it to the user * */ try { RuntimeMachine.RunCode(CallStack); /** * Check if the result of the preprocessing is the same as before. If nothing * has changed return NONCHANGE. This is only for rendering whole pages, not inflate. * */ if (!inflate) { if (Output == OldOutput) return "NONCHANGE"; OldOutput = Output; } } catch (Exception e) { // using ( System.IO.StreamReader SR = new System.IO.StreamReader("error.xml")) { // return SR.ReadToEnd(); } /*// clear output this.Output = ""; // Load error page using (System.IO.StreamReader SR = new System.IO.StreamReader("views\\error.xml")) { /* string errorView = new MakoEngine().Preprocess(SR.ReadToEnd(), "", false, "", true); RuntimeMachine = new JavaScriptEngine(); RuntimeMachine.SetFunction("__printx", new Func<String, object>(__printx)); RuntimeMachine.SetVariable("error", e.ToString() + "\n " ); RuntimeMachine.RunCode((errorView)); }*/ } return this.Output; } else { return CallStack; } }
/// <summary> /// This function preprosses the mako layer /// </summary> /// <param name="input">The input string to parse</param> /// <param name="argument">The argument sent to the parser</param> public String Preprocess(string input, object obj, bool onlyPreprocess = false) { string argument = ""; bool inflate = false; string uri = ""; if (input == null) { return(""); } #region OverlayManager Experimental /**** * STOCKHOLM 2011-07-01 14:45 * * New feature: Apply custom overlays specified by individual service: * Overlay are marked with <#namespace#> where "namespace" is an special * kind of <namespace>.xml view file inside an <extension_dir>/views/ folder * */ // First gain attention by the event OverlayEventArgs args = new OverlayEventArgs(); // Create event args args.URI = uri; if (RequestOverlay != null) { RequestOverlay(this, args); } // if the args has retained the phase, eg. not cancelled if (!args.Cancel) { // Substitute the overlay placeholders with the views if (args.ViewFolders != null) { foreach (KeyValuePair <string, string> overlay in args.ViewFolders) { using (StreamReader SR = new StreamReader(overlay.Value)) { String content = SR.ReadToEnd(); // Substitute overlay placeholders input = input.Replace("<#" + overlay.Key.Replace(".xml", "") + "#>", content); SR.Close(); } } } } // Remove unwanted trailings Regex a = new Regex(@"<\#[^\#]*\#>", RegexOptions.IgnoreCase); if (input != null) { input = a.Replace(input, ""); } #endregion this.RuntimeMachine.SetVariable("data", obj); /** * Begin normal operation * */ // Clear the output buffer Output = ""; /** * Tell the runtime machine about the argument * */ try { String[] arguments = argument.Split(':'); RuntimeMachine.SetVariable("parameter", argument.Replace(arguments[0] + ":", "").Replace(arguments[1] + ":", "")); RuntimeMachine.SetVariable("service", arguments[0]); } catch { } /** * This string defines the call-stack of the query * This is done before any other preprocessing * */ String CallStack = ""; String[] lines = input.Split('\n'); /** * Boolean indicating which parse mode the parser is in, * true = in executable text * false = in output line * */ bool parseMode = false; // Boolean indicating first line is parsing bool firstLine = true; /*** * Iterate through all lines and preprocess the page. * If page starts with an % it will be treated as an preparser code or all content * inside enclosing <? ?> * Two string builders, the first is for the current output segment and the second for the current * executable segmetn * */ StringBuilder outputCode = new StringBuilder(); StringBuilder executableSegment = new StringBuilder(); // The buffer for the final preprocessing output StringBuilder finalOutput = new StringBuilder(); // Append initial case outputCode.Append(""); // Boolean startCase. true = <? false \n% bool startCase = false; // Boolean which tells if the cursor is in the preparse or output part of the buffer (inside or outside an executable segment) bool codeMode = false; for (int i = 0; i < input.Length; i++) { // Check if at an overgoing to an code block if (codeMode) { if ((startCase && (input[i] == '?' || input[i] == '%') && input[i + 1] == '>') || (input[i] == '\n' && !startCase)) { codeMode = false; // Jump forward two times if endcase is ?> if (startCase) { i++; } // Get the final output string codeOutput = executableSegment.ToString(); // If in JSPython mode, convert all row breaks to ; and other syntax elements if (JSPython) { codeOutput = codeOutput.Replace("\n", ";"); /** * Convert statements * */ codeOutput = codeOutput.Replace(":", "{"); codeOutput = codeOutput.Replace("end", "}"); codeOutput = codeOutput.Replace("\nif ", "\nif("); codeOutput = codeOutput.Replace("then:", "){"); codeOutput = codeOutput.Replace("do:", "){"); codeOutput = codeOutput.Replace("endif", "}"); } codeOutput = codeOutput.Replace("lt;", "<"); codeOutput = codeOutput.Replace("lower than", "<"); codeOutput = codeOutput.Replace("lower", "<"); codeOutput = codeOutput.Replace("higher", ">"); codeOutput = codeOutput.Replace("highter than", ">"); codeOutput = codeOutput.Replace("gt;", ">"); // Append the code data to the string buffer finalOutput.Append(" " + codeOutput + " "); // Clear outputcode buffer executableSegment = new StringBuilder(); continue; } executableSegment.Append(input[i]); } else { // If at end, summarize the string if (i == input.Length - 1) { // Append the last string outputCode.Append(input[i]); // Format output code (Replace " to ¤ and swap back on preprocessing) String OutputCode = outputCode.ToString().Replace("\"", "¤").Replace("\n", "%BR%\");\n__printx(\""); OutputCode = this.HandleToTokens(OutputCode.ToString(), '@'); finalOutput.Append("__printx(\"" + OutputCode + "\");"); } try { if ((((input[i] == '\n' || input[i] == ' ' || input[i] == '\t') && input[i + 1] == '%' && input[i + 2] != '>')) || (input[i] == '<' && input[i + 1] == '?')) { startCase = (input[i] == '<' && input[i + 1] == '?'); codeMode = true; // Convert tokens to interpretable handles String OutputCode = outputCode.ToString().Replace("\"", "¤").Replace("\n", "%BR%\");\n__printx(\""); OutputCode = this.HandleToTokens(OutputCode.ToString(), '@'); OutputCode = this.HandleToTokens(OutputCode.ToString(), '$'); finalOutput.Append("__printx(\"" + OutputCode + "\");"); // Clear the output code buffer outputCode = new StringBuilder(); // Skip two tokens forward to not include those tokens to the code buffer i += 1; continue; } } catch { continue; } outputCode.Append(input[i]); } } // if exiting in text mode, append an end of the scalar string if (!parseMode) { CallStack += "\");"; } // Run the code RuntimeMachine.RegisterFunction("__printx", (MethodBase) new printx_func(__printx).Method, this); RuntimeMachine.RegisterFunction("synchronize_data", (MethodBase) new synchronize_func(synchronize_data).Method, this); //RuntimeMachine.RegisterFunction("include", (MethodBase)new synchronize_func(include).Method, this); CallStack = finalOutput.ToString(); CallStack = CallStack.Replace("\r", ""); Regex reg = new Regex(@"\#include\(\'(.*?)\'\)"); MatchCollection collection = reg.Matches(CallStack.ToString()); foreach (Match match in collection) { String baseString = match.Captures[0].Value; String c = baseString.Substring(10, baseString.Length - 8 - 4); using (StreamReader sr = new StreamReader(c)) { String newCode = sr.ReadToEnd(); newCode = Preprocess(newCode, obj, true); CallStack = CallStack.Replace(baseString, newCode); } } if (!onlyPreprocess) { /*** * Try run the page. If there was error return ERROR: <error> message so the * handler can choose to present it to the user * */ try { RuntimeMachine.RunCode(CallStack); /** * Check if the result of the preprocessing is the same as before. If nothing * has changed return NONCHANGE. This is only for rendering whole pages, not inflate. * */ if (!inflate) { if (Output == OldOutput) { return("NONCHANGE"); } OldOutput = Output; } } catch (Exception e) { // using ( System.IO.StreamReader SR = new System.IO.StreamReader("error.xml")) { // return SR.ReadToEnd(); } /*// clear output * this.Output = ""; * // Load error page * using (System.IO.StreamReader SR = new System.IO.StreamReader("views\\error.xml")) * { * /* string errorView = new MakoEngine().Preprocess(SR.ReadToEnd(), "", false, "", true); * RuntimeMachine = new JavaScriptEngine(); * RuntimeMachine.SetFunction("__printx", new Func<String, object>(__printx)); * RuntimeMachine.SetVariable("error", e.ToString() + "\n " ); * * RuntimeMachine.RunCode((errorView)); * }*/ } return(this.Output); } else { return(CallStack); } }
private void OnDisconnect(object sender, OverlayEventArgs e) { this.Rpc.Event(SessionEvents.DisconnectPlayer).Trigger("Thanks for playing"); }
private void OnDisconnect(object sender, OverlayEventArgs e) { this.Comms.Event(SessionEvents.DisconnectPlayer).ToServer().Emit("Thanks for playing"); }