Ejemplo n.º 1
0
 protected override void _OnAfterDraw()
 {
     _RenderVertexBuffer();
     if (_Device.EndScene().IsFailure)
     {
         CLog.Error("Failed to end scene");
     }
     try
     {
         //Now push the frame to the Viewport
         _Device.Present();
     }
     catch (Direct3D9Exception)
     {
         //In Direct3D devices can get lost.
         //This happens for example when opening the Task Manager in Vista/Windows 7 or if a UAC message is opening
         //We need to reset the device to get it to workable state again
         //After a reset Init() needs to be called because all data in the Direct3D default pool are lost and need to be recreated
         if (_Device.TestCooperativeLevel() == ResultCode.DeviceNotReset)
         {
             _Reset();
             _InitDevice();
         }
     }
     Application.DoEvents();
 }
Ejemplo n.º 2
0
        private void ShowSpriteName(string name)
        {
            if (UIConfig.Ins.SpriteGroupConfigs == null)
            {
                CLog.Error("RichText图集为空");
                return;
            }
            bool isFind = true;

            foreach (var group in UIConfig.Ins.SpriteGroupConfigs)
            {
                if (group != null)
                {
                    var sprites = group.KeySpritesData;
                    if (sprites.ContainsKey(name))
                    {
                        SpritesData   = sprites[name];
                        m_Icon.sprite = SpritesData.First;
                    }
                    else
                    {
                        isFind = false;
                    }
                }
            }
            if (!isFind)
            {
                CLog.Error("没有这个图片:{0}", name);
            }
        }
Ejemplo n.º 3
0
        public static int Read(IntPtr device, out byte[] data, int length)
        {
            data = new byte[length];
            IntPtr dataPtr = Marshal.AllocHGlobal(length);

            int result;

            try
            {
                result = hid_read(device, dataPtr, length);
            }
            catch (Exception e)
            {
                result = -1;
                CLog.Error("Error CHIDAPI.Read(): " + e);
            }

            if (result != -1)
            {
                Marshal.Copy(dataPtr, data, 0, result);
            }
            else
            {
                data = null;
            }

            Marshal.FreeHGlobal(dataPtr);
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 初始化Table menu
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public override void Init(BaseTableData tableData) //where ScrollTP : Presenter<ScrollTD>, new() where ScrollTD : PresenterData, new()
        {
            base.Init(tableData);

            if (DP == null)
            {
                CLog.Error("没有BaseDupplicate组件");
            }
            if (Scroll == null)
            {
                CLog.Error("没有BaseScroll组件");
            }
            if (Data.GetCustomDatas == null)
            {
                CLog.Error("TableData 的 GetCustomDatas 必须设置");
            }
            if (Data.OnRefresh == null)
            {
                CLog.Error("TableData 的 OnRefresh 必须设置");
            }

            Scroll.Init(tableData);
            Titles = DP.Init <BaseButton, BaseButtonData>(Data.TitleDatas);
            foreach (var item in Titles)
            {
                item.Data.OnClick += OnBntClick;
            }
        }
Ejemplo n.º 5
0
        public void Defend(BaseUnit unit, bool isCustomMoveLegion = true)
        {
            if (unit == null)
            {
                return;
            }
            var castle = unit as TCastle;

            if (castle == null)
            {
                CLog.Error("Defend:castle == null)");
                return;
            }
            if (IsInDefend())
            {
                return;
            }
            if (!SelfUnit.IsSelf(castle))
            {
                return;
            }
            if (castle.CastleStationedMgr.IsHaveDefender())
            {
                return;
            }
            PreDefendCastle = DefendCastle;
            DefendCastle    = castle;
            castle.CastleStationedMgr.OnBeDefend(SelfUnit);
            OnDefend(castle, isCustomMoveLegion);
            Callback_OnDefendChanged?.Invoke(PreDefendCastle, DefendCastle);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 不要手动调用此函数
 /// </summary>
 internal void Release()
 {
     if (--References < 0)
     {
         CLog.Error("refCount < 0");
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        ///     Loads the currently selected theme trying all others if current theme failed loading<br />
        ///     Therefore CConfig.Theme/Skin might be changed!<br />
        ///     Closes the program on failure!
        /// </summary>
        public static void Load()
        {
            CTheme theme = _Themes.FirstOrDefault(th => th is CBaseTheme && th.Name == CConfig.Config.Theme.Theme) ?? _Themes.FirstOrDefault(th => th is CBaseTheme);

            while (theme != null)
            {
                if (theme.Load())
                {
                    break;
                }
                theme.Unload();
                CLog.Error("Failed to load theme {ThemeName}! Removing...", CLog.Params(theme.Name, theme), true);
                _Themes.Remove(theme);
                theme = _Themes.FirstOrDefault(th => th is CBaseTheme);
            }
            CurrentThemes.Add(-1, theme);
            if (theme == null)
            {
                CLog.Fatal("No themes found! Cannot continue!");
            }
            else
            {
                CConfig.Config.Theme.Theme = theme.Name;
                CConfig.Config.Theme.Skin  = theme.CurrentSkin.Name;
                int[] ids = _Themes.Select(th => th.PartyModeID).Distinct().ToArray();
                foreach (int id in ids.Where(id => id >= 0))
                {
                    LoadPartymodeTheme(id);
                }
            }
        }
Ejemplo n.º 8
0
        public bool LoadProfile()
        {
            var xml = new CXmlDeserializer();

            try
            {
                xml.Deserialize(FilePath, this);
                //If ID couldn't be loaded, generate a new one and save it
                if (ID == Guid.Empty)
                {
                    ID = Guid.NewGuid();
                    SaveProfile();
                }
            }
            catch (Exception e)
            {
                if (_ConvertProfile(ref e))
                {
                    return(true);
                }
                CLog.Error("Error loading profile file " + Path.GetFileName(FilePath) + ": " + e.Message);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 9
0
 public T this[string key]
 {
     get
     {
         try
         {
             return(_Items[_HtIndex[key]]);
         }
         catch (Exception)
         {
             CLog.Error("Can't find " + typeof(T).Name.Substring(1) + " Element \"" + key + "\" in " + _ParentName);
             throw;
         }
     }
     set
     {
         if (!_HtIndex.ContainsKey(key))
         {
             _HtIndex.Add(key, _Items.Count);
             _Items.Add(value);
         }
         else
         {
             _Items[_HtIndex[key]] = value;
         }
     }
 }
Ejemplo n.º 10
0
 private void Awake()
 {
     if (avatar == null)
     {
         CLog.Error("Tank's gun has not been assigned!");
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 创建子界面
        /// </summary>
        public virtual T CreateSubView <T>(string path) where T : BaseView
        {
            GameObject tempGo     = null;
            var        tempPrefab = SelfBaseGlobal.GRMgr.GetUI(path);

            if (tempPrefab == null)
            {
                CLog.Error("没有这个prefab:" + path);
            }
            tempGo = Object.Instantiate(tempPrefab);
            T tempUI = null;

            if (tempGo != null)
            {
                tempUI = tempGo.GetComponent <T>();
                if (tempUI == null)
                {
                    CLog.Error("无法获取组建:" + typeof(T).Name + " Error path=" + path);
                    return(null);
                }
                tempUI.ViewLevel = ViewLevel.Sub;
                tempUI.UIMgr     = UIMgr;
                tempUI.Attach(this, RootView, SelfBaseGlobal);
                //移动到父节点下面
                tempUI.Trans.SetSiblingIndex(Trans.GetSiblingIndex() + SubViews.Count + 1);
                SubViews.Add(tempUI);
            }

            return(tempUI);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 开始一段旁白
 /// isPause=暂停
 /// isUnPauseOnEndTalk=对话结束后取消暂停
 /// </summary>
 /// <param name="id"></param>
 public virtual NarrationFragment Start(string id)
 {
     CurData = TDLuaMgr.Get <TData>(id);
     if (CurData == null)
     {
         CLog.Error($"没有找到这个Plot:{id}");
         return(null);
     }
     //如果剧情只显示一次,则返回
     if (CurData.IsShowOnce && Showed.Contains(id))
     {
         return(null);
     }
     CurNarrationIndex = 0;
     if (IsHave())
     {
         Showed.Add(id);
         var ret = CurData.Fragments[CurNarrationIndex];
         Callback_OnStartNarration?.Invoke(CurData, ret);
         Callback_OnChangeNarration?.Invoke(CurData);
         IsStartNarration = true;
         if (!PauseFlag)
         {
             BattleMgr.LockBattleStartFlow(true);
             PlotMgr?.SetPlotPause(true);
         }
         PauseFlag = true;
         return(ret);
     }
     return(null);
 }
Ejemplo n.º 13
0
        private bool _OnMessage(Message msg)
        {
            if (msg == null || msg.Handle == IntPtr.Zero)
            {
                return(true);
            }
            switch (msg.Type)
            {
            case MessageType.Eos:
                if (_Loop)
                {
                    Position = 0;
                }
                else
                {
                    _IsFinished = true;
                }
                break;

            case MessageType.Error:
                GException error;
                string     debug;
                msg.ParseError(out error, out debug);
                CLog.Error("Gstreamer error: message" + error.Message + ", code" + error.Code + " ,debug information" + debug);
                return(false);

            case MessageType.DurationChanged:
                _UpdateDuration();
                break;
            }
            msg.Dispose();
            return(true);
        }
Ejemplo n.º 14
0
 /// <summary>
 ///     Removes all textures from the screen
 /// </summary>
 protected override void _ClearScreen()
 {
     if (_Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0).IsFailure)
     {
         CLog.Error("Failed to clear the backbuffer");
     }
 }
Ejemplo n.º 15
0
	private SvEntityState GetSvEntityForGentity(GameEntity gEnt){
		if(gEnt == null || gEnt.sEnt.s.entityIndex < 0 || gEnt.sEnt.s.entityIndex >= CConstVar.MAX_GENTITIES){
			CLog.Error("GetSvEntityForGentity: bad entityIndex");
			return null;
		}
		return svEntities[gEnt.sEnt.s.entityIndex];
	}
Ejemplo n.º 16
0
        // 初始化Table menu
        public override void Init(UTableData tableData)
        {
            base.Init(tableData);

            if (DP == null)
            {
                CLog.Error("没有BaseDupplicate组件");
            }
            if (Scroll == null)
            {
                CLog.Error("没有BaseScroll组件");
            }
            if (Data.GetCustomDatas == null)
            {
                CLog.Error("TableData 的 GetCustomDatas 必须设置");
            }
            if (Data.OnRefresh == null)
            {
                CLog.Error("TableData 的 OnRefresh 必须设置");
            }

            Scroll.Init(tableData);
            Titles = DP.Init <UCheckBox, UCheckBoxData>(Data.TitleDatas);
            foreach (var item in Titles)
            {
                item.Data.OnClick += OnBntClick;
            }
        }
Ejemplo n.º 17
0
 public bool SaveFile(string filePath)
 {
     try
     {
         _Tw = new StreamWriter(filePath, false, _Song.Encoding);
         _WriteHeader();
         _WriteNotes();
     }
     catch (UnauthorizedAccessException)
     {
         CLog.Error("Cannot write " + filePath + ". Directory might be readonly or requires admin rights.");
         return(false);
     }
     catch (Exception e)
     {
         CLog.Error("Unhandled exception while writing " + filePath + ": " + e);
         return(false);
     }
     finally
     {
         if (_Tw != null)
         {
             _Tw.Dispose();
         }
     }
     return(true);
 }
Ejemplo n.º 18
0
        protected T CreateView <T>(string path) where T : BaseView
        {
            var tempGo = CreateGO(path);
            T   tempUI = null;

            if (tempGo != null)
            {
                tempUI = tempGo.GetComponent <T>();
                if (tempUI == null)
                {
                    CLog.Error("无法获取组建:" + typeof(T).Name + " Error path=" + path);
                    return(null);
                }
                tempUI.UIMgr = this;
                tempUI.Attach(RootView, RootView, SelfBaseGlobal);
            }
            //默认第一个创建的为rootView
            if (RootView == null)
            {
                RootView           = tempUI;
                RootView.ViewLevel = ViewLevel.Root;

                RootView.Canvas.sortingOrder = SortOrder;
                GameObject.DontDestroyOnLoad(RootView);
            }
            //其余的为Mainview
            else
            {
                tempUI.ViewLevel = ViewLevel.Main;
                MainViewGroup.Add(tempUI);
            }
            tempUI.Callback_OnOpen  += OnOpen;
            tempUI.Callback_OnClose += OnClose;
            return(tempUI);
        }
Ejemplo n.º 19
0
        public static bool LoadPartymodeTheme(int partyModeID)
        {
            Debug.Assert(partyModeID >= 0);
            CTheme theme = _Themes.FirstOrDefault(th => th.PartyModeID == partyModeID && th.Name == CConfig.Config.Theme.Theme);

            if (theme != null)
            {
                if (theme.Load())
                {
                    CurrentThemes.Add(partyModeID, theme);
                    return(true);
                }
                theme.Unload();
                CLog.Error("Failed to load theme " + theme + " for partymode! Removing...", true);
                _Themes.Remove(theme);
            }
            theme = _Themes.First(th => th.PartyModeID == partyModeID && th.Name == CSettings.DefaultName);
            if (theme.Load())
            {
                CurrentThemes.Add(partyModeID, theme);
                return(true);
            }
            CLog.Error("Failed to load default theme for partymode! Unloading partymode!", true);
            foreach (CPartyTheme th in _Themes.Where(th => th.PartyModeID == partyModeID))
            {
                th.Unload();
            }
            _Themes.RemoveAll(th => th.PartyModeID == partyModeID);
            return(false);
        }
Ejemplo n.º 20
0
        private bool _CheckRequiredElements()
        {
            List <string> missingTextures = _Required.Textures.FindAll(name => !_Textures.ContainsKey(name));
            List <string> missingVideos   = _Required.Videos.FindAll(name => !_Videos.ContainsKey(name));
            List <string> missingColors   = _Required.Colors.FindAll(name => !_Data.Colors.ContainsKey(name));

            if (missingTextures.Count + missingVideos.Count + missingColors.Count == 0)
            {
                return(true);
            }
            string msg = "The skin \"" + this + "\" is missing the following elements: ";

            if (missingTextures.Count > 0)
            {
                msg += Environment.NewLine + "Textures: " + String.Join(", ", missingTextures);
            }
            if (missingVideos.Count > 0)
            {
                msg += Environment.NewLine + "Videos: " + String.Join(", ", missingVideos);
            }
            if (missingColors.Count > 0)
            {
                msg += Environment.NewLine + "Colors: " + String.Join(", ", missingColors);
            }
            CLog.Error(msg);
            return(false);
        }
Ejemplo n.º 21
0
        private PortAudioSharp.PortAudio.PaStreamCallbackResult _MyPaStreamCallback(
            IntPtr input,
            IntPtr output,
            uint frameCount,
            ref PortAudioSharp.PortAudio.PaStreamCallbackTimeInfo timeInfo,
            PortAudioSharp.PortAudio.PaStreamCallbackFlags statusFlags,
            IntPtr userData)
        {
            try
            {
                if (frameCount > 0 && input != IntPtr.Zero)
                {
                    CRecordDevice dev = _Devices[userData.ToInt32()];
                    uint          numBytes;
                    numBytes = frameCount * (uint)dev.Channels * 2;

                    byte[] recbuffer = new byte[numBytes];

                    // copy from managed to unmanaged memory
                    Marshal.Copy(input, recbuffer, 0, (int)numBytes);
                    _HandleData(dev, recbuffer);
                }
            }
            catch (Exception e)
            {
                CLog.Error("Error on Stream Callback (rec): " + e);
            }

            return(PortAudioSharp.PortAudio.PaStreamCallbackResult.paContinue);
        }
Ejemplo n.º 22
0
        public UHUDItem Jump(GameObject prefab, BaseUnit unit, Transform node = null)
        {
            if (prefab == null)
            {
                CLog.Error("没有这个prefab");
                return(null);
            }

            if (spawnPool != null && spawnPool != null)
            {
                Transform temp = spawnPool.SpawnTrans(prefab, null, null, Trans);
                if (temp != null)
                {
                    UHUDItem tempText = temp.GetComponent <UHUDItem>();
                    if (tempText != null)
                    {
                        tempText.Init(unit, node);
                        tempText.OnLifeOver = OnLifeOver;
                        tempText.PUIView    = this;
                        AddList.Add(tempText);
                    }
                    return(tempText);
                }
            }
            return(null);
        }
Ejemplo n.º 23
0
        public void Siege(BaseUnit unit)
        {
            if (unit == null)
            {
                return;
            }
            var castle = unit as TCastle;

            if (castle == null)
            {
                CLog.Error("Siege:castle == null)");
                return;
            }
            if (IsInDefend())
            {
                return;
            }
            if (IsInSiege())
            {
                return;
            }
            if (!SelfUnit.IsEnemy(castle))
            {
                return;
            }
            PreSiegeCastle = SiegeCastle;
            SiegeCastle    = castle;
            castle.CastleStationedMgr.OnBeSiege(SelfUnit);
            OnSiege();
            Callback_OnSiegeChanged?.Invoke(PreSiegeCastle, SiegeCastle);
        }
Ejemplo n.º 24
0
    /// <summary>
    /// 加载语言表
    /// </summary>
    public void LoadConfig()
    {
        dicLang.Clear();
        string assetPath = AppSetting.ConfigBundleDir.TrimEnd('/') + AppSetting.ExtName;

        string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(assetPath.ToLower(), "LanguageConfig");

        if (assetPaths.Length > 0)
        {
            UnityEngine.Object      target = AssetDatabase.LoadMainAssetAtPath(assetPaths[0]);
            List <LangServerConfig> list   = JsonMapper.ToObject <List <LangServerConfig> >(target.ToString());
            Debug.Log("多语言表内容" + list.Count);
            for (int i = 0; i < list.Count; i++)
            {
                if (dicLang.ContainsKey(list[i].id))
                {
                    CLog.Error($"表[LanguageConfig]中有相同键({list[i].id})");
                }
                else
                {
                    dicLang.Add(list[i].id, list[i]);
                }
            }
        }
    }
Ejemplo n.º 25
0
        protected override bool _LoadSkin()
        {
            CSkin skin;

            if (!_Skins.TryGetValue(CConfig.Config.Theme.Skin, out skin))
            {
                skin = _Skins.Values.FirstOrDefault();
            }
            while (skin != null)
            {
                if (skin.Load())
                {
                    break;
                }
                skin.Unload();
                CLog.Error("Failed to load skin " + skin + "! Removing...", true);
                _Skins.Remove(skin.Name);
                skin = _Skins.Values.FirstOrDefault();
            }
            if (skin == null)
            {
                return(false);
            }
            CurrentSkin = skin;
            return(true);
        }
Ejemplo n.º 26
0
 /// <summary>
 /// 添加互斥
 /// </summary>
 /// <param name="isNeedReset">是否重置</param>
 /// <param name="isShowOne">是否至少选择一个</param>
 /// <param name="controls"></param>
 /// <returns></returns>
 protected UMutexer AddMutexerMain(bool isNeedReset, bool isShowOne, params UControl[] controls)
 {
     if (controls == null)
     {
         return(null);
     }
     //如果有默认Panel的话,添加到默认Panel
     if (MainPanel != null)
     {
         foreach (var item in controls)
         {
             if (item.IsCanBeViewFetch)
             {
                 CLog.Error("错误:{0}MainPanel的控件", item.GOName);
                 return(null);
             }
         }
         var ret = MainPanel.AddMutexer(isNeedReset, isShowOne, controls);
         if (MainMutexer == null)
         {
             MainMutexer = ret;
         }
         return(ret);
     }
     //没有默认Panel的话,添加到主界面
     else
     {
         var ret = AddMutexer(isNeedReset, isShowOne, controls);
         if (MainMutexer == null)
         {
             MainMutexer = ret;
         }
         return(ret);
     }
 }
Ejemplo n.º 27
0
        public static int ReadTimeout(IntPtr device, ref byte[] data, int length, int milliseconds)
        {
            IntPtr dataPtr = Marshal.AllocHGlobal(length);
            int    bytesRead;

            try
            {
                bytesRead = hid_read_timeout(device, dataPtr, length, milliseconds);
            }
            catch (Exception e)
            {
                bytesRead = -1;
                CLog.Error("Error CHIDAPI.ReadTimeout(): " + e);
            }

            if (bytesRead != -1)
            {
                Marshal.Copy(dataPtr, data, 0, bytesRead);
            }
            else
            {
                data = null;
            }

            Marshal.FreeHGlobal(dataPtr);

            return(bytesRead);
        }
Ejemplo n.º 28
0
        protected override bool _LoadSkin()
        {
            CSkin skin = null;

            for (int i = 0; i < 3; i++)
            {
                skin = _GetSkinToLoad(i);
                if (skin == null)
                {
                    continue;
                }
                if (skin.Load())
                {
                    break;
                }
                skin.Unload();
                CLog.Error("Failed to load skin " + skin + "! Removing...", true);
                _Skins.Remove(skin.Name);
            }
            if (skin == null)
            {
                return(false);
            }
            CurrentSkin = skin;
            return(true);
        }
Ejemplo n.º 29
0
        protected override Status OnDo()
        {
            Node child   = Child;
            int  doCount = 0;

            do
            {
                if (IsImmediate && doCount > 0)
                {
                    CLog.Error("repeattttt immmmmmeddddiateeeeee");
                }

                if (child.Status.IsDone)
                {
                    child.Reset();
                }
                child.Do();
                if (child.Status.IsDone)
                {
                    if (IsQuit())
                    {
                        return(QuitStatus());
                    }
                }
                doCount++;
            } while (IsImmediate && child.Status.IsDone && doCount <= MaxImmediateDoCount);

            return(Status.Run);
        }
Ejemplo n.º 30
0
 protected override void _OnBeforeDraw()
 {
     if (_Device.BeginScene().IsFailure)
     {
         CLog.Error("Failed to begin scene");
     }
 }