// 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 choosing the Measure to be taken. // Started from MenuObservationReport. // ------------------------------------------------------------ // Created by Maarten van Zomeren // © 2006, GeoDelft // Date Id Modification // 2007 11 13 Zmr Made the esc button not swallow //============================================================================= // ToDO // * May take measures // * Do something with result // * Put questions on the screen // * Change language class MenuMeasure extends GUIPage dependson(Measure); var string EN_Title, NL_Title; var array EN_QuestionString, NL_QuestionString; struct AnswerStruct { var string Answers[12]; // max of 11 strings of answers }; var AnswerStruct EN_AnswerString, NL_AnswerString; // one set of answer strings per question var RedMarker RMarker; var Conversationstate lastConvState; 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; var bool MayTakeMeasures, ActionCenterAllowedMeasure; function InitComponent(GUIController MyController, GUIComponent MyOwner) { local GUILabel Q1Label; local moCheckBox Q1Buttons[12]; local int i; local GUIButton GButt; local GeoLevelDetails GLD; Super.InitComponent(MyController, MyOwner); log("************************MenuMeasure********************"); 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; Controls[3].SetVisibility(false); 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.6; Q1Label.WinHeight = 0.02; GeoPC=GeoPlayerController(PlayerOwner()); GLD = new class'GeoLevelDetails'; //Is the player allowed to take measures MayTakeMeasures = GLD.TakeMeasures; RMarker = GeoPC.NearByMarker; lastConvState = RMarker.ConvState[RMarker.ConvState.Length-1]; ActionCenterAllowedMeasure = false; if(lastConvState!= none) { if(lastConvState.ConversationStates[lastConvState.ConversationStates.Length-1] == Con_Measure) { ActionCenterAllowedMeasure = true; } } for(i = 0; i < 7; 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.5; Q1Buttons[i].WinHeight = 0.02; if(true) { Q1Buttons[i].WinTop = Q1Label.WinTop + Q1Label.WinHeight + i* Q1Buttons[i].WinHeight + (i+1)*ButtonVGapSmall; Q1Buttons[i].WinLeft = Q1label.WinLeft + ButtonHGap; }else { Q1Buttons[i].WinTop = Q1Buttons[i-6].WinTop; Q1Buttons[i].WinLeft = Q1Buttons[i-6].WinLeft + Q1Buttons[i-6].WinWidth+SButtonHGap; } Q1Buttons[i].myLabel.TextFont = "MidGameButtonFont"; //Q1Buttons[i].SetFocus(Q1Buttons[i].MyCheckBox); Controls[i+6].bNeverFocus = true; if(!MayTakeMeasures || !ActionCenterAllowedMeasure) { log("May nog take measures"); Q1Buttons[i].SetVisibility(false); } } 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 () { bVisible = true; Controls[13].WinTop = 0; Controls[13].WinLeft = 0; Controls[13].SetVisibility(false); //Controls[3].SetVisibility(false); UpdateLanguage(); } 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 Controller.ReplaceMenu("GeoSimulator.MenuMarker"); return true; break; case 2: // Help Button Controller.OpenMenu("GeoSimulator.HelpMenuMeasure"); bVisible = false; return true; break; case 3: // NextButton (OK-Button) Log("Menu Measure - ID 3"); if(moCheckBox(controls[7]).MyCheckBox.MenuState==MSAT_Disabled) { //there was already a measure in place don't go to the levee expert Controller.ReplaceMenu("GeoSimulator.MenuMarker"); } else { StoreResult(); Log("Replace menu"); Controller.ReplaceMenu("GeoSimulator.MenuMeasureActionCenter"); } return true; break; } } } return true; } function bool SetRadioButtons(GUIComponent Sender) { local int j; local moCheckBox Abutton; Controls[3].bVisible = true; for(j = 0; j < 8;j++) { Abutton = moCheckBox(Controls[j+6]); if(Sender == Abutton.MyCheckBox ||sender == Abutton.MyLabel) { Abutton.Checked(true); }else { Abutton.Checked(false); } } return true; } function UpdateLanguage() { local moCheckBox Abutton; local int i; local int QStringNr; if(MayTakeMeasures) { QStringNr = 1; // the player may take measures in this game if(ActionCenterAllowedMeasure) { QStringNr = 2; } }else { // the player may not take measures in this game QStringNr = 0; } if(GeoPC.Dutch) { GUILabel(Controls[4]).Caption = NL_Title; GUILabel(Controls[5]).Caption = NL_QuestionString[QStringNr]; for(i = 0; i < 8; i++) { Abutton = moCheckBox(Controls[i+6]); Abutton.myLabel.Caption = " " $ NL_AnswerString.Answers[i]; //Abutton.SetFocus(none); } } else { GUILabel(Controls[4]).Caption = EN_Title; GUILabel(Controls[5]).Caption = EN_QuestionString[QStringNr]; for(i = 0; i < 8; i++) { Abutton = moCheckBox(Controls[i+6]); Abutton.myLabel.Caption = " " $ EN_AnswerString.Answers[i]; } } } function SetResults() { local Measure MeasureAlreadyTaken; local int i; MeasureAlreadyTaken = RMarker.MeasureTaken; log("MenuMeasure SetResult1"); if(MeasureAlreadyTaken == none) { Controls[3].bVisible = false; for(i = 6;i<13;i++ ) { if(moCheckBox(controls[i]).bChecked) { Controls[3].bVisible = true; } } log("MenuMeasure SetResult2"); }else { Controls[3].bVisible = true; log("MenuMeasure SetResult3"); if(MeasureAlreadyTaken.MeasureType == MEA_CoverInnerSlopeWithFoil ) { SetRadioButtons(moCheckBox(controls[6]).MyCheckBox); log("MenuMeasure SetResult4"); } if(MeasureAlreadyTaken.MeasureType == MEA_CoverOuterSlopeWithFoil ) { SetRadioButtons(moCheckBox(controls[7]).MyCheckBox); log("MenuMeasure SetResult4"); } else if (MeasureAlreadyTaken.MeasureType == MEA_SandBank_SlakeningSlope ) { SetRadioButtons(moCheckBox(controls[8]).MyCheckBox); log("MenuMeasure SetResult5"); } else if (MeasureAlreadyTaken.MeasureType == MEA_RemoveWaste) { SetRadioButtons(moCheckBox(controls[9]).MyCheckBox); log("MenuMeasure SetResult6"); } else if (MeasureAlreadyTaken.MeasureType == MEA_ContainmentRing) { SetRadioButtons(moCheckBox(controls[10]).MyCheckBox); log("MenuMeasure SetResult7"); } else if (MeasureAlreadyTaken.MeasureType == MEA_SandbagsToe) { SetRadioButtons(moCheckBox(controls[11]).MyCheckBox); log("MenuMeasure SetResult9"); } else if (MeasureAlreadyTaken.MeasureType == MEA_SandbagsTop) { SetRadioButtons(moCheckBox(controls[12]).MyCheckBox); log("MenuMeasure SetResult0"); } log("MenuMeasure already taken"); if(MeasureAlreadyTaken.bMeasureTaken) { log("MenuMeasure already taken"); for(i = 6;i<13;i++ ) { moCheckBox(controls[i]).MyCheckBox.MenuState=MSAT_Disabled; moCheckBox(controls[i]).MyLabel.MenuState=MSAT_Disabled; } } } } function StoreResult() { local Measure.EMeasures SelectedMeasureType; local array MeasuresPossible; local Measure MeasureToTake; local int i; log("StoreMeasure1"); if(moCheckBox(controls[6]).IsChecked()) { SelectedMeasureType = MEA_CoverInnerSlopeWithFoil; log("StoreMeasure3"); } else if (moCheckBox(controls[7]).IsChecked()) { SelectedMeasureType = MEA_CoverOuterSlopeWithFoil; } else if (moCheckBox(controls[8]).IsChecked()) { SelectedMeasureType = MEA_SandBank_SlakeningSlope; } else if (moCheckBox(controls[9]).IsChecked()) { SelectedMeasureType = MEA_RemoveWaste; } else if (moCheckBox(controls[10]).IsChecked()) { SelectedMeasureType = MEA_ContainmentRing; } else if (moCheckBox(controls[11]).IsChecked()) { SelectedMeasureType = MEA_SandbagsToe; } else if (moCheckBox(controls[12]).IsChecked()) { SelectedMeasureType = MEA_SandbagsTop; } if(RMarker.LTile != none) { if((RMarker.LTile).CurrentState == STA_Critical) { // look through all possible measures for this failure, and see if the // measure selected by the player is one of them. MeasuresPossible = (RMarker.LTile).Measures; log("you selected the measureType "$SelectedMeasureType); for(i=0;iend failure GeoPC.setFailureStable(Rmarker); } } else { // if the measure selected is not the right one, make a new Measure to put as // marker.MeasureTaken (possibly to be replaced later by the right measure) log("MeasureToTake == none, you chose the wrong measure"); MeasureToTake = new Class'Measure'; MeasureToTake.MeasureType = SelectedMeasureType; MeasureToTake.bMeasureEffective = false; } GeoPC.geoFb.logMeasure(MeasureToTake, RMarker.name); RMarker.MeasureTaken = MeasureToTake; } defaultproperties { Begin Object Class=GUIButton name=Background WinWidth=0.75 WinHeight=0.6 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' Controls(13)=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 = "Measure menu" EN_QuestionString[0] = "You are not authorized to take measures." EN_QuestionString[1] = "The Action Center didn't ask you to take measures on this failure yet." EN_QuestionString[2] = "Which measure do you want to take?" // 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]="Covering the inner slope with foil",Answers[1]="Covering the outer slope with foil",Answers[2]="Placing a sandbank / slackening the slope",Answers[3]="Remove foreign objects",Answers[4]="Making a sandbag containment ring",Answers[5]="Sandbags at the toe",Answers[6]="Sandbags at the top") NL_Title = "Maatregel menu" NL_QuestionString[0] = "U bent niet bevoegd om maatregelen te nemen." NL_QuestionString[1] = "Het Actiecentrum heeft u nog niet gevraagd om maatregelen te nemen." NL_QuestionString[2] = "Welke maatregel wilt u nemen?" // 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]="Binnentalud afdekken met folie",Answers[1]="Buitentalud afdekken met folie",Answers[2]="Berm van zand aanleggen / taludverflauwing",Answers[3]="Verplaats objecten en obstakels",Answers[4]="Opkisten",Answers[5]="Zandzakken aan de teen",Answers[6]="Zandzakken op de kruin") }