Пример #1
0
        public static void INIT()
        {
            DDInput.DIR_2.BtnId = 0;
            DDInput.DIR_4.BtnId = 1;
            DDInput.DIR_6.BtnId = 2;
            DDInput.DIR_8.BtnId = 3;
            DDInput.A.BtnId     = 4;
            DDInput.B.BtnId     = 7;
            DDInput.C.BtnId     = 5;
            DDInput.D.BtnId     = 8;
            DDInput.E.BtnId     = 6;
            DDInput.F.BtnId     = 9;
            DDInput.L.BtnId     = 10;
            DDInput.R.BtnId     = 11;
            DDInput.PAUSE.BtnId = 13;
            DDInput.START.BtnId = 12;

            DDInput.DIR_2.KeyId = DX.KEY_INPUT_DOWN;
            DDInput.DIR_4.KeyId = DX.KEY_INPUT_LEFT;
            DDInput.DIR_6.KeyId = DX.KEY_INPUT_RIGHT;
            DDInput.DIR_8.KeyId = DX.KEY_INPUT_UP;
            DDInput.A.KeyId     = DX.KEY_INPUT_Z;
            DDInput.B.KeyId     = DX.KEY_INPUT_X;
            DDInput.C.KeyId     = DX.KEY_INPUT_C;
            DDInput.D.KeyId     = DX.KEY_INPUT_V;
            DDInput.E.KeyId     = DX.KEY_INPUT_A;
            DDInput.F.KeyId     = DX.KEY_INPUT_S;
            DDInput.L.KeyId     = DX.KEY_INPUT_D;
            DDInput.R.KeyId     = DX.KEY_INPUT_F;
            DDInput.PAUSE.KeyId = DX.KEY_INPUT_SPACE;
            DDInput.START.KeyId = DX.KEY_INPUT_RETURN;

            DDAdditionalEvents.Ground_INIT();
        }
Пример #2
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        public static void GameStart()
        {
            foreach (string dllFile in "DxLib.dll:DxLib_x64.dll:DxLibDotNet.dll".Split(':'))             // DxLibDotNet.dll 等の存在確認 (1)
            {
                if (File.Exists(dllFile) == false)
                {
                    throw new DDError();
                }
            }

            DX.GetColor(0, 0, 0);        // DxLibDotNet.dll 等の存在確認 (2)

            DDConfig.Load();             // LogFile, LOG_ENABLED 等を含むので真っ先に

            // Log >

            File.WriteAllBytes(DDConfig.LogFile, BinTools.EMPTY);

            ProcMain.WriteLog = message =>
            {
                if (LogCount < DDConfig.LogCountMax)
                {
                    using (StreamWriter writer = new StreamWriter(DDConfig.LogFile, true, Encoding.UTF8))
                    {
                        writer.WriteLine("[" + DateTime.Now + "] " + message);
                    }
                    LogCount++;
                }
            };

            // < Log

            // *.INIT
            {
                DDGround.INIT();
                DDResource.INIT();
                DDDatStrings.INIT();
                DDUserDatStrings.INIT();
                DDFontRegister.INIT();
                DDKey.INIT();
            }

            DDSaveData.Load();

            // DxLib >

            if (DDConfig.LOG_ENABLED)
            {
                DX.SetApplicationLogSaveDirectory(FileTools.MakeFullPath(DDConfig.ApplicationLogSaveDirectory));
            }

            DX.SetOutApplicationLogValidFlag(DDConfig.LOG_ENABLED ? 1 : 0); // DxLib のログを出力 1: する 0: しない

            DX.SetAlwaysRunFlag(1);                                         // ? 非アクティブ時に 1: 動く 0: 止まる

            SetMainWindowTitle();

            //DX.SetGraphMode(DDConsts.Screen_W, DDConsts.Screen_H, 32);
            DX.SetGraphMode(DDGround.RealScreen_W, DDGround.RealScreen_H, 32);
            DX.ChangeWindowMode(1);             // 1: ウィンドウ 0: フルスクリーン

            //DX.SetFullSceneAntiAliasingMode(4, 2); // 適当な値が分からん。フルスクリーン廃止したので不要

            DX.SetWindowIconHandle(GetAppIcon());             // ウィンドウ左上のアイコン

            if (DDConfig.DisplayIndex != -1)
            {
                DX.SetUseDirectDrawDeviceIndex(DDConfig.DisplayIndex);
            }

            if (DX.DxLib_Init() != 0)             // ? 失敗
            {
                throw new DDError();
            }

            Finalizers.Add(() =>
            {
                if (DX.DxLib_End() != 0)                 // ? 失敗
                {
                    throw new DDError();
                }
            });

            DDUtils.SetMouseDispMode(DDGround.RO_MouseDispMode); // ? マウスを表示する。
            DX.SetWindowSizeChangeEnableFlag(0);                 // ウィンドウの右下をドラッグで伸縮 1: する 0: しない

            DX.SetDrawScreen(DX.DX_SCREEN_BACK);
            DX.SetDrawMode(DX.DX_DRAWMODE_BILINEAR);             // これをデフォルトとする。

            // < DxLib

            {
                int l;
                int t;
                int w;
                int h;
                int p1;
                int p2;
                int p3;
                int p4;

                DX.GetDefaultState(out w, out h, out p1, out p2, out l, out t, out p3, out p4);

                if (
                    w < 1 || IntTools.IMAX < w ||
                    h < 1 || IntTools.IMAX < h ||
                    l < -IntTools.IMAX || IntTools.IMAX < l ||
                    t < -IntTools.IMAX || IntTools.IMAX < t
                    )
                {
                    throw new DDError();
                }

                DDGround.MonitorRect = new I4Rect(l, t, w, h);
            }

            PostSetScreenSize(DDGround.RealScreen_W, DDGround.RealScreen_H);

            DDGround.GeneralResource = new DDGeneralResource();

            DDAdditionalEvents.PostGameStart();
            DDAdditionalEvents.PostGameStart_G2();

            DDSaveData.Load_Delay();
        }
Пример #3
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        public static void Load()
        {
            if (File.Exists(DDConsts.SaveDataFile) == false)
            {
                return;
            }

            byte[][] blocks = BinTools.Split(DDJammer.Decode(File.ReadAllBytes(DDConsts.SaveDataFile)));
            int      bc     = 0;

            string[] lines = DDUtils.Split(blocks[bc++]);
            int      c     = 0;

            if (lines[c++] != Program.APP_IDENT)
            {
                throw new DDError();
            }

            if (lines[c++] != Program.APP_TITLE)
            {
                throw new DDError();
            }

            // 項目が増えた場合を想定して try ~ catch しておく。

            try             // for Donut2
            {
                // TODO int.Parse -> IntTools.ToInt

                DDGround.RealScreen_W = int.Parse(lines[c++]);
                DDGround.RealScreen_H = int.Parse(lines[c++]);

                DDGround.RealScreenDraw_L = int.Parse(lines[c++]);
                DDGround.RealScreenDraw_T = int.Parse(lines[c++]);
                DDGround.RealScreenDraw_W = int.Parse(lines[c++]);
                DDGround.RealScreenDraw_H = int.Parse(lines[c++]);

                DDGround.MusicVolume = long.Parse(lines[c++]) / (double)IntTools.IMAX;
                DDGround.SEVolume    = long.Parse(lines[c++]) / (double)IntTools.IMAX;

                DDInput.DIR_2.BtnId = int.Parse(lines[c++]);
                DDInput.DIR_4.BtnId = int.Parse(lines[c++]);
                DDInput.DIR_6.BtnId = int.Parse(lines[c++]);
                DDInput.DIR_8.BtnId = int.Parse(lines[c++]);
                DDInput.A.BtnId     = int.Parse(lines[c++]);
                DDInput.B.BtnId     = int.Parse(lines[c++]);
                DDInput.C.BtnId     = int.Parse(lines[c++]);
                DDInput.D.BtnId     = int.Parse(lines[c++]);
                DDInput.E.BtnId     = int.Parse(lines[c++]);
                DDInput.F.BtnId     = int.Parse(lines[c++]);
                DDInput.L.BtnId     = int.Parse(lines[c++]);
                DDInput.R.BtnId     = int.Parse(lines[c++]);
                DDInput.PAUSE.BtnId = int.Parse(lines[c++]);
                DDInput.START.BtnId = int.Parse(lines[c++]);

                DDInput.DIR_2.KeyId = int.Parse(lines[c++]);
                DDInput.DIR_4.KeyId = int.Parse(lines[c++]);
                DDInput.DIR_6.KeyId = int.Parse(lines[c++]);
                DDInput.DIR_8.KeyId = int.Parse(lines[c++]);
                DDInput.A.KeyId     = int.Parse(lines[c++]);
                DDInput.B.KeyId     = int.Parse(lines[c++]);
                DDInput.C.KeyId     = int.Parse(lines[c++]);
                DDInput.D.KeyId     = int.Parse(lines[c++]);
                DDInput.E.KeyId     = int.Parse(lines[c++]);
                DDInput.F.KeyId     = int.Parse(lines[c++]);
                DDInput.L.KeyId     = int.Parse(lines[c++]);
                DDInput.R.KeyId     = int.Parse(lines[c++]);
                DDInput.PAUSE.KeyId = int.Parse(lines[c++]);
                DDInput.START.KeyId = int.Parse(lines[c++]);

                DDGround.RO_MouseDispMode = int.Parse(lines[c++]) != 0;

                // 新しい項目をここへ追加...
            }
            catch (Exception e)
            {
                ProcMain.WriteLog(e);
            }

            Load_Delay = () =>
            {
                try                 // for app
                {
                    lines = DDUtils.Split(blocks[bc++]);

                    DDAdditionalEvents.Load(lines);
                }
                catch (Exception e)
                {
                    ProcMain.WriteLog(e);
                }

                Load_Delay = () => { };                 // reset
            };
        }
Пример #4
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        public static void Save()
        {
            List <byte[]> blocks = new List <byte[]>();

            // for Donut2
            {
                List <string> lines = new List <string>();

                lines.Add(Program.APP_IDENT);
                lines.Add(Program.APP_TITLE);

                lines.Add("" + DDGround.RealScreen_W);
                lines.Add("" + DDGround.RealScreen_H);

                lines.Add("" + DDGround.RealScreenDraw_L);
                lines.Add("" + DDGround.RealScreenDraw_T);
                lines.Add("" + DDGround.RealScreenDraw_W);
                lines.Add("" + DDGround.RealScreenDraw_H);

                lines.Add("" + DoubleTools.ToLong(DDGround.MusicVolume * IntTools.IMAX));
                lines.Add("" + DoubleTools.ToLong(DDGround.SEVolume * IntTools.IMAX));

                lines.Add("" + DDInput.DIR_2.BtnId);
                lines.Add("" + DDInput.DIR_4.BtnId);
                lines.Add("" + DDInput.DIR_6.BtnId);
                lines.Add("" + DDInput.DIR_8.BtnId);
                lines.Add("" + DDInput.A.BtnId);
                lines.Add("" + DDInput.B.BtnId);
                lines.Add("" + DDInput.C.BtnId);
                lines.Add("" + DDInput.D.BtnId);
                lines.Add("" + DDInput.E.BtnId);
                lines.Add("" + DDInput.F.BtnId);
                lines.Add("" + DDInput.L.BtnId);
                lines.Add("" + DDInput.R.BtnId);
                lines.Add("" + DDInput.PAUSE.BtnId);
                lines.Add("" + DDInput.START.BtnId);

                lines.Add("" + DDInput.DIR_2.KeyId);
                lines.Add("" + DDInput.DIR_4.KeyId);
                lines.Add("" + DDInput.DIR_6.KeyId);
                lines.Add("" + DDInput.DIR_8.KeyId);
                lines.Add("" + DDInput.A.KeyId);
                lines.Add("" + DDInput.B.KeyId);
                lines.Add("" + DDInput.C.KeyId);
                lines.Add("" + DDInput.D.KeyId);
                lines.Add("" + DDInput.E.KeyId);
                lines.Add("" + DDInput.F.KeyId);
                lines.Add("" + DDInput.L.KeyId);
                lines.Add("" + DDInput.R.KeyId);
                lines.Add("" + DDInput.PAUSE.KeyId);
                lines.Add("" + DDInput.START.KeyId);

                lines.Add("" + (DDGround.RO_MouseDispMode ? 1 : 0));

                // 新しい項目をここへ追加...

                blocks.Add(DDUtils.SplitableJoin(lines.ToArray()));
            }

            // for app
            {
                List <string> lines = new List <string>();

                DDAdditionalEvents.Save(lines);

                blocks.Add(DDUtils.SplitableJoin(lines.ToArray()));
            }

            File.WriteAllBytes(DDConsts.SaveDataFile, DDJammer.Encode(BinTools.SplittableJoin(blocks.ToArray())));
        }