示例#1
0
        public void Init(Window main_window)
        {
            _main_window = main_window;
            m_theatre    = new Shinengine.Theatre.Theatre(BG, Usage, SBK, AirPt, character_usage, Lines, character, ShowIn, _Contents);

            #region logo
            m_logo = new Direct2DImage(new SharpDX.Size2((int)logo_frames[0].Size.Width, (int)logo_frames[0].Size.Height), 30)
            {
                Loadedsouce = logo_frames
            };
            m_logo.DrawProc += (t, s, w, h) =>
            {
                var frames = s as List <WICBitmap>;

                if (ims == frames.Count)
                {
                    ims = 0;
                }
                t.View.BeginDraw();
                t.View.Clear(null);
                D2DBitmap parl_map = D2DBitmap.FromWicBitmap(t.View, frames[ims]);
                t.View.DrawBitmap(parl_map, 1, InterpolationMode.Anisotropic);
                t.View.EndDraw();

                ims++;
                parl_map.Dispose();
                return(DrawProcResult.Normal);
            };
            m_logo.DrawStartup(Logo);


            #endregion
        }
示例#2
0
        public void Start(IntPtr hWnd, string path, Action endplay)
        {
            var vest = new Video(Video.VideoMode.LoadWithPlaying, path);

            dxVideo = new Direct2DImage(new SharpDX.Size2((int)vest.frameSize.Width, (int)vest.frameSize.Height), vest.Fps)
            {
                Loadedsouce = vest
            };
            dxVideo.Disposing += (Loadedsouce, s) => { (Loadedsouce as Video).Dispose(); };
            dxVideo.DrawProc  += DrawCallback;


            var video = dxVideo.Loadedsouce as Video;

            new Task(() =>
            {
                while (!video.CanRun)
                {
                    Thread.Sleep(1);
                }
                unsafe
                {
                    //       var intp = getPCM("assets.shine:09.pcm");
                    waveInit(hWnd, video.Out_channels, video.Out_sample_rate, video.Bit_per_sample, video.Out_buffer_size);


                    while (true)
                    {
                        if (!video.CanRun)
                        {
                            break;
                        }
                        if (video.EntiryPlayed && i == video.abits.Count && video.nFarm == video.bits.Count)
                        {
                            break;
                        }
                        if (i == video.abits.Count)
                        {
                            Thread.Sleep(1);
                            continue;
                        }
                        audio_time = (double)(video.abits[i]?.time_base);

                        waveWrite((byte *)video.abits[i]?.data, video.Out_buffer_size);
                        Marshal.FreeHGlobal((IntPtr)video.abits[i]?.data);
                        video.abits[i] = null;
                        i++;
                    }

                    waveClose();
                    this.Dispatcher.Invoke(endplay);
                }
            }).Start();


            video.Start();
            dxVideo.DrawStartup(BackGround);
        }
示例#3
0
        public Character(Theatre father, string name, string template, bool canshow = true, double?time = null, bool isAscy = true, double vel_x = 0, double vel_y = 0)
        {
            var layer = father.CharacterLayer;

            m_father = father;
            ManualResetEvent msbn = new ManualResetEvent(false);

            _name = name;

            if (time == null)
            {
                time = SharedSetting.SwitchSpeed;
            }
            layer.Dispatcher.Invoke(new Action(() =>
            {
                whereIsShowed = layer;

                Init_action = Stage.LoadBitmap(template);

                shower = new Image
                {
                    Width             = Init_action.Size.Width * (layer.Height / Init_action.Size.Height),
                    Height            = layer.Height,
                    VerticalAlignment = VerticalAlignment.Bottom,
                    Stretch           = Stretch.Fill,

                    Margin = new Thickness(vel_x, 0, 0, vel_y)
                };
                if (time != 0 || !canshow)
                {
                    shower.Opacity = 0;
                }
                whereIsShowed.Children.Add(shower);

                Direct2DImage direct2DImage = new Direct2DImage(new Size2((int)shower.Width, (int)shower.Height), 30);
                direct2DImage.DrawProc     += (View, Souce, Width, Height) =>
                {
                    D2DBitmap m_bp = D2DBitmap.FromWicBitmap(View.View, Init_action, new BitmapProperties1(new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied)));

                    View.View.BeginDraw();
                    View.View.Clear(null);

                    View.View.DrawBitmap(m_bp,
                                         new RawRectangleF(0, 0, Width, Height),
                                         1, SharpDX.Direct2D1.BitmapInterpolationMode.Linear,
                                         new RawRectangleF(0, 0, Init_action.Size.Width, Init_action.Size.Height));

                    View.View.EndDraw();

                    m_bp.Dispose();
                    return(DrawProcResult.Death);
                };

                direct2DImage.Disposing += (e, s) =>
                {
                    Last_Draw = s.LastDraw;
                    msbn.Set();
                };

                direct2DImage.DrawStartup(shower);
            }));
            msbn.WaitOne();
            msbn.Dispose();
            if (!canshow)
            {
                return;
            }


            EasyAmal aml = new EasyAmal(shower, "(Opacity)", 0.0, 1.0, (double)time);

            aml.Start(isAscy);
        }//已经确认过安全的代码,再次修改需要小心
示例#4
0
        static public GamingTheatre SwitchToSignalTheatre(int id, int start_place, Action end)
        {
            GamingTheatre m_game = new GamingTheatre();

            if (true)
            {
                ResizeEvt(m_game.SBK, new Size2(1280, 720), new Size2((int)m_window.sys_con_pite.Width, (int)m_window.sys_con_pite.Height));
            }
            m_game.Init(m_window);
            m_game.toTitle.Click += (e, v) =>
            {
                Title = SwitchToTitle();
                MainWindow.sys_pite.Content = Title.Content;

                TheatreMode.Dispose();

                if (TheatreMode != null)
                {
                    TheatreMode = null;
                }
            };
            m_game.SaveLoad.Click += (e, v) =>
            {
                if (GamingTheatre.isSkiping)
                {
                    return;
                }
                GamingTheatre.AutoMode = false;
                if (m_game.ShowIn.Children.Contains(m_game.auto_icon))
                {
                    m_game.ShowIn.Children.Remove(m_game.auto_icon);
                }

                var m_thread_intp = new Thread(() =>
                {
                    EasyAmal mpos = new EasyAmal(m_game.SBK, "(Opacity)", 1.0, 0.0, SharedSetting.SwitchSpeed);
                    mpos.Start(false);/// hide tview

                    m_game.Dispatcher.Invoke(new Action(() =>
                    {
                        SaveLoad mst = new SaveLoad(id, m_game.m_theatre.saved_frame, m_game.m_theatre.Stage.last_save);
                        if (true)
                        {
                            ResizeEvt(mst.Forgan, new Size2(1280, 720), new Size2((int)m_window.sys_con_pite.Width, (int)m_window.sys_con_pite.Height));
                        }
                        Sldata = mst;

                        bool canFocue         = false;
                        Sldata.exitlpg.Click += (e, v) =>
                        {
                            if (canFocue)
                            {
                                return;
                            }
                            canFocue = true;
                            new Thread(() =>
                            {
                                EasyAmal mpos2 = new EasyAmal(Sldata.Forgan, "(Opacity)", 1.0, 0.0, SharedSetting.SwitchSpeed, (e, c) =>
                                {
                                    MainWindow.sys_pite.Content = m_game.Content;
                                    EasyAmal mpos = new EasyAmal(m_game.SBK, "(Opacity)", 0.0, 1.0, SharedSetting.SwitchSpeed);
                                    mpos.Start(true);/// hide tview
                                    Sldata = null;
                                });
                                mpos2.Start(true);
                            }).Start();
                        };
                        Sldata.Forgan.MouseRightButtonUp += (e, v) =>
                        {
                            if (canFocue)
                            {
                                return;
                            }
                            canFocue = true;
                            new Thread(() =>
                            {
                                EasyAmal mpos2 = new EasyAmal(Sldata.Forgan, "(Opacity)", 1.0, 0.0, SharedSetting.SwitchSpeed, (e, c) =>
                                {
                                    MainWindow.sys_pite.Content = m_game.Content;
                                    EasyAmal mpos = new EasyAmal(m_game.SBK, "(Opacity)", 0.0, 1.0, SharedSetting.SwitchSpeed);
                                    mpos.Start(true);/// hide tview
                                    Sldata = null;
                                });
                                mpos2.Start(true);
                            }).Start();
                        };

                        EasyAmal mpos = new EasyAmal(mst.Forgan, "(Opacity)", 0.0, 1.0, SharedSetting.SwitchSpeed);
                        mpos.Start(true);

                        MainWindow.sys_pite.Content = mst.Content;
                    }));
                })
                {
                    IsBackground = true
                };
                m_thread_intp.Start();
            };
            m_game.setting.Click += (e, v) =>
            {
                if (GamingTheatre.isSkiping)
                {
                    return;
                }
                GamingTheatre.AutoMode = false;
                if (m_game.ShowIn.Children.Contains(m_game.auto_icon))
                {
                    m_game.ShowIn.Children.Remove(m_game.auto_icon);
                }
                #region 获取上一次绘图
                var lpic = m_game.m_theatre.Stage.last_save;

                var mbps = new WriteableBitmap((int)lpic.Size.Width, (int)lpic.Size.Height, 72, 72, System.Windows.Media.PixelFormats.Pbgra32, null);
                mbps.Lock();

                var mic_lock = lpic.Lock(BitmapLockFlags.Read);
                unsafe
                {
                    Direct2DImage.RtlMoveMemory((void *)mbps.BackBuffer, (void *)mic_lock.Data.DataPointer, lpic.Size.Height * mbps.BackBufferStride);
                }
                mic_lock.Dispose();
                mbps.AddDirtyRect(new Int32Rect(0, 0, (int)lpic.Size.Width, (int)lpic.Size.Height));
                mbps.Unlock();
                #endregion
                var m_thread_intp = new Thread(() =>
                {
                    m_game.m_theatre.Usage.Hide(null, false);
                    m_game.Dispatcher.Invoke(new Action(() =>
                    {
                        Setting mst = new Setting(mbps);
                        if (true)
                        {
                            ResizeEvt(mst.mpOi, new Size2(1280, 720), new Size2((int)m_window.sys_con_pite.Width, (int)m_window.sys_con_pite.Height));
                        }
                        Settere = mst;
                        Settere.fullandwindow.IsEnabled = false;
                        EasyAmal mpos = new EasyAmal(Settere.foreg, "(Opacity)", 0.0, 1.0, SharedSetting.SwitchSpeed);

                        bool canFocue          = false;
                        Settere.exitlpg.Click += (e, v) =>
                        {
                            if (canFocue)
                            {
                                return;
                            }
                            canFocue = true;
                            new Thread(() =>
                            {
                                EasyAmal mpos2 = new EasyAmal(Settere.foreg, "(Opacity)", 1.0, 0.0, SharedSetting.SwitchSpeed, (e, c) =>
                                {
                                    MainWindow.sys_pite.Content = m_game.Content;
                                    m_game.m_theatre.Usage.Show(null, true);
                                    Settere = null;
                                });
                                mpos2.Start(true);
                            }).Start();
                        };
                        Settere.mpOi.MouseRightButtonUp += (e, v) =>
                        {
                            if (canFocue)
                            {
                                return;
                            }
                            canFocue = true;
                            new Thread(() =>
                            {
                                EasyAmal mpos2 = new EasyAmal(Settere.foreg, "(Opacity)", 1.0, 0.0, SharedSetting.SwitchSpeed, (e, c) =>
                                {
                                    MainWindow.sys_pite.Content = m_game.Content;
                                    m_game.m_theatre.Usage.Show(null, true);
                                    Settere = null;
                                });
                                mpos2.Start(true);
                            }).Start();
                        };
                        mpos.Start(true);
                        MainWindow.sys_pite.Content = mst.Content;
                    }));
                })
                {
                    IsBackground = true
                };
                m_thread_intp.Start();
            };

            m_game.EnExit.Click += (e, v) =>
            {
                MessageBoxResult result = MessageBox.Show("是否要记住当前的进度?\n(下次进入游戏时不进入标题界面,而是直接从此处开始)", "提示", MessageBoxButton.YesNoCancel, MessageBoxImage.Information);
                if (result == MessageBoxResult.No)
                {
                    m_window.Close();
                }
                else if (result == MessageBoxResult.Yes)
                {
                    SharedSetting.Last = new SaveData.SaveInfo()
                    {
                        chapter = id, frames = m_game.m_theatre.saved_frame
                    };
                    m_window.Close();
                }
            };

            if (end == null)
            {
                for (int i = 0; i < ScriptList.Scripts.Length; i++)
                {
                    if (ScriptList.Scripts[i].id == id)
                    {
                        m_game.Start(ScriptList.Scripts[i].script, id, ScriptList.Scripts[i].scriptEnd);
                    }
                }
            }
            else
            {
                for (int i = 0; i < ScriptList.Scripts.Length; i++)
                {
                    if (ScriptList.Scripts[i].id == id)
                    {
                        m_game.Start(ScriptList.Scripts[i].script, id, end);
                    }
                }
            }

            m_game.BG.Opacity    = 0;
            m_game.Usage.Opacity = 0;

            if (start_place != 0)
            {
                m_game.m_theatre.SetNextLocatPosition(start_place);
            }
            else
            {
                m_game.m_theatre.saved_frame = 0;
            }

            MainWindow.sys_pite.Content = m_game.Content;

            return(m_game);
        }
示例#5
0
        }//已经确认过安全的代码,再次修改需要小心

        public void SwitchTo(int area, int index, double?time = null, bool isAysn = false)
        {
            if (time == null)
            {
                time = SharedSetting.TextSpeed;
            }

            if (time < 1.0 / 30.0 && time != 0)
            {
                throw new Exception("time can not be less than 1/30s");
            }
            Rect targetArea = ChAreas[area].area;

            WICBitmap rost_pitch = ChAreas[area].switches[index];

            shower.Dispatcher.Invoke(() =>
            {
                dx_switch = new Direct2DImage(new Size2((int)shower.Width, (int)shower.Height), 30)//////////////AAA
                {
                };
            });
            double soul_rate = 0;

            shower.Dispatcher.Invoke(() => { soul_rate = whereIsShowed.Height / Init_action.Size.Height; });
            dx_switch.FirstDraw += (e, v, w, h) =>
            {
                D2DBitmap m_ipq = D2DBitmap.FromWicBitmap(e.View, Last_Draw);/////////////////AAA
                e.View.BeginDraw();
                e.View.Clear(null);

                e.View.DrawBitmap(m_ipq,
                                  new RawRectangleF(0, 0, w, h),
                                  1, SharpDX.Direct2D1.BitmapInterpolationMode.Linear,
                                  new RawRectangleF(0, 0, Last_Draw.Size.Width, Last_Draw.Size.Height));

                e.View.EndDraw();

                m_ipq.Dispose();//////////////////BB
                return;
            };
            ManualResetEvent msbn = new ManualResetEvent(false);//////////////////AAA

            if (time == 0)
            {
                dx_switch.DrawProc += (e, v, w, h) =>
                {
                    D2DBitmap m_ipq  = D2DBitmap.FromWicBitmap(e.View, Init_action);
                    D2DBitmap m_ipq2 = D2DBitmap.FromWicBitmap(e.View, rost_pitch);

                    e.View.BeginDraw();

                    e.View.DrawBitmap(m_ipq,
                                      new RawRectangleF(0, 0, w, h),
                                      1, SharpDX.Direct2D1.BitmapInterpolationMode.Linear,
                                      new RawRectangleF(0, 0, Init_action.Size.Width, Init_action.Size.Height));

                    e.View.DrawBitmap(m_ipq2,
                                      new RawRectangleF(
                                          (float)(targetArea.Left * soul_rate),
                                          (float)(targetArea.Top * soul_rate),
                                          (float)(targetArea.Right * soul_rate),
                                          (float)(targetArea.Bottom * soul_rate)
                                          ),
                                      1, SharpDX.Direct2D1.BitmapInterpolationMode.Linear,
                                      new RawRectangleF(0, 0, rost_pitch.Size.Width, rost_pitch.Size.Height));

                    e.View.EndDraw();

                    m_ipq.Dispose();
                    m_ipq2.Dispose();
                    if (!isAysn)
                    {
                        msbn.Set();
                    }
                    return(DrawProcResult.Death);
                };
                dx_switch.Disposing += (e, s) =>
                {
                    if (Last_Draw != null)
                    {
                        if (!Last_Draw.IsDisposed)
                        {
                            Last_Draw.Dispose();
                        }
                    }
                    Last_Draw = s.LastDraw;
                };
            }
            else
            {
                double interrase = 1 / ((double)time * 30);
                double varb      = 0;

                D2DBitmap m_ipq  = D2DBitmap.FromWicBitmap(dx_switch.m_d2d_info.View, Last_Draw);  //////////////AAA
                D2DBitmap m_ipq2 = D2DBitmap.FromWicBitmap(dx_switch.m_d2d_info.View, rost_pitch); ///////////////AAA
                D2DBitmap m_ipq3 = D2DBitmap.FromWicBitmap(dx_switch.m_d2d_info.View, Init_action);
                dx_switch.DrawProc += (e, v, w, h) =>
                {
                    e.View.BeginDraw();
                    e.View.Clear(null);

                    #region 两次绘图
                    e.View.DrawBitmap(m_ipq,
                                      new RawRectangleF(0, 0, w, h),
                                      1, SharpDX.Direct2D1.BitmapInterpolationMode.Linear,
                                      new RawRectangleF(0, 0, Last_Draw.Size.Width, Last_Draw.Size.Height));

                    e.View.DrawBitmap(m_ipq3,
                                      new RawRectangleF(0, 0, w, h),
                                      (float)varb, SharpDX.Direct2D1.BitmapInterpolationMode.Linear,
                                      new RawRectangleF(0, 0, Init_action.Size.Width, Init_action.Size.Height));

                    e.View.DrawBitmap(m_ipq2,
                                      new RawRectangleF(
                                          (float)(targetArea.Left * soul_rate),
                                          (float)(targetArea.Top * soul_rate),
                                          (float)(targetArea.Right * soul_rate),
                                          (float)(targetArea.Bottom * soul_rate)
                                          ),
                                      (float)varb, SharpDX.Direct2D1.BitmapInterpolationMode.Linear,
                                      new RawRectangleF(0, 0, rost_pitch.Size.Width, rost_pitch.Size.Height));
                    #endregion

                    e.View.EndDraw();
                    if (varb > 1)
                    {
                        m_ipq.Dispose();
                        m_ipq2.Dispose();

                        if (!isAysn)
                        {
                            msbn.Set();
                        }
                        return(DrawProcResult.Death);//////////////////BB
                    }
                    varb += interrase;

                    return(DrawProcResult.Normal);
                };

                dx_switch.Disposing += (e, s) =>
                {
                    if (Last_Draw != null)
                    {
                        if (!Last_Draw.IsDisposed)
                        {
                            Last_Draw.Dispose();
                        }
                    }
                    Last_Draw = s.LastDraw;
                    m_ipq.Dispose();  //////////////////BB
                    m_ipq2.Dispose(); //////////////////BB
                    m_ipq3.Dispose();
                };
            }
            // Last_Draw.Dispose();

            shower.Dispatcher.Invoke(() => { dx_switch.DrawStartup(shower); });
            if (!isAysn)
            {
                msbn.WaitOne();
                msbn.Dispose();//////////////////BB
            }
            msbn.Dispose();
        }//已经确认过安全的代码,再次修改需要小心