示例#1
0
        private static void UpdateActiveScreen()
        {
            I2Point screenCenter;

            {
                DDWin32.POINT p;

                p.X = 0;
                p.Y = 0;

                DDWin32.ClientToScreen(DDWin32.GetMainWindowHandle(), out p);

                int l = p.X;
                int t = p.Y;
                int w = DDGround.RealScreen_W;
                int h = DDGround.RealScreen_H;

                screenCenter = new I2Point(l + w / 2, t + h / 2);
            }

            foreach (I4Rect monitor in DDWin32.GetAllMonitor())
            {
                if (
                    monitor.L <= screenCenter.X && screenCenter.X < monitor.R &&
                    monitor.T <= screenCenter.Y && screenCenter.Y < monitor.B
                    )
                {
                    DDGround.MonitorRect = monitor;
                    break;
                }
            }
        }
示例#2
0
 private static void Unload(string file)
 {
     if (DDWin32.RemoveFontResourceEx(file, DDWin32.FR_PRIVATE, IntPtr.Zero) == 0)             // ? 失敗
     {
         throw new DDError();
     }
 }
示例#3
0
        public static void Add(byte[] fileData, string localFile)
        {
            string dir  = WD.MakePath();
            string file = Path.Combine(dir, localFile);

            SCommon.CreateDir(dir);
            File.WriteAllBytes(file, fileData);

            if (DDWin32.AddFontResourceEx(file, DDWin32.FR_PRIVATE, IntPtr.Zero) == 0)             // ? 失敗
            {
                throw new DDError();
            }

            FontFiles.Add(file);
        }
示例#4
0
        private static void SetScreenPosition(int l, int t)
        {
            DX.SetWindowPosition(l, t);

            DDWin32.POINT p;

            p.X = 0;
            p.Y = 0;

            DDWin32.ClientToScreen(DDWin32.GetMainWindowHandle(), out p);

            int pToTrgX = l - (int)p.X;
            int pToTrgY = t - (int)p.Y;

            DX.SetWindowPosition(l + pToTrgX, t + pToTrgY);
        }
示例#5
0
        public static void GameStart()
        {
            foreach (string dllFile in "DxLib.dll:DxLib_x64.dll:DxLibDotNet.dll".Split(':'))             // DxLibDotNet.dll 等の存在確認 (1)
            {
                if (!File.Exists(dllFile))
                {
                    throw new DDError();
                }
            }

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

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

            // Log >

            File.WriteAllBytes(DDConfig.LogFile, SCommon.EMPTY_BYTES);

            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(SCommon.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 (0 <= DDConfig.DisplayIndex)
            {
                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(DDConsts.DEFAULT_DX_DRAWMODE);             // これをデフォルトとする。

            // < DxLib

            DDGround.MainScreen = new DDSubScreen(DDConsts.Screen_W, DDConsts.Screen_H);
            DDGround.MainScreen.ChangeDrawScreen();
            DDGround.LastMainScreen = new DDSubScreen(DDConsts.Screen_W, DDConsts.Screen_H);
            DDGround.KeptMainScreen = new DDSubScreen(DDConsts.Screen_W, DDConsts.Screen_H);

            if (DDConfig.DisplayIndex == -2)
            {
                I2Point  mousePt       = DDWin32.GetMousePosition();
                I4Rect[] monitors      = DDWin32.GetAllMonitor();
                I4Rect   activeMonitor = monitors[0];               // マウス位置のモニタを特定出来ない場合のモニタ

                foreach (I4Rect monitor in monitors)
                {
                    if (
                        monitor.L <= mousePt.X && mousePt.X < monitor.R &&
                        monitor.T <= mousePt.Y && mousePt.Y < monitor.B
                        )
                    {
                        activeMonitor = monitor;
                        break;
                    }
                }
                DDGround.MonitorRect = activeMonitor;
            }
            else
            {
                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 || SCommon.IMAX < w ||
                    h < 1 || SCommon.IMAX < h ||
                    l < -SCommon.IMAX || SCommon.IMAX < l ||
                    t < -SCommon.IMAX || SCommon.IMAX < t
                    )
                {
                    throw new DDError();
                }

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

            PostSetScreenSize(DDGround.RealScreen_W, DDGround.RealScreen_H);

            // Font
            {
                //DDFontRegister.Add(@"e20200928_NovelAdv\Font\Genkai-Mincho-font\genkai-mincho.ttf");
                //DDFontRegister.Add(@"e20200928_NovelAdv\Font\riitf\RiiT_F.otf");
                DDFontRegister.Add(@"dat\Font\K Gothic\K Gothic.ttf");
                DDFontRegister.Add(@"dat\Font\焚火フォント\03Takibi-Regular.otf");
                //DDFontRegister.Add(@"dat\Font\廻想体\Kaiso-Next-B.otf");
                DDFontRegister.Add(@"dat\Font\木漏れ日ゴシック\komorebi-gothic.ttf");
            }

            Ground.I          = new Ground();
            Ground.I.Picture2 = new ResourcePicture2();             // Ground.I を参照しているので Ground のコンストラクタには書けない。

            MainWin.I.PostGameStart_G3();

            DDSaveData.Load_Delay();

            Finalizers.Add(() =>
            {
                DDSaveData.Save();
            });
        }