diff --git a/.gitignore b/.gitignore index ff6d2a8df9..3df12c7dab 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ user.props 3rd/SteamSDK/release/x64 3rd/VRage.Native/debug/x64 3rd/VRage.Native/release/x64 +packages \ No newline at end of file diff --git a/3rd/HavokWrapper_SE/release/x64/HavokWrapper.dll b/3rd/HavokWrapper_SE/release/x64/HavokWrapper.dll new file mode 100644 index 0000000000..32534ee39c Binary files /dev/null and b/3rd/HavokWrapper_SE/release/x64/HavokWrapper.dll differ diff --git a/Sources/Sandbox.Game/Game/Screens/MyGuiScreenScenario.cs b/Sources/Sandbox.Game/Game/Screens/MyGuiScreenScenario.cs index 7d655ddcd6..b3c2f732b4 100644 --- a/Sources/Sandbox.Game/Game/Screens/MyGuiScreenScenario.cs +++ b/Sources/Sandbox.Game/Game/Screens/MyGuiScreenScenario.cs @@ -1,28 +1,19 @@ using ParallelTasks; -using Sandbox.Common; -using Sandbox.Common.ObjectBuilders; -using Sandbox.Definitions; using Sandbox.Engine.Networking; using Sandbox.Engine.Utils; using Sandbox.Game.GameSystems; -using Sandbox.Game.Gui; using Sandbox.Game.Localization; using Sandbox.Game.Multiplayer; using Sandbox.Game.Screens; -using Sandbox.Game.Screens.Helpers; using Sandbox.Game.World; using Sandbox.Graphics.GUI; using SteamSDK; using System; using System.Collections.Generic; using System.Diagnostics; -using System.IO; -using System.Linq; using System.Text; using VRage; -using VRage.FileSystem; using VRage.Game; -using VRage.Library.Utils; using VRage.Utils; using VRageMath; @@ -38,6 +29,8 @@ class MyGuiScreenScenario : MyGuiScreenScenarioBase string m_sessionPath; + MyGuiControlTable.Row m_selectedScenario = null; + #if !XB1 // XB1_NOWORKSHOP private List m_subscribedScenarios; #endif // !XB1 @@ -69,11 +62,16 @@ public MyObjectBuilder_Checkpoint Checkpoint //BUTTONS: MyGuiControlButton m_removeButton, m_publishButton, m_editButton, m_browseWorkshopButton; - MyGuiControlButton m_refreshButton, m_openInWorkshopButton; + MyGuiControlButton m_refreshButton, m_openInWorkshopButton; MyGuiControlList m_scenarioTypesList; MyGuiControlRadioButtonGroup m_scenarioTypesGroup; + // Counter for scenario type + int m_maxKeensScenario = 2; + int m_maxWorkshopScenario = 0; + int m_maxLocalScenario = 0; + public MyGuiScreenScenario() : base() { @@ -95,9 +93,6 @@ protected override void BuildControls() { base.BuildControls(); - Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE; - Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.65f, 0.1f); - var difficultyLabel = MakeLabel(MySpaceTexts.Difficulty); var onlineModeLabel = MakeLabel(MyCommonTexts.WorldSettings_OnlineMode); m_maxPlayersLabel = MakeLabel(MyCommonTexts.MaxPlayers); @@ -132,17 +127,20 @@ protected override void BuildControls() m_scenarioTypesList = new MyGuiControlList(); //BUTTONS - m_removeButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonRemove), onButtonClick: OnOkButtonClick); #if !XB1 // XB1_NOWORKSHOP + m_removeButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonRemove), onButtonClick: OnRemoveButtonClick); m_publishButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonPublish), onButtonClick: OnPublishButtonClick); + m_openInWorkshopButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonOpenInWorkshop), onButtonClick: OnOpenInWorkshopClick); #else // XB1 + m_removeButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonRemove), onButtonClick: OnOkButtonClick); m_publishButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonPublish), onButtonClick: OnOkButtonClick); + m_openInWorkshopButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonOpenInWorkshop), onButtonClick: OnOkButtonClick); #endif // XB1 m_editButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonEdit), onButtonClick: OnEditButtonClick); m_browseWorkshopButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonBrowseWorkshop), onButtonClick: OnBrowseWorkshopClick); m_refreshButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonRefresh), onButtonClick: OnRefreshButtonClick); - m_openInWorkshopButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonOpenInWorkshop), onButtonClick: OnOkButtonClick); + m_removeButton.Enabled = false; m_publishButton.Enabled = false; @@ -280,15 +278,37 @@ protected override void OnTableItemSelected(MyGuiControlTable sender, MyGuiContr { base.OnTableItemSelected(sender, eventArgs); - if (eventArgs.RowIndex<2) + m_selectedScenario = sender.SelectedRow; + // First check the keens scenario + if (eventArgs.RowIndex < m_maxKeensScenario ) { +#if !XB1 // XB1_NOWORKSHOP + m_removeButton.Enabled = false; + m_openInWorkshopButton.Enabled = false; +#endif m_publishButton.Enabled = false; m_onlineMode.Enabled = false; m_onlineMode.SelectItemByIndex(0); m_editButton.Enabled = false; } + // workshop scenario and local else { +#if !XB1 // XB1_NOWORKSHOP + if (eventArgs.RowIndex < m_maxKeensScenario+m_maxWorkshopScenario) + { + m_removeButton.Enabled = true; + m_openInWorkshopButton.Enabled = true; + } + else + { + m_removeButton.Enabled = false; // TODO: Remove this if RemoveLocal() is implemented + m_openInWorkshopButton.Enabled = false; + } +#else + m_removeButton.Enabled = false; // TODO: Remove this if RemoveLocal() is implemented + m_openInWorkshopButton.Enabled = false; +#endif m_publishButton.Enabled = false; m_onlineMode.Enabled = true; @@ -302,6 +322,93 @@ protected override void OnTableItemSelected(MyGuiControlTable sender, MyGuiContr } } } + + private void OnRemoveButtonClick(MyGuiControlButton obj) + { + if (m_selectedScenario == null) + return; + + Tuple tuple = (Tuple)m_selectedScenario.UserData; + if (tuple == null) + return; + MyWorldInfo scenario = tuple.Item2; + + MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( + buttonType: MyMessageBoxButtonsType.YES_NO, + messageText: new StringBuilder().AppendFormat(MyCommonTexts.MessageBoxTextAreYouSureYouWantToDeleteSave, scenario.SessionName), + messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionPleaseConfirm), + callback: OnDeleteConfirm)); + } + + + private void OnDeleteConfirm(MyGuiScreenMessageBox.ResultEnum callbackReturn) + { + if (callbackReturn == MyGuiScreenMessageBox.ResultEnum.YES) + { + +#if !XB1 // XB1_NOWORKSHOP + Tuple tuple = (Tuple)m_selectedScenario.UserData; + MyWorldInfo scenario = tuple.Item2; + // For workshop items + if (m_selectedRowIndex < m_maxKeensScenario + m_maxWorkshopScenario) + { + // Use steamAPI for unsubcribeItem... + MySandboxGame.Services.SteamService.SteamAPI.UGC.UnsubscribeItem((ulong)scenario.WorkshopId, OnCallResultSteamAPI); + } + // //user's from saves + else + { + RemoveLocal(); + } +#else + RemoveLocal(); +#endif + } + } + + +#if !XB1 // XB1_NOWORKSHOP + private void OnCallResultSteamAPI(bool arg1, RemoteStorageUnsubscribePublishedFileResult arg2) + { + m_scenarioTable.RemoveSelectedRow(); + m_selectedScenario = null; + m_maxWorkshopScenario -= 1; + m_openInWorkshopButton.Enabled = false; + m_removeButton.Enabled = false; + FillRight(); + } +#endif + + // TODO: Remove local + private void RemoveLocal() + { + // TODO: Remove local file... + + //m_scenarioTable.RemoveSelectedRow(); + //m_selectedScenario = null; + //m_maxLocalScenario -= 1; + //m_removeButton.Enabled = false; + //FillRight(); + } + + private void OnBrowseWorkshopClick(MyGuiControlButton obj) + { + MyGuiSandbox.OpenUrlWithFallback(MySteamConstants.URL_BROWSE_WORKSHOP_SCENARIOS, "Steam Workshop"); + } + + private void OnOpenInWorkshopClick(MyGuiControlButton obj) + { + if (m_selectedScenario == null) + return; + + Tuple tuple = (Tuple)m_selectedScenario.UserData; + if (tuple == null) + return; + + MyWorldInfo scenario = tuple.Item2; + string url = string.Format(MySteamConstants.URL_WORKSHOP_VIEW_ITEM_FORMAT, scenario.WorkshopId); + MyGuiSandbox.OpenUrlWithFallback(url, "Steam Workshop"); + } #endregion @@ -362,11 +469,14 @@ private void endKeens(IMyAsyncResult result, MyGuiScreenProgressAsync screen) messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError)); MyGuiSandbox.AddScreen(messageBox); } + + m_maxKeensScenario = m_availableSavesKeens.Count; + AfterPartLoaded(); screen.CloseScreen(); } - + private IMyAsyncResult beginLocal() { return new MyLoadWorldInfoListResult(); @@ -401,6 +511,7 @@ private void endWorkshop(IMyAsyncResult result, MyGuiScreenProgressAsync screen) m_availableSavesWorkshop.Add(new Tuple(WORKSHOP_PATH_TAG, wi)); } m_availableSavesWorkshop.Sort((x, y) => x.Item2.SessionName.CompareTo(y.Item2.SessionName)); + m_maxWorkshopScenario = m_subscribedScenarios.Count; AfterPartLoaded(); screen.CloseScreen(); } @@ -460,7 +571,7 @@ void OnPublishButtonClick(MyGuiControlButton sender) //var mod = (MyObjectBuilder_Checkpoint.ModItem)row.UserData; //var nameSB = m_selectedRow.GetCell(1).Text; //var name = nameSB.ToString(); - + MyStringId textQuestion, captionQuestion; if (worldInfo.WorkshopId != null) { @@ -501,44 +612,44 @@ void OnPublishButtonClick(MyGuiControlButton sender) { if (tagsResult == MyGuiScreenMessageBox.ResultEnum.YES) {*/ - MySteamWorkshop.PublishScenarioAsync(fullPath, worldInfo.SessionName, worldInfo.Description, worldInfo.WorkshopId, /*outTags,*/ SteamSDK.PublishedFileVisibility.Public, callbackOnFinished: delegate(bool success, Result result, ulong publishedFileId)//TODO public visibility!! - { - if (success) - { - ulong dummy; - var checkpoint = MyLocalCache.LoadCheckpoint(fullPath, out dummy); - worldInfo.WorkshopId = publishedFileId; - checkpoint.WorkshopId = publishedFileId; - MyLocalCache.SaveCheckpoint(checkpoint, fullPath); - - MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( - styleEnum: MyMessageBoxStyleEnum.Info, - messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextScenarioPublished), - messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionScenarioPublished), - callback: (a) => - { - MySteam.API.OpenOverlayUrl(string.Format("http://steamcommunity.com/sharedfiles/filedetails/?id={0}", publishedFileId)); - FillList(); - })); - } - else + MySteamWorkshop.PublishScenarioAsync(fullPath, worldInfo.SessionName, worldInfo.Description, worldInfo.WorkshopId, /*outTags,*/ SteamSDK.PublishedFileVisibility.Public, callbackOnFinished: delegate(bool success, Result result, ulong publishedFileId)//TODO public visibility!! + { + if (success) + { + ulong dummy; + var checkpoint = MyLocalCache.LoadCheckpoint(fullPath, out dummy); + worldInfo.WorkshopId = publishedFileId; + checkpoint.WorkshopId = publishedFileId; + MyLocalCache.SaveCheckpoint(checkpoint, fullPath); + + MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( + styleEnum: MyMessageBoxStyleEnum.Info, + messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextScenarioPublished), + messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionScenarioPublished), + callback: (a) => { - MyStringId error; - switch (result) - { - case Result.AccessDenied: - error = MyCommonTexts.MessageBoxTextPublishFailed_AccessDenied; - break; - default: - error = MySpaceTexts.MessageBoxTextScenarioPublishFailed; - break; - } - - MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( - messageText: MyTexts.Get(error), - messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionModPublishFailed))); - } - });/* + MySteam.API.OpenOverlayUrl(string.Format("http://steamcommunity.com/sharedfiles/filedetails/?id={0}", publishedFileId)); + FillList(); + })); + } + else + { + MyStringId error; + switch (result) + { + case Result.AccessDenied: + error = MyCommonTexts.MessageBoxTextPublishFailed_AccessDenied; + break; + default: + error = MySpaceTexts.MessageBoxTextScenarioPublishFailed; + break; + } + + MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( + messageText: MyTexts.Get(error), + messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionModPublishFailed))); + } + });/* } }));*/ } @@ -548,11 +659,6 @@ void OnPublishButtonClick(MyGuiControlButton sender) #endregion - private void OnBrowseWorkshopClick(MyGuiControlButton obj) - { - MyGuiSandbox.OpenUrlWithFallback(MySteamConstants.URL_BROWSE_WORKSHOP_SCENARIOS, "Steam Workshop"); - } - protected override MyStringId ScreenCaption { get { return MySpaceTexts.ScreenCaptionScenario; } diff --git a/Sources/Sandbox.Game/Game/Screens/MyGuiScreenScenarioBase.cs b/Sources/Sandbox.Game/Game/Screens/MyGuiScreenScenarioBase.cs index d99e9b4606..e6bb03c1aa 100644 --- a/Sources/Sandbox.Game/Game/Screens/MyGuiScreenScenarioBase.cs +++ b/Sources/Sandbox.Game/Game/Screens/MyGuiScreenScenarioBase.cs @@ -1,10 +1,4 @@ -using Sandbox.Common; -using Sandbox.Common.ObjectBuilders; -using Sandbox.Engine.Networking; -using Sandbox.Engine.Utils; -using Sandbox.Game.GameSystems; -using Sandbox.Game.Gui; -using Sandbox.Game.Localization; +using Sandbox.Engine.Utils; using Sandbox.Game.World; using Sandbox.Graphics.GUI; using System; @@ -36,8 +30,8 @@ protected enum StateEnum protected MyLayoutTable m_sideMenuLayout; protected MyLayoutTable m_buttonsLayout; - protected int m_selectedRow; - + protected int m_selectedRowIndex; + protected const float MARGIN_TOP = 0.1f; protected const float MARGIN_LEFT = 0.42f; protected const string WORKSHOP_PATH_TAG = "workshop"; @@ -96,7 +90,7 @@ protected virtual void BuildControls() m_sideMenuLayout = new MyLayoutTable(this, originL, layoutSize); m_sideMenuLayout.SetColumnWidthsNormalized(columnWidthLabel, columnWidthControl); m_sideMenuLayout.SetRowHeightsNormalized(rowHeight, rowHeight, rowHeight, rowHeight, rowHeight); - + m_sideMenuLayout.Add(nameLabel, MyAlignH.Left, MyAlignV.Top, 0, 0); m_sideMenuLayout.Add(m_nameTextbox, MyAlignH.Left, MyAlignV.Top, 0, 1); m_sideMenuLayout.Add(descriptionLabel, MyAlignH.Left, MyAlignV.Top, 1, 0); @@ -133,8 +127,8 @@ protected virtual void BuildControls() { int buttonRowCount = 2; int buttonColumnCount = 4; - Vector2 buttonSize = new Vector2(300f / 1600f, 70f / 1200f); - Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.83f, 0.16f); + Vector2 buttonSize = new Vector2(320f / 1600f, 70f / 1200f); + Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.865f, 0.16f); Vector2 buttonOffset = new Vector2(0.01f, 0.01f); Vector2 buttonLayoutSize = new Vector2((buttonSize.X + buttonOffset.X) * (buttonColumnCount), (buttonSize.Y + buttonOffset.Y) * (buttonRowCount)); m_buttonsLayout = new MyLayoutTable(this, buttonsOrigin, buttonLayoutSize); @@ -225,7 +219,7 @@ private void OnCancelButtonClick(object sender) protected virtual void OnTableItemSelected(MyGuiControlTable sender, MyGuiControlTable.EventArgs eventArgs) { - m_selectedRow = eventArgs.RowIndex; + m_selectedRowIndex = eventArgs.RowIndex; FillRight(); } @@ -322,12 +316,12 @@ protected void RefreshGameList(bool tutorials = false) // Select row with same world ID as we had before refresh. if (index == selectedIndex) { - m_selectedRow = index; + m_selectedRowIndex = index; m_scenarioTable.SelectedRow = row; } } - m_scenarioTable.SelectedRowIndex = m_selectedRow; + m_scenarioTable.SelectedRowIndex = m_selectedRowIndex; m_scenarioTable.ScrollToSelection(); FillRight(); } @@ -337,7 +331,7 @@ protected Tuple FindSave(MyGuiControlTable.Row row) return (Tuple)(row.UserData); } - + protected virtual MyGuiHighlightTexture GetIcon(Tuple save) { return MyGuiConstants.TEXTURE_ICON_BLUEPRINTS_LOCAL; diff --git a/Sources/VRage.Network/MyRakNetConnectionException.cs b/Sources/VRage.Network/MyRakNetConnectionException.cs index 697dc6b4eb..e9b707ab38 100644 --- a/Sources/VRage.Network/MyRakNetConnectionException.cs +++ b/Sources/VRage.Network/MyRakNetConnectionException.cs @@ -1,20 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Text; -namespace VRage.Network -{ - public class MyRakNetConnectionException : Exception - { -#if !XB1 - public readonly ConnectionAttemptResultEnum ConnectionResult; +//namespace VRage.Network +//{ +// public class MyRakNetConnectionException : Exception +// { +//#if !XB1 +// public readonly ConnectionAttemptResultEnum ConnectionResult; - public MyRakNetConnectionException(string message, ConnectionAttemptResultEnum connectionResult, Exception innerException = null) - : base(message, innerException) - { - ConnectionResult = connectionResult; - } -#endif - } -} +// public MyRakNetConnectionException(string message, ConnectionAttemptResultEnum connectionResult, Exception innerException = null) +// : base(message, innerException) +// { +// ConnectionResult = connectionResult; +// } +//#endif +// } +//} diff --git a/Sources/VRage.Network/MyRakNetStartupException.cs b/Sources/VRage.Network/MyRakNetStartupException.cs index 2d8e2152ba..14bbcf3e17 100644 --- a/Sources/VRage.Network/MyRakNetStartupException.cs +++ b/Sources/VRage.Network/MyRakNetStartupException.cs @@ -1,21 +1,21 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using VRage.Network; +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Text; +//using VRage.Network; -namespace VRage.Network -{ - public class MyRakNetStartupException : Exception - { -#if !XB1 - public readonly StartupResultEnum StartupResult; +//namespace VRage.Network +//{ +// public class MyRakNetStartupException : Exception +// { +//#if !XB1 +// public readonly StartupResultEnum StartupResult; - public MyRakNetStartupException(string message, StartupResultEnum startupResult, Exception innerException = null) - : base(message, innerException) - { - StartupResult = startupResult; - } -#endif - } -} +// public MyRakNetStartupException(string message, StartupResultEnum startupResult, Exception innerException = null) +// : base(message, innerException) +// { +// StartupResult = startupResult; +// } +//#endif +// } +//} diff --git a/Sources/VRage.Scripting/VRage.Scripting.csproj b/Sources/VRage.Scripting/VRage.Scripting.csproj index 53f8efb6a6..a3a452b349 100644 --- a/Sources/VRage.Scripting/VRage.Scripting.csproj +++ b/Sources/VRage.Scripting/VRage.Scripting.csproj @@ -33,20 +33,23 @@ MinimumRecommendedRules.ruleset - - ..\..\3rd\Microsoft.CodeAnalysis\Microsoft.CodeAnalysis.dll + + ..\..\packages\Microsoft.CodeAnalysis.Common.1.2.0\lib\net45\Microsoft.CodeAnalysis.dll + True - - ..\..\3rd\Microsoft.CodeAnalysis\Microsoft.CodeAnalysis.CSharp.dll + + ..\..\packages\Microsoft.CodeAnalysis.CSharp.1.2.0\lib\net45\Microsoft.CodeAnalysis.CSharp.dll + True - False - ..\..\3rd\Microsoft.CodeAnalysis\System.Collections.Immutable.dll + ..\..\packages\System.Collections.Immutable.1.1.37\lib\dotnet\System.Collections.Immutable.dll + True - - ..\..\3rd\Microsoft.CodeAnalysis\System.Reflection.Metadata.dll + + ..\..\packages\System.Reflection.Metadata.1.2.0\lib\portable-net45+win8\System.Reflection.Metadata.dll + True @@ -86,6 +89,13 @@ + + + + + + +