public static void Initialize(bool dontCheckSteam = false)
    {
        DebugUtil.LogArgs("Localization.Initialize!");
        bool flag = false;

        switch (GetSelectedLanguageType())
        {
        case SelectedLanguageType.Preinstalled:
        {
            string selectedPreinstalledLanguageCode = GetSelectedPreinstalledLanguageCode();
            if (!string.IsNullOrEmpty(selectedPreinstalledLanguageCode))
            {
                DebugUtil.LogArgs("Localization Initialize... Preinstalled localization");
                DebugUtil.LogArgs(" -> ", selectedPreinstalledLanguageCode);
                LoadPreinstalledTranslation(selectedPreinstalledLanguageCode);
            }
            else
            {
                flag = true;
            }
            break;
        }

        case SelectedLanguageType.UGC:
            if (!dontCheckSteam && SteamManager.Initialized && LanguageOptionsScreen.HasInstalledLanguage())
            {
                DebugUtil.LogArgs("Localization Initialize... SteamUGCService");
                PublishedFileId_t item = PublishedFileId_t.Invalid;
                LanguageOptionsScreen.LoadTranslation(ref item);
                if (item != PublishedFileId_t.Invalid)
                {
                    DebugUtil.LogArgs(" -> Loaded steamworks file id: ", item.ToString());
                }
                else
                {
                    DebugUtil.LogArgs(" -> Failed to load steamworks file id: ", item.ToString());
                }
            }
            else
            {
                flag = true;
            }
            break;

        case SelectedLanguageType.None:
            sFontAsset = GetFont(GetDefaultLocale().FontName);
            break;
        }
        if (flag)
        {
            ClearLanguage();
        }
    }
Esempio n. 2
0
 internal void Notify_SteamItemUnsubscribed(PublishedFileId_t pfid)
 {
     if (this.selectedMod != null && this.selectedMod.Identifier == pfid.ToString())
     {
         this.selectedMod = null;
     }
 }
Esempio n. 3
0
    private static string GetLanguageFile(PublishedFileId_t item, out System.DateTime lastModified)
    {
        lastModified = System.DateTime.MinValue;
        if ((UnityEngine.Object)Global.Instance == (UnityEngine.Object)null || Global.Instance.modManager == null)
        {
            Debug.LogFormat("Failed to load language file from local mod installation...too early in initialization flow.");
            return(GetLanguageFileFromSteam(item, out lastModified));
        }
        string language_id = item.ToString();
        Mod    mod         = Global.Instance.modManager.mods.Find((Mod candidate) => candidate.label.id == language_id);

        if (string.IsNullOrEmpty(mod.label.id))
        {
            Debug.LogFormat("Failed to load language file from local mod installation...mod not found.");
            return(GetLanguageFileFromSteam(item, out lastModified));
        }
        lastModified = mod.label.time_stamp;
        string text = Path.Combine(Application.streamingAssetsPath, "strings.po");

        byte[] array = mod.file_source.GetFileSystem().ReadBytes(text);
        if (array == null)
        {
            Debug.LogFormat("Failed to load language file from local mod installation...couldn't find {0}", text);
            return(GetLanguageFileFromSteam(item, out lastModified));
        }
        return(FileSystem.ConvertToText(array));
    }
 public static void VerifyTranslationModSubscription(GameObject context)
 {
     if (GetSelectedLanguageType() == SelectedLanguageType.UGC && SteamManager.Initialized && !LanguageOptionsScreen.HasInstalledLanguage())
     {
         PublishedFileId_t invalid           = PublishedFileId_t.Invalid;
         PublishedFileId_t publishedFileId_t = new PublishedFileId_t((uint)KPlayerPrefs.GetInt("InstalledLanguage", (int)invalid.m_PublishedFileId));
         Label             label             = default(Label);
         label.distribution_platform = Label.DistributionPlatform.Steam;
         label.id = publishedFileId_t.ToString();
         Label  rhs = label;
         string arg = UI.FRONTEND.TRANSLATIONS_SCREEN.UNKNOWN;
         foreach (Mod mod in Global.Instance.modManager.mods)
         {
             if (mod.label.Match(rhs))
             {
                 arg = mod.title;
                 break;
             }
         }
         ClearLanguage();
         GameObject gameObject = KScreenManager.AddChild(context, ScreenPrefabs.Instance.ConfirmDialogScreen.gameObject);
         KScreen    component  = gameObject.GetComponent <KScreen>();
         component.Activate();
         ConfirmDialogScreen component2          = component.GetComponent <ConfirmDialogScreen>();
         ConfirmDialogScreen confirmDialogScreen = component2;
         string        title_text   = UI.CONFIRMDIALOG.DIALOG_HEADER;
         string        text         = string.Format(UI.FRONTEND.TRANSLATIONS_SCREEN.MISSING_LANGUAGE_PACK, arg);
         string        confirm_text = UI.FRONTEND.TRANSLATIONS_SCREEN.RESTART;
         System.Action on_confirm   = App.instance.Restart;
         confirmDialogScreen.PopupConfirmDialog(text, on_confirm, null, null, null, title_text, confirm_text, null, null, true);
     }
 }
Esempio n. 5
0
    private void OnSubmitItemUpdateResult(SubmitItemUpdateResult_t pResult, bool failed)
    {
        if (pResult.m_bUserNeedsToAcceptWorkshopLegalAgreement)
        {
            Debug.LogError("Player needs to agree to the user agreement.");
        }
        if (failed == false)
        {
            if (pResult.m_eResult != EResult.k_EResultOK)
            {
                Debug.LogError("Steam SubmitItemUpdate error " + pResult.m_eResult.ToString());
            }
            else
            {
                if (pResult.m_bUserNeedsToAcceptWorkshopLegalAgreement)
                {
                    Debug.LogWarning("User needs to accept workshop legal agreement");
                }

                string itemPath = "steam://url/CommunityFilePage/" + steamworks_id.ToString();
                SteamFriends.ActivateGameOverlayToWebPage(itemPath);
            }
        }
        else
        {
            Debug.LogError("Error on Steam Workshop item update");
        }

        waiting_for_create = false;
        uploading          = false;
        ignore             = prev_ignore;
        UpdateMetadata();
    }
 public void SetPublishedFileId(PublishedFileId_t newPfid)
 {
     if (!(publishedFileIdInt == newPfid))
     {
         publishedFileIdInt = newPfid;
         File.WriteAllText(PublishedFileIdPath, newPfid.ToString());
     }
 }
 internal void Notify_SteamItemUnsubscribed(PublishedFileId_t pfid)
 {
     if (selectedMod != null && selectedMod.FolderName == pfid.ToString())
     {
         selectedMod = null;
     }
     RecacheSelectedModRequirements();
     modsInListOrderDirty = true;
 }
Esempio n. 8
0
 public void SetPublishedFileId(PublishedFileId_t newPfid)
 {
     if (this.publishedFileIdInt == newPfid)
     {
         return;
     }
     this.publishedFileIdInt = newPfid;
     File.WriteAllText(this.PublishedFileIdPath, newPfid.ToString());
 }
Esempio n. 9
0
            public static bool Prefix(PublishedFileId_t pfid)
            {
                Debug.Log("Notify_Unsubscribed");

                // deregister item in WorkshopItems
                var item = workshopitems.FirstOrDefault(i => i.PublishedFileId == pfid);

                workshopitems.TryRemove(item);

                // deregister item in ModLister
                var mod = modlister.FirstOrDefault(m => m.Source == ContentSource.SteamWorkshop &&
                                                   m.Identifier == pfid.ToString());

                modlister.TryRemove(mod);

                // remove button
                ModButtonManager.Notify_Unsubscribed(pfid.ToString());

                ScenarioLister.MarkDirty();
                return(false);
            }
Esempio n. 10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            e.Graphics.DrawImage(globals.GetTexture(ulFileID.ToString(), "jpg"), new Rectangle(1, 1, Height - 2, Height - 2));

            if (m_bWhitelisted)
            {
                e.Graphics.DrawImage(Properties.Resources.verified, new Rectangle(Height - 18, Height - 18, 18, 18));
            }

            e.Graphics.FillRectangle(new SolidBrush(colOverlay), new Rectangle(0, 0, Width, Height));
            e.Graphics.DrawRectangle(Pens.Black, new Rectangle(1, 1, Height - 2, Height - 2));

            StringFormat formatter = new StringFormat();

            formatter.LineAlignment = StringAlignment.Center;
            formatter.Alignment     = StringAlignment.Near;

            if (m_bUploading)
            {
                bool              bDrawProgress = false;
                string            statusString = "";
                ulong             punBytesProcessed = 0, punBytesTotal = 0;
                EItemUpdateStatus uploadStatus = SteamUGC.GetItemUpdateProgress(updateHandle, out punBytesProcessed, out punBytesTotal);

                if (uploadStatus == EItemUpdateStatus.k_EItemUpdateStatusPreparingConfig)
                {
                    statusString = "Preparing Content...";
                }
                else if (uploadStatus == EItemUpdateStatus.k_EItemUpdateStatusPreparingContent)
                {
                    statusString  = string.Format("Uploading Content: {0} / {1} bytes", punBytesProcessed, punBytesTotal);
                    bDrawProgress = true;
                }
                else if (uploadStatus == EItemUpdateStatus.k_EItemUpdateStatusUploadingContent || uploadStatus == EItemUpdateStatus.k_EItemUpdateStatusUploadingPreviewFile)
                {
                    statusString = "Configuring Content...";
                }
                else if (uploadStatus == EItemUpdateStatus.k_EItemUpdateStatusCommittingChanges)
                {
                    statusString = "Committing Changes...";
                }

                e.Graphics.DrawString(statusString, new Font("Times New Roman", 11, FontStyle.Bold), new SolidBrush(Color.White), new Rectangle(Height + 2, 1, Width - Height - 2, 30), formatter);
                if (bDrawProgress && (punBytesTotal > 0))
                {
                    e.Graphics.DrawImage(globals.GetTexture("bar"), new Rectangle(Height + 2, 33, Width - Height - 24, 16));

                    double flPercent = ((double)punBytesProcessed) / ((double)punBytesTotal);
                    double flWide    = (double)(Width - Height - 24) * flPercent;
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(145, 200, 15, 15)), new Rectangle(Height + 2, 33, (int)flWide, 16));
                    e.Graphics.DrawRectangle(Pens.Black, new Rectangle(Height + 2, 33, Width - Height - 24, 16));
                }

                return;
            }

            e.Graphics.DrawString(pszName, new Font("Times New Roman", 20, FontStyle.Bold), new SolidBrush(Color.White), new Rectangle(Height + 2, 1, Width - Height - 2, 30), formatter);
            e.Graphics.DrawString(pszDescription, new Font("Times New Roman", 10, FontStyle.Regular), new SolidBrush(Color.White), new Rectangle(Height + 3, 33, Width - Height - 3, 20), formatter);

            formatter.LineAlignment = StringAlignment.Center;
            formatter.Alignment     = StringAlignment.Far;

            e.Graphics.DrawString(pszDate, new Font("Times New Roman", 10, FontStyle.Bold), new SolidBrush(Color.White), new Rectangle(Width - 142, 2, 140, 20), formatter);
        }
        public CreationPanel(string title, string description, string tags, int visibility, PublishedFileId_t fileID)
        {
            pszTagList             = new List <string>();
            m_bShouldUpdateItem    = true;
            m_bHasChangedImagePath = false;
            Text = "Update Addon";

            // Set the stuff:
            pszContentPath = null;
            pszImagePath   = string.Format("{0}\\workshopper\\addons\\{1}.jpg", globals.GetTexturePath(), fileID.ToString());

            m_pTitle.Text       = title;
            m_pDescription.Text = description;
            itemUniqueID        = fileID;

            if (visibility == 0)
            {
                m_pVisibilityChoices[0].Select();
            }
            else if (visibility == 1)
            {
                m_pVisibilityChoices[1].Select();
            }
            else if (visibility == 2)
            {
                m_pVisibilityChoices[2].Select();
            }

            GetTagsFromString(tags);

            for (int i = 0; i < pszTagList.Count(); i++)
            {
                if (pszTagList[i] == "Classic")
                {
                    m_pCheckBox[0].ActiviateItem(true);
                }

                else if (pszTagList[i] == "Elimination")
                {
                    m_pCheckBox[1].ActiviateItem(true);
                }

                else if (pszTagList[i] == "Arena")
                {
                    m_pCheckBox[2].ActiviateItem(true);
                }

                else if (pszTagList[i] == "Weapons")
                {
                    m_pCheckBox[3].ActiviateItem(true);
                }

                else if (pszTagList[i] == "Survivors")
                {
                    m_pCheckBox[4].ActiviateItem(true);
                }

                else if (pszTagList[i] == "Sounds")
                {
                    m_pCheckBox[5].ActiviateItem(true);
                }

                else if (pszTagList[i] == "Textures")
                {
                    m_pCheckBox[6].ActiviateItem(true);
                }

                else if (pszTagList[i] == "Other")
                {
                    m_pCheckBox[7].ActiviateItem(true);
                }
            }

            m_pPatchNotes.Visible = m_pPatchNotes.Enabled = true;

            Invalidate();
        }