Advertisement
EduardogomeS_r

GLARE HEADER (ANIMATED GLOBE ICON)

Jun 22nd, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.47 KB | None | 0 0
  1. /* All Credits to KRYPTUS, just a copy from your NGU post.
  2.  
  3. Noticed more and more menu developers are figuring this out and adding it, figured why not share. It's all fairly simple to begin with but I included some notes and explanations so people actually know how what they're copy & pasting does for once. I was going to initially post this on the C++ thread as most things are posted but nowadays any actual content or tutorials posted there just gets lost. One night a few weeks ago I spent a few late hours looking for this. I didn't really intend to use it (until I tried it and liked it), friends were asking about it and I was curious. I figured out the placement and structure of essentially every other component of the menus except for the header. The next morning I spent 5 minutes and found it. Hope some who were looking for it enjoy using it!
  4. */
  5. //With Glare Rotation
  6.  
  7. // Global variable(s)
  8. scaleform gGlareHandle; // int
  9. float gGlareDir;
  10.  
  11. // Function(s)
  12. float conv360(float base, float min, float max) {
  13.     // This is the function the script used. I just adapted it for C++.
  14.     float fVar0;
  15.     if (min == max) return min;
  16.     fVar0 = max - min;
  17.     base -= round(base - min / fVar0) * fVar0;
  18.     if (base < min) base += fVar0;
  19.     return base;
  20. }
  21. void drawGlare(float pX, float pY, float sX = 1, float sY = 1, int r = 255, int g = 255, int b = 255) {
  22.     // Request the scaleform
  23.     gGlareHandle = REQUEST_SCALEFORM_MOVIE("MP_MENU_GLARE");
  24.     // Get Player Camera Rotation
  25.     Vector3 rot = _GET_GAMEPLAY_CAM_ROT(2);
  26.     // Calculate Glare Rotation
  27.     float dir = conv360(rot.z, 0, 360);
  28.     // Check if custom rotation is necessary for the rotation component.
  29.     if ((gGlareDir == 0 || gGlareDir - dir > 0.5) || gGlareDir - dir < -0.5) {
  30.         // Set global variable to current direction
  31.         gGlareDir = dir;
  32.         // Open Data Slot Function
  33.         _PUSH_SCALEFORM_MOVIE_FUNCTION(gGlareHandle, "SET_DATA_SLOT");
  34.         // Set Data Slot Value/Parameter
  35.         _PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_FLOAT(gGlareDir);
  36.         // Close Data Slot Function
  37.         _POP_SCALEFORM_MOVIE_FUNCTION_VOID();
  38.     }
  39.     // Draw Scaleform
  40.     DRAW_SCALEFORM_MOVIE(gGlareHandle, pX, pY, sX, sY, r, g, b, 255, 0); // Custom positioning & size
  41.     // DRAW_SCALEFORM_MOVIE_FULLSCREEN(gGlareHandle, r, g, b, 255, 0); // Default positioning & size
  42. }
  43.  
  44. // When you want it gone, call this. If you don't, opening the Interaction Menu will cause measurements to break when you try to draw this again.
  45. SET_SCALEFORM_MOVIE_AS_NO_LONGER_NEEDED(&gGlareHandle);
  46.  
  47. //Without Glare Rotation (simpler)
  48.  
  49. // Global variable(s)
  50. scaleform gGlareHandle; // int
  51.  
  52. // Function(s)
  53. void drawGlare(float pX, float pY, float sX = 1, float sY = 1, int r = 255, int g = 255, int b = 255) {
  54.     // Request the scaleform
  55.     gGlareHandle = REQUEST_SCALEFORM_MOVIE("MP_MENU_GLARE");
  56.     // Draw Scaleform
  57.     DRAW_SCALEFORM_MOVIE(gGlareHandle, pX, pY, sX, sY, r, g, b, 255, 0); // Custom positioning & size
  58.     // DRAW_SCALEFORM_MOVIE_FULLSCREEN(gGlareHandle, r, g, b, 255, 0); // Default positioning & size
  59. }
  60.  
  61. // When you want it gone, call this. If you don't, opening the Interaction Menu will cause measurements to break when you try to draw this again.
  62. SET_SCALEFORM_MOVIE_AS_NO_LONGER_NEEDED(&gGlareHandle);
  63.  
  64.  
  65. #Note: Positioning is based on the original placement as it's origin. It doesn't have the same measurements as normal text & rects do. Same for size, the default is 1, I believe.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement