Exemplo n.º 1
0
        void CreateLibrary(string libName)
        {
            DialogComplexProgress d = (DialogComplexProgress)DialogManager.CreateComplexProgressLinear();

            d.Initialize("Creating new library...", "Loading", MaterialIconHelper.GetIcon(MaterialIconEnum.HOURGLASS_EMPTY));
            d.InitializeCancelButton("CANCEL", ServiceController.shared.CancelCreateLibrary);
            d.Show();

            ServiceController.shared.CreateLibrary(libName, (suc1, suc2, id) => {
                d.Hide();

                if (!suc1)
                {
                    DialogManager.ShowAlert("Unable to communicate with server!",
                                            "Connection Error", MaterialIconHelper.GetIcon(MaterialIconEnum.ERROR));
                }
                else if (!suc2)
                {
                    DialogManager.ShowAlert("Login has expired! Please relogin and try again.",
                                            "Login Expired", MaterialIconHelper.GetIcon(MaterialIconEnum.ERROR));
                }
                else
                {
                    DialogManager.ShowAlert("Library has been created.", "Success", MaterialIconHelper.GetIcon(MaterialIconEnum.CHECK));

                    // Add the newly created library here.
                    Library lib     = new Library();
                    lib.libraryId   = id;
                    lib.libraryName = libName;
                    libraryExplorer.libraries.Add(lib);
                    libraryExplorer.ConfigureCells();
                }
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Syncs the currently editing floor to the database.
        /// </summary>
        public void SaveFloor()
        {
            if (!root.activeInHierarchy)
            {
                DialogManager.ShowAlert("Open a library first!",
                                        "Unable to Save", MaterialIconHelper.GetIcon(MaterialIconEnum.ERROR));
                return;
            }

            DialogComplexProgress d = (DialogComplexProgress)DialogManager.CreateComplexProgressLinear();

            d.Initialize("Uploading changes to database...", "Saving", MaterialIconHelper.GetIcon(MaterialIconEnum.HOURGLASS_EMPTY));
            d.InitializeCancelButton("CANCEL", ServiceController.shared.CancelUpdateFloor);
            d.Show();

            ServiceController.shared.UpdateFloor(floorController.floor, (suc1, suc2) => {
                d.Hide();

                if (!suc1)
                {
                    DialogManager.ShowAlert("Unable to communicate with server!",
                                            "Connection Error", MaterialIconHelper.GetIcon(MaterialIconEnum.ERROR));
                }
                else if (!suc2)
                {
                    DialogManager.ShowAlert("Login has expired! Please copy the text from File > Export Floor, relogin, open this floor again, File > Import Floor, and try again.",
                                            "Login Expired", MaterialIconHelper.GetIcon(MaterialIconEnum.ERROR));
                }
                else
                {
                    DialogManager.ShowAlert("Floor has been updated.", "Success", MaterialIconHelper.GetIcon(MaterialIconEnum.CHECK));
                }
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// The login button is pressed.
        /// </summary>
        public void OnLoginButtonPress()
        {
            // Placeholder
            string username = usernameInputField.inputField.text;
            string password = passwordInputField.inputField.text;
            string api      = addressInputField.inputField.text;

            DialogComplexProgress d = (DialogComplexProgress)DialogManager.CreateComplexProgressLinear();

            d.Initialize("Connecting to server...", "Loading", MaterialIconHelper.GetIcon(MaterialIconEnum.HOURGLASS_EMPTY));
            d.InitializeCancelButton("Cancel", () => {
                ServiceController.shared.CancelLogin();
                d.Hide();
            });

            d.Show();

            ServiceController.shared.Login(api, username, password, (success, authenticated) => {
                if (success && authenticated)
                {
                    PlayerPrefs.SetString(PlayerPrefsKey.SavedAddress, api);
                    PlayerPrefs.SetString(PlayerPrefsKey.SavedUsername, username);
                    AsyncOperation o       = SceneManager.LoadSceneAsync(1);
                    o.allowSceneActivation = false;

                    TweenManager.TweenFloat(v => {
                        Color c = screenTransitionMask.color;
                        c.a     = v;
                        screenTransitionMask.color = c;
                    }, 0, 1, 0.6f, 0, () => o.allowSceneActivation = true);
                }
                else
                {
                    if (!success)
                    {
                        DialogManager.ShowAlert("Unable to connect to the given address.",
                                                "Connection Error", MaterialIconHelper.GetIcon(MaterialIconEnum.ERROR));
                    }
                    else
                    {
                        DialogManager.ShowAlert("Incorrect username or password.",
                                                "Login Failed", MaterialIconHelper.GetIcon(MaterialIconEnum.ERROR));
                    }
                }

                d.Hide();
            });
        }
Exemplo n.º 4
0
        void OnLibraryCellPress(int index)
        {
            // Configure library view controller.
            if (libraries[index].floors == null)
            {
                // We need to load this library from server first! That means a loading
                // dialog.
                DialogComplexProgress d = (DialogComplexProgress)DialogManager.CreateComplexProgressLinear();
                d.Initialize("Getting library floor plans...", "Loading", MaterialIconHelper.GetIcon(MaterialIconEnum.HOURGLASS_EMPTY));
                d.InitializeCancelButton("Cancel", () => {
                    ServiceController.shared.CancelGetLibrary();
                    d.Hide();
                });

                d.Show();

                ServiceController.shared.GetLibrary(libraries[index].libraryId, (success, lib) => {
                    d.Hide();

                    if (success)
                    {
                        // Load the library.
                        libraries[index] = lib;
                        libraryViewController.Show(libraries[index]);
                    }
                    else
                    {
                        // Display error.
                        DialogManager.ShowAlert("Unable to connect to server!",
                                                "Connection Error", MaterialIconHelper.GetIcon(MaterialIconEnum.ERROR));
                    }
                });
            }
            else
            {
                libraryViewController.Show(libraries[index]);
            }
        }
Exemplo n.º 5
0
        void CreateFloor(string floorName)
        {
            int libId = displayingLibrary.libraryId;
            int order = displayingLibrary.floors.Count;

            DialogComplexProgress d = (DialogComplexProgress)DialogManager.CreateComplexProgressLinear();

            d.Initialize("Creating new floor...", "Loading", MaterialIconHelper.GetIcon(MaterialIconEnum.HOURGLASS_EMPTY));
            d.InitializeCancelButton("CANCEL", ServiceController.shared.CancelCreateFloor);
            d.Show();

            ServiceController.shared.CreateFloor(libId, floorName, order, (suc1, suc2, id) => {
                d.Hide();

                if (!suc1)
                {
                    DialogManager.ShowAlert("Unable to communicate with server!",
                                            "Connection Error", MaterialIconHelper.GetIcon(MaterialIconEnum.ERROR));
                }
                else if (!suc2)
                {
                    DialogManager.ShowAlert("Login has expired! Please relogin and try again.",
                                            "Login Expired", MaterialIconHelper.GetIcon(MaterialIconEnum.ERROR));
                }
                else
                {
                    DialogManager.ShowAlert("Floor has been created.", "Success", MaterialIconHelper.GetIcon(MaterialIconEnum.CHECK));

                    // Add the newly created floor here.
                    Floor f      = new Floor();
                    f.floorId    = id;
                    f.floorName  = floorName;
                    f.floorOrder = order;
                    displayingLibrary.floors.Add(f);
                    UpdateFloorPreviews(displayingLibrary);
                }
            });
        }