// 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 what type of damage is to be reported. // Started from MenuMarker. // ------------------------------------------------------------ // Created by Maarten Wesselius // © 2006, GeoDelft // Date Id Modification // 2006-10-26 The Formatted code // 2006-10-26 The Shortened text to fit in box // 2006-10-27 The Resized and rearranged controls // 2006-11-13 Bas Fixed Esc handling //============================================================================= class MenuObservationMain extends GUIPage; var bool bAllowSelect; var string EN_Title, NL_Title, EN_NoObs, NL_NoObs, EN_RepPrefix, NL_RepPrefix, EN_ObsListString, NL_ObsListString, EN_RepTabsString, NL_RepTabsString, EN_NewObsString, NL_NewObsString, EN_DeleteObsString, NL_DeleteObsString, EN_EditRepString, NL_EditRepString, EN_AddRepString, NL_AddRepString, EN_Ok, NL_Ok; var GeoPlayerController GeoPC; var bool bEditReport; var bool bIgnoreEsc; var float HGap; var float VGap; var float BarHeight; var float BarVPos; var float SButtonSize; var float SButtonVGap; var float SButtonHGap; var float TitleLeftGap; var float MiddleEdge; var float TabPanelLeft, TabPanelTop, TabPanelWidth, TabPanelHeight; var Signal ObservationSelected; //============================================================================= // Date Id Modification // 2006-10-26 The Created this header // 2006-11-22 Zmr hide quit button, moved help button //============================================================================= function InitComponent(GUIController MyController, GUIComponent MyOwner) { Super.InitComponent(MyController, MyOwner); OnClose = InternalOnClose; OnKeyEvent = InternalOnKeyEvent; // 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; Controls[1].SetVisibility(false); // When True change position COntrols[2] // HelpButton Controls[2].WinTop = Controls[1].WinTop; Controls[2].WinLeft = Controls[1].WinLeft;// - SButtonSize - SButtonHGap; Controls[2].WinWidth = SButtonSize; Controls[2].WinHeight = SButtonSize; // Menu Title Controls[3].WinTop = Controls[1].WinTop; Controls[3].WinLeft = Controls[0].WinLeft + TitleLeftGap; Controls[3].WinWidth = 0.6; Controls[3].WinHeight = 0.1; // Observations Label Controls[4].WinLeft = Controls[3].WinLeft; Controls[4].WinTop = Controls[3].WinTop + Controls[3].WinHeight + VGap; // Observation List Controls[5].WinLeft = Controls[3].WinLeft; Controls[5].WinTop = Controls[4].WinTop + Controls[4].WinHeight + VGap; Controls[5].WinWidth = MiddleEdge - HGap/2 - Controls[5].WinLeft; GUIListBox(Controls[5]).List.OnChange = ObservationListChange; GUIListBox(Controls[5]).List.TextAlign = TXTA_Left; // Delete Observation Button Controls[7].WinLeft = Controls[5].WinLeft + Controls[5].WinWidth/2 - Controls[7].WinWidth/2; Controls[7].WinTop = Controls[0].WinTop + Controls[0].WinHeight - VGap - Controls[7].WinHeight; // New Observation Button Controls[6].WinLeft = Controls[5].WinLeft + Controls[5].WinWidth/2 - Controls[6].WinWidth/2; Controls[6].WinTop = Controls[7].WinTop - VGap - Controls[6].WinHeight; // height of Observation List Controls[5].WinHeight = Controls[6].WinTop - VGap - Controls[5].WinTop; // Reports Label Controls[8].WinTop = Controls[4].WinTop; Controls[8].WinLeft = MiddleEdge + HGap/2; // Reports TabControl Controls[9].WinLeft = Controls[8].WinLeft; Controls[9].WinTop = Controls[5].WinTop; Controls[9].WinHeight = Controls[5].WinHeight; Controls[9].WinWidth = Controls[0].WinLeft + Controls[0].WinWidth - HGap - MiddleEdge - HGap/2; TabPanelLeft = Controls[9].WinLeft; TabPanelTop = Controls[9].WinTop + GUITabControl(Controls[9]).TabHeight; TabPanelWidth = Controls[9].WinWidth; TabPanelHeight = Controls[9].WinHeight - GUITabControl(Controls[9]).TabHeight; // Edit/Add Reports Button Controls[10].WinLeft = Controls[9].WinLeft + Controls[9].WinWidth/2 - Controls[10].WinWidth/2; Controls[10].WinTop = Controls[9].WinTop + Controls[9].WinHeight + VGap; //***************** // Just for testing //***************** Controls[11].WinLeft = Controls[10].WinLeft; Controls[11].WinTop = Controls[10].WinTop + Controls[10].WinHeight + VGap; GeoPC=GeoPlayerController(PlayerOwner()); if(GeoPC!=None) { ResetObservationList(); UpdateLanguage(); } else { log("ERROR WITH GEOPLAYERCONTROLLER"); } } //============================================================================= // Date Id Modification // 2006-10-26 The Created this header //============================================================================= function InternalOnClose(optional Bool bCanceled) { Super.OnClose(bCanceled); } //============================================================================= // Date Id Modification // 2006-10-26 The Created this header //============================================================================= function bool InternalOnKeyEvent(out byte Key, out byte State, float delta) { // 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 ) { Controller.ReplaceMenu("GeoSimulator.MenuMarker"); return true; } } //============================================================================= // Date Id Modification // 2006-10-26 The Created this header //============================================================================= function bool InternalOnClick(GUIComponent Sender) { local int i; if(bAllowSelect) { if(Sender == Controls[1]) { // Quit Button Controller.ReplaceMenu("GeoSimulator.MenuMarker"); } else if(Sender == Controls[2]) { // Help Button Controller.ReplaceMenu("GeoSimulator.HelpMenuObservationMain"); } else if(Sender == Controls[6]) { // New Observation Button GeoPC.ResetNewSignal(); // making a new report, so when saving it, save it as an original too Controller.ReplaceMenu("GeoSimulator.MenuChooseSignal"); } else if(Sender == Controls[7]) { // Delete Observation Button if(ObservationSelected.bApproved || ObservationSelected.SignalReports.length > 1) { ChangeAllow(false); Controller.OpenMenu("GeoInterface.NoDelete"); } else { DeleteObservation(); } } else if(Sender == Controls[10]) { // Edit / Add Report Button // put the currently selected observation in GeoPC.NewSignal and set // GeoPC.ReportingMode, then open the right menu if(ObservationSelected != None) { // initialize NewSignal GeoPC.NewSignal = ObservationSelected; // initialize EditIndex i = 0; while(i < GeoPC.NearByMarker.Signals.length && GeoPC.NearByMarker.Signals[i] != ObservationSelected) { i++; } GeoPC.EditIndex = i; if(!bEditReport && (ObservationSelected.IsA('SignalFloatingWaste') || ObservationSelected.IsA('SignalHumanActivity') || ObservationSelected.IsA('SignalBioActivity'))) { ChangeAllow(false); Controller.OpenMenu("GeoInterface.NoAddReport"); } else if(bEditReport && GeoPC.NewSignal.SignalReports.length == 1) { GeoPC.ReportingMode = MODE_EditingFirstReport; Controller.ReplaceMenu("GeoSimulator.MenuSignalLocation"); } else if (bEditReport) { GeoPC.ReportingMode = MODE_EditingLaterReport; GoToQuestionsMenu(GeoPC.NewSignal); } else { GeoPC.ReportingMode = MODE_AddingNewReport; GeoPC.bCreatedNewSignalReport = false; GoToQuestionsMenu(GeoPC.NewSignal); } } } else if(Sender == Controls[11]) { Controller.ReplaceMenu("GeoSimulator.MenuMarker"); } } return true; } //============================================================================= // removes the currently selected observation from the list // Date Id Modification // 2006-10-26 The Created this header //============================================================================= function DeleteObservation() { local int i; i = 0; while(i < GeoPC.NearByMarker.Signals.length && GeoPC.NearByMarker.Signals[i] != ObservationSelected) { i++; } GeoPC.geoFb.logDeleteSignal(GeoPC.NearByMarker.Signals[i]); GeoPC.NearByMarker.Signals.Remove(i, 1); GeoPC.NearByMarker.SignalOriginals.Remove(i, 1); ResetObservationList(); } //============================================================================= // Date Id Modification // 2006-10-26 The Created this header //============================================================================= function GoToQuestionsMenu(Signal s) { // open Menu of appropriate SignalQuestions switch(s.SignalType) { case SIG_RipRapPitching: Controller.ReplaceMenu("GeoSimulator.MenuRipPitching"); break; case SIG_GrassRevetment: Controller.ReplaceMenu("GeoSimulator.MenuGrass"); break; case SIG_Crack: Controller.ReplaceMenu("GeoSimulator.MenuCrack"); break; case SIG_Settlement: Controller.ReplaceMenu("GeoSimulator.MenuSettlement"); break; case SIG_HorizontalMovement: Controller.ReplaceMenu("GeoSimulator.MenuHorizontalMovement"); break; case SIG_Uprise: Controller.ReplaceMenu("GeoSimulator.MenuUprise"); break; case SIG_Liquefaction: Controller.ReplaceMenu("GeoSimulator.MenuLiquefaction"); break; case SIG_WaterOutflow: Controller.ReplaceMenu("GeoSimulator.MenuWaterOutflow"); break; case SIG_OverToppingWash: Controller.ReplaceMenu("GeoSimulator.MenuOverToppingWash"); break; case SIG_FloatingWasteOther: Controller.ReplaceMenu("GeoSimulator.MenuFloatingWaste"); break; case SIG_HumanActivity: Controller.ReplaceMenu("GeoSimulator.MenuHumanActivity"); break; case SIG_BioActivity: Controller.ReplaceMenu("GeoSimulator.MenuBioActivity"); break; } } //============================================================================= // Date Id Modification // 2006-10-26 The Created this header //============================================================================= function ChangeAllow(bool allow) { bAllowSelect = allow; } //============================================================================= // this function fills the observation GUIListBox with all Signals reported // Date Id Modification // 2006-10-26 The Created this header //============================================================================= function ResetObservationList() { local array allSignals; local Signal thisSignal; local GUIList list; local int i, k, DupliCount; local string obsString, newString; local QAHashTable HashTable; allSignals = GeoPC.NearByMarker.Signals; list = GUIListBox(Controls[5]).List; list.Clear(); if(allSignals.length == 0) { if(GeoPC.Dutch) obsString = NL_NoObs; else obsString = EN_NoObs; list.Add(obsString); Controls[8].setVisibility(false); Controls[9].setVisibility(false); Controls[10].setVisibility(false); Controls[7].setVisibility(false); list.SetIndex(-1); ResetReportTabs(); } else { HashTable = New class'QAHashTable'; for(i = 0; i < allSignals.length; i++) { thisSignal = allSignals[i]; if(GeoPC.Dutch) obsString = thisSignal.NL_DamageName; else obsString = thisSignal.EN_DamageName; // give indices to duplicate signal names by keeping track using a hashtable DupliCount = HashTable.getValue(obsString); if(DupliCount == -1) { // first observation for this signal HashTable.add(obsString, 1); newString = obsString; } else { // there was already an observation for this signal newString = obsString $ " ("$ (DupliCount + 1) $")"; if(DupliCount == 1) { // there was only one observation for this signal before; give this one an index too k = 0; while(k < list.ItemCount && list.GetItemAtIndex(k) != obsString) { k++; } if(k != list.ItemCount) { list.Replace(k, obsString$" (1)", list.getObjectAtIndex(k)); } } HashTable.setValue(obsString, DupliCount + 1); } list.Add(newString, thisSignal); if(i == GeoPC.EditIndex) { // the signal just added/edited; select it in the list list.SetIndex(i); } } } } //============================================================================= // called when a tab is clicked // Date Id Modification // 2006-10-26 The Created this header //============================================================================= function TabChange(GUIComponent Sender) { //log("TabChange!"); } //============================================================================= // called whenever anything changes to the list (different selection, or change in list elements) // Date Id Modification // 2006-10-26 The Created this header //============================================================================= function ObservationListChange(GUIComponent Sender) { local GUIList list; list = GUIListBox(Controls[5]).List; //log("ObservationListChange"); // if different observation than before, initialize and show the tabs for the reports of this observation if(list.GetObject() == None) { ObservationSelected = None; } else if(Signal(list.GetObject()) != ObservationSelected) { ObservationSelected = Signal(list.GetObject()); // set bEditReport to false if called through to actionCenter if(ObservationSelected.bApproved) { bEditReport = false; if(GeoPC.Dutch) GUIButton(Controls[10]).Caption = NL_AddRepString; else GUIButton(Controls[10]).Caption = EN_AddRepString; } else { bEditReport = true; if(GeoPC.Dutch) GUIButton(Controls[10]).Caption = NL_EditRepString; else GUIButton(Controls[10]).Caption = EN_EditRepString; } } ResetReportTabs(); } //============================================================================= // makes and fills tabs for the reports of observation s // Date Id Modification // 2006-10-26 The Created this header //============================================================================= function ResetReportTabs() { local GUITabControl tabC; local GUITabPanel tempTab; local string prefix; local int r, nrTabs; tabC = GUITabControl(Controls[9]); //log("ResetReportTabs!"); // delete all tabs in GUITabController tabC.TabStack.length = 0; if(ObservationSelected == None) { //log("no observatie selected..."); } else { // define number of tabs to add nrTabs = ObservationSelected.SignalReports.length; if(nrTabs == 0) nrTabs = 1; // add a tab for each signalreport (and at least one, also when there's no signalreports) for(r = 1; r <= nrTabs; r++) { if(GeoPC.Dutch) prefix = NL_RepPrefix; else prefix = EN_RepPrefix; if(r == nrTabs) tempTab = tabC.AddTab(prefix$r,"GeoSimulator.Tab_ReportData",,,true); else tempTab = tabC.AddTab(prefix$r,"GeoSimulator.Tab_ReportData"); // give it the right size (how to do this in a better way?) Tab_ReportData(tempTab).SetSize(TabPanelLeft, TabPanelTop, TabPanelWidth, TabPanelHeight); Tab_ReportData(tempTab).ShowReport(ObservationSelected, r - 1); } } } //============================================================================= // Date Id Modification // 2006-10-26 The Created this header //============================================================================= function UpdateLanguage() { if(GeoPC.Dutch) { GUILabel(Controls[3]).Caption = NL_Title; GUILabel(Controls[4]).Caption = NL_ObsListString; GUIButton(Controls[6]).Caption = NL_NewObsString; GUIButton(Controls[7]).Caption = NL_DeleteObsString; GUILabel(Controls[8]).Caption = NL_RepTabsString; GUIButton(Controls[11]).Caption = NL_Ok; if(bEditReport) GUIButton(Controls[10]).Caption = NL_EditRepString; else GUIButton(Controls[10]).Caption = NL_AddRepString; } else { GUILabel(Controls[3]).Caption = EN_Title; GUILabel(Controls[4]).Caption = EN_ObsListString; GUIButton(Controls[6]).Caption = EN_NewObsString; GUIButton(Controls[7]).Caption = EN_DeleteObsString; GUILabel(Controls[8]).Caption = EN_RepTabsString; GUIButton(Controls[11]).Caption = EN_Ok; if(bEditReport) GUIButton(Controls[10]).Caption = EN_EditRepString; else GUIButton(Controls[10]).Caption = EN_AddRepString; } } //============================================================================= // Date Id Modification // 2006-10-26 The Created this header //============================================================================= defaultproperties { Begin Object Class=GUIButton name=Background WinWidth=0.85 WinHeight=0.8 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" 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=GUILabel Name=MenuTitle Caption="***" TextAlign=TXTA_Left TextColor=(R=255,G=120,B=0,A=255) TextFont="HeaderFont" bMultiLine=true End Object Controls(3)=GUILabel'MenuTitle' Begin Object class=GUILabel Name=theLabels Caption="***" TextAlign=TXTA_Left TextFont="MidGameFont" WinHeight=0.02 WinWidth=0.3 End Object // label above obs list Controls(4)=GUILabel'theLabels' Begin Object class=GUIListBox Name=ObsList bVisibleWhenEmpty=True StyleName="SquareMenuButton" End Object Controls(5)=GUIListBox'ObsList' Begin Object Class=GUIButton Name=theButtons Caption="***" StyleName="MidGameButton" bNeverFocus=true WinWidth=0.25 WinHeight=0.05 OnClick=InternalOnClick End Object // buttons for: new obs, delete obs Controls(6)=GUIButton'theButtons' Controls(7)=GUIButton'theButtons' // label above report tabs Controls(8)=GUILabel'theLabels' Begin Object Class=GUITabControl Name=reportTabs TabHeight=0.04 OnChange=TabChange bAcceptsInput=true bDockPanels=true End Object Controls(9)=GUITabControl'reportTabs' // button below report tabs Controls(10)=GUIButton'theButtons' Controls(11)=GUIButton'theButtons' HGap=0.03 VGap=0.02 BarHeight=0.21 BarVPos=0.5 SButtonSize=0.06 SButtonHGap=0.02 SButtonVGap=0.02 TitleLeftGap=0.05 MiddleEdge=0.475 OpenSound=sound'RuntimeInterfaceSounds.SelectDshort' bRequire640x480=false bAllowedAsLast=true bAllowSelect=true bIgnoreEsc=true EN_Title="Observation Overview" EN_NoObs="No observations yet." EN_RepPrefix="rep." EN_ObsListString="Observations made:" EN_RepTabsString="Reports made for this observation:" EN_NewObsString="New observation" EN_DeleteObsString="Remove observation" EN_EditRepString="Edit current report" EN_AddRepString="Add new report" EN_Ok="Ok" NL_Title="Observatie overzicht" NL_NoObs="Nog geen observaties." NL_RepPrefix="rap." NL_ObsListString="Gemaakte observaties:" NL_RepTabsString="Rapporten voor deze observatie:" NL_NewObsString="Nieuwe observatie" NL_DeleteObsString="Verwijder observatie" NL_EditRepString="Wijzig huidig rapport" NL_AddRepString="Voeg nieuw rapport toe" NL_Ok="Ok" }