// // CPT operator / SondeerGame // This source file is (c) by Deltares. // - October 2014 // /// jln - 07-08-2008 /// The "sondeer computer" dialog. class dialogSondeerComputer_APBerg extends dialogSondeerComp; var automated GeoFrameFullScreen DialogBackground; 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 GeoLabel SondeerDistanceLabel; var automated GeoSlider SondeerDistance; 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; var GUISondeerColumn columns[4]; var automated GUISondeerColumn Column1; var automated GUISondeerColumn Column2; var automated GUISondeerColumn Column3; var automated GUISondeerColumn Column4; /* 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; */ const FORMAT_GRAPH = 0; const FORMAT_TEXTONLY = 1; /// Do incremental offset. var float incrementaloffsethelling; var float incrementalhellingdirection; /// Number of updates: (for calculating average) var int updates; /// Returns helling value: function float GetHelling() { return Column4.CurrentValue; } /// Set broken state: function SetBroken() { /// Cone broken": GeoPC.PlayerActions.ConusBroken = true; AutomaticButton.SetFocus(none); 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); /// Reset max: currentmax = 0; //// Reset: GeoPC.playeractions.AverageSondeerSpeed = 0.0; GeoPC.playeractions.SondeerDepth = 0.0 ; GeoPC.PlayerActions.CasingDepth = 0 ; GeoPC.PlayerActions.UsingCasing = false; GeoPC.PlayerActions.ManualDepth = 0.0; /// Set sondeer speed: /// With 10% margi nand some additional fault tolerance. SondeerSpeed.SetValue (RandRange(1.80, 2.40)); /// Test, find sondering object and get the current sondeerlocation: // simply get sondeer location for the time being. // ForEach GeoPC.AllActors( class 'SondeerLocation', sl) // { // GeoPC.CurrentSondeerLocation = sl; // } 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); } incrementaloffsethelling = 1; /// Init colors: WhiteColor = class'Canvas'.static.MakeColor(255,255,225); RedColor = class'Canvas'.static.MakeColor(255,0,0, 255); sondeertime = 0; /// Stop at start: // SondeerSpeed.SetValue(0); setNewSpeed(0); bAutomaticSonderen=false; MaximumLines = int(Localize("Sondering1","linecount",SondeerFile)); if (GeoPC.CompanyName == "Fugro") { DialogBackground.SwitchFugro(true); Column1.SetBoxColor(Column1.BlackColor); Column2.SetBoxColor(Column1.BlackColor); Column3.SetBoxColor(Column1.BlackColor); Column4.SetBoxColor(Column1.BlackColor); } else { DialogBackground.SwitchFugro(false); Column1.SetBoxColor(Column1.BlueColor); Column2.SetBoxColor(Column1.BlueColor); Column3.SetBoxColor(Column1.BlueColor); Column4.SetBoxColor(Column1.BlueColor); } ColumnWidth = Column1.WinWidth; ColumnSpace = (1 - (ColumnWidth *4)) / 5; Column1.WinLeft = ColumnSpace; Column2.WinLeft = Column1.WinLeft + Column1.WinWidth + ColumnSpace; Column3.WinLeft = Column2.WinLeft + Column2.WinWidth + ColumnSpace; Column4.WinLeft = Column3.WinLeft + Column3.WinWidth + ColumnSpace; Column1.GeoPC = GeoPC; Column2.GeoPC = GeoPC; Column3.GeoPC = GeoPC; Column4.GeoPC = GeoPC; Column1.SetLabelTop(IL8N("puntweerstand"), "MPa"); Column2.SetLabelTop(IL8N("lokalewrijving"), "MPa"); Column3.SetLabelTop(IL8N("wrijvingsgetal"), " % "); Column4.SetLabelTop(IL8N("helling"), " º "); Column3.WaterSpanningToKPA = true; Column3.SetLabelBottom(IL8N("waterspanning"), " kPa "); Column4.SetLabelBottom(IL8N("snelheid"), " cm/sec "); Column1.SetStatsType(GEF_ConusWeerstand, GEF_Diepte); Column2.SetStatsType(GEF_Wrijving, GEF_NONE); Column3.SetStatsType(GEF_Wrijvingsgetal, GEF_Waterspanning); Column4.SetStatsType(GEF_ResultanteHelling, GEF_Snelheid); Column1.SetSondeerFile(SondeerFile); Column2.SetSondeerFile(SondeerFile); Column3.SetSondeerFile(SondeerFile); Column4.SetSondeerFile(SondeerFile); Column1.SetType(FORMAT_GRAPH, FORMAT_TEXTONLY); /// jln - 18-11-2008 todo, enable/disable it fro mconfig: /// Only enabled in level 3: /// Now only enabled when mpa > 40; if (GeoPC.GetScenarioNumber() == 3) { CasingButton.MenuState = MSAT_Blurry; } else { CasingButton.MenuState = MSAT_Disabled; } //SondeerDistance.Value = 10; } function setNewSpeed(float cmpersecond) { local float speed; /// Calculate speed per second: speed = 1 / cmpersecond; /// Update timer if we are currently busy already. if (bAutomaticSonderen || bManualSonderen) { setTimer(speed, true); } } function Timer() { sondeertime++; InternalSondeerTimeUpdate(); if (bManualSonderen) { /// Decrease step counter, at 0 we will stop: GeoPC.PlayerActions.ManualDepth += 0.1; manualsondeersteps--; } //if (Column1.CurrentValue >= 45) //{ /// Enable casing button when mpa > 45; // CasingButton.MenuState = MSAT_Blurry; // } Column1.UpdateData(sondeertime, false); Column2.UpdateData(sondeertime, false); Column3.UpdateData(sondeertime, false); Column4.UpdateData(sondeertime, false); Column1.UpdateData(sondeertime, true); Column2.UpdateData(sondeertime, true); Column3.UpdateData(sondeertime, true); Column4.UpdateData(sondeertime, true, true, SondeerSpeed.Value); 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); Column2.OnDraw(MyCanvas); Column3.OnDraw(MyCanvas); Column4.OnDraw(MyCanvas); return true; } function SetDisplacement(int what, float value) { /// jln - 15-12-2008 /// Determine which column to use... Geomill version is a lot easier here. if (what == GEF_ConusWeerstand) { column1.SetDisplacementFactor(true, value); return; } if (what == GEF_Wrijving) { column2.SetDisplacementFactor(true, value); return; } if (what == GEF_Wrijvingsgetal) { column3.SetDisplacementFactor(true, value); return; } if (what == GEF_Waterspanning) { column3.SetDisplacementFactor(false, value); return; } if (what == GEF_ResultanteHelling) { column4.SetDisplacementFactor(true, value); return; } Log("Displacement not found: (apberg)" @ what); } function bool ButtonClick(GUIComponent Sender) { // local int i; // local float y; // local bool ret; //if (Sender == None || AllowSelect == false) return false; 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; ///Loop amount of lines necessary. /// 0.1 = 10cm // 1 = 100 cm = 1 m //Log(SondeerDistance.Value); /// 5 lines = 50cm; /* y = 5; //(SondeerDistance.Value / 10) / 3; /// Add manual depth: GeoPC.PlayerActions.ManualDepth += 0.5; // SondeerDistance.Value; // for (i = 0; i < (SondeerDistance.Value / 2)+1; i++) for (i = 0; i < y; i++) { sondeertime++; ret = InternalSondeerTimeUpdate(); Column1.UpdateData(sondeertime, false); Column2.UpdateData(sondeertime, false); Column3.UpdateData(sondeertime, false); Column4.UpdateData(sondeertime, false); Column1.UpdateData(sondeertime, true); Column2.UpdateData(sondeertime, true); Column3.UpdateData(sondeertime, true); Column4.UpdateData(sondeertime, true, true, SondeerSpeed.Value); //sondeertime += y; /// Break : if (ret == false) break; } Log("Sondeertime: " @ sondeertime); */ } return 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 SondeerSpeedChange(GUIComponent Sender) { local float value; value = GeoSlider(Sender).Value; /// Exceeding max? if (value > currentmax) { currentmax = value; GeoPC.playeractions.maxsondeerspeed = value; } setNewSpeed(value); } function SondeerDistanceChange(GUIComponent Sender) { ManualButton.Caption = IL8N("ManualPrefix") @ GeoSlider(Sender).Value $ IL8N("ManualSuffix"); } function OnMouseDown(GUIComponent Sender, bool bRepeat) { log("pressed: " @ Sender @ " " @ bRepeat); } function OnMouseUp(GUIComponent Sender) { Log("release: " @ Sender); } function bool InternalOnKeyEvent(out byte Key, out byte State, float delta) { return true; } defaultproperties { OnMousePressed=OnMouseDown OnMouseRelease=OnMouseUp OnKeyEvent=InternalOnKeyEvent Begin Object Class=GeoFrameFullScreen name=TDialogBackground End Object Begin Object class=GeoLabel Name=TAutomaticLabel IniOption="TAutomaticLabel" WinLeft=0.06 WinTop=0.84 bVisible=false End Object Begin Object Class=GeoButton name=TAutomaticButton OnClick=ButtonClick IniOption="TAutomaticButton" WinWidth=0.22 WinLeft=0.045 WinTop=0.83 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.84 bVisible=false End Object Begin Object Class=GeoButton name=TManualButton OnClick=ButtonClick IniOption="TManualButton" WinWidth=0.2 WinLeft=0.35 WinTop=0.83 End Object Begin Object Class=GeoButton name=TCasingButton OnClick=ButtonClick IniOption="TCasingButton" WinWidth=0.2 WinLeft=0.58 WinTop=0.83 End Object Begin Object class=GeoLabel Name=TSondeerDistanceLabel IniOption="TSondeerDistanceLabel" WinLeft=0.35 WinTop=0.895 bVisible=false End Object Begin Object class=GeoSlider Name=TSondeerDistance WinWidth=0.3 WinLeft=0.35 WinTop=0.92 MinValue=10.0 MaxValue=300.0 Step=10 OnChange=SondeerDistanceChange bVisible=false End Object Begin Object Class=GeoButton name=TFinishButton OnClick=ButtonClick IniOption="TFinishButton" WinLeft=0.83 WinTop=0.83 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 name=TColumn1 OnClick=ButtonClick StyleName="GeoMenuButton" IniOption="TFinishButton" WinLeft=0.025 WinTop=0.02 End Object Begin Object Class=GUISondeerColumn name=TColumn2 OnClick=ButtonClick StyleName="GeoMenuButton" IniOption="TFinishButton" WinLeft=0.45 WinTop=0.02 End Object Begin Object Class=GUISondeerColumn name=TColumn3 OnClick=ButtonClick StyleName="GeoMenuButton" IniOption="TFinishButton" WinLeft=0.55 WinTop=0.02 End Object Begin Object Class=GUISondeerColumn name=TColumn4 OnClick=ButtonClick StyleName="GeoMenuButton" IniOption="TFinishButton" WinLeft=0.80 WinTop=0.02 End Object Column1 = TColumn1 Column2 = TColumn2 Column3 = TColumn3 Column4 = TColumn4 DialogBackground=TDialogBackground Automaticlabel=TAutomaticLabel AutomaticButton=TAutomaticButton SondeerSpeedLabel=TSondeerSpeedLabel SondeerSpeed=TSondeerSpeed ManualLabel=TManualLabel ManualButton=TManualButton CasingButton = TCasingButton SondeerDistanceLabel=TSondeerDistanceLabel SondeerDistance=TSondeerDistance ExitButton = TExitButton FinishButton = TFinishButton }