public MyGuiScreenEditorCopyTool(MyMwcObjectBuilder_Sector sectorBuilder) : base(new Vector2(0.5f, 0.5f), new Vector2(0.8f, 0.88f)) { m_size = new Vector2(0.815f, 0.95f); m_sectorBuilder = sectorBuilder; //Vector2 controlsDelta = new Vector2(0, 0.0525f); //Vector2 controlsColumn1Origin = new Vector2(-m_size.Value.X / 2.0f + 0.03f, -m_size.Value.Y / 2.0f + 0.08f); AddCaption(MyTextsWrapperEnum.CopyTool, MyGuiConstants.LABEL_TEXT_COLOR, new Vector2(0, 0.01f)); m_objectList = new MyGuiControlListbox(this, new Vector2(0f, -0.02f), MyGuiConstants.LISTBOX_LONGMEDIUM_SIZE, MyGuiConstants.DEFAULT_CONTROL_BACKGROUND_COLOR, null, .6f, 1, 17, 1, false, true, false, null, null, MyGuiManager.GetScrollbarSlider(), MyGuiManager.GetHorizontalScrollbarSlider(), 2, 1, MyGuiConstants.LISTBOX_BACKGROUND_COLOR_BLUE, 0f, 0f, 0f, 0f, 0, 0, -0.01f, -0.01f, -0.02f, 0.02f); m_objectList.MultipleSelection = true; Controls.Add(m_objectList); //AddOkAndCancelButtonControls(); Vector2 buttonPosition = new Vector2(0, m_size.Value.Y / 2.0f - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_Y - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y - 0.02f); Vector2 buttonSize = new Vector2(0.25f, MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y); Controls.Add(new MyGuiControlButton(this, new Vector2(MyGuiConstants.MESSAGE_BOX_BORDER_AREA_X - 0.05f - m_size.Value.X / 2, 0) + buttonPosition + buttonSize / 2, buttonSize, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.SelectAllNone, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnSelectAllNone, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, new Vector2(m_size.Value.X / 2 - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_X - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.X - buttonSize.X + 0.01f, 0) + buttonPosition + buttonSize / 2, buttonSize, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.AddSelectedToSector, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnAddSelected, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, new Vector2(m_size.Value.X / 2 - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_X - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.X +0.05f, 0) + buttonPosition + MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE / 2, MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Cancel, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnCancel, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); FillControls(); }
private void SandboxSectorLoaded(MyMwcVector3Int targetSector, MyMwcObjectBuilder_Checkpoint checkpoint, MyMwcObjectBuilder_Sector cachedSector, MyMwcStartSessionRequestTypeEnum startSessionType, MyMissionID? startMission) { if (checkpoint.SectorObjectBuilder == null) // Server said, use cache { checkpoint.SectorObjectBuilder = cachedSector; } else { MyLocalCache.SaveCheckpoint(checkpoint); } MyGuiScreenGamePlay.ReloadGameplayScreen(checkpoint, startSessionType, MyGuiScreenGamePlayType.GAME_SANDBOX, startMission); }
private void TravelSectorLoaded(MyMwcTravelTypeEnum travelType, MyMwcVector3Int targetSector, byte[] sectorDataResponse, MyMwcObjectBuilder_Sector cachedSector) { var checkpoint = GetCheckpointBuilder(false); checkpoint.SectorObjectBuilder = cachedSector; // Overwrite current sector checkpoint.CurrentSector.Position = targetSector; UpdatePlayerPosition(travelType, ref checkpoint.PlayerObjectBuilder.ShipObjectBuilder.PositionAndOrientation.Position); if (sectorDataResponse != null) { checkpoint.SectorObjectBuilder = MyMwcObjectBuilder_Base.FromBytes<MyMwcObjectBuilder_Sector>(sectorDataResponse); MyLocalCache.Save(null, checkpoint.SectorObjectBuilder, checkpoint.CurrentSector); } // Change NEW_STORY to LOAD_CHECKPOINT, because it's necessary, travel is never new story MyMwcStartSessionRequestTypeEnum? sessionStart = null; if (MyGuiScreenGamePlay.Static != null) { sessionStart = MyGuiScreenGamePlay.Static.GetSessionType(); if (sessionStart.HasValue && sessionStart.Value == MyMwcStartSessionRequestTypeEnum.NEW_STORY) { sessionStart = MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT; } } MyGuiScreenGamePlay.ReloadGameplayScreen(checkpoint, sessionStart, null, null, travelType); }
//private void LoadSector() //{ // // Handles also cache // var travelScreen = new MyGuiScreenEnterSectorProgress(MyMwcTravelTypeEnum.SOLAR, m_checkpoint.CurrentSector.Position, new MinerWarsMath.Vector3(), OnTravelSuccess, m_checkpoint.CurrentSector); // MyGuiManager.AddScreen(travelScreen); //} private void OnTravelSuccess(MyMwcObjectBuilder_Sector sector, Vector3 newPosition) { m_checkpoint.SectorObjectBuilder = sector; m_loadCheckpointSuccessfulAction(m_checkpoint); CloseScreen(); }
//this method creates world objects from object builders received from server public static void CreateFromSectorObjectBuilder(MyMwcObjectBuilder_Sector sectorBuilder) { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("CreateFromSectorObjectBuilder"); if (MyFakes.VOXEL_IMPORT) { UpdateBuildersForVoxelImport(sectorBuilder); } CreateFromObjectBuilders(sectorBuilder.SectorObjects); MySolarSectorData defaultSectorData = MySolarSystemConstants.GetDefaultArea().SectorData; MySolarSectorData currentSectorData = defaultSectorData; if (sectorBuilder.AreaTemplate.HasValue) { var sectorData = MySolarSystemConstants.Areas[sectorBuilder.AreaTemplate.Value].SectorData; currentSectorData = sectorData.InterpolateWith(defaultSectorData, 1 - sectorBuilder.AreaMultiplier); } MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMwcObjectBuilder_Sector"); SetSectorProperties(currentSectorData); MyBackgroundCube.ReloadContent(); MyDistantImpostors.ReloadContent(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); MyVoxelMaps.AutoRecalculateVoxelMaps = true; #if PROFILING Console.WriteLine("Total voxel load: {0}", MyPerformanceTimer.VoxelLoad.GetTotalTimeSpent()); Console.WriteLine("Total voxel content merge: {0}", MyPerformanceTimer.VoxelContentMerge.GetTotalTimeSpent()); Console.WriteLine("Total voxel material merge: {0}", MyPerformanceTimer.VoxelMaterialMerge.GetTotalTimeSpent()); Console.WriteLine("Total voxel hand: {0}", MyPerformanceTimer.VoxelHandLoad.GetTotalTimeSpent()); #endif //PROFILING MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); }
private static void UpdateBuildersForVoxelImport(MyMwcObjectBuilder_Sector sectorBuilder) { sectorBuilder.SectorObjects.RemoveAll(x => x.GetObjectBuilderType() != MyMwcObjectBuilderTypeEnum.SmallShip_Player && x.GetObjectBuilderType() != MyMwcObjectBuilderTypeEnum.Sector); sectorBuilder.SectorObjects.Add(new MyMwcObjectBuilder_VoxelMap(new Vector3(-160, -100, 3000), MyMwcVoxelFilesEnum.VoxelImporterTest, MyMwcVoxelMaterialsEnum.Cobalt_01)); }