// September 2015 // Levee Patroller / Dijk Patrouille // This source file is (c) by Deltares. This source file is open source but only available to select users. Do not redistribute without written permission of Stichting Deltares, Delft, The Netherlands. // This header has been automatically generated. //============================================================================= // In game menu for filling in the Diagnosis // Started from MenuObservationReport. // ------------------------------------------------------------ // Created by Maarten van Zomeren // © 2006, GeoDelft // Date Id Modification // 2006 11 22 Zmr Made the quit button an cancel button // 2007 11 13 Zmr Made the esc button not swallow //============================================================================= class MenuDiagnosis extends GUIPage; var string EN_Title, NL_Title, EN_QuestionString, NL_QuestionString; struct AnswerStruct { var string Answers[6]; // max of 8 strings of answers }; var AnswerStruct EN_AnswerString, NL_AnswerString; // one set of answer strings per question var GeoPlayerController GeoPC; var bool bIgnoreEsc; var int AnswersGiven; var float ButtonWidth; var float ButtonHeight; var float ButtonHGap; var float ButtonVGapSmall; var float ButtonVGapLarge; var float BarHeight; var float BarVPos; var float SButtonSize; var float SButtonVGap; var float SButtonHGap; var float TitleLeftGap; function InitComponent(GUIController MyController, GUIComponent MyOwner) { local GUILabel Q1Label; local moCheckBox Q1Buttons[6]; local int i; local GUIButton GButt; Super.InitComponent(MyController, MyOwner); OnKeyEvent = InternalOnKeyEvent; OnClose = InternalOnClose; OnOpen = InternalOnOpen; // Menu Background Controls[0].WinLeft = (1 - Controls[0].WinWidth) / 2; Controls[0].WinTop = (1 - Controls[0].WinHeight) / 2; // QuitButton Controls[1].WinTop = 0.5 - (Controls[0].WinHeight / 2) + SButtonVGap; Controls[1].WinLeft = 0.5 + (Controls[0].WinWidth / 2) - SButtonSize - SButtonHGap; Controls[1].WinWidth = SButtonSize; Controls[1].WinHeight = SButtonSize; // HelpButton Controls[2].WinTop = Controls[1].WinTop; Controls[2].WinLeft = Controls[1].WinLeft - SButtonSize - SButtonHGap; Controls[2].WinWidth = SButtonSize; Controls[2].WinHeight = SButtonSize; // NextButton (OK-Button) Controls[3].WinTop = Controls[0].WinTop + Controls[0].WinHeight - SButtonSize - SButtonVGap; Controls[3].WinLeft = Controls[1].WinLeft-(SButtonSize +SButtonHGap); Controls[3].WinWidth = 2*SButtonSize + SButtonHGap; Controls[3].WinHeight = SButtonSize; GButt = GUIButton(Controls[3]); // Menu Title Controls[4].WinTop = Controls[1].WinTop; Controls[4].WinLeft = 0.5 - (Controls[0].WinWidth / 2) + TitleLeftGap; Controls[4].WinWidth = 0.4; Controls[4].WinHeight = 0.1; Q1Label = GUILabel(Controls[5]); Q1Label.WinTop = Controls[4].WinTop + Controls[4].WinHeight + ButtonVGapLarge; Q1Label.WinLeft = Controls[4].WinLeft; Q1Label.WinWidth = 0.4; Q1Label.WinHeight = 0.02; for(i = 0; i < 6; i++) { Q1Buttons[i] = moCheckBox(Controls[i+6]); Q1Buttons[i].MyCheckBox.OnClick = SetRadioButtons; Q1Buttons[i].MyLabel.bAcceptsInput = true; Q1Buttons[i].MyLabel.OnClick = SetRadioButtons; Q1Buttons[i].WinWidth = 0.2; Q1Buttons[i].WinHeight = 0.02; Q1Buttons[i].WinTop = Q1Label.WinTop + Q1Label.WinHeight + i* Q1Buttons[i].WinHeight + (i+1)*ButtonVGapSmall; Q1Buttons[i].WinLeft = Q1label.WinLeft + ButtonHGap; Q1Buttons[i].myLabel.TextFont = "MidGameButtonFont"; // Q1Buttons[i].myLabel.Caption = "I=" $ i; //Q1Buttons[i].SetFocus(Q1Buttons[i].MyCheckBox); Controls[i+6].bNeverFocus = true; Log("item: " $ i+6 @ Q1Buttons[i] @ Q1Buttons[i].WinTop @ Q1Buttons[i].WinLeft ); } GeoPC=GeoPlayerController(PlayerOwner()); // if(GeoPC!=None) UpdateLanguage(); //else /// log("ERROR WITH TYPE OF GAME"); SetResults(); InternalOnOpen(); //Controls[0].SetFocus(none); //Controls[0].FocusFirst(Controls[0]); } function bool InternalOnKeyEvent(out byte Key, out byte State, float delta) { //must not swallow if( Key == 0x1B) { Controller.ReplaceMenu("GeoSimulator.MenuMarker"); } return true; /*// Swallow first escape key event (key up from key down that opened menu) if(bIgnoreEsc && Key == 0x1B) { bIgnoreEsc = false; return true; } else if (Key ==0x1B ) { GeoPC.InMenu(false); Controller.CloseMenu(); return true; }*/ } function InternalOnClose(optional Bool bCanceled) { Super.OnClose(bCanceled); } event InternalOnOpen () { Controls[12].WinTop = 0; Controls[12].WinLeft = 0; Controls[12].SetVisibility(false); bVisible = true; } function bool InternalOnClick(GUIComponent Sender) { local int i; local PlayerController pc; pc = PlayerOwner(); for(i = 0; i < Controls.length; i++) { if(Sender == Controls[i]) { switch(i) { case 1: // Quit Button //StoreResult(); Controller.ReplaceMenu("GeoSimulator.MenuMarker"); break; case 2: // Help Button Controller.OpenMenu("GeoSimulator.HelpMenuDiagnosis"); bVisible = false; break; case 3: // Previous Button StoreResult(); Controller.ReplaceMenu("GeoSimulator.MenuMarker"); break; } } } return true; } function bool SetRadioButtons(GUIComponent Sender) { local int j; local moCheckBox Abutton; Controls[3].bVisible = true; for(j = 6; j < 12;j++) { Abutton = moCheckBox(Controls[j]); if(Sender == Abutton.MyCheckBox || Sender == Abutton.MyLabel) { Abutton.Checked(true); }else { Abutton.Checked(false); } } return true; } function UpdateLanguage() { local moCheckBox Abutton; local int i; if(GeoPC.Dutch) { GUILabel(Controls[4]).Caption = NL_Title; GUILabel(Controls[5]).Caption = NL_QuestionString; for(i = 6; i < 12; i++) { Log("NL: " $ i-6 @ NL_AnswerString.Answers[i-6]); Abutton = moCheckBox(Controls[i]); Abutton.myLabel.Caption = " " $ NL_AnswerString.Answers[i-6]; //Abutton.SetFocus(none); } } else { GUILabel(Controls[4]).Caption = EN_Title; GUILabel(Controls[5]).Caption = EN_QuestionString; for(i = 6; i < 12; i++) { Abutton = moCheckBox(Controls[i]); Abutton.myLabel.Caption = " " $ EN_AnswerString.Answers[i-6]; } } } function SetResults() { local int i; //when no radiobutton is checked, hide the ok-button if(GeoPC.NearByMarker.Mechanism == FM_None){ Controls[3].bVisible = false; for(i = 6;i<12;i++ ) { if(moCheckBox(controls[i]).bChecked) { Controls[3].bVisible = true; } } }else{ Controls[3].bVisible = true; } if(GeoPC.NearByMarker.Mechanism == FM_Piping) { SetRadioButtons(moCheckBox(controls[6]).MyCheckBox); }else if (GeoPC.NearByMarker.Mechanism == FM_Micro) { SetRadioButtons(moCheckBox(controls[7]).MyCheckBox); }else if (GeoPC.NearByMarker.Mechanism == FM_Macro) { SetRadioButtons(moCheckBox(controls[8]).MyCheckBox); }else if (GeoPC.NearByMarker.Mechanism == FM_ErosionInner || GeoPC.NearByMarker.Mechanism == FM_ErosionInnerMicro ) { SetRadioButtons(moCheckBox(controls[9]).MyCheckBox); }else if (GeoPC.NearByMarker.Mechanism == FM_ErosionOuterFloatingWaste || GeoPC.NearByMarker.Mechanism == FM_ErosionOuterRipRap) { SetRadioButtons(moCheckBox(controls[10]).MyCheckBox); }else if (GeoPC.NearByMarker.Mechanism == FM_WaterQuality) { SetRadioButtons(moCheckBox(controls[11]).MyCheckBox); } } function StoreResult() { if(moCheckBox(controls[6]).IsChecked()) { GeoPC.NearByMarker.Mechanism = FM_Piping; } else if (moCheckBox(controls[7]).IsChecked()) { GeoPC.NearByMarker.Mechanism = FM_Micro; } else if (moCheckBox(controls[8]).IsChecked()) { GeoPC.NearByMarker.Mechanism = FM_Macro; } else if (moCheckBox(controls[9]).IsChecked()) { if(GeoPC.NearByMarker.LTile != none) { if((GeoPC.NearByMarker.LTile).Mechanism == FM_ErosionInner) { GeoPC.NearByMarker.Mechanism = FM_ErosionInner; }else if((GeoPC.NearByMarker.LTile).Mechanism == FM_ErosionInnerMicro) { GeoPC.NearByMarker.Mechanism = FM_ErosionInnerMicro; }else { GeoPC.NearByMarker.Mechanism = FM_ErosionInner; } }else { GeoPC.NearByMarker.Mechanism = FM_ErosionInner; } } else if (moCheckBox(controls[10]).IsChecked()) { if(GeoPC.NearByMarker.LTile != none) { if((GeoPC.NearByMarker.LTile).Mechanism == FM_ErosionOuterFloatingWaste) { GeoPC.NearByMarker.Mechanism = FM_ErosionOuterFloatingWaste; }else if((GeoPC.NearByMarker.LTile).Mechanism == FM_ErosionOuterRipRap) { GeoPC.NearByMarker.Mechanism = FM_ErosionOuterRipRap; }else { GeoPC.NearByMarker.Mechanism = FM_ErosionOuterRipRap; } }else { GeoPC.NearByMarker.Mechanism = FM_ErosionOuterRipRap; } } else if (moCheckBox(controls[11]).IsChecked()) { GeoPC.NearByMarker.Mechanism = FM_WaterQuality; } else { GeoPC.NearByMarker.Mechanism = FM_None; } GeoPC.geoFb.logDiagnosis(GeoPC.NearByMarker.name, GeoPC.NearByMarker.Mechanism); } defaultproperties { Begin Object Class=GUIButton name=Background WinWidth=0.60 WinHeight=0.50 bAcceptsInput=false bNeverFocus=true StyleName="GeoCallBar" End Object Controls(0)=GUIButton'Background' Begin Object Class=GUIGFxButton Name=QuitButton Caption="" Graphic=Material'InGameMenuImagesT.NoBackgroundButtons.Closed' Position=ICP_Scaled StyleName="MidGameButton_Orange" OnClick=InternalOnClick bNeverFocus=true End Object Controls(1)=GUIButton'QuitButton' Begin Object Class=GUIGFxButton Name=HelpButton Caption="" Graphic=Material'InGameMenuImagesT.NoBackgroundButtons.Questionmark' Position=ICP_Scaled StyleName="MidGameButton" bNeverFocus=true OnClick=InternalOnClick End Object Controls(2)=GUIButton'HelpButton' Begin Object Class=GUIButton Name=Ok Caption="Ok" StyleName="MidGameButton" bNeverFocus=true OnClick=InternalOnClick End Object Controls(3)=GUIButton'Ok' Begin Object class=GUILabel Name=MenuTitle Caption="***" TextAlign=TXTA_Left TextColor=(R=255,G=120,B=0,A=255) TextFont="HeaderFont" bMultiLine=true End Object Controls(4)=GUILabel'MenuTitle' // Controls 5 to 30 are the labels for the questions, and the buttons for the possible answers // common properties of all answer buttons Begin Object class=moCheckBox Name=AnswerButton Caption="***" INIOption="@Internal" INIDefault="True" CaptionWidth=1 bSquare=true bFlipped=true bHeightFromComponent=false WinHeight=0.02 //bNeverFocus=true ComponentJustification=TXTA_Left LabelJustification=TXTA_Right End Object // QUESTION 1 Begin Object class=GUILabel Name=Question1Label Caption="***" TextFont="MidGameFont" End Object Controls(5)=GUILabel'Question1Label' Controls(6)=moCheckBox'AnswerButton' Controls(7)=moCheckBox'AnswerButton' Controls(8)=moCheckBox'AnswerButton' Controls(9)=moCheckBox'AnswerButton' Controls(10)=moCheckBox'AnswerButton' Controls(11)=moCheckBox'AnswerButton' Controls(12)=moCheckBox'AnswerButton' //standard variables ButtonWidth=0.2 ButtonHeight=0.04 ButtonHGap=0.025 ButtonVGapLarge=0.03 ButtonVGapSmall=0.02 BarHeight=0.21 BarVPos=0.5 SButtonSize=0.06 SButtonHGap=0.02 SButtonVGap=0.02 TitleLeftGap=0.05 OpenSound=sound'RuntimeInterfaceSounds.SelectDshort' bRequire640x480=false bAllowedAsLast=true bIgnoreEsc = true EN_Title = "Diagnosis report" EN_QuestionString = "What is the type of failure mechanism?" // Note: the following has to be all on one line, unfortunately. Initialisation of a struct in default properties with spaces or enters inbetween will not compile. EN_AnswerString=(Answers[0]="Piping",Answers[1]="Micro-instability",Answers[2]="Macro-instability",Answers[3]="Erosion inner slope",Answers[4]="Erosion outer slope",Answers[5]="Water quality") NL_Title = "Diagnose rapport" NL_QuestionString = "Wat is het type faalmechanisme?" // Note: the following has to be all on one line, unfortunately. Initialisation of a struct in default properties with spaces or enters inbetween will not compile. NL_AnswerString=(Answers[0]="Piping",Answers[1]="Micro-instabiliteit",Answers[2]="Macro-instabiliteit",Answers[3]="Erosie binnentalud",Answers[4]="Erosie buitentalud",Answers[5]="Waterkwaliteit") }