// 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. //============================================================================= // Menu that shows up map of the level // Loads MyLevel.LevelMap.MapPreview texture from each level // ------------------------------------------------------------ // Created by Rui Guimaraes // © 2006, Geodelft // // Date Id Modification // 2006-09-12 Gui Warping done // 2006-09-28 Gui Updated for new training map // 2006-12-04 zmr When bMovingToWarning etc and the warningmarker is shown different. // 2007-06-10 gui Maps sizes can now be editable individually in GeoMapDetails //============================================================================= class MenuMap extends GUIPage; var string EN_Topic, NL_Topic; var GeoPlayerController GeoPC; var bool bIgnoreEsc; var float ButtonWidth; var float ButtonHeight; var float ButtonHGap; var float ButtonVGap; var float BarHeight; var float BarVPos; var float SButtonSize; var float SButtonVGap; var float SButtonHGap; const MAX_MARKERS_POS = 37; struct ExtraCompressedPosition { var vector Location; var rotator Rotation; }; var ExtraCompressedPosition ArrayPositions[MAX_MARKERS_POS]; //Variables for map texture (can be easilly changed this way) var float MapHeight, MapWidth, MapCenterX, MapCenterY; var bool ShowboundingBoxes; function InitComponent(GUIController MyController, GUIComponent MyOwner) { local string MapName; Super.InitComponent(MyController, MyOwner); OnKeyEvent = InternalOnKeyEvent; OnClose = InternalOnClose; GeoPC=GeoPlayerController(PlayerOwner()); MapName=string(GeoPC.Outer); // BUTTON 1 Controls[1].WinTop = 0.15 + SButtonVGap; Controls[1].WinLeft = 0.5 + (0.7 / 2) - (SButtonSize) - SButtonHGap; Controls[1].WinWidth = SButtonSize; Controls[1].WinHeight = SButtonSize; // BUTTON 2 Controls[2].WinTop = Controls[1].WinTop; Controls[2].WinLeft = Controls[1].WinLeft - (SButtonSize) - SButtonHGap;; Controls[2].WinWidth = SButtonSize; Controls[2].WinHeight = SButtonSize; //UPDATE BACKGROUND IMAGE GuiImage(Controls[5]).Image=Material(DynamicLoadObject(MapName$".LevelMap.MapPreview", class'Material')); UpdateLimits(); UpdateMarkers(); ShowboundingBoxes = bool(Localize("DebugInfo", "Showboxes", "GeoSimulator")); if(GeoPC!=None) UpdateLanguage(); else Warn("Error with the type of game."); Controls[0].SetFocus(none); GeoPC.geoFb.logEvent("show_map"); } function bool InternalOnKeyEvent(out byte Key, out byte State, float delta) { if(Key == 0x1B || Key == 0x6D || Key == 0x4D || Key == 0x4B) // EXITS WITH ESC, M and m, k { if(bIgnoreEsc) { bIgnoreEsc=false; return true; } else { GeoPC.InMenu(false); Controller.CloseMenu(); return true; } } } function bool OnDraw(Canvas MyCanvas) { Super.OnDraw(MyCanvas); UpdatePlayerPosition(); /// Display debug boxes? if (ShowboundingBoxes) { UpdateFailures(MyCanvas); } return true; } function UpdateLimits() { local GeoMapDetails GMD; local GeoLevelDetails GLD; local int MapNumber; GMD = new class'GeoMapDetails'; GLD = new class'GeoLevelDetails'; MapNumber = GLD.CurrentLevelScenarioNumber; MapHeight=GMD.GetHeight(MapNumber); MapWidth=GMD.GetWidth(MapNumber); MapCenterX=GMD.GetCenterX(MapNumber); MapCenterY=GMD.GetCenterY(MapNumber); Log("Update limits - mapnumber: " @ MapNumber); } function UpdatePlayerPosition() { local PlayerController pc; local float TempWidth, TempHeight; pc = PlayerOwner(); TempWidth=(Controls[5].WinWidth) / 2; TempHeight=(Controls[5].WinHeight) / 2; Controls[6].WinLeft= 0.5 - ((pc.Pawn.Location.x - MapCenterX)/ MapWidth) * TempWidth - (Controls[6].WinWidth / 2); Controls[6].WinTop= 0.54 - ((pc.Pawn.Location.y - MapCenterY)/ MapHeight) * TempHeight - (Controls[6].WinHeight / 2); /* 2007-11-08 Jln Debugging purposes Log("control5 winwidth:" @ Controls[5].WinWidth @ " height: " @Controls[5].WinHeight ); Log("control6 winwidth:" @ Controls[6].WinWidth @ " height: " @Controls[6].WinHeight ); Log("mapwidth:" @ MapWidth @ " height: " @MapHeight); Log("center x:" @ MapCenterX @ " y: " @MapCenterY); Log("REAL player x:" @ pc.Pawn.Location.x @ " y: " @ pc.Pawn.Location.y); Log("MAP player x:" @ Controls[6].WinLeft @ " y: " @ Controls[6].WinTop); */ TexRotator(GuiImage(Controls[6]).Image).Rotation.Yaw=-pc.Pawn.Rotation.Yaw + 16384; Controls[6].bVisible=true; } /// jln - 05-03-2009 New code, display failure mechanism rectangles function UpdateFailures(Canvas C) { local LeveeFailure F; local int i; local float TempWidth, TempHeight; local vector coords[4]; TempWidth=(Controls[5].WinWidth) / 2; TempHeight=(Controls[5].WinHeight) / 2; ForEach GeoPC.DynamicActors( class 'LeveeFailure', F) { for ( i = 0; i < 4; i++) { coords[i].x = (0.5 - (((F.BoundingBoxCache[i].x - MapCenterX) / MapWidth) * TempWidth)) * C.SizeX; coords[i].y = (0.54 - (((F.BoundingBoxCache[i].y - MapCenterY) / MapHeight) * TempHeight)) * C.SizeY; } DrawLine(C, coords[0].x,coords[0].y, coords[1].x,coords[1].y); DrawLine(C, coords[1].x,coords[1].y, coords[2].x,coords[2].y); DrawLine(C, coords[2].x,coords[2].y, coords[3].x,coords[3].y); DrawLine(C, coords[3].x,coords[3].y, coords[0].x,coords[0].y); } } function UpdateMarkers() { local int i; local float TempWidth, TempHeight; local actor A; // FIND ALL RED MARKER ONCE i = 7; //First controller for markers TempWidth=(Controls[5].WinWidth) / 2; TempHeight=(Controls[5].WinHeight) / 2; ForEach GeoPC.DynamicActors( class 'Actor', A, 'RedMarker') { Controls[i].WinLeft= 0.5 - ((A.Location.x - MapCenterX) / MapWidth) * TempWidth - (Controls[i].WinWidth / 2); Controls[i].WinTop= 0.54 - ((A.Location.y - MapCenterY) / MapHeight) * TempHeight - (Controls[i].WinHeight); Controls[i].bVisible=true; if(GeoPC.bRememberWarning || GeoPC.bCorrectionWarning ||GeoPC.bMovingToWarning) { //log("MenuMap, GOTO Marker???"); if(A.Location.X == GeoPC.wMsg.warningMarker.Location.X && A.Location.Y == GeoPC.wMsg.warningMarker.Location.Y) { //log("MenuMap, GOTO Marker!!!"); GUIGFxButton(Controls[i]).Graphic=Material'GUIContent.Menu.ArrowBlueDown'; } } ArrayPositions[i].Location=A.Location; ArrayPositions[i].Rotation=A.Rotation; if (i TODO: see how to create object here i++; } log("MenuMap FakeRedMarker1"); ForEach GeoPC.AllActors( class 'Actor', A, 'FakeRedMarker') { Controls[i].WinLeft= 0.5 - ((A.Location.x - MapCenterX) / MapWidth) * TempWidth - (Controls[i].WinWidth / 2); Controls[i].WinTop= 0.54 - ((A.Location.y - MapCenterY) / MapHeight) * TempHeight - (Controls[i].WinHeight); Controls[i].bVisible=true; ArrayPositions[i].Location=A.Location; ArrayPositions[i].Rotation=A.Rotation; log("MenuMap FakeRedMarker2"); if (i TODO: see how to create object here i++; } } function InternalOnClose(optional Bool bCanceled) { local PlayerController pc; pc = PlayerOwner(); // Turn pause off if currently paused if(pc != None && pc.Level.Pauser != None) pc.SetPause(false); Super.OnClose(bCanceled); } function bool InternalOnClick(GUIComponent Sender) { local int i; local PlayerController pc; pc = PlayerOwner(); for(i=0; i<11; i++) { if(Sender==Controls[i]) { switch(i) { case 1: GeoPC.InMenu(false); Controller.CloseMenu(); // Close _all_ menus break; case 2: //HELP Controller.ReplaceMenu("GeoSimulator.HelpMenuMap"); GeoPC.InMenu(true); break; case 3: Controller.OpenMenu("GeoInterface.NotAvailable"); break; } } } return true; } function bool MoveOnClick(GUIComponent Sender) { local int i; local PlayerController pc; local vector TempLocation; local float TempSin, TempCos; local bool returner; returner = false; pc = PlayerOwner(); // log("MoveOnClick1"); for(i=6; i< MAX_MARKERS_POS + 1; i++) { //log("MoveOnClick2"); if(Sender==Controls[i]) { // log("MoveOnClick3"); // log("Rot:" @ArrayPositions[i].Rotation.Yaw); TempSin=sin(pi * (ArrayPositions[i].Rotation.Yaw / 65536.0) * 2.0); TempCos=cos(pi * (ArrayPositions[i].Rotation.Yaw / 65536.0) * 2.0); // log("Sin:" @TempSin); //log("Cos:" @TempSin); TempLocation.x=ArrayPositions[i].Location.x - GeoPlayerController(pc).PlacementOfMarkerXY * TempCos; TempLocation.y=ArrayPositions[i].Location.y - GeoPlayerController(pc).PlacementOfMarkerXY * TempSin; TempLocation.z=ArrayPositions[i].Location.z + GeoPlayerController(pc).PlacementOfMarkerZ; // log(TempLocation.x); // log(TempLocation.y); // log(TempLocation.z); if(!(pc.Pawn.SetLocation(TempLocation))) warn("New Location not possible1"); if(!(pc.Pawn.SetRotation(ArrayPositions[i].Rotation))) warn("New Location not possible2"); if(!(pc.Pawn.SetRotation(ArrayPositions[i].Rotation))) warn("New Location not possible3"); returner = true; GeoPC.geoFb.logEvent("Teleport"); } } return returner; } function UpdateLanguage() { if(GeoPC.Dutch) { GUILabel(Controls[4]).Caption=NL_Topic; } else { GUILabel(Controls[4]).Caption=EN_Topic; } } /// Draw line on the canvas: function DrawLine(Canvas c, int x1, int y1, int x2, int y2) { local int deltax; // The difference in the x's local int deltay; // The difference in the y's local int y; // Start y off at the first pixel value local int ynum; // The starting value for the numerator local int x; local int prevx; local int prevy; local int xinc1; local int xinc2; local int yinc1; local int yinc2; local int den; local int num; local int numadd; local int numpixels; local int curpixel; curpixel = 0; deltax = abs(x2 - x1); deltay = abs(y2 - y1); y = y1; x = x1; ynum = deltax / 2; prevx = x1; prevy = y; if (x2 >= x1) // The x-values are increasing { xinc1 = 1; xinc2 = 1; } else // The x-values are decreasing { xinc1 = -1; xinc2 = -1; } if (y2 >= y1) // The y-values are increasing { yinc1 = 1; yinc2 = 1; } else // The y-values are decreasing { yinc1 = -1; yinc2 = -1; } if (deltax >= deltay) // There is at least one x-value for every y-value { xinc1 = 0; // Don't change the x when numerator >= denominator yinc2 = 0; // Don't change the y for every iteration den = deltax; num = deltax / 2; numadd = deltay; numpixels = deltax; // There are more x-values than y-values } else // There is at least one y-value for every x-value { xinc2 = 0; // Don't change the x for every iteration yinc1 = 0; // Don't change the y when numerator >= denominator den = deltay; num = deltay / 2; numadd = deltax; numpixels = deltay; // There are more y-values than x-values } for (curpixel = 0; curpixel <= numpixels; curpixel++) { c.SetPos( x, y); c.DrawLine(0, 1); //up num += numadd; // Increase the numerator by the top of the fraction prevx = x; prevy = y; if (num >= den) // Check if numerator >= denominator { num -= den; // Calculate the new numerator value x += xinc1; // Change the x as appropriate y += yinc1; // Change the y as appropriate } x += xinc2; // Change the x as appropriate y += yinc2; // Change the y as appropriate } } defaultproperties { Begin Object Class=GUIButton name=QuitBackground WinWidth=0.7 WinLeft=0.15 WinTop=0.15 WinHeight=0.7 bAcceptsInput=false bNeverFocus=true StyleName="GeoCallBar" End Object Controls(0)=GUIButton'QuitBackground' Begin Object Class=GUIGFxButton Name=NoReport Caption="" Graphic=Material'InGameMenuImagesT.NoBackgroundButtons.Closed' Position="ICP_Scaled" StyleName="MidGameButton" OnClick=InternalOnClick End Object Controls(1)=GUIButton'NoReport' 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=GUIGFxButton Name=NextPage Caption="" Graphic=Material'InGameMenuImagesT.NoBackgroundButtons.Next' Position="ICP_Scaled" StyleName="MidGameButton" bNeverFocus=true bVisible=false OnClick=InternalOnClick End Object Controls(3)=GUIButton'NextPage' Begin Object class=GUILabel Name=TopicDesc Caption="***" TextALign=TXTA_Center TextColor=(R=255,G=120,B=0,A=255) TextFont="HeaderFont" WinWidth=1 WinLeft=0 WinTop=0.2 WinHeight=32 End Object Controls(4)=GUILabel'TopicDesc' // ************************************************************** // MAP // // ************************************************************** Begin Object class=GUIImage Name=Map WinWidth=0.66 WinLeft=0.17 WinTop=0.25 WinHeight=0.58 ImageStyle="ISTY_Scaled" End Object Controls(5)=GUIImage'Map' Begin Object class=GUIImage Name=Player WinWidth=0.02 WinHeight=0.02 ImageStyle="ISTY_Justified" Image=Material'GeoGameplayTextures.MapIcons.PlayerRotator' bVisible=false End Object Controls(6)=GUIImage'Player' Begin Object class=GUIGFxButton Name=MiniMarker WinWidth=0.014 WinHeight=0.02 Position="ICP_Scaled" Graphic=Material'GeoGameplayTextures.MapIcons.MiniMarker' bVisible=false OnClick=MoveOnClick End Object Controls(7)=GUIGFxButton'MiniMarker' // Problem trying to create them only when necessary Controls(8)=GUIGFxButton'MiniMarker' Controls(9)=GUIGFxButton'MiniMarker' Controls(10)=GUIGFxButton'MiniMarker' Controls(11)=GUIGFxButton'MiniMarker' Controls(12)=GUIGFxButton'MiniMarker' Controls(13)=GUIGFxButton'MiniMarker' Controls(14)=GUIGFxButton'MiniMarker' Controls(15)=GUIGFxButton'MiniMarker' Controls(16)=GUIGFxButton'MiniMarker' Controls(17)=GUIGFxButton'MiniMarker' Controls(18)=GUIGFxButton'MiniMarker' Controls(19)=GUIGFxButton'MiniMarker' Controls(20)=GUIGFxButton'MiniMarker' Controls(21)=GUIGFxButton'MiniMarker' Controls(22)=GUIGFxButton'MiniMarker' Controls(23)=GUIGFxButton'MiniMarker' Controls(24)=GUIGFxButton'MiniMarker' Controls(25)=GUIGFxButton'MiniMarker' Controls(26)=GUIGFxButton'MiniMarker' Controls(27)=GUIGFxButton'MiniMarker' Controls(28)=GUIGFxButton'MiniMarker' Controls(29)=GUIGFxButton'MiniMarker' Controls(30)=GUIGFxButton'MiniMarker' Controls(31)=GUIGFxButton'MiniMarker' Controls(32)=GUIGFxButton'MiniMarker' Controls(33)=GUIGFxButton'MiniMarker' Controls(34)=GUIGFxButton'MiniMarker' Controls(35)=GUIGFxButton'MiniMarker' Controls(36)=GUIGFxButton'MiniMarker' Controls(37)=GUIGFxButton'MiniMarker' ButtonWidth=0.17 ButtonHeight=0.12 ButtonHGap=0.02 ButtonVGap=0.037 BarHeight=0.21 BarVPos=0.5 SButtonSize=0.06 SButtonHGap=0.02 SButtonVGap=0.02 OpenSound=sound'RuntimeInterfaceSounds.SelectDshort' bIgnoreEsc=true bRequire640x480=false bAllowedAsLast=true EN_Topic="Map" NL_Topic="Kaart" }