Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* All Credits to KRYPTUS, just a copy from your NGU post.
- 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!
- */
- //With Glare Rotation
- // Global variable(s)
- scaleform gGlareHandle; // int
- float gGlareDir;
- // Function(s)
- float conv360(float base, float min, float max) {
- // This is the function the script used. I just adapted it for C++.
- float fVar0;
- if (min == max) return min;
- fVar0 = max - min;
- base -= round(base - min / fVar0) * fVar0;
- if (base < min) base += fVar0;
- return base;
- }
- void drawGlare(float pX, float pY, float sX = 1, float sY = 1, int r = 255, int g = 255, int b = 255) {
- // Request the scaleform
- gGlareHandle = REQUEST_SCALEFORM_MOVIE("MP_MENU_GLARE");
- // Get Player Camera Rotation
- Vector3 rot = _GET_GAMEPLAY_CAM_ROT(2);
- // Calculate Glare Rotation
- float dir = conv360(rot.z, 0, 360);
- // Check if custom rotation is necessary for the rotation component.
- if ((gGlareDir == 0 || gGlareDir - dir > 0.5) || gGlareDir - dir < -0.5) {
- // Set global variable to current direction
- gGlareDir = dir;
- // Open Data Slot Function
- _PUSH_SCALEFORM_MOVIE_FUNCTION(gGlareHandle, "SET_DATA_SLOT");
- // Set Data Slot Value/Parameter
- _PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_FLOAT(gGlareDir);
- // Close Data Slot Function
- _POP_SCALEFORM_MOVIE_FUNCTION_VOID();
- }
- // Draw Scaleform
- DRAW_SCALEFORM_MOVIE(gGlareHandle, pX, pY, sX, sY, r, g, b, 255, 0); // Custom positioning & size
- // DRAW_SCALEFORM_MOVIE_FULLSCREEN(gGlareHandle, r, g, b, 255, 0); // Default positioning & size
- }
- // 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.
- SET_SCALEFORM_MOVIE_AS_NO_LONGER_NEEDED(&gGlareHandle);
- //Without Glare Rotation (simpler)
- // Global variable(s)
- scaleform gGlareHandle; // int
- // Function(s)
- void drawGlare(float pX, float pY, float sX = 1, float sY = 1, int r = 255, int g = 255, int b = 255) {
- // Request the scaleform
- gGlareHandle = REQUEST_SCALEFORM_MOVIE("MP_MENU_GLARE");
- // Draw Scaleform
- DRAW_SCALEFORM_MOVIE(gGlareHandle, pX, pY, sX, sY, r, g, b, 255, 0); // Custom positioning & size
- // DRAW_SCALEFORM_MOVIE_FULLSCREEN(gGlareHandle, r, g, b, 255, 0); // Default positioning & size
- }
- // 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.
- SET_SCALEFORM_MOVIE_AS_NO_LONGER_NEEDED(&gGlareHandle);
- #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