// // CPT operator / SondeerGame // This source file is (c) by Deltares. // - October 2014 // /// jln - 30-09-2008 ApprovalCheck component which is 3 checkboxes in one. class GeoApprovalCheck extends GUIMultiComponent; var automated GeoImageButton btnQuestionMark; var automated GeoImageButton btnCorrect; var automated GeoImageButton btnIncorrect; /// approval state: var int iApprovalState; /// Which approval type is this(opdracht, algemeen,veiligheid, voorbereiding); var string sApprovalType; function InitComponent(GUIController MyController, GUIComponent MyOwner) { Super.Initcomponent(MyController, MyOwner); btnQuestionMark = GeoImageButton(AddComponent("GeoGUI.GeoImageButton")); btnCorrect = GeoImageButton(AddComponent("GeoGUI.GeoImageButton")); btnIncorrect = GeoImageButton(AddComponent("GeoGUI.GeoImageButton")); /// Set images: btnQuestionMark.Graphic = Material'GeoGUIContent.Icons.questionmark_selected'; btnCorrect.Graphic = Material'GeoGUIContent.Icons.checkmark_unselected'; btnIncorrect.Graphic = Material'GeoGUIContent.Icons.cross_unselected'; btnQuestionMark.WinLeft = WinLeft; btnCorrect.WinLeft = WinLeft + btnQuestionMark.WinWidth + 0.04; btnIncorrect.WinLeft = WinLeft + btnCorrect.WinWidth + btnQuestionMark.WinWidth + 0.04; self.WinWidth = btnQuestionMark.WinWidth + btnCorrect.WinWidth + btnIncorrect.WinWidth + 2 * 0.04; /// Questionmark is not clickable: //btnQuestionMark.OnClick = ButtonClick; btnCorrect.OnClick = ButtonClick; btnIncorrect.OnClick = ButtonClick; OnPreDraw = InternalOnPreDraw; /// Default is questionmark: iApprovalState = -1; } /// jln - 30-09-2008 Check which button is pressed and change graphics: function bool ButtonClick(GUIComponent Sender) { local string ScenarioFile; local bool bresult; local string message; local GeoPlayerController GeoPC; GeoPC = GeoPlayerController(PlayerOwner()); ScenarioFile = "scenario" $ GeoPC.GetScenarioNumber(); if (Sender == btnQuestionMark) { btnQuestionMark.Graphic = Material'GeoGUIContent.Icons.questionmark_selected'; btnCorrect.Graphic = Material'GeoGUIContent.Icons.checkmark_unselected'; btnIncorrect.Graphic = Material'GeoGUIContent.Icons.cross_unselected'; SetApprovalState(-1); } if (Sender == btnCorrect) { btnQuestionMark.Graphic = Material'GeoGUIContent.Icons.questionmark_unselected'; btnCorrect.Graphic = Material'GeoGUIContent.Icons.checkmark_selected'; btnIncorrect.Graphic = Material'GeoGUIContent.Icons.cross_unselected'; SetApprovalState(0); } if (Sender == btnIncorrect) { btnQuestionMark.Graphic = Material'GeoGUIContent.Icons.questionmark_unselected'; btnCorrect.Graphic = Material'GeoGUIContent.Icons.checkmark_unselected'; btnIncorrect.Graphic = Material'GeoGUIContent.Icons.cross_selected'; SetApprovalState(1); } btnQuestionMark.OnClick = None; btnCorrect.OnClick = None; btnIncorrect.OnClick = None; /// Get value from Scenario file: bresult = bool(GeoPC.IL8N(sApprovalType $ "Controle", "Checklist", true)); Log("Result from file: " @ bresult); /// Incorrect choice (should have been correct, incorrect given): if (bResult == true && iApprovalState == 1 ) { Log("Incorrect given, should have been correct"); GeoPC.playeractions.nrErrorsInChecks += 1; // tell player in a pop up dialog message = GeoPC.IL8N(sApprovalType $ "ControleText", "Checklist", true); Controller.OpenMenu("GeoInterface.dialogAlert", message, "InGameMenuImagesT.ImageButtons.Boss"); MenuOpdrachtBon(MenuOwner).EnableClicked(sApprovalType, 0); } /// Incorrect choice (should have been incorrect, correct given): else if (bResult == false && iApprovalState == 0 ) { Log("Correct given, should have been incorrect"); GeoPC.playeractions.nrErrorsInChecks += 1; // no pop up dialog; but there will be consequences } /// correct choice (should have been incorrect, incorrect given): else if (bResult == false && iApprovalState == 1 ) { Log("Incorrect given, should have been incorrect also"); // congratulate player in a pop up dialog message = GeoPC.IL8N(sApprovalType $ "ControleText", "Checklist", true); Controller.OpenMenu("GeoInterface.dialogAlert", message, "InGameMenuImagesT.ImageButtons.Boss"); MenuOpdrachtBon(MenuOwner).EnableClicked(sApprovalType, 1); } else { /// Everything ok? MenuOpdrachtBon(MenuOwner).EnableClicked(sApprovalType, 0); } return true; } /// jln - 30-09-2008 Get approval state function SetApprovalState(int istate) { iApprovalState = istate; } /// jln - 30-09-2008 Return approval state function int GetApprovalState() { return iApprovalState; } function bool InternalOnPreDraw(Canvas C) { btnQuestionMark.WinLeft = WinLeft; btnCorrect.WinLeft = WinLeft + btnQuestionMark.WinWidth + 0.01; btnIncorrect.WinLeft = WinLeft + btnIncorrect.WinWidth + btnQuestionMark.WinWidth + (2*0.01); btnIncorrect.WinTop = WinTop; btnCorrect.WinTop = WinTop; btnQuestionMark.WinTop = WinTop; return true; } defaultproperties { WinWidth=0.4 WinHeight=0.1 }