public MyScriptItemInfo(MyBlueprintTypeEnum type,string scriptName,ulong? id = null,string description =null,MySteamWorkshop.SubscribedItem item=null): base(type,id) { ScriptName = scriptName; Description = description; SteamItem = item; }
public MyGuiScreenWorkshopTags(string typeTag, MySteamWorkshop.Category[] categories, string[] tags, Action<MyGuiScreenMessageBox.ResultEnum, string[]> callback) : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, GetScreenSize(categories)) { Static = this; m_typeTag = typeTag ?? ""; m_activeTags = new Dictionary<string, MyStringId>(categories.Length); foreach (var category in categories) { m_activeTags.Add(category.Id, category.LocalizableName); } m_callback = callback; EnabledBackgroundFade = true; RecreateControls(true); SetSelectedTags(tags); }
private const int TAGS_MAX_LENGTH = 128; // DONT TOUCH THIS private static Vector2 GetScreenSize(MySteamWorkshop.Category[] categories) { return new Vector2(0.4f, 0.05f * (categories.Length + 1) + 0.2f); }
private MyGuiControlButton MakeButtonCategory(Vector2 position, MySteamWorkshop.Category category) { var idWithoutSpaces = category.Id.Replace(" ", ""); var button = MakeButtonTiny(position, 0f, category.LocalizableName, new MyGuiHighlightTexture { Normal = string.Format(@"Textures\GUI\Icons\buttons\{0}.dds", idWithoutSpaces), Highlight = string.Format(@"Textures\GUI\Icons\buttons\{0}Highlight.dds", idWithoutSpaces), SizePx = new Vector2(64f, 64f), }, OnCategoryButtonClick); button.UserData = category.Id; button.HighlightType = MyGuiControlHighlightType.FORCED; m_categoryButtonList.Add(button); return button; }
void ExtractWorkshopItem(MySteamWorkshop.SubscribedItem subItem) { string archive = Path.Combine(m_workshopBlueprintFolder, subItem.PublishedFileId.ToString() + m_workshopBlueprintSuffix); var extractPath = Path.Combine(TEMP_PATH, subItem.PublishedFileId.ToString()); if (Directory.Exists(extractPath)) { Directory.Delete(extractPath); } Directory.CreateDirectory(extractPath); var extracted = MyZipArchive.OpenOnFile(archive); var modInfo = new MyObjectBuilder_ModInfo(); modInfo.SubtypeName = subItem.Title; modInfo.WorkshopId = subItem.PublishedFileId; modInfo.SteamIDOwner = subItem.SteamIDOwner; var infoFile = Path.Combine(TEMP_PATH,subItem.PublishedFileId.ToString(), "info.temp"); if (File.Exists(infoFile)) { File.Delete(infoFile); } var infoSuccess = MyObjectBuilderSerializer.SerializeXML(infoFile, false, modInfo); if (extracted.FileExists("thumb.png")) { var stream = extracted.GetFile("thumb.png").GetStream(); if (stream != null) { using (var file = File.Create(Path.Combine(extractPath, "thumb.png"))) { stream.CopyTo(file); } } stream.Close(); } extracted.Dispose(); var info = new MyBlueprintItemInfo(MyBlueprintTypeEnum.STEAM, subItem.PublishedFileId); var listItem = new MyGuiControlListbox.Item(text: new StringBuilder(subItem.Title), toolTip: subItem.Title, icon: MyGuiConstants.TEXTURE_ICON_MODS_WORKSHOP.Normal, userData: info); var itemIndex = m_blueprintList.Items.FindIndex(item => ((item.UserData as MyBlueprintItemInfo).PublishedItemId == (listItem.UserData as MyBlueprintItemInfo).PublishedItemId) && (item.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.STEAM); if (itemIndex == -1) { m_blueprintList.Add(listItem); } }
bool IsExtracted(MySteamWorkshop.SubscribedItem subItem) { var extractPath = Path.Combine(TEMP_PATH, subItem.PublishedFileId.ToString()); return Directory.Exists(extractPath); }
void OnBlueprintDownloadedThumbnail(MySteamWorkshop.SubscribedItem item) { m_okButton.Enabled = true; m_blueprintList.Enabled = true; string path = Path.Combine(m_workshopBlueprintFolder, "temp",item.PublishedFileId.ToString(), "thumb.png");; if (File.Exists(path)) { m_thumbnailImage.SetTexture(path); if (!m_activeDetail) { if (m_thumbnailImage.BackgroundTexture != null) { m_thumbnailImage.Visible = true; } } } else { m_thumbnailImage.Visible = false; m_thumbnailImage.BackgroundTexture = null; } m_downloadQueued.Remove(item.PublishedFileId); m_downloadFinished.Add(item.PublishedFileId); }
void OnBlueprintDownloadedDetails(MySteamWorkshop.SubscribedItem workshopDetails) { var path2 = Path.Combine(m_workshopBlueprintFolder, workshopDetails.PublishedFileId.ToString() + m_workshopBlueprintSuffix); if (File.Exists(path2)) { m_thumbnailImage.Visible = false; m_detailScreen = new MyGuiDetailScreenSteam( callBack: delegate(MyGuiControlListbox.Item item) { m_selectedItem = item; m_activeDetail = false; m_detailScreen = null; if (Task.IsComplete) { RefreshBlueprintList(); } }, selectedItem: m_selectedItem, parent: this, thumbnailTexture: m_selectedImage.BackgroundTexture, textScale: m_textScale ); m_activeDetail = true; MyScreenManager.InputToNonFocusedScreens = true; MyScreenManager.AddScreen(m_detailScreen); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( buttonType: MyMessageBoxButtonsType.OK, styleEnum: MyMessageBoxStyleEnum.Error, messageCaption: new StringBuilder("Error"), messageText: new StringBuilder("Cannot find the blueprint file.") )); } }
void DownloadBlueprintFromSteam(MySteamWorkshop.SubscribedItem item) { if (MySteamWorkshop.IsBlueprintUpToDate(item)) { return; } MySteamWorkshop.DownloadBlueprintBlocking(item,false); ExtractWorkshopItem(item); }