Exemplo n.º 1
0
    void Awake()
    {
        loadItems     = true;
        uploadingItem = null;

        if (SteamManager.Initialized)
        {
            m_ItemInstalled = Callback <ItemInstalled_t> .Create(OnItemInstalled);

            m_DownloadItemResult = Callback <DownloadItemResult_t> .Create(OnItemDownloaded);

            m_DeleteItemResult = CallResult <DeleteItemResult_t> .Create(OnItemDeleted);

            m_callSteamUGCQueryCompleted = CallResult <SteamUGCQueryCompleted_t> .Create(OnUGCSteamUGCQueryCompleted);

            QueryPersonalWorkshopItems();
        }
    }
Exemplo n.º 2
0
    void DrawModWindow()
    {
        const float hSpacing = 250.0f;

        ImGui.SetNextWindowSize(new Vector2(700.0f, 300.0f), ImGuiCond.FirstUseEver);

        ImGui.PushStyleColor(ImGuiCol.WindowBg, backgroundColor);
        ImGui.PushStyleColor(ImGuiCol.Button, buttonColor);
        ImGui.PushStyleColor(ImGuiCol.ButtonHovered, buttonHoveredColor);
        ImGui.PushStyleColor(ImGuiCol.ButtonActive, buttonActiveColor);
        ImGui.PushStyleColor(ImGuiCol.TitleBgActive, headerColor);
        ImGui.PushStyleColor(ImGuiCol.PopupBg, buttonColor);
        ImGui.PushStyleColor(ImGuiCol.ResizeGrip, buttonColor);
        ImGui.PushStyleColor(ImGuiCol.ResizeGripHovered, buttonActiveColor);
        ImGui.PushStyleColor(ImGuiCol.ResizeGripActive, buttonActiveColor);
        ImGui.PushStyleColor(ImGuiCol.FrameBg, buttonColor);
        ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, buttonHoveredColor);
        ImGui.PushStyleColor(ImGuiCol.FrameBgActive, buttonActiveColor);
        ImGui.PushStyleColor(ImGuiCol.CheckMark, headerColor);

        ImGui.Begin("Mod window");
        ImGui.Text("Installed mods"); // TODO gray them out when mods are not enabled

        ImGui.SameLine();
        ImGui.PushStyleColor(ImGuiCol.Text, buttonTextColor);
        if (ImGui.Button("Refresh Steam"))
        {
            QueryPersonalWorkshopItems();
            loadItems = true;
        }
        ImGui.PopStyleColor(1);

        for (int i = 0; i < ModManager.importedMods.Count; i++)
        {
            Mod mod = ModManager.importedMods[i];

            ImGui.Text(mod.steamworksItem.GetName());
            ImGui.SameLine(hSpacing);
            ImGui.Text(mod.GetTypeString());
            ImGui.SameLine(1.2f * hSpacing);
            ImGui.PushStyleColor(ImGuiCol.Text, buttonTextColor);
            if (ImGui.Button("Show info##" + i))
            {
                if (uploadingItem != null)
                {
                    uploadingItem.waiting_for_create = false;
                }
                uploadingItem = mod.steamworksItem;
                uploadingItem.waiting_for_create = true;
            }
            if (ImGui.IsItemHovered())
            {
                ImGui.SetTooltip("Show mod info and Workshop upload window");
            }
            ImGui.PopStyleColor(1);

            ImGui.SameLine();
            ImGui.Checkbox($"Disabled ##{mod.path}", ref mod.steamworksItem.ignore);

            ImGui.PushStyleColor(ImGuiCol.Text, buttonTextColor);
            if (!mod.IsLocalMod())
            {
                ImGui.SameLine();
                if (ImGui.Button("Unsubscribe##" + i))
                {
                    ModManager.importedMods.Remove(mod);

                    SteamUGC.UnsubscribeItem(mod.steamworksItem.GetSteamworksId());
                    QueryPersonalWorkshopItems();
                    i--;
                    continue;
                }
                ImGui.SameLine();
                if (ImGui.Button("Show in Steam##" + i))
                {
                    string itemPath = $"steam://url/CommunityFilePage/{mod.steamworksItem.GetSteamworksId()}";
                    SteamFriends.ActivateGameOverlayToWebPage(itemPath);
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip("Open Steam overlay to Workshop page");
                }
            }
            ImGui.PopStyleColor(1);
        }

        ImGui.PushStyleColor(ImGuiCol.Text, buttonTextColor);
        if (ImGui.Button("Close"))
        {
            optionsmenuscript.show_mod_ui = false;
        }
        ImGui.PopStyleColor(1);

        ImGui.End();

        ImGui.PopStyleColor(13);
    }