Guest User

Untitled

a guest
May 15th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. // Somewhere in your setup, do this:
  2. JSObject jsHud = awesomium.WebView.CreateGlobalJavascriptObject("hud");
  3. jsHud.Bind("OnMouseUp", false, OnMouseUp);
  4. jsHud.Bind("OnMouseDown", false, OnMouseDown);
  5. // and use the following JS: http://pastebin.com/sCRk259m
  6.  
  7.  
  8. // Then make some functions:
  9.  
  10. protected void OnMouseDown(object sender, JavascriptMethodEventArgs e)
  11. {
  12.     bool mouseUpOverHUD = e.Arguments[0];
  13.     MouseButton mouseButton = (MouseButton)(int)e.Arguments[1];
  14.    
  15. }
  16.  
  17.  
  18. /// <summary>
  19. /// Handle mouse up everywhere except the controls
  20. /// </summary>
  21. protected void OnMouseUp(object sender, JavascriptMethodEventArgs e)
  22. {
  23.     bool mouseUpOverHUD = e.Arguments[0];
  24.     MouseButton mouseButton = (MouseButton)(int)e.Arguments[1];
  25.     bool clickHandled = mouseUpOverHUD;
  26.  
  27.     if (mouseButton == MouseButton.LEFT)
  28.     {
  29.  
  30.         if (!clickHandled && creatingEntityID != null)
  31.         {
  32.             // Have we just tried to build this guy?
  33.             if (/*mouse.LeftButton == EnhancedButtonState.JUST_RELEASED &&*/ IsValidToBuildHere())
  34.             {
  35.                 // Yes, build this now!
  36.                 BuildStructure();
  37.                 clickHandled = true;
  38.             }
  39.         }
  40.     }
  41.     else if (mouseButton == MouseButton.RIGHT && creatingEntityID != null)
  42.     {
  43.         OnCancelCreation();
  44.     }
  45.  
  46.     if(!clickHandled)
  47.     {
  48.         selectionSystem.OnMouseUp(sender, mouseButton, theMouse);
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment