Example #1
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();
        }
Example #2
0
 //
 //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
 //
 public static void GameEnd()
 {
     DDSaveData.Save();
 }