Ejemplo n.º 1
0
        public static void SetCurtain(int frameMax, double destWhiteLevel, double startWhiteLevel)
        {
            frameMax        = IntTools.ToRange(frameMax, 0, 3600);      // 0 frame - 1 min
            destWhiteLevel  = DoubleTools.ToRange(destWhiteLevel, -1.0, 1.0);
            startWhiteLevel = DoubleTools.ToRange(startWhiteLevel, -1.0, 1.0);

            CurtainQueue.Clear();

            if (frameMax == 0)
            {
                CurtainQueue.Enqueue(destWhiteLevel);
            }
            for (int frmcnt = 0; frmcnt <= frameMax; frmcnt++)
            {
                double wl;

                if (frmcnt == 0)
                {
                    wl = startWhiteLevel;
                }
                else if (frmcnt == frameMax)
                {
                    wl = destWhiteLevel;
                }
                else
                {
                    wl = startWhiteLevel + (destWhiteLevel - startWhiteLevel) * ((double)frmcnt / frameMax);
                }

                CurtainQueue.Enqueue(wl);
            }
        }
Ejemplo n.º 2
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        public static void SetBlendAdd(double a)
        {
            int pal = DoubleTools.ToInt(a * 255.0);

            pal = IntTools.ToRange(pal, 0, 255);

            Extra.BlendAdd = pal;
        }
Ejemplo n.º 3
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        public static void SetBright(I3Color color)
        {
            color.R = IntTools.ToRange(color.R, 0, 255);
            color.G = IntTools.ToRange(color.G, 0, 255);
            color.B = IntTools.ToRange(color.B, 0, 255);

            Extra.Bright = color;
        }
Ejemplo n.º 4
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        public static void SetAlpha(double a)
        {
            int pal = DoubleTools.ToInt(a * 255.0);

            pal = IntTools.ToRange(pal, 0, 255);

            Extra.A = pal;
        }
Ejemplo n.º 5
0
        public static void SetSIPixel(int si_h, int x, int y, SIPixel i)
        {
            i.R = IntTools.ToRange(i.R, 0, 255);
            i.G = IntTools.ToRange(i.G, 0, 255);
            i.B = IntTools.ToRange(i.B, 0, 255);
            i.A = IntTools.ToRange(i.A, 0, 255);

            if (DX.DrawPixelSoftImage(si_h, x, y, i.R, i.G, i.B, i.A) != 0)
            {
                throw new GameError();
            }
        }
Ejemplo n.º 6
0
        private void BtnOk_Click(object sender, EventArgs e)
        {
            this.OkPressed = true;

            {
                int value = (int)this.FPS.Value;
                value        = IntTools.ToRange(value, Consts.FPS_MIN, Consts.FPS_MAX);
                this.Ret_FPS = value;
            }

            this.Close();
        }
Ejemplo n.º 7
0
        public static void SetSoftImageDot(int siHandle, int x, int y, Dot dot)
        {
            dot.R = IntTools.ToRange(dot.R, 0, 255);
            dot.G = IntTools.ToRange(dot.G, 0, 255);
            dot.B = IntTools.ToRange(dot.B, 0, 255);
            dot.A = IntTools.ToRange(dot.A, 0, 255);

            if (DX.DrawPixelSoftImage(siHandle, x, y, dot.R, dot.G, dot.B, dot.A) != 0)
            {
                throw new DDError();
            }
        }
Ejemplo n.º 8
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        public static void SetBright(double r, double g, double b)
        {
            int pR = DoubleTools.ToInt(r * 255.0);
            int pG = DoubleTools.ToInt(g * 255.0);
            int pB = DoubleTools.ToInt(b * 255.0);

            pR = IntTools.ToRange(pR, 0, 255);
            pG = IntTools.ToRange(pG, 0, 255);
            pB = IntTools.ToRange(pB, 0, 255);

            Extra.Bright = new I3Color(pR, pG, pB);
        }
Ejemplo n.º 9
0
        private void MS_SetSelectedRowIndex(int rowidx)
        {
            rowidx = IntTools.ToRange(rowidx, -1, this.MainSheet.RowCount - 1);

            if (rowidx == -1)
            {
                this.MainSheet.ClearSelection();
            }
            else
            {
                this.MainSheet.Rows[rowidx].Selected = true;
                this.MS_Scroll(rowidx);
            }
        }
Ejemplo n.º 10
0
        private void DrawMap()
        {
            int w = this.Map.W;
            int h = this.Map.H;

            int camL = DDGround.ICamera.X;
            int camT = DDGround.ICamera.Y;
            int camR = camL + DDConsts.Screen_W;
            int camB = camT + DDConsts.Screen_H;

            I2Point lt = Map.ToTablePoint(camL, camT);
            I2Point rb = Map.ToTablePoint(camR, camB);

            lt.X -= 2;             // margin
            lt.Y -= 2;             // margin
            rb.X += 2;             // margin
            rb.Y += 2;             // margin

            lt.X = IntTools.ToRange(lt.X, 0, w - 1);
            lt.Y = IntTools.ToRange(lt.Y, 0, h - 1);
            rb.X = IntTools.ToRange(rb.X, 0, w - 1);
            rb.Y = IntTools.ToRange(rb.Y, 0, h - 1);

            for (int x = lt.X; x <= rb.X; x++)
            {
                for (int y = lt.Y; y <= rb.Y; y++)
                {
                    int mapTileX = x * MapTile.WH + MapTile.WH / 2;
                    int mapTileY = y * MapTile.WH + MapTile.WH / 2;

                    //if (DDUtils.IsOut(new D2Point(mapTileX, mapTileY), new D4Rect(camL, camT, camR, camB), MapTile.WH * 2) == false) // old
                    {
                        MapCell cell = this.Map.GetCell(x, y);

                        if (cell.Tile != null)                         // ? ! 描画無し
                        {
                            DDDraw.DrawCenter(
                                cell.Tile.Picture,
                                mapTileX - camL + this.DrawMap_SlideX,
                                mapTileY - camT + this.DrawMap_SlideY
                                );
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
        private void MS_SetFPS(int value)
        {
            value = IntTools.ToRange(value, Consts.FPS_MIN, Consts.FPS_MAX);             // 2bs

            this.MS_CallSelectedRows(row =>
            {
                int rowidx     = row.Index;
                AudioInfo info = this.MS_GetRow(rowidx);

                if (info.Status == AudioInfo.Status_e.PROCESSING)
                {
                    throw new Exception("処理中の行は変更出来ません。");
                }

                info.FPS = value;

                this.MS_SetRow(rowidx, info);
            });
        }
Ejemplo n.º 12
0
        public void MouseEachFrame()
        {
            uint status;

            if (GameEngine.WindowIsActive)
            {
                MouseRot = DX.GetMouseHWheelRotVol();
                status   = (uint)DX.GetMouseInput();
            }
            else             // ? 非アクティブ -> 無入力
            {
                MouseRot = 0;
                status   = 0u;
            }
            MouseRot = IntTools.ToRange(MouseRot, -IntTools.IMAX, IntTools.IMAX);

            GameDefine.UpdateInput(ref MouseStatus[(int)MOUBTN.L], (status & DX.MOUSE_INPUT_LEFT) != 0u);
            GameDefine.UpdateInput(ref MouseStatus[(int)MOUBTN.M], (status & DX.MOUSE_INPUT_MIDDLE) != 0u);
            GameDefine.UpdateInput(ref MouseStatus[(int)MOUBTN.R], (status & DX.MOUSE_INPUT_RIGHT) != 0u);
        }
Ejemplo n.º 13
0
        private Ground()
        {
            this.SaveFile = Path.Combine(ProcMain.SelfDir, Path.GetFileNameWithoutExtension(ProcMain.SelfFile)) + ".dat";

            try
            {
                Screen screen = Screen.AllScreens[0];

                this.画像を二重に表示_MonitorW = screen.Bounds.Width;
                this.画像を二重に表示_MonitorH = screen.Bounds.Height;
            }
            catch
            {
                this.画像を二重に表示_MonitorW = Consts.MonitorW_Min;
                this.画像を二重に表示_MonitorH = Consts.MonitorH_Min;
            }

            this.画像を二重に表示_MonitorW = IntTools.ToRange(this.画像を二重に表示_MonitorW, Consts.MonitorW_Min, Consts.MonitorW_Max);
            this.画像を二重に表示_MonitorH = IntTools.ToRange(this.画像を二重に表示_MonitorH, Consts.MonitorH_Min, Consts.MonitorH_Max);
        }
Ejemplo n.º 14
0
        public static void EachFrame()
        {
            uint status;

            if (DDEngine.WindowIsActive)
            {
                _rot   = DX.GetMouseWheelRotVol();
                status = (uint)DX.GetMouseInput();
            }
            else
            {
                _rot   = 0;
                status = 0u;
            }
            _rot = IntTools.ToRange(_rot, -IntTools.IMAX, IntTools.IMAX);

            DDUtils.UpdateInput(ref L.Status, (status & (uint)DX.MOUSE_INPUT_LEFT) != 0u);
            DDUtils.UpdateInput(ref R.Status, (status & (uint)DX.MOUSE_INPUT_RIGHT) != 0u);
            DDUtils.UpdateInput(ref M.Status, (status & (uint)DX.MOUSE_INPUT_MIDDLE) != 0u);
        }
Ejemplo n.º 15
0
        public static void MusicFade(int frameMax, double destVRate, double startVRate)
        {
            if (CurrDestMusic == null)
            {
                return;
            }

            frameMax   = IntTools.ToRange(frameMax, 1, 3600);           // 1 frame - 1 min
            destVRate  = DoubleTools.ToRange(destVRate, 0.0, 1.0);
            startVRate = DoubleTools.ToRange(startVRate, 0.0, 1.0);

            for (int frmcnt = 0; frmcnt <= frameMax; frmcnt++)
            {
                double vRate;

                if (frmcnt == 0)
                {
                    vRate = startVRate;
                }
                else if (frmcnt == frameMax)
                {
                    vRate = destVRate;
                }
                else
                {
                    vRate = startVRate + ((destVRate - startVRate) * frmcnt) / frameMax;
                }

                PlayList.Enqueue(CreatePI('V', CurrDestMusic, false, false, vRate));
            }
            CurrDestMusicVolumeRate = destVRate;

            if (destVRate == 0.0)             // ? フェード目標音量ゼロ -> 曲停止
            {
                MusicStop();
            }
        }
Ejemplo n.º 16
0
        private static void ConvImageJpeg(string rFile, string wFile, string midPathBase)
        {
            int w;
            int h;

            try             // 画像読み込みテスト
            {
                using (Bitmap.FromFile(rFile))
                { }
            }
            catch (Exception e)
            {
                ProcMain.WriteLog(e);

                throw new Exception("画像ファイル読み込みエラー");
            }

            using (Image bmp = Bitmap.FromFile(rFile))
            {
                w = bmp.Width;
                h = bmp.Height;

                bmp.Save(midPathBase + "1.bmp", ImageFormat.Bmp);                 // 透過を無効にしたいだけ、、、
            }

            ProcMain.WriteLog("w: " + w);
            ProcMain.WriteLog("h: " + h);

            if (w < 1 || IntTools.IMAX < w)
            {
                throw new Exception("画像ファイルの幅に問題があります。");
            }

            if (h < 1 || IntTools.IMAX < h)
            {
                throw new Exception("画像ファイルの高さに問題があります。");
            }

            if (Ground.I.画像を二重に表示)
            {
                int mon_w = Ground.I.画像を二重に表示_MonitorW;
                int mon_h = Ground.I.画像を二重に表示_MonitorH;

                // 高さと幅はそれぞれ偶数でなければならない。
                mon_w &= ~1;
                mon_h &= ~1;

                int ww = mon_w;
                int hh;

                {
                    long t = h;
                    t *= mon_w;
                    t /= w;

                    if (mon_h <= t)
                    {
                        hh = (int)t;
                    }
                    else
                    {
                        hh = mon_h;

                        t  = w;
                        t *= mon_h;
                        t /= h;

                        ww = (int)t;
                    }
                }

                string aa;

                if (Ground.I.画像を二重に表示_明るさ == 100)
                {
                    aa = "";
                }
                else
                {
                    aa = ":" + Ground.I.画像を二重に表示_明るさ.ToString("D2");
                }

                int ll = (ww - mon_w) / 2;
                int tt = (hh - mon_h) / 2;

                Run("ImgTools.exe /rf " + midPathBase + "1.bmp /wf " + midPathBase + "1w.png /e " + ww + " " + hh +
                    " /C " + ll + " " + tt + " " + mon_w + " " + mon_h +
                    " /BOKASHI 0 0 " + mon_w + " " + mon_h + " " + Ground.I.画像を二重に表示_ぼかし + " 1 " +
                    " /DOTFLTR A R" + aa + " G" + aa + " B" + aa
                    );

                if (File.Exists(midPathBase + "1w.png") == false)
                {
                    throw new Exception("画像処理エラー(1w)");
                }

                ww = mon_w;

                {
                    long t = h;
                    t *= mon_w;
                    t /= w;

                    if (t <= mon_h)
                    {
                        hh = (int)t;
                    }
                    else
                    {
                        hh = mon_h;

                        t  = w;
                        t *= mon_h;
                        t /= h;

                        ww = (int)t;
                    }
                }

                Run("ImgTools.exe /rf " + midPathBase + "1.bmp /wf " + midPathBase + "1f.png /e " + ww + " " + hh);

                if (File.Exists(midPathBase + "1f.png") == false)
                {
                    throw new Exception("画像処理エラー(1f)");
                }

                ll = (mon_w - ww) / 2;
                tt = (mon_h - hh) / 2;

                Run("ImgTools.exe /rf " + midPathBase + "1w.png /wf " + midPathBase + "2.png /2 " + midPathBase + "1f.png /PASTE " + ll + " " + tt);
            }
            else
            {
                int ww = IntTools.ToRange(w, Consts.IMAGE_WH_MIN, Consts.IMAGE_WH_MAX);
                int hh;

                {
                    long t = h;
                    t *= ww;
                    t /= w;

                    if (Consts.IMAGE_WH_MIN <= t && t <= Consts.IMAGE_WH_MAX)
                    {
                        hh = (int)t;
                    }
                    else
                    {
                        hh = IntTools.ToRange(h, Consts.IMAGE_WH_MIN, Consts.IMAGE_WH_MAX);

                        t  = w;
                        t *= hh;
                        t /= h;
                        t  = LongTools.ToRange(t, Consts.IMAGE_WH_MIN, Consts.IMAGE_WH_MAX);

                        ww = (int)t;
                    }
                }

                ProcMain.WriteLog("ww.1: " + ww);
                ProcMain.WriteLog("hh.1: " + hh);

                // 高さと幅はそれぞれ偶数でなければならない。
                ww &= ~1;
                hh &= ~1;

                ProcMain.WriteLog("ww.2: " + ww);
                ProcMain.WriteLog("hh.2: " + hh);

                Run("ImgTools.exe /rf " + midPathBase + "1.bmp /wf " + midPathBase + "2.png /e " + ww + " " + hh);
            }
            if (File.Exists(midPathBase + "2.png") == false)
            {
                throw new Exception("画像処理エラー(ImgTools)");
            }

            Run("BmpToCsv.exe /J " + Ground.I.JpegQuality + " " + midPathBase + "2.png " + midPathBase + "3.jpg");

            if (File.Exists(midPathBase + "3.jpg") == false)
            {
                throw new Exception("画像処理エラー(BmpToCsv)");
            }

            File.Move(midPathBase + "3.jpg", wFile);
        }
Ejemplo n.º 17
0
        private void MainTimer_Tick(object sender, EventArgs e)
        {
            if (this.MT_Enabled == false || this.MT_Busy)
            {
                return;
            }

            this.MT_Busy = true;

            try
            {
                if (this.XBtnPressed)
                {
                    this.XBtnPressed = false;
                    this._中止ボタン_Click(null, null);
                    return;
                }

                // ----

                if (Gnd.Conv.Cancelled || Gnd.Conv.Errored)
                {
                    if (this.Th.IsAlive == false)
                    {
                        this.MT_Enabled = false;
                        this.Close();
                        return;
                    }
                }
                else if (1 <= this.FinishedCount)
                {
                    if (this.FinishedCount == 10)
                    {
                        this.MT_Enabled = false;
                        this.Close();
                        return;
                    }

                    {
                        int prog = IntTools.IMAX;

                        if (this.ProgBar.Value != prog)
                        {
                            this.ProgBar.Value = prog;
                        }
                    }

                    this.FinishedCount++;
                }
                else
                {
                    if (this.Th.IsAlive == false)
                    {
                        this.FinishedCount = 1;
                        return;
                    }

                    {
                        double curr = this.CurrProg;
                        double dest;

                        lock (SYNCROOT)
                        {
                            dest = this.DestProg;
                        }
                        curr -= dest;
                        curr *= 0.9985;
                        curr += dest;

                        this.CurrProg = curr;
                    }

                    {
                        int prog = IntTools.ToInt(this.CurrProg * IntTools.IMAX);

                        prog = IntTools.ToRange(prog);

                        if (this.ProgBar.Value != prog)
                        {
                            this.ProgBar.Value = prog;
                        }
                    }

                    {
                        string message = null;

                        lock (SYNCROOT)
                        {
                            if (this.NextMessage != null)
                            {
                                message          = this.NextMessage;
                                this.NextMessage = null;
                            }
                        }
                        if (message != null)
                        {
                            _メッセージ.Text = message;
                        }
                    }

                    if (this.MT_Count % 20 == 0)
                    {
                        string status;
                        Color  statusColor;

                        lock (SYNCROOT)
                        {
                            status      = this.NextStatus;
                            statusColor = this.NextStatusColor;
                        }
                        if (status != null)
                        {
                            if (_ステータス.Text != status)
                            {
                                _ステータス.Text = status;
                            }
                        }
                        if (statusColor != null)
                        {
                            if (_ステータス.ForeColor != statusColor)
                            {
                                _ステータス.ForeColor = statusColor;
                            }
                        }
                    }

                    if (this.RequestGC)
                    {
                        GC.Collect();
                        this.RequestGC = false;
                    }
                }
            }
            finally
            {
                this.MT_Busy = false;
                this.MT_Count++;
            }
        }
Ejemplo n.º 18
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        public int IntVolumeConfig(string title, int value, int minval, int maxval, int valStep, int valFastStep, Action <int> valChanged, Action pulse)
        {
            const int PULSE_FRM = 60;

            int origval = value;

            DDCurtain.SetCurtain();
            DDEngine.FreezeInput();

            for (; ;)
            {
                bool chgval = false;

                if (DDInput.A.IsPound() || this.MouseUsable && DDMouse.L.GetInput() == -1)
                {
                    break;
                }
                if (DDInput.B.IsPound() || this.MouseUsable && DDMouse.R.GetInput() == -1)
                {
                    if (value == origval)
                    {
                        break;
                    }

                    value  = origval;
                    chgval = true;
                }
                if (this.MouseUsable)
                {
                    value += DDMouse.Rot;
                    chgval = true;
                }
                if (DDInput.DIR_8.IsPound())
                {
                    value += valFastStep;
                    chgval = true;
                }
                if (DDInput.DIR_6.IsPound())
                {
                    value += valStep;
                    chgval = true;
                }
                if (DDInput.DIR_4.IsPound())
                {
                    value -= valStep;
                    chgval = true;
                }
                if (DDInput.DIR_2.IsPound())
                {
                    value -= valFastStep;
                    chgval = true;
                }
                if (chgval)
                {
                    value = IntTools.ToRange(value, minval, maxval);
                    valChanged(value);
                }
                if (DDEngine.ProcFrame % PULSE_FRM == 0)
                {
                    pulse();
                }

                DDCurtain.DrawCurtain();

                if (this.WallColor != null)
                {
                    DX.DrawBox(0, 0, DDConsts.Screen_W, DDConsts.Screen_H, DDUtils.GetColor(this.WallColor.Value), 1);
                }

                if (this.WallPicture != null)
                {
                    DDDraw.DrawRect(this.WallPicture, 0, 0, DDConsts.Screen_W, DDConsts.Screen_H);
                    DDCurtain.DrawCurtain(this.WallCurtain);
                }
                if (this.Color != null)
                {
                    DDPrint.SetColor(this.Color.Value);
                }

                if (this.BorderColor != null)
                {
                    DDPrint.SetBorder(this.BorderColor.Value);
                }

                DDPrint.SetPrint(this.X, this.Y, this.YStep);
                DDPrint.Print(title);
                DDPrint.PrintRet();

                DDPrint.Print(string.Format("[{0}] 最小={1} 最大={2}", value, minval, maxval));
                DDPrint.PrintRet();

                DDPrint.Print("★ 左=下げる");
                DDPrint.PrintRet();
                DDPrint.Print("★ 右=上げる");
                DDPrint.PrintRet();
                DDPrint.Print("★ 下=速く下げる");
                DDPrint.PrintRet();
                DDPrint.Print("★ 上=速く上げる");
                DDPrint.PrintRet();
                DDPrint.Print("★ 調整が終わったら決定ボタンを押して下さい。");
                DDPrint.PrintRet();

                DDEngine.EachFrame();
            }
            DDEngine.FreezeInput();

            return(value);
        }
Ejemplo n.º 19
0
        public void Perform()
        {
            DDCurtain.SetCurtain();
            DDEngine.FreezeInput();

            Ground.I.Music.Filed_01.Play();

            long frmProcMilAvgNumer = 0L;
            long frmProcMilAvgDenom = 0L;

            int effectPerFrm = 10;
            int effectCount  = 1;

            for (; ;)
            {
                if (DDInput.PAUSE.IsPound())
                {
                    break;
                }
                if (DDInput.A.IsPound())
                {
                    effectPerFrm--;
                }
                if (DDInput.B.IsPound())
                {
                    effectPerFrm++;
                }
                if (DDInput.C.IsPound())
                {
                    effectCount++;
                }
                if (DDInput.D.IsPound())
                {
                    effectCount--;
                }
                effectPerFrm = IntTools.ToRange(effectPerFrm, 1, 10);
                effectCount  = IntTools.ToRange(effectCount, 1, 100);

                if (DDEngine.ProcFrame % effectPerFrm == 0)
                {
                    for (int c = 0; c < effectCount; c++)
                    {
                        new DDCommonEffect(DDGround.GeneralResource.Dummy)
                        {
                            X     = 400.0,
                            Y     = 300.0,
                            Z     = 0.5,
                            XAdd2 = Math.Cos(DDEngine.ProcFrame / 100.0 + c) * 0.1,
                            YAdd2 = Math.Sin(DDEngine.ProcFrame / 100.0 + c) * 0.1,
                        }
                        .Fire();
                    }
                }
                this.DrawWall();



                // フォントのテスト
                DDFontUtils.DrawString_XCenter(
                    400, 20,
                    "げんかいみんちょう",
                    DDFontUtils.GetFont("源界明朝", 70, 6, true, 2)
                    );
                DDFontUtils.DrawString_XCenter(
                    400, 520,
                    "りいてがき",
                    DDFontUtils.GetFont("りいてがき筆", 50, 6, true, 2)
                    );



                frmProcMilAvgNumer += DDEngine.FrameProcessingMillis;
                frmProcMilAvgDenom++;

                double frmProcMilAvg = (double)frmProcMilAvgNumer / frmProcMilAvgDenom;

                if (DDEngine.ProcFrame % 100 == 0)
                {
                    frmProcMilAvgNumer /= 2;
                    frmProcMilAvgDenom /= 2;
                }

                DDDraw.SetTaskList(DDGround.EL);
                DDDraw.SetAlpha(0.5);
                DDDraw.SetBright(new I3Color(0, 0, 0));
                DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, 0, 0, DDConsts.Screen_W, 16);
                DDDraw.Reset();

                DDPrint.SetPrint();
                DDPrint.SetTaskList(DDGround.EL);
                DDPrint.SetColor(new I3Color(255, 128, 0));
                DDPrint.Print(string.Format(
                                  "FST={0},HCT={1},FPM={2},FPW={3},FPMA={4:F3}(EPF={5},EC={6},ELC={7})"
                                  , DDEngine.FrameStartTime
                                  , DDEngine.HzChaserTime
                                  , DDEngine.FrameProcessingMillis
                                  , DDEngine.FrameProcessingMillis_Worst
                                  , frmProcMilAvg
                                  , effectPerFrm
                                  , effectCount
                                  , DDGround.EL.Count
                                  ));
                DDPrint.Reset();



                DDEngine.EachFrame();
            }
            DDEngine.FreezeInput();
            DDMusicUtils.Fade();
            DDCurtain.SetCurtain(30, -1.0);

            foreach (DDScene scene in DDSceneUtils.Create(40))
            {
                this.DrawWall();
                DDEngine.EachFrame();
            }
            DDGround.EL.Clear();
        }
Ejemplo n.º 20
0
 //
 //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
 //
 public static void Range(ref int value, int minval, int maxval)
 {
     value = IntTools.ToRange(value, minval, maxval);
 }
Ejemplo n.º 21
0
		public void Main(ArgsReader ar)
		{
			int portNo = 80;
			DocRoot docRoot = new DocRoot();
			MIMEType mimeType = new MIMEType();

			if (ar.HasArgs())
				portNo = int.Parse(ar.NextArg());

			portNo = IntTools.ToRange(portNo, 1, 65535);

			while (ar.HasArgs())
				docRoot.AddRootDir(ar.NextArg());

			HTTPServerChannel.RequestTimeoutMillis = 30000; // 30 sec
			HTTPServerChannel.ResponseTimeoutMillis = 2 * 86400000; // 2 day
			//HTTPServerChannel.FirstLineTimeoutMillis = 2000; // 2 sec == def
			HTTPServerChannel.IdleTimeoutMillis = 10000; // 10 sec
			HTTPServerChannel.BodySizeMax = 2000000; // 2 MB
			HTTPServerChannel.BuffSize = 500000; // 500 KB

			JsonTools.DecodeStringFilter = v => JString.ToJString(v, true, true, true, true);
			JsonTools.DecodeNestingLevelMax = 30;
			JsonTools.DecodeObjectCountMax = 1000;

			HTTPServer hs = new HTTPServer()
			{
				PortNo = portNo,
				//Backlog = 100, // == def
				//ConnectMax = 30, // == def

				Interlude = () =>
				{
					return Console.KeyAvailable == false;
				},

				HTTPConnected = channel =>
				{
					string method = channel.Method;
					string path = channel.Path;

					HTTPRequest hr = new HTTPRequest();

					hr.IP = channel.Channel.Handler.RemoteEndPoint.ToString(); // TODO
					hr.Method = JString.ToJString(channel.Method, false, false, false, false); // 正規化
					hr.URLPath = JString.ToJString(channel.Path, true, false, false, true); // 正規化

					// HACK ??? ParsePathQuery より前に DecodeURL しているのでクエリに '?', '&', '=' を使えない???

					ParsePathQuery(hr);

					// 特別な処理:アスタリスクの直前までをパスと見なす。
					{
						int i = hr.Path.IndexOf('*');

						if (i != -1)
							hr.Path = hr.Path.Substring(0, i);
					}

					if (hr.Path[hr.Path.Length - 1] == '/')
						hr.Path += "index.html";

					hr.Path = CommonUtils.GetFairRelPath(hr.Path);
					hr.HTTP_Version = JString.ToJString(channel.HTTPVersion, false, false, false, false); // 正規化

					foreach (string[] headerPair in channel.HeaderPairs)
					{
						hr.HeaderPairs.Add(
							JString.ToJString(headerPair[0], true, false, false, true), // 正規化
							JString.ToJString(headerPair[1], true, false, false, true)  // 正規化
							);
					}

					if (hr.Method == "GET")
					{
						hr.Json = null;
					}
					else if (method == "POST")
					{
						hr.Json = JsonTools.Decode(channel.Body); // 正規化
					}
					else
					{
						throw new Exception("不明なメソッド");
					}

					// HACK ??? フォルダの場合の 301 対応

					string targetFile = docRoot.GetRootDirs().Select(v => Path.Combine(v, hr.Path)).FirstOrDefault(v => File.Exists(v));

					if (targetFile == null)
					{
						channel.ResStatus = 404;
					}
					else
					{
						if (StringTools.EndsWithIgnoreCase(targetFile, ".alt.txt"))
						{
							string intervateClassName = File.ReadAllLines(targetFile, Encoding.ASCII)[0];
							Type intervateClass = Type.GetType(intervateClassName + "," + Assembly.GetEntryAssembly().GetName().Name);
							ReflectTools.MethodUnit intervateCtor = ReflectTools.GetConstructor(intervateClass);
							IService service = (IService)intervateCtor.Construct(new object[0]);

							object ret = service.Perform(hr, ref targetFile);

							if (ret != null)
							{
								string sRet = JsonTools.Encode(ObjectTree.Conv(ret));
								byte[] resBody = Encoding.UTF8.GetBytes(sRet);

								channel.ResStatus = 200;
								channel.ResBody_B = resBody;
								channel.ResContentType = "application/json";

								goto endSetResponse;
							}
						}
						channel.ResStatus = 200;

						if (new FileInfo(targetFile).Length <= 2000000)
							channel.ResBody_B = File.ReadAllBytes(targetFile);
						else
							channel.ResBody = ResponseFileReader(targetFile);

						channel.ResContentType = mimeType.FileToContentType(targetFile);

					endSetResponse:
						;
					}
				},
			};

			ProcMain.WriteLog("Server Started");

			hs.Perform();

			ProcMain.WriteLog("Server Ended");
		}
Ejemplo n.º 22
0
        public void Draw()
        {
            if (PlayerLookLeftFrm == 0 && DDUtils.Random.Real2() < 0.002)             // キョロキョロするレート
            {
                PlayerLookLeftFrm = 150 + (int)(DDUtils.Random.Real2() * 90.0);
            }

            DDUtils.CountDown(ref PlayerLookLeftFrm);

            double xZoom = this.FacingLeft ? -1 : 1;

            // 立ち >

            DDPicture picture = Ground.I.Picture.PlayerStands[120 < PlayerLookLeftFrm ? 1 : 0][(DDEngine.ProcFrame / 20) % 2];

            if (1 <= this.MoveFrame)
            {
                if (this.MoveSlow)
                {
                    picture = Ground.I.Picture.PlayerWalk[(DDEngine.ProcFrame / 10) % 2];
                }
                else
                {
                    picture = Ground.I.Picture.PlayerDash[(DDEngine.ProcFrame / 5) % 2];
                }
            }
            if (this.TouchGround == false)
            {
                picture = Ground.I.Picture.PlayerJump[0];
            }
            if (1 <= this.ShagamiFrame)
            {
                picture = Ground.I.Picture.PlayerShagami;
            }

            // < 立ち

            // 攻撃中 >

            if (1 <= this.AttackFrame)
            {
                picture = Ground.I.Picture.PlayerAttack;

                if (1 <= this.MoveFrame)
                {
                    if (this.MoveSlow)
                    {
                        picture = Ground.I.Picture.PlayerAttackWalk[(DDEngine.ProcFrame / 10) % 2];
                    }
                    else
                    {
                        picture = Ground.I.Picture.PlayerAttackDash[(DDEngine.ProcFrame / 5) % 2];
                    }
                }
                if (this.TouchGround == false)
                {
                    picture = Ground.I.Picture.PlayerAttackJump;
                }
                if (1 <= this.ShagamiFrame)
                {
                    picture = Ground.I.Picture.PlayerAttackShagami;
                }
            }

            // < 攻撃中

            if (this.DeadScene.IsFlaming())
            {
                int koma = IntTools.ToRange(this.DeadScene.Count / 20, 0, 1);

                if (this.TouchGround)
                {
                    koma *= 2;
                }

                koma *= 2;
                koma++;

                picture = Ground.I.Picture.PlayerDamage[koma];

                DDDraw.SetTaskList(DDGround.EL);
            }
            if (this.DamageScene.IsFlaming())
            {
                picture = Ground.I.Picture.PlayerDamage[0];
                xZoom  *= -1;
            }

            if (this.DamageScene.IsFlaming() || this.MutekiScene.IsFlaming())
            {
                DDDraw.SetTaskList(DDGround.EL);
                DDDraw.SetAlpha(0.5);
            }
            DDDraw.DrawBegin(
                picture,
                DoubleTools.ToInt(this.X - DDGround.ICamera.X),
                DoubleTools.ToInt(this.Y - DDGround.ICamera.Y) - 16
                );
            DDDraw.DrawZoom_X(xZoom);
            DDDraw.DrawEnd();
            DDDraw.Reset();

            // debug
            {
                DDDraw.DrawBegin(DDGround.GeneralResource.Dummy, this.X - DDGround.ICamera.X, this.Y - DDGround.ICamera.Y);
                DDDraw.DrawZoom(0.1);
                DDDraw.DrawRotate(DDEngine.ProcFrame * 0.01);
                DDDraw.DrawEnd();
            }
        }