Пример #1
0
        private void InitSettings()
        {
            GameSettings = GameSettingsManager.GetSettings("core");
#if UNITY_EDITOR
            debug = true;
#else
            debug = GameSettings.GetBool("debug");
#endif
            GameSettings.RegisterSettingsUpdateCallback("control", new GameHandler(TAG, OnControlSettingsChanged));
            GameSettings.RequireSettingsLoad("control");
        }
Пример #2
0
        private void InitModDebug()
        {
            UIManager    = (UIManager)GameManager.GetManager(UIManager.TAG);
            DebugManager = (IDebugManager)GameManager.GetManager("DebugManager");
            DebugManager.RegisterCommand("loadmod", OnCommandLoadMod, 1, "[packagePath:string] [initialize:true/false] 加载模组 [模组完整路径] [是否立即初始化]");
            DebugManager.RegisterCommand("unloadmod", OnCommandUnLoadMod, 1, "[packageUid:int]  加载模组 [模组UID]");
            DebugManager.RegisterCommand("initmod", OnCommandInitializeMod, 1, "[packageUid:int]  初始化模组 [模组UID]");
            DebugManager.RegisterCommand("modasset", OnCommandShowModAssets, 1, "[packageUid:int]  显示模组包内所有资源 [模组UID]");
            DebugManager.RegisterCommand("mods", OnCommandShowAllMod, 0, "显示所有模组");
            DebugManager.AddCustomDebugToolItem("模组管理器", new GameHandler(TAG, OnDebugToolItemClick));

            settings    = GameSettingsManager.GetSettings("core");
            hideCoreMod = settings.GetBool("modmgr.hideCoreMod", true);

            InitModManagementWindow();
        }
Пример #3
0
        //设置加载
        private bool OnControlSettingsChanged(string evtName, params object[] param)
        {
            keyFront        = (KeyCode)System.Enum.Parse(typeof(KeyCode), GameSettings.GetString("control.key.front", "UpArrow"));
            keyFront2       = (KeyCode)System.Enum.Parse(typeof(KeyCode), GameSettings.GetString("control.key.front2", "W"));
            keyUp           = (KeyCode)System.Enum.Parse(typeof(KeyCode), GameSettings.GetString("control.key.up", "Q"));
            keyDown         = (KeyCode)System.Enum.Parse(typeof(KeyCode), GameSettings.GetString("control.key.down", "E"));
            keyBack         = (KeyCode)System.Enum.Parse(typeof(KeyCode), GameSettings.GetString("control.key.back", "DownArrow"));
            keyBack2        = (KeyCode)System.Enum.Parse(typeof(KeyCode), GameSettings.GetString("control.key.back2", "S"));
            keyLeft         = (KeyCode)System.Enum.Parse(typeof(KeyCode), GameSettings.GetString("control.key.left", "LeftArrow"));
            keyLeft2        = (KeyCode)System.Enum.Parse(typeof(KeyCode), GameSettings.GetString("control.key.left2", "A"));
            keyRight        = (KeyCode)System.Enum.Parse(typeof(KeyCode), GameSettings.GetString("control.key.right", "RightArrow"));
            keyRight2       = (KeyCode)System.Enum.Parse(typeof(KeyCode), GameSettings.GetString("control.key.right2", "D"));
            keyRoateCamera  = (KeyCode)System.Enum.Parse(typeof(KeyCode), GameSettings.GetString("control.key.roate", "LeftShift"));
            keyRoateCamera2 = (KeyCode)System.Enum.Parse(typeof(KeyCode), GameSettings.GetString("control.key.roate2", "RightShift"));
            keyUpCamera     = (KeyCode)System.Enum.Parse(typeof(KeyCode), GameSettings.GetString("control.key.up_cam", "Space"));

            reverseControl = GameSettings.GetBool("control.reverse", false);

            InitKeyEvents();
            return(true);
        }
Пример #4
0
        private bool OnVideoSettingsUpdated(string evtName, params object[] param)
        {
            int  resolutionsSet = GameSettings.GetInt("video.resolution", defaultResolution);
            bool fullScreen     = GameSettings.GetBool("video.fullScreen", Screen.fullScreen);
            int  quality        = GameSettings.GetInt("video.quality", QualitySettings.GetQualityLevel());
            int  vSync          = GameSettings.GetInt("video.vsync", QualitySettings.vSyncCount);

            GameLogger.Log(TAG, "OnVideoSettingsUpdated:\nresolutionsSet: {0}\nfullScreen: {1}" +
                           "\nquality: {2}\nvSync : {3}", resolutionsSet, fullScreen, quality, vSync);

            Screen.SetResolution(resolutions[resolutionsSet].width, resolutions[resolutionsSet].height, true);
            Screen.fullScreen     = fullScreen;
            Screen.fullScreenMode = fullScreen ? FullScreenMode.FullScreenWindow : FullScreenMode.Windowed;
            QualitySettings.SetQualityLevel(quality, true);
            QualitySettings.vSyncCount = vSync;

            GameManager.GameMediator.DispatchGlobalEvent(GameEventNames.EVENT_SCREEN_SIZE_CHANGED, "*",
                                                         resolutions[resolutionsSet].width, resolutions[resolutionsSet].height);
            GameManager.UIManager.RequestRelayoutForScreenSizeChaged();

            return(true);
        }
Пример #5
0
        private void InitModManagementWindow()
        {
            mod_icon_not_load = GameManager.FindStaticAssets <Sprite>("mod_icon_not_load");
            mod_icon_default  = GameManager.FindStaticAssets <Sprite>("mod_icon_default");
            mod_icon_failed   = GameManager.FindStaticAssets <Sprite>("mod_icon_failed");
            mod_icon_bad      = GameManager.FindStaticAssets <Sprite>("mod_icon_bad");

            modManagerView  = GameCloneUtils.CloneNewObjectWithParent(GameManager.FindStaticPrefabs("UIModManagement"), UIManager.UIRoot.transform).GetComponent <RectTransform>();
            modManageWindow = UIManager.CreateWindow("模组管理", modManagerView);
            modManageWindow.SetSize(500, 300);
            modManageWindow.SetMinSize(400, 250);
            modManageWindow.CloseAsHide = true;
            modManageWindow.Hide();
            modManageWindow.MoveToCenter();
            modManageWindow.onHide += (windowId) => { SaveModEnableStatusList(); };
            modManageWindow.onShow += (windowId) => { FlushModList(); };
            modList                  = modManagerView.transform.Find("UIScrollView/Viewport/Content").gameObject.GetComponent <UICommonList>();
            TextModCount             = modManagerView.transform.Find("TextModCount").GetComponent <Text>();
            hideCoreMod              = settings.GetBool("modmgr.hideCoreMod", true);
            UIToggleHideCoreMod      = modManagerView.transform.Find("UIToggleHideCoreMod").GetComponent <Toggle>();
            UIToggleHideCoreMod.isOn = hideCoreMod;
            UIToggleHideCoreMod.onValueChanged.AddListener((b) =>
            {
                hideCoreMod = b;
                FlushModList();
            });

            GameManager.GameMediator.RegisterEventHandler(GameEventNames.EVENT_MOD_REGISTERED, "ModDebug", (evtName, param) =>
            {
                OnModAdded((GameMod)param[1]);
                return(false);
            });
            GameManager.GameMediator.RegisterEventHandler(GameEventNames.EVENT_MOD_UNLOAD, "ModDebug", (evtName, param) =>
            {
                OnModRemoved((GameMod)param[1]);
                return(false);
            });
            GameManager.GameMediator.RegisterEventHandler(GameEventNames.EVENT_MOD_LOAD_FAILED, "ModDebug", (evtName, param) =>
            {
                GameMod m = (GameMod)param[1];
                UpdateModListItemInfos(modList.GetItemById(m.Uid), m);
                return(false);
            });
            GameManager.GameMediator.RegisterEventHandler(GameEventNames.EVENT_MOD_LOAD_SUCCESS, "ModDebug", (evtName, param) =>
            {
                GameMod m = (GameMod)param[1];
                UpdateModListItemInfos(modList.GetItemById(m.Uid), m);
                return(false);
            });
            GameManager.GameMediator.RegisterEventHandler(GameEventNames.EVENT_GLOBAL_ALERT_CLOSE, "ModDebug", (evtName, param) =>
            {
                if (currentModConfirm != null)
                {
                    int id       = (int)param[0];
                    bool confirm = (bool)param[1];
                    if (confirm)
                    {
                        if (id == unloadModConfirmUid)
                        {
                            UnLoadGameMod(currentModConfirm);
                            currentModConfirm = null;
                        }
                        else if (id == initModConfirmUid)
                        {
                            currentModConfirm.Load(this);
                            currentModConfirm = null;
                        }
                    }
                }
                return(false);
            });

            InitModList();
        }