- 完善设置面板的具体功能,全局性的设置项已经可以发挥作用了
- 调整部分项目结构和AB包设置,打包测试设置面板的功能
This commit is contained in:
@@ -4,7 +4,7 @@ using Definition;
|
||||
using Definition.Enum;
|
||||
using GameFramework.DataTable;
|
||||
using GameFramework.Event;
|
||||
using StarForce;
|
||||
using Sound;
|
||||
using UnityGameFramework.Runtime;
|
||||
using ProcedureOwner = GameFramework.Fsm.IFsm<GameFramework.Procedure.IProcedureManager>;
|
||||
|
||||
@@ -57,7 +57,8 @@ namespace Procedure
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.Scene.LoadScene(AssetUtility.GetSceneAsset(drScene.AssetName), Constant.AssetPriority.SceneAsset, this);
|
||||
GameEntry.Scene.LoadScene(AssetUtility.GetSceneAsset(drScene.AssetName), Constant.AssetPriority.SceneAsset,
|
||||
this);
|
||||
_backgroundMusicId = drScene.BackgroundMusicId;
|
||||
}
|
||||
|
||||
@@ -83,6 +84,9 @@ namespace Procedure
|
||||
SceneId sceneId = (SceneId)_nextSceneId;
|
||||
switch (sceneId)
|
||||
{
|
||||
case SceneId.Menu:
|
||||
ChangeState<ProcedureMenu>(procedureOwner);
|
||||
break;
|
||||
case SceneId.GameplayA:
|
||||
ChangeState<ProcedureCombine>(procedureOwner);
|
||||
break;
|
||||
@@ -105,7 +109,7 @@ namespace Procedure
|
||||
|
||||
if (_backgroundMusicId > 0)
|
||||
{
|
||||
GameEntry.Sound.PlayMusic(_backgroundMusicId);
|
||||
GameEntry.Sound.PlayBGM(_backgroundMusicId);
|
||||
}
|
||||
|
||||
_isChangeSceneComplete = true;
|
||||
@@ -141,7 +145,8 @@ namespace Procedure
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Info("Load scene '{0}' dependency asset '{1}', count '{2}/{3}'.", ne.SceneAssetName, ne.DependencyAssetName, ne.LoadedCount.ToString(), ne.TotalCount.ToString());
|
||||
Log.Info("Load scene '{0}' dependency asset '{1}', count '{2}/{3}'.", ne.SceneAssetName,
|
||||
ne.DependencyAssetName, ne.LoadedCount.ToString(), ne.TotalCount.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
using GameFramework.Localization;
|
||||
using System;
|
||||
using Definition;
|
||||
using StarForce;
|
||||
using Definition;
|
||||
using Sound;
|
||||
using UnityGameFramework.Runtime;
|
||||
using ProcedureOwner = GameFramework.Fsm.IFsm<GameFramework.Procedure.IProcedureManager>;
|
||||
|
||||
@@ -17,19 +15,10 @@ namespace Procedure
|
||||
|
||||
// 构建信息:发布版本时,把一些数据以 Json 的格式写入 Assets/GameMain/Configs/BuildInfo.txt,供游戏逻辑读取
|
||||
GameEntry.BuiltinData.InitBuildInfo();
|
||||
|
||||
// 语言配置:设置当前使用的语言,如果不设置,则默认使用操作系统语言
|
||||
InitLanguageSettings();
|
||||
|
||||
// 变体配置:根据使用的语言,通知底层加载对应的资源变体
|
||||
InitCurrentVariant();
|
||||
|
||||
// 声音配置:根据用户配置数据,设置即将使用的声音选项
|
||||
InitSoundSettings();
|
||||
|
||||
|
||||
// 默认字典:加载默认字典文件 Assets/GameMain/Configs/DefaultDictionary.xml
|
||||
// 此字典文件记录了资源更新前使用的各种语言的字符串,会随 App 一起发布,故不可更新
|
||||
GameEntry.BuiltinData.InitDefaultDictionary();
|
||||
// GameEntry.BuiltinData.InitDefaultDictionary();
|
||||
}
|
||||
|
||||
protected override void OnUpdate(ProcedureOwner procedureOwner, float elapseSeconds, float realElapseSeconds)
|
||||
@@ -39,89 +28,5 @@ namespace Procedure
|
||||
// 运行一帧即切换到 Splash 展示流程
|
||||
ChangeState<ProcedureSplash>(procedureOwner);
|
||||
}
|
||||
|
||||
private void InitLanguageSettings()
|
||||
{
|
||||
if (GameEntry.Base.EditorResourceMode && GameEntry.Base.EditorLanguage != Language.Unspecified)
|
||||
{
|
||||
// 编辑器资源模式直接使用 Inspector 上设置的语言
|
||||
return;
|
||||
}
|
||||
|
||||
Language language = GameEntry.Localization.Language;
|
||||
if (GameEntry.Setting.HasSetting(Constant.Setting.Language))
|
||||
{
|
||||
try
|
||||
{
|
||||
string languageString = GameEntry.Setting.GetString(Constant.Setting.Language);
|
||||
language = (Language)Enum.Parse(typeof(Language), languageString);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (language != Language.English
|
||||
&& language != Language.ChineseSimplified
|
||||
&& language != Language.ChineseTraditional
|
||||
&& language != Language.Korean)
|
||||
{
|
||||
// 若是暂不支持的语言,则使用英语
|
||||
language = Language.English;
|
||||
|
||||
GameEntry.Setting.SetString(Constant.Setting.Language, language.ToString());
|
||||
GameEntry.Setting.Save();
|
||||
}
|
||||
|
||||
GameEntry.Localization.Language = language;
|
||||
Log.Info("Init language settings complete, current language is '{0}'.", language.ToString());
|
||||
}
|
||||
|
||||
private void InitCurrentVariant()
|
||||
{
|
||||
if (GameEntry.Base.EditorResourceMode)
|
||||
{
|
||||
// 编辑器资源模式不使用 AssetBundle,也就没有变体了
|
||||
return;
|
||||
}
|
||||
|
||||
string currentVariant = null;
|
||||
switch (GameEntry.Localization.Language)
|
||||
{
|
||||
case Language.English:
|
||||
currentVariant = "en-us";
|
||||
break;
|
||||
|
||||
case Language.ChineseSimplified:
|
||||
currentVariant = "zh-cn";
|
||||
break;
|
||||
|
||||
case Language.ChineseTraditional:
|
||||
currentVariant = "zh-tw";
|
||||
break;
|
||||
|
||||
case Language.Korean:
|
||||
currentVariant = "ko-kr";
|
||||
break;
|
||||
|
||||
default:
|
||||
currentVariant = "zh-cn";
|
||||
break;
|
||||
}
|
||||
|
||||
GameEntry.Resource.SetCurrentVariant(currentVariant);
|
||||
Log.Info("Init current variant complete.");
|
||||
}
|
||||
|
||||
private void InitSoundSettings()
|
||||
{
|
||||
GameEntry.Sound.Mute("Music", GameEntry.Setting.GetBool(Constant.Setting.MusicMuted, false));
|
||||
GameEntry.Sound.SetVolume("Music", GameEntry.Setting.GetFloat(Constant.Setting.MusicVolume, 0.3f));
|
||||
GameEntry.Sound.Mute("Sound", GameEntry.Setting.GetBool(Constant.Setting.SoundMuted, false));
|
||||
GameEntry.Sound.SetVolume("Sound", GameEntry.Setting.GetFloat(Constant.Setting.SoundVolume, 1f));
|
||||
GameEntry.Sound.Mute("UISound", GameEntry.Setting.GetBool(Constant.Setting.UISoundMuted, false));
|
||||
GameEntry.Sound.SetVolume("UISound", GameEntry.Setting.GetFloat(Constant.Setting.UISoundVolume, 1f));
|
||||
Log.Info("Init sound settings complete.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
using GameFramework;
|
||||
using System;
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
using GameFramework.Resource;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CustomUtility;
|
||||
using DataTable;
|
||||
using Definition;
|
||||
using Definition.Enum;
|
||||
using Setting;
|
||||
using Sound;
|
||||
using TMPro;
|
||||
using UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityGameFramework.Runtime;
|
||||
using ProcedureOwner = GameFramework.Fsm.IFsm<GameFramework.Procedure.IProcedureManager>;
|
||||
|
||||
@@ -19,11 +24,10 @@ namespace Procedure
|
||||
public static readonly string[] DataTableNames = new string[]
|
||||
{
|
||||
"Entity",
|
||||
"Music",
|
||||
"BGM",
|
||||
"Scene",
|
||||
"Sound",
|
||||
"UIForm",
|
||||
"UISound",
|
||||
"SE",
|
||||
"Dialog",
|
||||
"DialogLine"
|
||||
};
|
||||
@@ -72,15 +76,12 @@ namespace Procedure
|
||||
}
|
||||
}
|
||||
|
||||
procedureOwner.SetData<VarInt32>("NextSceneId", (int)SceneId.Main);
|
||||
procedureOwner.SetData<VarInt32>("NextSceneId", (int)SceneId.Menu);
|
||||
ChangeState<ProcedureChangeScene>(procedureOwner);
|
||||
}
|
||||
|
||||
private void PreloadResources()
|
||||
{
|
||||
// Preload configs
|
||||
LoadConfig("DefaultConfig");
|
||||
|
||||
// Preload data tables
|
||||
foreach (string dataTableName in DataTableNames)
|
||||
{
|
||||
@@ -88,18 +89,13 @@ namespace Procedure
|
||||
}
|
||||
|
||||
// Preload dictionaries
|
||||
LoadDictionary("Default");
|
||||
// LoadDictionary("Default");
|
||||
|
||||
// Preload fonts
|
||||
LoadFont("MainFont");
|
||||
LoadTMPFont("MainTMPFont");
|
||||
}
|
||||
|
||||
private void LoadConfig(string configName)
|
||||
{
|
||||
string configAssetName = AssetUtility.GetConfigAsset(configName, false);
|
||||
_loadedFlag.Add(configAssetName, false);
|
||||
GameEntry.Config.ReadData(configAssetName, this);
|
||||
LoadSetting();
|
||||
}
|
||||
|
||||
private void LoadDataTable(string dataTableName)
|
||||
@@ -152,6 +148,81 @@ namespace Procedure
|
||||
}));
|
||||
}
|
||||
|
||||
private void LoadSetting()
|
||||
{
|
||||
var setting = GameEntry.Setting.GetGameSetting();
|
||||
|
||||
GameEntry.Sound.SetVolume("BGM", setting.BGMVolume);
|
||||
GameEntry.Sound.SetVolume("SE", setting.SEVolume);
|
||||
|
||||
ScreenResolutionType resolution = setting.ScreenResolution;
|
||||
int width = 0, height = 0;
|
||||
switch (resolution)
|
||||
{
|
||||
case ScreenResolutionType._1280x720:
|
||||
width = 1280;
|
||||
height = 720;
|
||||
break;
|
||||
case ScreenResolutionType._1366x768:
|
||||
width = 1366;
|
||||
height = 768;
|
||||
break;
|
||||
case ScreenResolutionType._1600x900:
|
||||
width = 1600;
|
||||
height = 900;
|
||||
break;
|
||||
case ScreenResolutionType._1920x1080:
|
||||
width = 1920;
|
||||
height = 1080;
|
||||
break;
|
||||
case ScreenResolutionType._2560x1440:
|
||||
width = 2560;
|
||||
height = 1440;
|
||||
break;
|
||||
case ScreenResolutionType._2560x1600:
|
||||
width = 2560;
|
||||
height = 1600;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
ScreenWindowType resolutionWindow = setting.ScreenWindow;
|
||||
switch (resolutionWindow)
|
||||
{
|
||||
case ScreenWindowType.FullScreen:
|
||||
Screen.SetResolution(width, height, FullScreenMode.ExclusiveFullScreen);
|
||||
break;
|
||||
case ScreenWindowType.Borderless:
|
||||
Screen.SetResolution(width, height, FullScreenMode.FullScreenWindow);
|
||||
break;
|
||||
case ScreenWindowType.Windowed:
|
||||
Screen.SetResolution(width, height, FullScreenMode.Windowed);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
Application.targetFrameRate = -1;
|
||||
QualitySettings.vSyncCount = setting.VSync ? 1 : 0;
|
||||
if (setting.AntiAliasing)
|
||||
{
|
||||
foreach (var asset in GraphicsSettings.allConfiguredRenderPipelines)
|
||||
{
|
||||
if (asset.name == "URP-AntiAliasing") GraphicsSettings.renderPipelineAsset = asset;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var asset in GraphicsSettings.allConfiguredRenderPipelines)
|
||||
{
|
||||
if (asset.name == "URP-Normal") GraphicsSettings.renderPipelineAsset = asset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Event Hanlders
|
||||
|
||||
private void OnLoadConfigSuccess(object sender, GameEventArgs e)
|
||||
{
|
||||
LoadConfigSuccessEventArgs ne = (LoadConfigSuccessEventArgs)e;
|
||||
@@ -223,5 +294,7 @@ namespace Procedure
|
||||
Log.Error("Can not load dictionary '{0}' from '{1}' with error message '{2}'.", ne.DictionaryAssetName,
|
||||
ne.DictionaryAssetName, ne.ErrorMessage);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user