예제 #1
0
 public bool TrySafeRegisterApp(ROSApp app)
 {
     if (app.IsDialogue())
     {
         if (dialogues.ContainsValue(app))
         {
             return(false);
         }
         dialogues.Add(app.GetType(), app);
         app.AppInit();
         Debug.Log("Dialogue registered: " + app);
         return(true);
     }
     else
     {
         if (apps.ContainsValue(app))
         {
             return(false);
         }
         apps.Add(app.GetType(), app);
         app.AppInit();
         Debug.Log("App registered: " + app);
         return(true);
     }
 }
예제 #2
0
 public void RegisterApp(ROSApp app)
 {
     if (!TrySafeRegisterApp(app))
     {
         Debug.LogError("App already registered: " + app);
     }
 }
예제 #3
0
    public ROSApp ShowApp(ROSApp app)
    {
        if (app.IsSingleton())
        {
            if (openSingletonApps.ContainsKey(app.GetType()))
            {
                ROSApp singletonApp = openSingletonApps[app.GetType()];
                singletonApp.Open();
                return(singletonApp);
            }
            else
            {
                // move to display area (to make sure we don't duplicate
                app.transform.SetParent(appDisplayArea, true);
                app.Open();
                openSingletonApps.Add(app.GetType(), app);
                return(app);
            }
        }

        // duplicate gameobject and put under working area
        GameObject appObj = Instantiate(app.gameObject, appDisplayArea);
        ROSApp     newApp = appObj.GetComponent <ROSApp>();

        newApp.Open();
        return(newApp);
    }
예제 #4
0
 /// <summary>
 /// Called from ROSApp no matter how the app is closed
 /// </summary>
 /// <param name="app"></param>
 public void AppClosed(ROSApp app)
 {
     if (app.IsSingleton() && openSingletonApps.ContainsKey(app.GetType()))
     {
         openSingletonApps.Remove(app.GetType());
         app.transform.SetParent(appBuildArea, true);
     }
 }
예제 #5
0
    public ROSApp ShowDialogue(ROSApp app)
    {
        // duplicate gameobject and put under working area
        GameObject appObj = Instantiate(app.gameObject, dialogueDisplayArea);
        ROSApp     newApp = appObj.GetComponent <ROSApp>();

        // hide old one
        if (openDialogueStack.Count != 0)
        {
            openDialogueStack.Peek().Hide();
        }

        openDialogueStack.Push(newApp);
        newApp.AddResponseAction(DialogueClosed);

        blockingArea.alpha          = 1f;
        blockingArea.blocksRaycasts = true;

        newApp.Open();
        return(newApp);
    }
예제 #6
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        ROSApp app = (ROSApp)target;

        // just assist in finding references if we can
        if (GUILayout.Button("Find References"))
        {
            Transform windowControl = app.transform.Find("Window Control Panel");

            if (windowControl == null)
            {
                Debug.LogError("Could not find the Window Control Panel");
            }
            else
            {
                Transform appIcon = windowControl.Find("App Icon");
                if (appIcon == null)
                {
                    Debug.LogError("Could not find the App Icon in the control panel.");
                }
                else
                {
                    app.appIconImage = appIcon.GetComponent <Image>();
                }

                Transform appTitle = windowControl.Find("App Title");
                if (appTitle == null)
                {
                    Debug.LogError("Could not find the App Title in the control panel.");
                }
                else
                {
                    app.appTitleText = appTitle.GetComponent <Text>();
                }

                Transform exitImage = windowControl.Find("App Close Icon");
                if (exitImage == null)
                {
                    Debug.LogError("Could not find the App Close Icon in the control panel.");
                }
            }
            Transform resize = app.transform.Find("Resize Image");
            if (resize == null)
            {
                Debug.LogError("Could not find the Resize Image.");
            }
            else
            {
                app.resizeImage = resize.GetComponent <Image>();
            }

            Transform scrollRect = app.transform.Find("Content View");
            if (scrollRect == null)
            {
                Debug.LogError("Could not find the Content View scroll rect.");
            }
            else
            {
                app.scrollRect = scrollRect.GetComponent <ScrollRect>();

                Transform content = scrollRect.GetChild(0).GetChild(0);
                if (content.name != "Content")
                {
                    Debug.LogError("Could not find the Content under the Content View->Viewport");
                }
                else
                {
                    app.scrollContentPane = (RectTransform)content;
                }
            }
        }
    }
예제 #7
0
    private void Awake()
    {
        Desktop = this;

        // Add pick up / put down detection
        selectable.OnInteract += OnInteract;
        //selectable.OnFocus += OnPickedUp; // this seems broken for now
        selectable.OnDefocus += OnPutDown;

        Application.logMessageReceivedThreaded += HandleLog;

        lastFrameTime = Time.time;
        size          = appDisplayArea.rect.size;

        // try loading all the apps under appDisplayArea (this ensures apps like the console are setup before any log messages go that way)
        foreach (ROSApp app in appsToLoad)
        {
            if (app.IsDialogue())
            {
                Debug.LogError("ROSApp marked as dialogue but put in appsToLoad: " + app);
                continue;
            }
            RegisterApp(app);
        }
        appsToLoad.Clear();
        foreach (ROSApp dia in dialoguesToLoad)
        {
            if (!dia.IsDialogue())
            {
                Debug.LogError("ROSApp not marked as dialogue but put in dialoguesToLoad: " + dia);
                continue;
            }
            if (dia.IsSingleton())
            {
                Debug.LogError("ROSApp marked as dialogue is marked singleton, this isn't allowed: " + dia);
                continue;
            }
            RegisterApp(dia);
        }
        dialoguesToLoad.Clear();

        // load all app icons
        foreach (Type type in apps.Keys)
        {
            ROSApp app = apps[type];

            GameObject iconObj = Instantiate(appIconTemplate, appIconParent, false);
            iconObj.name = "App Icon:" + type;

            iconObj.transform.GetChild(0).GetComponent <Image>().color = Color.clear;

            iconObj.transform.GetChild(1).GetComponent <Image>().sprite = (app.appIcon != null ? app.appIcon : defaultAppIcon);

            iconObj.transform.GetChild(2).GetComponent <Text>().text = app.appName;

            iconObj.SetActive(true);

            appIconLookup.Add(iconObj, app);
        }

        dialogueBuildArea.gameObject.SetActive(false);
        appBuildArea.gameObject.SetActive(false);

        UpdateTimeTexts();
    }
예제 #8
0
 public static ROSApp OpenDialogue(ROSApp app)
 {
     return(Desktop.ShowDialogue(app));
 }
예제 #9
0
 public ROSApp LaunchApp(ROSApp app)
 {
     return(Desktop.ShowApp(app));
 }