// // CPT operator / SondeerGame // This source file is (c) by Deltares. // - October 2014 // //============================================================================= // Class for MAIN MENU (without background) // The first menu of the game, where you can choose whether you are going to do a trainingslevel, single exercise etc... // - 2 languages // ------------------------------------------------------------ // // © 2006, Geodelft // // Date Id Modification // 2006-10-09 The Created this header // 2006-10-10 The Added correct init for traininglevel // 2006-10-28 gui Bug with language corrected // 2006-11-17 The Disabled language selection // 2006-11-17 The Disabled gamestory // 2006-11-17 The Set version to 1.0.1.1 // 2006-11-17 The Formatted code // 2006-11-29 The Corrected copyright notice // 2006-12-11 The Set version to 1.0.1.2 // 2006-12-11 gui Complete exercise added again (for testing) // 2006-12-13 The Set version to 1.0.2.0 // 2007-02-02 The Added IsReleaseVersion and set it to true // 2007-03-15 The Added IsSingleLevelDemoVersionEN and set it to true // 2007-04-13 The Added IsSingleLevelDemoVersionNL and set it to true // 2007-04-16 The Disabled Single Level Demo // 2007-05-30 wsl Removed AllowClose-OnCanClose system // 2007-05-30 wsl Added bIgnoreEsc system to swallow the Esc-keyevents from submenus // 2008-06-12 wsl Started making different version for Demonstrator //============================================================================= class MenuMainMenu extends GeoGUIPage; var bool bIgnoreEsc; var automated GeoLabel VersionLabel; var automated GeoTitle TitleLabel; var automated GeoFrame DialogBackgroundUpper; var automated GeoFrame DialogBackgroundLower; var automated GeoLabel ScenarioLabel; var automated GeoList ScenarioList; var automated GeoButton StartButton; var automated GeoButton SettingsButton; var automated GeoButton ExitButton; var automated GeoScrollText Scroll_HighScores; var SondeerWagen SpinnyDude; // MUST be set to null when you leave the window var vector SpinnyDudeOffset; var GUIRotatingObject RotatingObject; var vector RotatingOffset; var float ratio; /// jln - 05-08-2008 Init component and language. function InitComponent(GUIController MyController, GUIComponent MyOwner) { Super.InitComponent(MyController, MyOwner); // currently, everything is done in event Opened !! because this is called every time } // when menu opened (first time, but also when returning from settings menu) // make sure all texts are in the right language event Opened(GUIComponent Sender) { local array results; //local Actor a; Super.Opened(Sender); //Log(Sender); //Log("loop"); // ForEach PlayerOwner().AllActors( class'Actor', A) // { // Log(A); // } // overwrite GeoPC variable. The first time the menu opens, this will be a // GeoPlayerControllerIntro. After that, it will be the GeoPlayerController // with the right language settings. log("event Opened main menu; GeoPC set to "$GeoPC$", language is "$GeoPC.GetLanguage()); GeoPC = GeoPlayerController(PlayerOwner()); /// All texts configured by INIOption property InitLanguages(GeoPC.GetLanguage()); /// Add scenarios to listbox ScenarioList.Clear(); ScenarioList.Add(IL8N("scenario1"),"1"); ScenarioList.Add(IL8N("scenario2"),"2"); ScenarioList.Add(IL8N("scenario3"),"3"); ScenarioList.Add(IL8N("scenario4"),"4"); /// Get company name in label VersionLabel.Caption = Localize( "game", "version", "sondeergame"); results = split(Controller.GetCurrentRes(), "x"); log("results[0] = "$results[0]$", results[1] = "$results[1]); ratio = float(results[0]) / float(results[1]); log("ratio = "$ratio); Log(RotatingObject); log("rotating object initialized"); SetTimer(0.01,true); /// jln Get race var: GeoPC.RaceMode = bool(Localize("Game", "RaceMode", "SondeerGame")); if (GeoPC.RaceMode == true) { Log("Race mode enabled!"); Scroll_HighScores.Show(); SetScoreS(); } DialogBackgroundUpper.ChangeFrameStyle("noleft"); DialogBackgroundLower.ChangeFrameStyle("noright"); } //============================================================================= // Date Id Modification // 2006-11-17 The Created this header //============================================================================= function InternalOnClose(optional Bool bCanceled) { Super.OnClose(bCanceled); } //============================================================================= // Date Id Modification // 2006-11-17 The Created this header //============================================================================= event NotifyLevelChange() { if (RotatingObject != None) { RotatingObject.destroy(); RotatingObject = None; } Controller.CloseMenu(true); } event Closed(GUIComponent Sender, bool bCancelled) { super.Closed(Sender, bCancelled); Log("MenuMainMenu - Closed()"); if (RotatingObject != None) { RotatingObject.destroy(); RotatingObject = None; } } function Timer() { /// x = depth, y = left/right, z = height (0=bottom) if(ratio > 1.34) { RotatingOffset = vect(6600,800,650); } else { RotatingOffset = vect(6600,800,800); } RotatingObject.Update(); } //============================================================================= // Date Id Modification // 2006-11-17 The Created this header //============================================================================= function bool MyKeyEvent(out byte Key,out byte State,float delta) { if(Key == 0x1B) // Escape pressed { if(bIgnoreEsc) { bIgnoreEsc = false; return true; } else { ChangeAllow(false); Controller.OpenMenu("GeoInterface.dialogQuitPage"); return true; } } return false; } function bool ButtonClick(GUIComponent Sender) { local string ScenarioFile; local array maps; if (Sender != None && AllowSelect) Log(Sender); Log(Sender.Name); Log(Sender.IniOption); switch(Sender) { case ExitButton: ChangeAllow(false); Controller.OpenMenu("GeoInterface.dialogQuitPage"); break; case StartButton: /// Use scenario file to load the proper map (1-4) later on /// Right now we'll simply use a hardcoded map. ScenarioFile = "Scenario" $ ScenarioList.Get(); /// Set scenario index in player controller: GeoPlayerController(PlayerOwner()).SetScenarioNumber( int(ScenarioList.Get()) ); maps[0] = ""; maps[1] = "Scenario1BoerenErf"; maps[2] = "Scenario2Landaanwinning"; maps[3] = "Scenario3Industrie"; maps[4] = "Scenario4Achterdedijk"; Log( "ScenarioFile: " @ ScenarioFile); Log( "Scenario index: " @ GeoPlayerController(PlayerOwner()).GetScenarioNumber()); GeoPlayerController(PlayerOwner()).Saveconfig(); // PlayerOwner().Consolecommand("OPEN Phase1"); PlayerOwner().Consolecommand("OPEN " $ maps[ int(ScenarioList.Get())] ); Controller.CloseAll(false); break; case SettingsButton: ChangeAllow(false); Controller.OpenMenu("GeoInterface.MenuSettings"); break; } return true; } function bool OnDraw(Canvas MyCanvas) { // local float ix, iy; local vector CamPos, X, Y, Z; local rotator CamRot; local Actor camactor; Super.OnDraw(MyCanvas); // initialize rotating sondeerwagen of appropriate company if (RotatingObject == None) { RotatingObject = PlayerOwner().Spawn(class'GeoInterface.GUIRotatingObject'); RotatingObject.LinkMesh(GeoPlayerController(PlayerOwner()).GetSondeerWagenMesh()); RotatingObject.Skins[0] = GeoPlayerController(PlayerOwner()).GetSondeerWagenSkin(); /// x = depth, y = left/right, z = height (0=bottom) RotatingOffset = vect(6600,800,800); RotatingObject.SetDrawScale(1); RotatingObject.Init(); } /// Render 3d model: //W ScriptLog: 0.00,0.00,110.00 - 515,51897,0 CamPos = vect(-3000,0,160); // -1121 - 64978 - 0 //CamRot = rot(515,51897,0); CamRot.Yaw = 512; CamRot.Pitch = -8192; CamRot.Roll = 0; /// This will ensure that we always have the correct position: PlayerOwner().SetRotation(CamRot); PlayerOwner().SetLocation(CamPos); PlayerOwner().PlayerCalcView(camactor,CamPos,CamRot); camactor.SetRotation(CamRot); camactor.SetLocation(CamPos); PlayerOwner().PlayerCalcView(camactor,CamPos,CamRot); GetAxes(CamRot, X, Y, Z); RotatingObject.SetLocation(CamPos + (RotatingOffset.X * X) + (RotatingOffset.Y * Y) + (RotatingOffset.Z * Z)); PlayerOwner().SetViewTarget(None); // Log(RotatingObject); MyCanvas.DrawActor(RotatingObject, false, true, 45.0); //MyCanvas.Style = ViewPortOwner.Actor.ERenderStyle.STY_Normal; return true; } function array Split(string str, string div) { local array temp; local bool bEOL; local string tempChar; local int precount, curcount, wordcount, strLength; strLength = len(str); bEOL = false; precount = 0; curcount = 0; wordcount = 0; if (strLength == 0) return temp; while(!bEOL) { tempChar = Mid(str, curcount, 1); //go up by 1 count if(tempChar != div) curcount++; else if(tempChar == div) { temp[wordcount] = Mid(str, precount, curcount-precount); wordcount++; precount = curcount + 1; //removes the divider. curcount++; } if(curcount == strLength)//end of string, flush out the final word. { temp[wordcount] = Mid(str, precount, curcount); bEOL = true; } } return temp; } //============================================================================= // Date Id Modification // 2007-02-03 Gui Function for having scores updated //============================================================================= function SetScores() { local int i; local int score; local string playername; local int NumberOfPlayers; local string ToAdd; local GlobalScore GScore; local string wholestring; GScore = new class'GlobalScore'; NumberOfPlayers = GScore.TotalScores.Length; wholestring = ""; Scroll_HighScores.SetContent(" "); for(i = 0; i=0) { ToAdd = ToAdd @" "$score; }else if(score<100 && score >=-10) { ToAdd = ToAdd @" "$score; }else if(score<1000 && score >=-100) { ToAdd = ToAdd @" "$score; }else { ToAdd = ToAdd @" "$score; } ToAdd = ToAdd @" "$ playername; if(i==0) wholestring = wholestring $ ToAdd; //scr_HighScores.AddText(ToAdd); else { wholestring = wholestring $ "|" $ ToAdd; } // scr_HighScores.AddText("|"$ToAdd); } Log("Set text: " @ wholestring); Scroll_HighScores.SetContent(wholestring); } //============================================================================= // Date Id Modification //============================================================================= defaultproperties { Background=Texture'GeoDelft.Backgrounds.BackGround_veld1' AllowSelect = true bAllowedAsLast=true bDisconnectOnOpen=false bIgnoreEsc=true bPersistent=false WinLeft=0.0 WinTop=0.0 WinHeight=1.0 WinWidth=1.0 Begin Object class=GeoTitle Name=TTitleLabel IniOption="TTitleLabel" WinLeft=0.085 WinTop=0.24 End Object Begin Object class=GeoLabel Name=TVersionLabel IniOption="" TextFont="GeoNormalFont" WinLeft=0.74 WinTop=0.93 WinHeight=0.1 RenderWeight=4 End Object Begin Object Class=GeoFrame name=TDialogBackgroundNoLeft WinWidth=0.86 WinLeft=0.0 WinTop=0.08 WinHeight=0.4 End Object Begin Object Class=GeoFrame name=TDialogBackgroundNoRight WinWidth=0.75 WinLeft=0.25 WinTop=0.62 WinHeight=0.34 End Object Begin Object class=GeoLabel Name=TScenarioLabel IniOption="TScenarioLabel" TextFont="GeoNormalFont" WinLeft=0.43 WinTop=0.705 End Object Begin Object class=GeoList Name=TScenarioList WinHeight=0.15 WinLeft=0.40 WinTop=0.74 WinWidth=0.24 End Object Begin Object Class=GeoButton Name=TStartButton OnClick=ButtonClick IniOption="TStartButton" WinLeft=0.7 WinTop=0.70 End Object Begin Object Class=GeoButton Name=TSettingsButton OnClick=ButtonClick IniOption="TSettingsButton" WinLeft=0.7 WinTop=0.77 End Object Begin Object Class=GeoButton Name=TExitButton OnClick=ButtonClick IniOption="TExitButton" WinLeft=0.7 WinTop=0.84 End Object Begin Object Class=GeoScrollText Name=TScroll_HighScores CharDelay=0.0001 EOLDelay=0.001 bNeverFocus=true bVisibleWhenEmpty=true bNoTeletype=false bStripColors=false bVisible=false WinLeft=0.1 WinTop=0.2 WinHeight=0.5 WinWidth=0.5 End Object TitleLabel=TTitleLabel VersionLabel=TVersionLabel DialogBackgroundUpper=TDialogBackgroundNoLeft DialogBackgroundLower=TDialogBackgroundNoRight ScenarioLabel = TScenarioLabel ScenarioList = TScenarioList StartButton = TStartButton SettingsButton = TSettingsButton ExitButton = TExitButton Scroll_HighScores= TScroll_HighScores; //OnClose=InternalOnClose OnKeyEvent=MyKeyEvent }