// // CPT operator / SondeerGame // This source file is (c) by Deltares. // - October 2014 // /// jln - 07-08-2008 /// The "sondeer computer" dialog. class dialogSondeerComputer_GeoMil extends dialogSondeerComp; var automated GeoFrameFullScreen DialogBackground; var automated GUISondeerColumn_GeoMil Column1; var automated GeoLabel AutomaticLabel; var automated GeoButton AutomaticButton; var automated GeoLabel SondeerSpeedLabel; var automated GeoSlider SondeerSpeed; var automated GeoLabel ManualLabel; var automated GeoButton ManualButton; var automated GeoButton FinishButton; var automated GeoButton ExitButton; var automated GeoButton CasingButton; var color RedColor; var color WhiteColor; /// jln - 01-12-2008 Or are we doing some manual work? var bool bManualSonderen; var int manualsondeersteps; /* const GEF_NONE = -1; const GEF_SondeerLengte = 0; const GEF_ConusWeerstand = 1; const GEF_Wrijving = 2; const GEF_Wrijvingsgetal = 3; const GEF_Waterspanning = 4; const GEF_ResultanteHelling = 5; const GEF_HellingNZ = 6; const GEF_HellingOW = 7; const GEF_Diepte = 8; const GEF_Tijd = 9; const GEF_Snelheid = 10; */ /// Number of updates: (for calculating average) var int updates; /// Returns helling value: function float GetHelling() { return Column1.axislabels[4].currentvalue; } /// Set broken state: function SetBroken() { /// Cone broken": GeoPC.PlayerActions.ConusBroken = true; AutomaticButton.MenuStateChange(MSAT_Blurry); AutomaticButton.MenuStateChange(MSAT_Disabled); ManualButton.MenuStateChange(MSAT_Blurry); ManualButton.MenuStateChange(MSAT_Disabled); CasingButton.MenuStateChange(MSAT_Blurry); CasingButton.MenuStateChange(MSAT_Disabled); ExitButton.MenuStateChange(MSAT_Blurry); ExitButton.MenuStateChange(MSAT_Disabled); } function InitComponent(GUIController MyController, GUIComponent MyOwner) { // local SondeerLocation sl; local float ColumnWidth; local float ColumnSpace; Super.InitComponent(MyController, MyOwner); DialogBackground.SwitchToGeoMil(); SondeerFile = "Sondering1"; //// Reset: GeoPC.playeractions.AverageSondeerSpeed = 0.0; GeoPC.playeractions.SondeerDepth = 0.0 ; GeoPC.PlayerActions.CasingDepth = 0 ; GeoPC.PlayerActions.UsingCasing = false; GeoPC.PlayerActions.ManualDepth = 0.0; /// Reset maximum speed: currentmax = 0; /// Set sondeer speed: /// With 10% margi nand some additional fault tolerance. SondeerSpeed.SetValue (RandRange(1.80, 2.40)); if (GeoPC.CurrentSondeerLocation != None) { Log("Current sondeer location: " @ GeoPC.CurrentSondeerLocation); /// Set sondeer file: SondeerFile = GeoPC.CurrentSondeerLocation.SondeerFile; } else { /// We are NOT at a sondeerlocation, tell player and close this dialog. Controller.OpenMenu("GeoInterface.dialogNoSondeerLocation"); Controller.CloseMenu(false); } /// Init colors: WhiteColor = class'Canvas'.static.MakeColor(255,255,225); RedColor = class'Canvas'.static.MakeColor(255,0,0, 255); MaximumLines = int(Localize("Sondering1","linecount",SondeerFile)); ColumnWidth = Column1.WinWidth; ColumnSpace = (1 - (ColumnWidth)) / 3.4; Column1.WinLeft = ColumnSpace + 0.01; Column1.GeoPC = GeoPC; Column1.SetSondeerFile(SondeerFile); if (GeoPC.GetScenarioNumber() == 3) { CasingButton.MenuState = MSAT_Blurry; } else { CasingButton.MenuState = MSAT_Disabled; } sondeertime = 0; setNewSpeed(0); } function Timer() { sondeertime++; InternalSondeerTimeUpdate(); Column1.UpdateData(sondeertime, false); if (bManualSonderen) { /// Decrease step counter, at 0 we will stop: GeoPC.PlayerActions.ManualDepth += 0.1; manualsondeersteps--; } GeoPC.playeractions.AverageSondeerSpeed += SondeerSpeed.Value; updates++; /// Update the depth the player went: GeoPC.playeractions.SondeerDepth = sondeertime / 10.0; /// If steps are zero, stop manual: if (bManualSonderen == true && manualsondeersteps < 0) { setTimer(0); } } function bool OnDraw(Canvas MyCanvas) { Super.OnDraw(MyCanvas); Column1.OnDraw(MyCanvas); return true; } function setNewSpeed(float cmpersecond) { local float speed; /// Calculate speed per second: speed = 1 / cmpersecond; Column1.SetSpeed(cmpersecond); /// Update timer if we are currently busy already. if (bAutomaticSonderen || bManualSonderen) { setTimer(speed, true); } } // wsl: only called by dialogFinishSondering!!!!! function FinalNulMeting() { log("FinalNulMeting!"); setNewSpeed(0); setTimer(0); bAutomaticSonderen = false; AutomaticButton.MenuState = MSAT_Disabled; ManualButton.MenuState = MSAT_Disabled; CasingButton.MenuState = MSAT_Disabled; ExitButton.MenuState = MSAT_Disabled; AllowSelect = false; // this will close dialogFinishSondering Controller.CloseMenu(false); // this will open MenuNulMeting in it's place Controller.OpenMenu("GeoInterface.MenuNulMeting", "after"); FinishButton.Caption = IL8N("send"); } function SetDisplacement(int what, float value) { Column1.SetDisplacementFactor(what, value); } function SondeerSpeedChange(GUIComponent Sender) { local float value; value = GeoSlider(Sender).Value; /// Exceeding max? if (value > currentmax) { currentmax = value; GeoPC.playeractions.maxsondeerspeed = value; } Column1.SetSpeed(value); setNewSpeed(value); } function bool ButtonClick(GUIComponent Sender) { if (Sender == CasingButton) { /// Place casing button: GeoPC.PlayerActions.UsingCasing = true; GeoPC.PlayerActions.CasingDepth = sondeertime; /// Disable button: CasingButton.MenuState = MSAT_Disabled; Controller.OpenMenu("GeoInterface.dialogAlert", IL8N("casingplaced")); } if (Sender == ExitButton) { Controller.OpenMenu("GeoInterface.dialogStopSonderen"); } else if (Sender == Finishbutton) { /// Check if player actually did some sondering already: if (sondeertime == 0) { Controller.OpenMenu("GeoInterface.dialogAlert", IL8N("depthstill0")); return false; } if(!bPerformedFinalNulmeting) { AllowSelect = false; Controller.OpenMenu("GeoInterface.dialogFinishSondering"); } else { /// Calculate average: GeoPC.playeractions.AverageSondeerSpeed /= updates; GeoPC.ClientCloseMenu(true); GeoPC.ClientOpenMenu("GeoInterface.MenuEndGame"); } } else if (Sender == AutomaticButton) { if (bAutomaticSonderen == false) { Log("Start auto"); AutomaticButton.MenuStateChange(MSAT_Focused ); bManualSonderen = false; bAutomaticSonderen = true; setNewSpeed(SondeerSpeed.Value); AutomaticButton.Caption = IL8N("AutoStop"); } else { Log("Stop auto"); AutomaticButton.MenuState = MSAT_Blurry; setNewSpeed(0); setTimer(0, true); bAutomaticSonderen = false; bManualSonderen=false; AutomaticButton.Caption = IL8N("AutoStart"); } } else if (Sender == ManualButton) { /// Do not allow sondering at 0.0 cm/s if (SondeerSpeed.Value == 0) return false; /// Manual sonderen: bManualSonderen = true; /// Disable automatic: AutomaticButton.MenuStateChange(MSAT_Blurry); AutomaticButton.MenuStateChange(MSAT_Disabled); AutomaticButton.MenuStateChange(MSAT_Blurry); //setNewSpeed(0); //setTimer(0); bAutomaticSonderen = false; AutomaticButton.Caption = IL8N("AutoStart"); AutomaticButton.MenuState = MSAT_Blurry; /// Do use the speed: setNewSpeed(SondeerSpeed.Value); /// 50 cm = 5 steps: (+0) manualsondeersteps=4; /// Update once: Timer(); return true; } return true; } defaultproperties { Begin Object Class=GeoFrameFullScreen name=TDialogBackground End Object Begin Object class=GeoLabel Name=TAutomaticLabel IniOption="TAutomaticLabel" WinLeft=0.06 WinTop=0.845 bVisible=false End Object Begin Object Class=GeoButton name=TAutomaticButton OnClick=ButtonClick IniOption="TAutomaticButton" WinWidth=0.22 WinLeft=0.045 WinTop=0.845 End Object Begin Object class=GeoLabel Name=TSondeerSpeedLabel IniOption="TSondeerSpeedLabel" WinLeft=0.03 WinTop=0.895 End Object Begin Object class=GeoSlider Name=TSondeerSpeed WinWidth=0.3 WinLeft=0.03 WinTop=0.92 MinValue=0.0 MaxValue=4.0 OnChange=SondeerSpeedChange End Object Begin Object class=GeoLabel Name=TManualLabel IniOption="TManualLabel" WinLeft=0.4 WinTop=0.845 bVisible=false End Object Begin Object Class=GeoButton name=TManualButton OnClick=ButtonClick IniOption="TManualButton" WinWidth=0.2 WinLeft=0.35 WinTop=0.845 End Object Begin Object Class=GeoButton name=TCasingButton OnClick=ButtonClick IniOption="TCasingButton" WinWidth=0.2 WinLeft=0.58 WinTop=0.845 End Object Begin Object Class=GeoButton name=TFinishButton OnClick=ButtonClick IniOption="TFinishButton" WinLeft=0.83 WinTop=0.845 End Object Begin Object Class=GeoButton name=TExitButton OnClick=ButtonClick StyleName="GeoMenuButton" IniOption="TExitButton" WinLeft=0.83 WinTop=0.9 End Object Begin Object Class=GUISondeerColumn_GeoMil name=TColumn1 OnClick=ButtonClick StyleName="GeoMenuButton" IniOption="TFinishButton" WinLeft=0.1 WinTop=0.02 End Object DialogBackground=TDialogBackground Column1 = TColumn1 Automaticlabel=TAutomaticLabel AutomaticButton=TAutomaticButton SondeerSpeedLabel=TSondeerSpeedLabel SondeerSpeed=TSondeerSpeed ManualLabel=TManualLabel ManualButton=TManualButton CasingButton = TCasingButton ExitButton = TExitButton FinishButton = TFinishButton }