예제 #1
0
    void NormalMenu()
    {
        float yInitial   = (Screen.height - (kButtonHeight + kMargin) * 6) / 2.0f;
        Rect  buttonRect = new Rect((Screen.width - kButtonWidth) / 4.0f,
                                    yInitial, kButtonWidth, kButtonHeight);

        // Left column ////////////////////////////////////////////////////////
        if (GUI.Button(buttonRect, m_workingPrinter.isAwake ? "Sleep" : "Wake"))
        {
            if (!m_workingPrinter.isAwake)
            {
                pc.WakePrinter(m_workingPrinter);
            }
            else
            {
                pc.SleepPrinter(m_workingPrinter);
            }
        }

        buttonRect.y += kButtonHeight + kMargin;
        if (GUI.Button(buttonRect, "Print Test"))
        {
            // Print
            pc.SchedulePrint(VoxelBlob.NewTestDisc());
            HandleMenu = PrintingMenu;
            Dispatcher <float> .AddListener(PrinterController.kOnPrintingProgress, OnPrintingProgress);
        }

        buttonRect.y += kButtonHeight + kMargin;
        if (GUI.Button(buttonRect, @"Print Test Scene"))
        {
            string   filePath;
            string[] extensions     = new string[] { "radiant" };
            string[] extensionNames = new string[] { "Radiant scene" };

            if (FileDialogs.ShowOpenFileDialog(out filePath, extensions, extensionNames))
            {
                System.IO.FileStream stream = new System.IO.FileStream(filePath, System.IO.FileMode.Open);
                VoxelBlob            blob   = VoxelBlob.NewFromFile(stream, false);
                pc.SchedulePrint(blob);
                HandleMenu = PrintingMenu;
                Dispatcher <float> .AddListener(PrinterController.kOnPrintingProgress, OnPrintingProgress);
            }
            else
            {
                Text.Log(@"Aborted opening.");
            }
        }

        /*
         * buttonRect.y += kButtonHeight + kMargin;
         * if (GUI.Button(buttonRect, "Request Token Test")) {
         *      StartCoroutine(OAuth1.GetRequestToken(ExternalSite.ShapeWays, RequestResponse));
         *      HandleMenu = AuthorizationMenu;
         * }
         */

        /*
         * GUI.enabled = !m_isSaved;
         * buttonRect.y += kButtonHeight + kMargin;
         * if (GUI.Button(buttonRect, "Save")) {
         *      string filePath = NativePanels.SaveFileDialog("model.radiant", "radiant");
         *      SaveBlob(filePath);
         *      Text.Log("Saved " + filePath);
         *      m_isSaved = true;
         *      Dispatcher<Sfx>.Broadcast(AudioManager.kPlaySfx, Sfx.Select);
         * }
         *
         * GUI.enabled = true;
         * buttonRect.y += kButtonHeight + kMargin;
         * if (GUI.Button(buttonRect, "Load")) {
         *      //PlayerPrefs.SetString(VoxelBlob.kSerializedKey, serializedBlob);
         *      string filePath = NativePanels.OpenFileDialog(new string[]{"radiant"});
         *      LoadBlob(filePath);
         *      m_isSaved = true;
         *      Dispatcher<Sfx>.Broadcast(AudioManager.kPlaySfx, Sfx.Select);
         * }
         */

        // Right column ///////////////////////////////////////////////////////
        buttonRect.x      = (Screen.width - kButtonWidth) * 0.75f;
        buttonRect.y      = yInitial;
        buttonRect.height = kButtonHeight;
        buttonRect.width  = kButtonWidth / 3.0f;
        buttonRect.x     += buttonRect.width + kMargin;
        if (GUI.Button(buttonRect, "^"))
        {
            pc.BeginMotorChanges(m_workingPrinter);
            pc.MoveVerticallyBy(-10.0f, Change.Execute);
            pc.EndMotorChanges();
        }

        buttonRect.y += kButtonHeight + kMargin;
        buttonRect.x  = buttonRect.x - buttonRect.width - kMargin;
        if (GUI.Button(buttonRect, "<"))
        {
            pc.BeginMotorChanges(m_workingPrinter);
            pc.MoveHorizontallyBy(10.0f, Change.Execute);
            pc.EndMotorChanges();
        }

        buttonRect.x += buttonRect.width + kMargin;
        if (GUI.Button(buttonRect, "v"))
        {
            pc.BeginMotorChanges(m_workingPrinter);
            pc.MoveVerticallyBy(10.0f, Change.Execute);
            pc.EndMotorChanges();
        }

        buttonRect.x += buttonRect.width + kMargin;
        if (GUI.Button(buttonRect, ">"))
        {
            pc.BeginMotorChanges(m_workingPrinter);
            pc.MoveHorizontallyBy(-10.0f, Change.Execute);
            pc.EndMotorChanges();
        }
    }