// // CPT operator / SondeerGame // This source file is (c) by Deltares. // - October 2014 // class dialogPreparation extends GeoGUIPage config(GeoUser); var GeoButton EindeVoorbereidingButton; var GeoButton IgnoreButton; var string EventStrings[7]; function InitComponent(GUIController MyController, GUIComponent MyOwner) { local int i, prepcount; local string item; local GeoButton btn; local GeoLabel lbl; local GeoMultiLineLabel IntroTextBox; local float LeftColumnLeft, LeftColumnRight, RightColumnLeft, RightColumnRight; local string strsuffix; Super.InitComponent(MyController, MyOwner); /// jln - 16-09-2008 Set scenario file. ScenarioFile = "scenario" $ GeoPC.GetScenarioNumber(); EindeVoorbereidingButton = GeoButton(Controls[1]); IgnoreButton = GeoButton(Controls[2]); /// Intro text: IntroTextBox = GeoMultiLineLabel(Controls[10]); IntroTextBox.SetContent( IL8N("introtext") ); /// Suffix: Is used to add geomil to the end of the section; strsuffix = ""; if (GeoPC.GetCompany() == "Geomil") { strsuffix = ".geomil"; } // all the preparation buttons and labels prepcount = int(Localize("Preparation." $ GeoPC.PlayerLanguage $ strsuffix, "prepcount" , ScenarioFile)); for (i = 0; i < prepcount; i++) { /// Get preparation name and associated event: item = (Localize("Preparation." $ GeoPC.PlayerLanguage $ strsuffix, "prep" $ i , ScenarioFile)); EventStrings[i] = Localize("Preparation." $ GeoPC.PlayerLanguage $ strsuffix, "prepevent" $ i , ScenarioFile); btn = GeoButton(Controls[i+3]); lbl = GeoLabel(Controls[i+11]); btn.SetVisibility(true); lbl.SetVisibility(true); /*if(prepcount < 7) { // everything in one row Controls[i+3].WinLeft = 0.1;//Controls[0].WinLeft + Controls[0].WinWidth / 4.0; Controls[i+3].WinTop = 0.205 + (i * (Controls[i+3].WinHeight + 0.01)); }*/ // make two rows LeftColumnLeft = 0.07; RightColumnLeft = Controls[0].WinLeft + Controls[0].WinWidth / 2.4; LeftColumnRight = RightColumnLeft - 0.03; RightColumnRight = Controls[0].WinLeft + Controls[0].WinWidth - 0.05; if(i < 4) { lbl.WinLeft = LeftColumnLeft; btn.WinLeft = LeftColumnRight - btn.WinWidth; } else { lbl.WinLeft = RightColumnLeft; btn.WinLeft = RightColumnRight - btn.WinWidth; } btn.WinTop = 0.26 + ((i%4) * (btn.WinHeight + 0.01)); lbl.WinTop = btn.WinTop + 0.012; lbl.Caption = item; if(EventStrings[i] == "drilldesc") { btn.MenuState = MSAT_Disabled; } else if( (EventStrings[i] == "closehole" || EventStrings[i] == "closeholesand") && GeoPC.GetScenarioNumber() != 3) { btn.MenuState = MSAT_Disabled; } //Log("Preparation item: " @ item); } } function InternalOnChange(GUIComponent Sender) { Log("change: " @ Sender); } function bool InternalOnKeyEvent(out byte Key,out byte State,float delta) { /// Swallow Escape key event if(Key == 0x1B) return true; return true; } function bool ButtonClick(GUIComponent Sender) { if (Sender == Ignorebutton) { Log("Ignoring"); GeoPC.SondeerLocationToSkip = GeoPC.CurrentSondeerLocation; GeoPC.ClientCloseMenu(true); } else if (Sender == EindeVoorbereidingButton) { /// Store the fact that we have prepared: GeoPC.playeractions.FinishedPreparations = true; /// End preparation, nog we have to move the verhicle to the proper place. //GeoPC.FindAndHide("dialogPreparation"); GeoPC.ClientCloseMenu(true); /// Player now has to put the sondeer truck at the correct place GeoHud(GeoPC.myHud).SetMessage("Zet de sondeerwagen nu op de juiste plek", 1, 10); //GeoPC.ChangeSondeerWagenView(); } return true; } function bool PreparationButtonClick(GUIComponent Sender) { local string action, eventname; local GeoLabel lbl; local int i; Sender.SetVisibility(false); // get label, get event for(i = 3; i < 10; i++) { if(Sender == Controls[i]) // all the buttons { action = EventStrings[i-3]; eventname = "sondeer1" $ action; lbl = GeoLabel(Controls[i + 8]); lbl.Caption = lbl.Caption @ "-" @ IL8N("executed"); if(action == "closehole") { lbl.WinWidth = 0.5; } } } GeoPC.TriggerActions( eventname ); Log("Sender click: " @ Sender @ " - Event to trigger: " @ eventname); /// Check if we can actually perform the action ourselves if (action == "predrill") { // We have pre drilled: GeoPC.playeractions.PerformedPreDig = true; /// Set current sondeer location state to "predrill" GeoPC.CurrentSondeerLocation.SetState(1); /// Enable button of boorbeschrijving: for (i = 0; i < ArrayCount(EventStrings); i++) { if (EventStrings[i] == "drilldesc" || EventStrings[i] == "closehole" || EventStrings[i] == "closeholesand") GeoButton(Controls[i+3]).MenuState = MSAT_Blurry; } } else if (action == "closeholesand") { // We have closed the drilled hole: GeoPC.playeractions.ReturnedSand = true; GeoPC.playeractions.OnlyReturnedSand = true; /// Disable the other one: for (i = 0; i < ArrayCount(EventStrings); i++) { if (EventStrings[i] == "closehole") GeoButton(Controls[i+3]).MenuState = MSAT_Disabled; } /// Close hole state. GeoPC.CurrentSondeerLocation.SetState(3); } else if (action == "closehole") { // We have closed the drilled hole (but with junk, possibly, not just sand): GeoPC.playeractions.ReturnedSand = true; /// Disable the other one: for (i = 0; i < ArrayCount(EventStrings); i++) { if (EventStrings[i] == "closeholesand") GeoButton(Controls[i+3]).MenuState = MSAT_Disabled; } /// Close hole state. GeoPC.CurrentSondeerLocation.SetState(2); } else if (action == "drilldesc") { /// Player requested a boorbeschrijving: GeoPC.playeractions.AskedForBoorBeschrijving = true; /// Display 'boorbeschrijving'; Controller.OpenMenu("GeoInterface.MenuBoorBeschrijving"); } else if (action == "raisehood") { /// Raise hood: // We have raised the hood GeoPC.playeractions.RaisedHood = true; GeoPC.RaiseHood(); } else if (action == "changeclothing") { // put on working clothes GeoPC.playeractions.PutOnClothes = true; } else if (action == "closegates") { // put on working clothes GeoPC.playeractions.ClosedGates = true; } return true; } defaultproperties { AllowSelect=false bAllowedAsLast=true bDisconnectOnOpen=false bPersistent=false bNeverFocus=true Begin Object Class=GeoFrame name=TDialogBackground WinLeft=0.03 WinTop=0.07 WinWidth=0.75 WinHeight=0.48 End Object Controls(0)=GeoFrame'TDialogBackground' Begin Object Class=GeoButton Name=TIgnoreButton OnClick=ButtonClick IniOption="TIgnoreButton" WinWidth=0.14 WinLeft=0.21 WinTop=0.45 bNeverFocus=true bVisible=false End Object Controls(2)=GeoButton'TIgnoreButton' Begin Object Class=GeoButton Name=TEindeVoorbereiding OnClick=ButtonClick IniOption="TEindeVoorbereidingButton" WinWidth=0.24 WinLeft=0.49 WinTop=0.45 bNeverFocus=true End Object Controls(1)=GeoButton'TEindeVoorbereiding' Begin Object class=GeoButton Name=PreparationButtons bVisible=false WinWidth=0.115 WinHeight=0.044 IniOption="execute" OnClick=PreparationButtonClick End Object Begin Object class=GeoLabel Name=PreparationLabels bVisible=false End Object Begin Object class=GeoMultiLineLabel name=TTextBox StyleName="MultiLineLabel" bNeverFocus=true WinTop=0.13 WinLeft=0.07 WinHeight=0.1 WinWidth=0.58 End Object Controls(3)=GeoButton'PreparationButtons' Controls(4)=GeoButton'PreparationButtons' Controls(5)=GeoButton'PreparationButtons' Controls(6)=GeoButton'PreparationButtons' Controls(7)=GeoButton'PreparationButtons' Controls(8)=GeoButton'PreparationButtons' Controls(9)=GeoButton'PreparationButtons' Controls(10)=TTextBox Controls(11)=GeoLabel'PreparationLabels' Controls(12)=GeoLabel'PreparationLabels' Controls(13)=GeoLabel'PreparationLabels' Controls(14)=GeoLabel'PreparationLabels' Controls(15)=GeoLabel'PreparationLabels' Controls(16)=GeoLabel'PreparationLabels' Controls(17)=GeoLabel'PreparationLabels' }