コード例 #1
0
        public static bool Init()
        {
            graphics = new GraphicsContext();
            SampleDraw.Init(graphics);

            int sx = (graphics.Screen.Width / 2) - ((96 * 2) + (16 * 2));
            int sy = (graphics.Screen.Height / 2) - (96 / 2);

            playButton   = new SampleButton(sx + 0, sy - 24, 96, 48);
            stopButton   = new SampleButton(sx + 112, sy - 24, 96, 48);
            pauseButton  = new SampleButton(sx + 224, sy - 24, 96, 48);
            resumeButton = new SampleButton(sx + 336, sy - 24, 96, 48);
            volumeSlider = new SampleSlider(sx + 88, sy + 96, 256, 48);

            volTextPosX = (sx + 88) - 96;
            volTextPosY = (sy + 96) + 12;

            playButton.SetText("Play");
            stopButton.SetText("Stop");
            pauseButton.SetText("Pause");
            resumeButton.SetText("Resume");

            bgm       = new Bgm("/Application/Sample/Audio/BgmPlayerSample/GAME_BGM_01.mp3");
            bgmPlayer = bgm.CreatePlayer();

            return(true);
        }
コード例 #2
0
ファイル: HttpSample.cs プロジェクト: weimingtom/Sakura
        public static bool Init()
        {
            graphics = new GraphicsContext();
            SampleDraw.Init(graphics);

            connectButton = new SampleButton(48, 48, 256, 64);
            connectButton.SetText("Connect");

            connectState = ConnectState.None;

            return(true);
        }
コード例 #3
0
ファイル: SocketSample.cs プロジェクト: weimingtom/Sakura
        public static bool Init()
        {
            graphics = new GraphicsContext();
            SampleDraw.Init(graphics);

            serverButton = new SampleButton(32, 32, 128, 48);
            clientButton = new SampleButton(32 + (SampleDraw.Width / 2), 32, 128, 48);

            serverButton.SetText(tcpServer.buttonString);
            clientButton.SetText(tcpClient.buttonString);

            return(true);
        }
コード例 #4
0
            public SoundButton(int id, int pixelX, int pixelY)
            {
                textSprite   = new SampleSprite("SE " + id, 0xffffffff, SampleDraw.CurrentFont, pixelX - 64, pixelY + 12);
                playButton   = new SampleButton(pixelX, pixelY, 96, 48);
                stopButton   = new SampleButton(pixelX + 112, pixelY, 96, 48);
                volumeSlider = new SampleSlider(pixelX + 224, pixelY, 256, 48);

                playButton.SetText("Play");
                stopButton.SetText("Stop");

                sound       = new Sound(soundName[id]);
                soundPlayer = sound.CreatePlayer();
            }
コード例 #5
0
        public static bool Init()
        {
            graphics = new GraphicsContext();
            SampleDraw.Init(graphics);

            int rectW = 256;
            int rectH = 64;
            int rectX = (SampleDraw.Width - rectW) / 2;
            int rectY = (SampleDraw.Height - 24 - rectH * 3) / 2;

            browserButton = new SampleButton(rectX, rectY, rectW, rectH);

            browserButton.SetText("Browser");

            return(true);
        }
コード例 #6
0
ファイル: DialogSample.cs プロジェクト: weimingtom/Sakura
        public static bool Init()
        {
            graphics = new GraphicsContext();
            SampleDraw.Init(graphics);

            int rectW = SampleDraw.Width / 2;
            int rectH = 32;
            int rectX = (SampleDraw.Width - rectW) / 2;
            int rectY = (SampleDraw.Height - 24) / 2;

            button = new SampleButton(rectX, rectY, rectW, rectH);
            button.SetText("InputText", SampleButton.TextAlign.Left, SampleButton.VerticalAlign.Middle);

            dialog = null;

            return(true);
        }
コード例 #7
0
ファイル: StorageSample.cs プロジェクト: weimingtom/Sakura
        // use objects intialize.
        private static void SetupObjects()
        {
            int sx   = (screenWidth - (BUTTON_NO * 192)) / 2;
            int soff = (192 - 96) / 2;

            button0 = new SampleButton(sx + (192 * 0) + soff, 128, 128, 48);
            button1 = new SampleButton(sx + (192 * 1) + soff, 128, 128, 48);
            button2 = new SampleButton(sx + (192 * 2) + soff, 128, 128, 48);

            button0.SetText(BUTTON_LOAD);
            button1.SetText(BUTTON_SAVE);
            button2.SetText(BUTTON_DELETE);

            string label = "";

            dialogXPos      = (screenWidth - 480) / 2;
            inputTextButton = new SampleButton(dialogXPos, 256, 480, 32);
            inputTextButton.SetText(label, SampleButton.TextAlign.Left, SampleButton.VerticalAlign.Middle);
            dialog = null;
        }
コード例 #8
0
ファイル: ClipboardSample.cs プロジェクト: weimingtom/Sakura
        public static bool Init()
        {
            graphics = new GraphicsContext();
            SampleDraw.Init(graphics);


            inputTextButton = new SampleButton(32, 64, 480, 32);
            copyButton      = new SampleButton(544, 64, 96, 32);
            pasteButton     = new SampleButton(32, 240, 96, 32);
            copyTextButton  = new SampleButton(160, 240, 480, 32);

            copyTextButton.ButtonColor = 0xff7f7f7f;

            inputTextButton.SetText("InputText", SampleButton.TextAlign.Left, SampleButton.VerticalAlign.Middle);
            copyButton.SetText("Copy");
            pasteButton.SetText("Paste");
            copyTextButton.SetText("CopyText", SampleButton.TextAlign.Left, SampleButton.VerticalAlign.Middle);

            dialog = null;

            return(true);
        }
コード例 #9
0
ファイル: SocketSample.cs プロジェクト: weimingtom/Sakura
        public static bool Render()
        {
            graphics.SetClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            graphics.Clear();
            serverButton.SetText(tcpServer.buttonString);
            clientButton.SetText(tcpClient.buttonString);

            List <TouchData> touchDataList = Touch.GetData(0);

            // Modify status
            if (serverButton.TouchDown(touchDataList))
            {
                tcpServer.ChangeStatus();
            }
            if (clientButton.TouchDown(touchDataList))
            {
                tcpClient.ChangeStatus();
            }

            /*
             * uint[] colorTable = {0xffff0000,
             *                                       0xff00ff00,
             *                                       0xff0000ff,
             *                                       0xffffff00};
             */
            foreach (var touchData in touchDataList)
            {
                /*
                 *                      if (touchData.Status == TouchStatus.Down ||
                 *                              touchData.Status == TouchStatus.Move) {
                 *
                 *                              int pointX = (int)((touchData.X + 0.5f) * Graphics2D.Width);
                 *                              int pointY = (int)((touchData.Y + 0.5f) * Graphics2D.Height);
                 *                              int radius = (int)(touchData.Force * 32);
                 *                              int colorId = touchData.ID % colorTable.Length;
                 *
                 *                              Graphics2D.FillCircle(colorTable[colorId], pointX, pointY, radius);
                 *
                 *                      }
                 */
                if (touchData.Status == TouchStatus.Down)
                {
                    int pointX = (int)((touchData.X + 0.5f) * SampleDraw.Width);
                    int pointY = (int)((touchData.Y + 0.5f) * SampleDraw.Height);
                    if (pointX < (SampleDraw.Width / 2))
                    {
                        tcpServer.SetMyPosition(pointX, pointY);
                    }
                    else
                    {
                        tcpClient.SetMyPosition(pointX - (SampleDraw.Width / 2), pointY);
                    }
                }
            }

            // Display button and status
            serverButton.Draw();
            clientButton.Draw();
            drawStatus(tcpServer);
            drawStatus(tcpClient);

            SampleDraw.DrawText("Network Sample", 0xffffffff, 0, 0);
            graphics.SwapBuffers();

            return(true);
        }
コード例 #10
0
ファイル: StorageSample.cs プロジェクト: weimingtom/Sakura
        // check objects change state,
        private static bool CheckChangeState()
        {
            bool             changeState   = false;
            List <TouchData> touchDataList = Touch.GetData(0);

            // button.
            if (button0.TouchDown(touchDataList))
            {
                if (true == System.IO.File.Exists(@SAVE_FILE))
                {
                    using (System.IO.FileStream hStream = System.IO.File.Open(@SAVE_FILE, FileMode.Open)) {
                        if (hStream != null)
                        {
                            long size = hStream.Length;
                            inputData = new byte[size];
                            hStream.Read(inputData, 0, (int)size);
                            inputDataSize = (int)size;
                            string label = System.Text.Encoding.Unicode.GetString(inputData);
                            inputTextButton.SetText(label);
                            hStream.Close();
                            eventAction = EVENT_LOAD;
                        }
                    }
                }
            }

            else if (button1.TouchDown(touchDataList))
            {
                if (inputDataSize > 0)
                {
                    using (System.IO.FileStream hStream = System.IO.File.Open(@SAVE_FILE, FileMode.Create)) {
                        hStream.SetLength((int)inputDataSize);
                        hStream.Write(inputData, 0, (int)inputDataSize);
                        hStream.Close();
                        isFileExist = true;
                        eventAction = EVENT_WRITE;
                    }
                }
            }

            else if (button2.TouchDown(touchDataList))
            {
                if (true == System.IO.File.Exists(@SAVE_FILE))
                {
                    System.IO.File.Delete(@SAVE_FILE);
                    inputTextButton.SetText(" ");
                    inputDataSize = 0;
                    inputData     = null;
                    isFileExist   = false;
                    eventAction   = EVENT_DELETE;
                }
            }


            // input dialog.
            if (inputTextButton.TouchDown(touchDataList))
            {
                if (dialog == null)
                {
                    dialog      = new TextInputDialog();
                    dialog.Text = inputTextButton.Label;
                    dialog.Open();
                }
                return(true);
            }

            if (dialog != null)
            {
                if (dialog.State == CommonDialogState.Finished)
                {
                    if (dialog.Result == CommonDialogResult.OK)
                    {
                        string setLabelStr;
                        int    i;

                        int len = dialog.Text.Length;

                        if (len > MAX_INPUT_CHARACTOR)
                        {
                            len = MAX_INPUT_CHARACTOR;
                        }

                        setLabelStr = dialog.Text.Substring(0, len);

                        inputTextButton.Label = setLabelStr;

                        byte[] byteArray0 = System.Text.Encoding.Unicode.GetBytes(setLabelStr);
                        inputData = new byte[byteArray0.Length];
                        for (i = 0; i < byteArray0.Length; i++)
                        {
                            inputData[i] = byteArray0[i];
                        }

                        inputDataSize = byteArray0.Length;

                        changeState = true;
                    }
                    dialog.Dispose();
                    dialog = null;
                }
            }

            return(changeState);
        }
コード例 #11
0
        // check objects change state,
        private static bool CheckChangeState()
        {
            bool             changeState   = false;
            List <TouchData> touchDataList = Touch.GetData(0);

            // button.
            if (button0.ButtonColor == DISABLE_COLOR &&
                button0.TouchDown(touchDataList))
            {
                button0.SetText(BUTTON_PRESS);
                button0.ButtonColor = ENABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON0] = 1;
                changeState = true;
            }
            else if (button0.ButtonColor == ENABLE_COLOR &&
                     button0.TouchDown(touchDataList))
            {
                button0.SetText(BUTTON_RELEASE);
                button0.ButtonColor = DISABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON0] = 0;
                changeState = true;
            }

            if (button1.ButtonColor == DISABLE_COLOR &&
                button1.TouchDown(touchDataList))
            {
                button1.SetText(BUTTON_PRESS);
                button1.ButtonColor = ENABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON1] = 1;
                changeState = true;
            }
            else if (button1.ButtonColor == ENABLE_COLOR &&
                     button1.TouchDown(touchDataList))
            {
                button1.SetText(BUTTON_RELEASE);
                button1.ButtonColor = DISABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON1] = 0;
                changeState = true;
            }

            if (button2.ButtonColor == DISABLE_COLOR &&
                button2.TouchDown(touchDataList))
            {
                button2.SetText(BUTTON_PRESS);
                button2.ButtonColor = ENABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON2] = 1;
                changeState = true;
            }
            else if (button2.ButtonColor == ENABLE_COLOR &&
                     button2.TouchDown(touchDataList))
            {
                button2.SetText(BUTTON_RELEASE);
                button2.ButtonColor = DISABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON2] = 0;
                changeState = true;
            }

            if (button3.ButtonColor == DISABLE_COLOR &&
                button3.TouchDown(touchDataList))
            {
                button3.SetText(BUTTON_PRESS);
                button3.ButtonColor = ENABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON3] = 1;
                changeState = true;
            }
            else if (button3.ButtonColor == ENABLE_COLOR &&
                     button3.TouchDown(touchDataList))
            {
                button3.SetText(BUTTON_RELEASE);
                button3.ButtonColor = DISABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON3] = 0;
                changeState = true;
            }

            // slider.
            slider.Update(touchDataList);
            float curRate = slider.Rate;

            if (curRate != oldRate)
            {
                byte[] byteArray;
                byteArray = BitConverter.GetBytes(curRate);
                for (int i = 0; i < byteArray.Length; i++)
                {
                    persistentMemoryData[STATE_ADDR_SLIDER + i] = byteArray[i];
                }
                oldRate     = curRate;
                changeState = true;
            }

            // input dialog.
            if (inputTextButton.TouchDown(touchDataList))
            {
                if (dialog == null)
                {
                    dialog      = new TextInputDialog();
                    dialog.Text = inputTextButton.Label;
                    dialog.Open();
                }
                return(true);
            }

            if (dialog != null)
            {
                if (dialog.State == CommonDialogState.Finished)
                {
                    if (dialog.Result == CommonDialogResult.OK)
                    {
                        string setLabelStr;
                        int    i;

                        int len = dialog.Text.Length;

                        if (len > MAX_INPUT_CHARACTOR)
                        {
                            len = MAX_INPUT_CHARACTOR;
                        }

                        setLabelStr = dialog.Text.Substring(0, len);

                        inputTextButton.Label = setLabelStr;

                        byte[] byteArray0 = System.Text.Encoding.Unicode.GetBytes(setLabelStr);
                        for (i = 0; i < byteArray0.Length; i++)
                        {
                            persistentMemoryData[STATE_ADDR_STRING + i] = byteArray0[i];
                        }

                        byte[] byteArray1 = BitConverter.GetBytes(len);
                        for (i = 0; i < byteArray1.Length; i++)
                        {
                            persistentMemoryData[STATE_ADDR_STRING_NO + i] = byteArray1[i];
                        }

                        changeState = true;
                    }
                    dialog.Dispose();
                    dialog = null;
                }
            }

            return(changeState);
        }
コード例 #12
0
        // use objects intialize.
        private static void SetupObjects()
        {
            int sx   = (screenWidth - (BUTTON_NO * 128)) / 2;
            int soff = (128 - 96) / 2;

            button0 = new SampleButton(sx + (128 * 0) + soff, 128, 96, 48);
            button1 = new SampleButton(sx + (128 * 1) + soff, 128, 96, 48);
            button2 = new SampleButton(sx + (128 * 2) + soff, 128, 96, 48);
            button3 = new SampleButton(sx + (128 * 3) + soff, 128, 96, 48);

            if (0 == persistentMemoryData[STATE_ADDR_BUTTON0])
            {
                button0.SetText(BUTTON_RELEASE);
                button0.ButtonColor = DISABLE_COLOR;
            }
            else
            {
                button0.SetText(BUTTON_PRESS);
                button0.ButtonColor = ENABLE_COLOR;
            }

            if (0 == persistentMemoryData[STATE_ADDR_BUTTON1])
            {
                button1.SetText(BUTTON_RELEASE);
                button1.ButtonColor = DISABLE_COLOR;
            }
            else
            {
                button1.SetText(BUTTON_PRESS);
                button1.ButtonColor = ENABLE_COLOR;
            }

            if (0 == persistentMemoryData[STATE_ADDR_BUTTON2])
            {
                button2.SetText(BUTTON_RELEASE);
                button2.ButtonColor = DISABLE_COLOR;
            }
            else
            {
                button2.SetText(BUTTON_PRESS);
                button2.ButtonColor = ENABLE_COLOR;
            }

            if (0 == persistentMemoryData[STATE_ADDR_BUTTON3])
            {
                button3.SetText(BUTTON_RELEASE);
                button3.ButtonColor = DISABLE_COLOR;
            }
            else
            {
                button3.SetText(BUTTON_PRESS);
                button3.ButtonColor = ENABLE_COLOR;
            }

            // for slider setting
            byte[] byteArray = new byte[4];
            for (int i = 0; i < 4; i++)
            {
                byteArray[i] = persistentMemoryData[STATE_ADDR_SLIDER + i];
            }
            float rate = BitConverter.ToSingle(byteArray, 0);

            sx          = (screenWidth - 384) / 2;
            slider      = new SampleSlider(sx, 360, 384, 48);
            slider.Rate = rate;
            oldRate     = rate;

            // for text dialog setting
            byte[] byteArrayD0 = new byte[4];
            for (int i = 0; i < 4; i++)
            {
                byteArrayD0[i] = persistentMemoryData[STATE_ADDR_STRING_NO + i];
            }
            int len      = BitConverter.ToInt32(byteArrayD0, 0);
            int readSize = len * 2;

            byte[] byteArrayD1 = new byte[readSize];
            for (int i = 0; i < readSize; i++)
            {
                byteArrayD1[i] = persistentMemoryData[STATE_ADDR_STRING + i];
            }

            string label = "";

            if (len != 0)
            {
                label = System.Text.Encoding.Unicode.GetString(byteArrayD1);
            }

            sx = (screenWidth - 480) / 2;
            inputTextButton = new SampleButton(sx, 256, 480, 32);
            inputTextButton.SetText(label, SampleButton.TextAlign.Left, SampleButton.VerticalAlign.Middle);
            dialog = null;
        }