TechOFreak

Episode 48 Functions

Aug 18th, 2021
959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.33 KB | None | 0 0
  1. //From my Amnesia Rebirth Tutorial Series
  2. //Episode 48 Main Menus Pt.3! Full Intro!
  3. //https://www.youtube.com/playlist?list=PL4KkjlmOwLwwMVqedCNpi6caUxhgyf8Qr
  4. //-----------------------------------------------------------
  5.  
  6. //Entire main_menu.hps code below
  7.  
  8. #include "interfaces/Map_Interface.hps"
  9. #include "helpers/helper_imgui.hps"
  10. #include "helpers/helper_map.hps"
  11. #include "helpers/helper_game.hps"
  12. #include "helpers/helper_audio.hps"
  13. #include "helpers/helper_effects.hps"
  14. #include "helpers/helper_player.hps"
  15. #include "inputhandler_types.hps"
  16. #include "helpers/helper_imgui_options.hps"
  17. #include "custom/helpers/helper_menu.hps"
  18.  
  19.  
  20. class cScrMap : iScrMap
  21. {
  22.     [volatile] cConfigFile@ mpConfig;
  23.    
  24.     void Setup()
  25.     {
  26.         @mpConfig = cLux_GetUserConfig();
  27.        
  28.         mpConfig.SetBool("Main", "IntroPlayed", mpConfig.GetBool("Main", "IntroPlayed", false));
  29.        
  30.         mpConfig.Save();
  31.         Effect_Fade_Out(0);
  32.     }
  33.    
  34.     bool showIntroMessage1 = false;
  35.     bool showIntroMessage2 = false;
  36.     bool showIntroMessage3 = false;
  37.    
  38.     void OnGui(float afTimeStep){
  39.         introMessage1();
  40.         introMessage2();
  41.         introMessage3();
  42.     }
  43.        
  44.     void PreloadData()
  45.     {
  46.     }
  47.  
  48.     void OnStart()
  49.     {
  50.         if(cLux_ScriptDebugOn())
  51.         {
  52.         }
  53.     }
  54.  
  55.     void OnEnter()
  56.     {  
  57.         PauseMenu_Enabled(false);
  58.         Player_ShowCrossHairIcons(false);
  59.         Music_Play("amb1.ogg", 1.0f, true, eMusicPrio_BgAmb);
  60.        
  61.         if(mpConfig.GetBool("Main", "IntroPlayed", false)){
  62.             //Intro has already played
  63.             Effect_Fade_In(1);
  64.             CameraAnimation_Begin("NoCameraAnimation", "", false);
  65.             MainMenu_Show(true);
  66.         }else{
  67.             //Intro hasn't played
  68.             showIntroMessage1 = true;
  69.             Map_AddTimer("Timer_StartCameras", 3.0f, "OnTimer_StartCameras");
  70.         }
  71.     }
  72.    
  73.     int stage = 1;
  74.    
  75.     void OnTimer_StartCameras(const tString &in asTimer){
  76.         if(stage == 1){
  77.             Effect_Fade_In(1);
  78.             CameraAnimation_Begin("IntroAnimation1", "", false);
  79.         }else if(stage == 2){
  80.             Effect_Fade_In(1);
  81.             CameraAnimation_End();
  82.             CameraAnimation_Begin("IntroAnimation2", "", false);
  83.         }else if(stage == 3){
  84.             Effect_Fade_In(1);
  85.             CameraAnimation_End();
  86.             CameraAnimation_Begin("CameraAnimation", "", false);
  87.         }
  88.     }
  89.  
  90.     void OnLeave()
  91.     {
  92.         Player_ShowCrossHairIcons(true);
  93.         Music_Stop(3.0f, eMusicPrio_BgAmb);
  94.     }
  95.    
  96.     bool IntroAnimation1_2_CameraNodePassed(const tString &in asEntity, int alDirection)
  97.     {
  98.         Effect_Fade_Out(0.5f);
  99.         showIntroMessage2 = true;
  100.         stage = 2;
  101.         Map_AddTimer("Timer_StartCameras", 3.0f, "OnTimer_StartCameras");
  102.         return true;
  103.     }
  104.    
  105.     bool IntroAnimation2_2_CameraNodePassed(const tString &in asEntity, int alDirection)
  106.     {
  107.         Effect_Fade_Out(0.5f);
  108.         showIntroMessage3 = true;
  109.         stage = 3;
  110.         Map_AddTimer("Timer_StartCameras", 3.0f, "OnTimer_StartCameras");
  111.         return true;
  112.     }
  113.    
  114.     bool OnAnimatonEnd(const tString &in asEntity, int alDirection)
  115.     {
  116.         MainMenu_Show(true);
  117.         mpConfig.SetBool("Main", "IntroPlayed", true);
  118.         mpConfig.Save();
  119.         return true;
  120.     }
  121.    
  122.     ///////////////////////////////
  123.     //Messages
  124.     ///////////////////////////////
  125.    
  126.     void introMessage1(){
  127.         if(showIntroMessage1){
  128.             float messageFadeTime = 2.0f;
  129.            
  130.             cImGuiLabelData label;
  131.             label.mFontAlign = eFontAlign_Center;
  132.             label.mFont.mvSize = cVector2f(50,50);
  133.             label.mColorBase = ImGui_FadeOscillateColor("label1", cColor(1,1,1,0), cColor(1,1,1,1), messageFadeTime, eEasing_Linear);
  134.            
  135.             ImGui_SetTransCategory("Messages");
  136.             ImGui_DoLabelExt("IntroMessage_1", label, ImGui_NrmPos(0,0,10), ImGui_NrmSize(1,1));
  137.            
  138.             if(label.mColorBase.a == 0) showIntroMessage1 = false;
  139.         }
  140.     }
  141.    
  142.     void introMessage2(){
  143.         if(showIntroMessage2){
  144.             float messageFadeTime = 2.0f;
  145.            
  146.             cImGuiLabelData label;
  147.             label.mFontAlign = eFontAlign_Center;
  148.             label.mFont.mvSize = cVector2f(50,50);
  149.             label.mColorBase = ImGui_FadeOscillateColor("label2", cColor(1,1,1,0), cColor(1,1,1,1), messageFadeTime, eEasing_Linear);
  150.            
  151.             ImGui_SetTransCategory("Messages");
  152.             ImGui_DoLabelExt("IntroMessage_2", label, ImGui_NrmPos(0,0,10), ImGui_NrmSize(1,1));
  153.            
  154.             if(label.mColorBase.a == 0) showIntroMessage2 = false;
  155.         }
  156.     }
  157.    
  158.     void introMessage3(){
  159.         if(showIntroMessage3){
  160.             float messageFadeTime = 2.0f;
  161.            
  162.             cImGuiLabelData label;
  163.             label.mFontAlign = eFontAlign_Center;
  164.             label.mFont.mvSize = cVector2f(50,50);
  165.             label.mColorBase = ImGui_FadeOscillateColor("label3", cColor(1,1,1,0), cColor(1,1,1,1), messageFadeTime, eEasing_Linear);
  166.            
  167.             ImGui_SetTransCategory("Messages");
  168.             ImGui_DoLabelExt("IntroMessage_3", label, ImGui_NrmPos(0,0,10), ImGui_NrmSize(1,1));
  169.            
  170.             if(label.mColorBase.a == 0) showIntroMessage3 = false;
  171.         }
  172.     }
  173.  
  174. }
Advertisement
Add Comment
Please, Sign In to add comment