// // CPT operator / SondeerGame // This source file is (c) by Deltares. // - October 2014 // //============================================================================= // // ------------------------------------------------------------ // © 2006, Geodelft // // Date Id Modification // 2006-10-07 The Created this header // 2006-10-08 The Implemented Dutch translations // 2006-10-25 The Hide control InputMouseSmoothStr //============================================================================= class MenuHandBookTab extends GeoGUITabPanel; var automated GeoFrame BackGround; //var automated GeoImageButton PreviousPage; var automated GeoScrollText cScroll_LevelDescription; var automated GeoImage Pict; var automated GeoButton btn1, btn2,btn3,btn4,btn5,btn6,btn7; var array infoButtons; enum HandBookImageModes { MODE_None, MODE_Square, MODE_NoneSquare }; struct HandBookInfo { var string NL_ButtonText; var string EN_ButtonText; var array NL_Text; var array EN_Text; var material Picture; var HandBookImageModes ImageMode; }; var array HandBookDataSet; var string FirstBullit,XthBullit,AfterLastBullit; var GuiComponent GuiOwner; var MenuHandBook MenuOwner;// in this case the MenuHandBook, where this tab is created. //============================================================================= // Date Id Modification // 2006-10-07 The Created this header //============================================================================= function InitComponent(GUIController MyController, GUIComponent MyOwner) { local int i; Super.Initcomponent(MyController, MyOwner); GuiOwner = MyOwner; GeoPC = GeoPlayerController(PlayerOwner()); MenuOwner = MenuHandbook(MyOwner.MenuOwner); infoButtons[0] = btn1; infoButtons[1] = btn2; infoButtons[2] = btn3; infoButtons[3] = btn4; infoButtons[4] = btn5; infoButtons[5] = btn6; infoButtons[6] = btn7; // FIlling the data set so the buttons can be made; MakeData(); // positioning the Buttons /// Hide all buttons first: for(i = 0; i < infoButtons.length ; i++) { infoButtons[i].bVisible = false; } for(i = 0; i < HandBookDataSet.length ; i++) { if (infoButtons[i] != None) { infoButtons[i].bVisible = true; infoButtons[i].WinWidth = 0.24; infoButtons[i].WinLeft = MenuOwner.TabLeft; infoButtons[i].WinTop = 0.06 + i * (infoButtons[i].WinHeight + 0.01); infoButtons[i].Caption = HandBookDataSet[i].NL_ButtonText; } if(i == 0) { // how to put focus on the first button?? infoButtons[i].bNeverFocus = false; infoButtons[i].bFocusOnWatch = true; infoButtons[i].bHasFocus = true; SetFocus(infoButtons[i]); } } LoadHandBookInfo(HandBookDataSet[0]); /// Btn 1 is pressed by default: btn1.MenuState = MSAT_Focused; } //============================================================================= // Date Id Modification // 2006-10-07 The Created this function //============================================================================= function ShowPanel(bool bShow) { Super.ShowPanel(bShow); LoadHandBookInfo(HandBookDataSet[0]); } function MakeData() { local int i; local int items; local string file, content, content2; local string picture; local string sclass; sclass = String(self.Class); HandBookDataSet.Remove(0,HandBookDataSet.Length); file = "handbook_" $ GeoPlayerController(PlayerOwner()).GetLanguage(); items = int(Localize(sclass, "items", file)); HandBookDataSet.insert(0, items); for (i = 0; i < items; i++) { HandBookDataSet[i].NL_ButtonText = Localize(sclass, "ButtonText" $ i, file); HandBookDataSet[i].NL_Text.Insert(0,1); content = Localize(sclass, "Text" $ i $ "a", file); GeoPlayerController(PlayerOwner()).ReplaceText(content, "$FirstBullit$", FirstBullit); GeoPlayerController(PlayerOwner()).ReplaceText(content, "$XthBullit$", XthBullit); GeoPlayerController(PlayerOwner()).ReplaceText(content, "$AfterLastBullit$", AfterLastBullit); content2 = Localize(sclass, "Text" $ i $ "b", file); GeoPlayerController(PlayerOwner()).ReplaceText(content2, "$FirstBullit$", FirstBullit); GeoPlayerController(PlayerOwner()).ReplaceText(content2, "$XthBullit$", XthBullit); GeoPlayerController(PlayerOwner()).ReplaceText(content2, "$AfterLastBullit$", AfterLastBullit); HandBookDataSet[i].NL_Text[0] = content $ content2; picture = Localize(sclass, "Picture" $ i, file); /// Picture present? if (Len(picture) > 0) { HandBookDataSet[i].Picture = Material(DynamicLoadObject(picture, class'Material')); } } } function LoadHandBookInfo(HandBookInfo HBInfo) { local int i; local string text; if (HBInfo.Picture != None) { Pict.Image = HBInfo.Picture; } //Log("B"); cScroll_LevelDescription.MyScrollText.Separator = "|"; //Log("C"); text = ""; for(i = 0; i< HBInfo.NL_Text.Length; i++) { text = text $ HBInfo.NL_Text[i]; } //Log("D"); /// Set owner title: //MenuOwner.MenuTitle.Caption = MenuOwner.Title $ " - " $ IL8N("Title") $ " - " $ HBInfo.NL_ButtonText; /// Set text: cScroll_LevelDescription.SetContent(text); cScroll_LevelDescription.InternalOnAdjustTop(cScroll_LevelDescription); } function bool InternalOnClick(GUIComponent Sender) { local int i; for (i = 0; i < infoButtons.length; i++) { /// Button is normal: infoButtons[i].MenuState = MSAT_Blurry; } for (i = 0; i < infoButtons.length; i++) { //log("found: " @ i @ "- "@ Sender); if (infoButtons[i] == Sender) { //Log(HandBookDataSet[i].NL_text[0]); LoadHandBookInfo(HandBookDataSet[i]); /// This button is pressed: infoButtons[i].MenuState = MSAT_Focused; break; } } return true; } //============================================================================= // Date Id Modification // 2006-10-07 The Created this header //============================================================================= defaultproperties { WinTop=0 WinLeft=0 WinHeight=1 WinWidth=1 Begin Object Class=GeoScrollText Name=TcScroll_LevelDescription WinLeft = 0.35 WinTop = 0.03 WinWidth = 0.55 WinHeight = 0.53 End Object Begin Object class=GeoImage Name=TPict ImageStyle=ISTY_Justified ImageAlign=IMGA_Center WinLeft = 0.4 WinTop = 0.4 WinWidth = 0.3 WinHeight = 0.3 bVisible=false End Object Begin Object Class=GeoButton Name=TOk OnClick=InternalOnClick bNeverFocus=true End Object cScroll_LevelDescription = TcScroll_LevelDescription Pict = TPict btn1 = TOk btn2 = TOk btn3 = TOk btn4 = TOk btn5 = TOk btn6 = TOk btn7 = TOk //standard variables FirstBullit = "|| * " XthBullit = "| * " AfterLastBullit = "||" }