Exemplo n.º 1
0
    public void NextCameraView()
    {
        CameraView curView = GetCameraView();

        switch (curView)
        {
        case CameraView.FirstPerson:
            editCameraView = CameraView.ThirdPerson;
            SetCameraView(CameraView.ThirdPerson, true);
            break;

        case CameraView.ThirdPerson:
            editCameraView = CameraView.Isometric;
            SetCameraView(CameraView.Isometric, true);
            break;

        case CameraView.Isometric:
            editCameraView = CameraView.FirstPerson;
            SetCameraView(CameraView.FirstPerson, true);
            break;

        case CameraView.ActorDriven:
            dynamicPopup.Show("You can't change the camera because this game uses a custom camera.\n" +
                              "To go back to the normal camera, go into EDIT MODE and delete your camera.", "OK", () => { });
            break;

        default:
            return;
        }
    }
Exemplo n.º 2
0
    void Report()
    {
        string description = descriptionInputText.text;

        if (description.IsNullOrEmpty())
        {
            return;
        }

        if (!PhotonNetwork.isMasterClient && reportee != PhotonNetwork.masterClient)
        {
            networking.SendReportToMasterClient(reportee.NickName, description);
        }

#if USE_PUN
        object steamId = "(N/A)";
        reportee.CustomProperties.TryGetValue((object)NetworkingController.SteamIdPlayerProperty, out steamId);
#endif

        // Feedback
        if (reportee != PhotonNetwork.masterClient)
        {
            popups.Show("Thank you for reporting the player. We will review your message and take appropriate action if necessary. The Game Master has also been notified and may kick the player from the game.", "OK", () => { }, 800f);
        }
        else
        {
            popups.Show(new DynamicPopup.Popup
            {
                fullWidthButtons = true,
                textWrapWidth    = 800f,
                getMessage       = () => $"Thank you for reporting the player. We will review your message and take appropriate action if necessary. Would you like to leave the current game or continue playing?",
                buttons          = new List <PopupButton.Params>()
                {
                    new PopupButton.Params {
                        getLabel = () => "Leave Game", onClick = () => scenes.LoadSplashScreen()
                    },
                    new PopupButton.Params {
                        getLabel = () => "Continue Playing", onClick = () => { }
                    }
                }
            });
        }

        if (kicking)
        {
            networking.KickPlayer(reportee);
        }
        Close();
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.LeftAlt) && Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.End))
        {
            holdTime += Time.deltaTime;
        }
        else
        {
            holdTime = 0f;
        }

        if (holdTime > 2f)
        {
            var buttons = new List <PopupButton.Params>();
            buttons.Add(new PopupButton.Params
            {
                getLabel = () => "Clear and Quit",
                onClick  = () =>
                {
                    PlayerPrefs.DeleteAll();
                    PlayerPrefs.Save();
                    // Assume whoever does this is a developer.
                }
            });
            popups.Show(new DynamicPopup.Popup {
                getMessage = () => "Clear all player prefs?", buttons = buttons
            });
        }
    }
    private void HandleModuleCompileError(VoosEngine.ModuleCompileError error)
    {
        string behaviorUri = error.moduleKey;

        var beh  = behaviorSystem.GetBehaviorData(behaviorUri);
        var meta = JsonUtility.FromJson <BehaviorCards.CardMetadata>(beh.metadataJson);

        HashSet <string> usingBrainIds = new HashSet <string>(from entry in behaviorSystem.BrainsForBehavior(behaviorUri)
                                                              select entry.id);

        VoosActor oneActor = (from actor in voosEngine.EnumerateActors()
                              where usingBrainIds.Contains(actor.GetBrainName())
                              select actor).FirstOrDefault();

        string actorsUsing = oneActor == null ? "No actors using it" : $"One actor using it: {oneActor.GetDebugName()}";
        string msg         = $"<color=yellow>Error with card '{meta.cardSystemCardData.title}' (line {error.lineNum}). {actorsUsing}. The error:</color>\n<color=red>{error.message}</color>";

        CommandTerminal.HeadlessTerminal.Buffer.HandleLog(msg, TerminalLogType.Error, null);

        // NOTE: Ideally, we'd do this if we know the code editor isn't viewing this particular behavior
        if (Time.timeSinceLevelLoad < 5f && (!IsCodeEditorOpen() || error.lineNum == -1))
        {
            popup.Show($"There was an error with card '{meta.cardSystemCardData.title}' (line {error.lineNum}):\n{error.message}\n<color=#666666>{actorsUsing}.</color>", "OK", null, 1400f);
        }
    }
Exemplo n.º 5
0
    void Start()
    {
        if (Application.isEditor)
        {
            return;
        }

        List <string> missingFiles = new List <string>();

        foreach (var line in File.ReadAllLines(ManifestFile))
        {
            string path = line.Trim();
            if (!File.Exists(path))
            {
                missingFiles.Add(path);
                Util.LogError($"Missing critical file: {path}");
            }
        }

        if (missingFiles.Count > 0)
        {
            popups.Show(
                "<size=80%>Sorry, we have detected that some Game Builder files are missing from the installation directory.\n"
                + "The game will now quit, and you'll be sent to instructions on how to restore these files.\n"
                + "Also, if you're running anti-virus, please make sure it is configured properly for Steam games.\n"
                + $"<size=50%>One missing file (of {missingFiles.Count}): {missingFiles[0]}",
                "Quit and open restore instructions", () =>
            {
                Application.OpenURL("https://support.steampowered.com/kb_article.php?ref=2037-QEUH-3335");
                Application.Quit();
            });
        }
    }
Exemplo n.º 6
0
    public void OpenLocal(GameBundleLibrary.Entry entry)
    {
        gameObject.SetActive(true);
        gameSource = GameSource.Local;
        GameBundle.Metadata metadata = entry.bundle.GetMetadata();
        descriptionField.text = $"<b>{metadata.name}</b>\n{metadata.description}";

        Texture2D texture = entry.bundle.GetThumbnail();

        SetThumbnail(texture != null ? texture : placeholderThumbnailTexture);

        playAction = () => OnPlayTriggered(playOpts =>
        {
            LoadLibraryBundle(entry, playOpts);
        });
        buildAction = () => popups.Show("Not implemented", "OK", () => { });
    }
Exemplo n.º 7
0
 void WarnThatDifferentNameWillOverwrite(System.Action overwriteAction)
 {
     popups.Show(new DynamicPopup.Popup
     {
         fullWidthButtons = true,
         textWrapWidth    = 800f,
         getMessage       = () => $"You gave the project a different name since last save.\nSave as new file or overwrite?",
         buttons          = new List <PopupButton.Params>()
         {
             new PopupButton.Params {
                 getLabel = () => "Save as new file", onClick = SaveNew
             },
             new PopupButton.Params {
                 getLabel = () => "Overwrite last save", onClick = overwriteAction
             }
         }
     });
 }
    // Update is called once per frame
    void Update()
    {
        string url = GUIUtility.systemCopyBuffer;

        // Don't incur cost of checking, or bother the player, if buffer is unchanged.
        if (url == lastCopyBuffer)
        {
            return;
        }
        lastCopyBuffer = url;

        ulong workshopId = Util.ExtractIdFromWorkshopUrl(url);

        if (workshopId != 0)
        {
            popups.ShowTwoButtons($"You copied a Steam Workshop URL! Play it?\nDetected item ID: {workshopId}",
                                  $"Play", () =>
            {
                float progress                 = 0f;
                bool keepShowing               = true;
                var downloadingPopup           = new DynamicPopup.Popup();
                downloadingPopup.getMessage    = () => $"Downloading.. {Mathf.Floor((progress * 100))} %";
                downloadingPopup.keepShowing   = () => keepShowing;
                downloadingPopup.isCancellable = false;
                popups.Show(downloadingPopup);

                string displayName = $"Item {workshopId}";

                workshopSource.Get(workshopId, path =>
                {
                    keepShowing = false;
                    if (path.IsEmpty())
                    {
                        popups.ShowWithCancel($"Woops - could not download the workshop item. Maybe restart and try again?\nMessage: {path.GetErrorMessage()}", "OK", null, 800f);
                    }
                    else
                    {
                        loadingScreen.ShowAndDo(() =>
                                                sceneController.LoadWorkshopItem(
                                                    new LoadableWorkshopItem
                        {
                            displayName          = displayName,
                            installedLocalFolder = path.Get(),
                            steamId = workshopId
                        },
                                                    new GameBuilderApplication.PlayOptions(), null));
                    }
                },
                                   prog => progress = prog,
                                   // TODO could also grab thumbnail async..
                                   item => displayName = item.Name
                                   );
            },
                                  "Cancel", () => { });
        }
    }
Exemplo n.º 9
0
    protected override void DoImport(WorkshopItem item)
    {
        Dictionary <string, SavedActorPrefab> prefabs = SceneActorLibrary.ReadPrefabsFromDir(item.InstalledLocalFolder, item);
        bool containsOverrides = false;

        foreach (var entry in prefabs)
        {
            if (sceneActorLibrary.Exists(entry.Key))
            {
                containsOverrides = true;
            }
        }
        if (containsOverrides)
        {
            popups.ShowThreeButtons(
                "This actor already exists in your library.",
                "Overwrite", () =>
            {
                sceneActorLibrary.PutPrefabs(prefabs, true);
                popups.Show(
                    $"{item.Name} was successfully imported. Check your custom actors!",
                    "Ok"
                    );
            },
                "Duplicate", () =>
            {
                sceneActorLibrary.PutPrefabs(prefabs);
                popups.Show(
                    $"{item.Name} was successfully imported. Check your custom actors!",
                    "Ok"
                    );
            },
                "Cancel", () => { });
        }
        else
        {
            sceneActorLibrary.PutPrefabs(prefabs);
            popups.Show(
                $"{item.Name} was successfully imported. Check your custom actors!",
                "Ok"
                );
        }
    }
Exemplo n.º 10
0
    private void OnBehaviorsLoaded(WorkshopItem item, Dictionary <string, Behaviors.Behavior> behaviors)
    {
        bool containsOverrides = false;

        foreach (var entry in behaviors)
        {
            if (behaviorSystem.EmbeddedBehaviorExists(entry.Key))
            {
                containsOverrides = true;
            }
        }
        if (containsOverrides)
        {
            popups.ShowThreeButtons(
                "Some cards in this pack already exist in your library.",
                "Overwrite", () =>
            {
                behaviorSystem.PutBehaviors(behaviors, true);
                popups.Show(
                    $"{item.Name} was successfully imported. Check your card library!",
                    "Ok"
                    );
            },
                "Duplicate", () =>
            {
                behaviorSystem.PutBehaviors(behaviors);
                popups.Show(
                    $"{item.Name} was successfully imported. Check your card library!",
                    "Ok"
                    );
            },
                "Cancel", () => { });
        }
        else
        {
            behaviorSystem.PutBehaviors(behaviors);
            popups.Show(
                $"{item.Name} was successfully imported. Check your card library!",
                "Ok"
                );
        }
    }
Exemplo n.º 11
0
    void OnUploadComplete(string name, Util.Maybe <ulong> maybeId, string id)
    {
        if (maybeId.IsEmpty())
        {
            popups.Show("Error uploading file to Steam Workshop:\n" + maybeId.GetErrorMessage(), "OK", () => { });
            DestroyImportFeedback(id);
            return;
        }

        terrainManager.AddCustomStyle(maybeId.Value, () => DestroyImportFeedback(id));
    }
Exemplo n.º 12
0
    void MaybeShowCopyTip()
    {
        if (didShowCopyTip)
        {
            return;
        }

        if (numDuplicatesCreated > 5)
        {
            popups.Show($"Making lots of {GetSelected().name}s? You may want to copy them instead (CTRL + C) so you can easily edit them all together later.", "Got it", () => { }, 800f);
            didShowCopyTip = true;
        }
    }
Exemplo n.º 13
0
    void OnSelectedFileToUpload(string[] selections)
    {
        if (selections == null || selections.Length == 0)
        {
            // Canceled.
            return;
        }
        string fullPath = selections[0];

        if (fullPath.IsNullOrEmpty())
        {
            return;
        }
        if (!File.Exists(fullPath))
        {
            popups.Show("File does not exist: " + fullPath, "OK", () => { });
            return;
        }
        long size = new FileInfo(fullPath).Length;

        if (size > IMAGE_FILE_SIZE_LIMIT)
        {
            popups.Show("That file is too big (" + size + " bytes). The limit is " + IMAGE_FILE_SIZE_LIMIT + " bytes", "OK", () => { });
            return;
        }

        string name = Path.GetFileNameWithoutExtension(fullPath);
        string ext  = Path.GetExtension(fullPath).ToLowerInvariant();

        name = string.IsNullOrEmpty(name) ? "Untitled image" : name;
        pleaseWait.SetActive(true);
        string tempDir = Util.CreateTempDirectory();

        File.Copy(fullPath, Path.Combine(tempDir, "image" + ext));

        workshopAssetSource.Put(tempDir, name, name, GameBuilder.SteamUtil.GameBuilderTags.Image, null, null, OnWorkshopUploadComplete);
    }
Exemplo n.º 14
0
    private void RemoveSelectedParticleEffect()
    {
        string claimId = ParticleEffectSystem.PFX_CLAIM_PREFIX + selectedParticleEffectId;
        string owner   = claimKeeper.GetEffectiveOwnerNickname(claimId);

        if (owner == null || claimKeeper.IsMine(claimId))
        {
            particleEffectSystem.DeleteParticleEffect(selectedParticleEffectId);
        }
        else
        {
            popups.Show(
                $"Sorry, can't delete {name} right now. {owner} is editing it.",
                "Ok");
        }
    }
Exemplo n.º 15
0
    private void ExportToDisk(ActorPrefab prefab)
    {
#if USE_FILEBROWSER
        string path = Crosstales.FB.FileBrowser.OpenSingleFolder("Select save location");
        if (!path.IsNullOrEmpty())
        {
            sceneActorLibrary.WritePrefabToDir(prefab.GetId(), path);
            popups.Show("Actor exported!", "Ok");
        }
#else
        sceneActorLibrary.WritePrefabToDir(prefab.GetId(), System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "GBActors"));
        popups.Show("Actor exported to Documents/GBActors folder.\nFor more control over export location, build with the free CrossTales FileBrowser plugin.", "Ok");
#endif
    }
Exemplo n.º 16
0
    void OnSoundUploadComplete(string name, Util.Maybe <ulong> result, string id)
    {
        Util.Tuple <ProgressItemUI, WorkshopAssetSource.GetUploadProgress> tuple = importingListItems[id];
        importingListItems.Remove(id);
        Destroy(tuple.first.gameObject);

        if (result.IsEmpty())
        {
            popups.Show("Error uploading sound to Steam Workshop:\n" + result.GetErrorMessage(), "OK", () => { });
            return;
        }
        SoundEffect soundEffect = new SoundEffect(
            id, name, SoundEffectContent.NewWithSteamWorkshopId(result.Value));

        soundEffectSystem.PutSoundEffect(soundEffect);
        // TODO: maybe immediately open the just-created sound effect?
    }
Exemplo n.º 17
0
 private void ShowMultiplayerPopup()
 {
     dynamicPopup.Show(new DynamicPopup.Popup
     {
         getMessage    = () => "Exit current game and see multiplayer games?",
         isCancellable = true,
         buttons       = new List <PopupButton.Params>()
         {
             new PopupButton.Params
             {
                 getLabel = () => "Exit",
                 onClick  = OnMultiplayerExitButton
             },
             new PopupButton.Params
             {
                 getLabel = () => "Cancel",
             }
         },
         fullWidthButtons = true
     });
 }
Exemplo n.º 18
0
    private void OnFinishSelectionForLocal(IEnumerable <string> result)
    {
#if USE_FILEBROWSER
        var paths = Crosstales.FB.FileBrowser.OpenFolders("Select save location", null);
        if (paths.Count() == 0)
        {
            return;
        }
        string path = paths.First();
        if (path.IsNullOrEmpty())
        {
            return;
        }
        behaviorSystem.WriteEmbeddedBehaviorsToDirectory(result, Path.Combine(path, "cardPack_" + System.DateTime.Now.ToString("yyyyMMddTHHmm")));
        popups.Show("Cards exported!", "Ok");
#else
        behaviorSystem.WriteEmbeddedBehaviorsToDirectory(result, Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "GBCards", "cardPack_" + System.DateTime.Now.ToString("yyyyMMddTHHmm")));
        popups.Show("Cards exported to Documents/GBCards folder.\nFor more control over export location, build with the free CrossTales FileBrowser plugin.", "Ok");
#endif
    }
Exemplo n.º 19
0
    public void Show(VoosActor actor)
    {
        // Start with player 0 to avoid warnings/etc.
        AssignPlayerToActor(0, actor.GetName());

        string name = actor.GetDisplayName();
        List <PopupButton.Params> buttons = new List <PopupButton.Params>();

        int myPlayerNumber = playerControlsManager.GetMyPlayerNumber();

        int maxPlayerSlotNumber = 4; // Show at least player 1-4, unless there are more players.

        foreach (VirtualPlayerManager.VirtualPlayerInfo player in virtualPlayerManager.EnumerateVirtualPlayers())
        {
            maxPlayerSlotNumber = Mathf.Max(player.slotNumber, maxPlayerSlotNumber);
        }
        for (int i = 1; i <= maxPlayerSlotNumber; i++)
        {
            int thisNumber = i; // For closures below
            buttons.Add(new PopupButton.Params
            {
                getLabel = () => $"Player {thisNumber}" + ((thisNumber == myPlayerNumber) ? " (myself)" : ""),
                onClick  = () => OnClickedPlayerNumber(actor, thisNumber)
            });
        }
        buttons.Add(new PopupButton.Params {
            getLabel = () => "Nobody for now", onClick = () => OnClickedPlayerNumber(actor, 0)
        });
        buttons.Add(new PopupButton.Params {
            getLabel = () => "It's an NPC", onClick = () => OnClickedIsNpc(actor)
        });
        popups.Show(new DynamicPopup.Popup
        {
            getMessage = () => $"Who will control this {name}?",
            buttons    = buttons,
        });
    }
Exemplo n.º 20
0
    public void DeleteTargetActors()
    {
        VoosActor builtin = targetActors.FirstOrDefault(a => a.IsBuiltinActor());

        if (builtin != null)
        {
            popups.Show($"Sorry, built-in actors such as {builtin.GetDisplayName()} cannot be deleted.", "OK");
        }
        var deletableActors = targetActors.Where(a => a != null && !a.IsLockedByAnother() && !a.IsBuiltinActor()).ToList();

        if (deletableActors.Count == 0)
        {
            return;
        }
        var actorStates = engine.SaveActorHierarchy(deletableActors);
        var label       = deletableActors.Count > 1 ? $"Delete {deletableActors.Count} actors" : $"Delete {deletableActors[0].GetDisplayName()}";

        undoStack.Push(new UndoStack.Item
        {
            actionLabel           = label,
            getUnableToDoReason   = () => null,
            getUnableToUndoReason = () => null,
            doIt = () =>
            {
                foreach (var state in actorStates)
                {
                    ActorUndoUtil.GetValidActorThen(
                        engine, state.name,
                        validActor => this.DeleteActor(validActor));
                }
            },
            undo = () => engine.RestoreActorHierarchy(actorStates)
        });

        SetCameraFollowingActor(false);
    }
Exemplo n.º 21
0
    void Start()
    {
#if USE_PUN
        StartCoroutine(PumpPlayerInitCoroutine());

        var diag = GetComponent <PhotonStatsGui>();
        if (diag != null)
        {
            diag.enabled = false;
        }

        try
        {
            // Don't destroy things created by clients. We will need to clean up the
            // player ghost object only. Even if we're not the master client, we still
            // need this. Because if the master quits, we might become the master, and
            // we need to prevent Photon from destroying all objects!
            if (!PhotonNetwork.inRoom)
            {
                PhotonNetwork.autoCleanUpPlayerObjects = false;
            }
            else
            {
                // Setting this causes an error if we're in a room, but we should make
                // sure it's false still.
                Debug.Assert(PhotonNetwork.autoCleanUpPlayerObjects == false);
            }

            PhotonNetwork.autoJoinLobby = false;
            bool isMultiplayer = GameBuilderApplication.CurrentGameOptions.playOptions.isMultiplayer;

            System.DateTime banLastDate;
            if (isMultiplayer && IsUserBanned(GetSteamID(), out banLastDate))
            {
                popups.Show($"You have been temporarily banned from multiplayer games for reported inappropriate or abusive behavior. You will be able to play again after {banLastDate.ToString("MMMM dd, yyyy")}.", "Back", () =>
                {
                    scenes.LoadSplashScreen();
                }, 800f);
                return;
            }

            if (isMultiplayer)
            {
                Util.Log($"Multiplayer!");
                SetupPlayerProperties();
                mode = Mode.Online;
                PhotonNetwork.offlineMode = false;
            }
            else
            {
            }

            if (PhotonNetwork.connected && PhotonNetwork.inRoom)
            {
                // We are still connected and in a room. This is a map switch.
                mode = Mode.Online;
                Util.Log($"StayOnline mode. Pretending we just joined the room.");
                didSwitchMaps = true;
                OnJoinedRoom();
            }
            else if (PhotonNetwork.connected && PhotonNetwork.insideLobby && isMultiplayer)
            {
                // Joining or creating.

                string roomToJoin = GameBuilderApplication.CurrentGameOptions.joinCode;
                if (!roomToJoin.IsNullOrEmpty())
                {
                    // We're joining a room from the lobby
                    Util.Log($"Trying to join room {roomToJoin}..");
                    // Try to join existing room
                    PhotonNetwork.JoinRoom(roomToJoin.ToLower());
                }
                else
                {
                    // We're creating a new game, and happen to be in a lobby already.
                    TryCreateRoom();
                }
            }
            else
            {
                switch (mode)
                {
                case Mode.Online:
                    string gameVersion = GetPhotonGameVersion();
                    // If we're trying to join a game, make sure we connect to their region.
                    string joinCode = GameBuilderApplication.CurrentGameOptions.joinCode;
                    if (joinCode == "*")
                    {
                        // TEMP join random visible game in best region
                        PhotonNetwork.ConnectToBestCloudServer(gameVersion);
                    }
                    else if (joinCode != null)
                    {
                        string regionCodeStr = joinCode.Split(JoinCodeSeparator)[0];
                        try
                        {
                            CloudRegionCode regionCode = (CloudRegionCode)System.Int32.Parse(regionCodeStr);
                            PhotonNetwork.ConnectToRegion(regionCode, gameVersion);
                        }
                        catch (System.OverflowException)
                        {
                            OnInvalidJoinCodeRegion();
                        }
                    }
                    else
                    {
                        // Ok we're starting a new game, so just connect to the best.
                        PhotonNetwork.ConnectToBestCloudServer(gameVersion);
                    }
                    break;

                case Mode.Offline:
                    if (PhotonUtil.ActuallyConnected())
                    {
                        PhotonNetwork.Disconnect();
                    }
                    DestroyImmediate(GetComponent <ExitGames.UtilityScripts.PlayerRoomIndexing>());
                    Util.Log($"Starting offline mode, t = {Time.realtimeSinceStartup}");
                    PhotonNetwork.offlineMode = true;
                    break;
                }
            }
        }
        catch (System.FormatException e)
        {
            OnFatalError(BadJoinCodeMessage);
        }
        catch (System.Exception e)
        {
            OnFatalError(e.ToString());
        }
#else
        // Non-PUN route
        mode = Mode.Offline;
        StartCoroutine(NonPunStartRoutine());
#endif
    }
Exemplo n.º 22
0
 private void ShowDynamicPopup()
 {
     dynamicPopup.Show();
 }