From 8f28e8d8284340da34a43eb9882eaaf985157ab9 Mon Sep 17 00:00:00 2001 From: Silverlan Date: Thu, 3 Oct 2024 20:59:08 +0200 Subject: [PATCH 01/15] feat: add support for multi-font text rendering --- assets/scripts/localization/jp/language.udm | 1 - assets/scripts/localization/zh-cn/language.udm | 1 - build_scripts/scripts/external_libs.py | 2 +- core/client/src/c_engine.cpp | 15 +++------------ core/client/src/gui/wiconsole.cpp | 2 +- core/client/src/lua/libraries/c_lengine.cpp | 3 +-- core/shared/include/pragma/util/font_set.hpp | 1 - 7 files changed, 6 insertions(+), 19 deletions(-) diff --git a/assets/scripts/localization/jp/language.udm b/assets/scripts/localization/jp/language.udm index 55ecfad80..495d306bc 100644 --- a/assets/scripts/localization/jp/language.udm +++ b/assets/scripts/localization/jp/language.udm @@ -5,7 +5,6 @@ "font" { $array characterSetRequirements [string]["jp"] - $string requiredChars " !\"'()*+-./0123456789:=>ABCDEFGHIKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{}ē、。々「」あいうえおかがきぎくぐけげこごさざしじすずせぜそぞただちっつづてでとどなにねのはばびへべほぼまみむめもゃやょよらりるれろわをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチッツテデトドナニネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロワンヴ・ー一三上下不与世両中主乗乱乳了予事二互五人今介他付代以仮件任伝伸似位低体何作使例供価便係保信俳個候倣値停側備傾働像優元先光入全共具内円再写凍処凸凹出分切列初別利制刻則削前割力功加助効動化半単印原参反取受口可右号各合同名向否含告周味呼命品員問善器四回因囲図固圧在地均垂型域基報場塩境増声変外多大天太央失奥奨好始子字存学完定実害容密対寿専射小少尺屈屋展属履岐岩工左巻布常幅平広序底度座延式引張強当形彩影役径待後従得御復心必応快性情想意感態慎成戻所手承投抗折択抵押抽拒拡持指挙振挿捨捻排探接推描提換援携撃播撮操支改攻放敗散数整文料斜断新方旅既日早明易星映時景晶暴曜曲更書替最有期木本材条枚果枠査根格案棄椅植検業極楽概構様標模横機次止正武歩歪歳歴残段殺比毛気水氷決沢況法泡波泥注浮浸消液深混添済減渡渦測湿源準滑漬漸炎点無焦焼煙照燃爆版牙牛物牲特犠状独率玉珀珠現球理琥環生用由画界番異発白的皮目直相真眼矢知矩短石砂破確礎示禅私移種稼空突立端第等筒算管箱節範築簡粋粒粗精糖系約純級素索細紹終結絞絡統絶継続緑緒線編縫縮繁繰置義羽翠者聴肉肢胃背胸能脈脚腕膏膚自致舞般良色英草落著蔽薄行衝表衰被装補複要見規視覚覧親観角解言計設許証評試詳認語説読誰調諾識警象費貼質赤起超足距跡身車軌転軸輝輪込近返追退送逆透通速造連進遅遇運過道達違遠適遭遮遷選部郭配重野量金鈍鉄鉛銀銅錐録長閉開間関閾防限除陽隔際集離難雪震霧露青静非面音響頂順領頭頻題顔類風飛駆験骨高髪鶏麦黄黒!&():?" } $bool enabled true } \ No newline at end of file diff --git a/assets/scripts/localization/zh-cn/language.udm b/assets/scripts/localization/zh-cn/language.udm index 22f153af3..fe13adc4a 100644 --- a/assets/scripts/localization/zh-cn/language.udm +++ b/assets/scripts/localization/zh-cn/language.udm @@ -4,7 +4,6 @@ "font" { $array characterSetRequirements [string]["zh"] - $string requiredChars " \"'()*+-./0123456789:=>ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{}àáèéìíòóùúāēěīōūǎǐǒǔǜα“”。一三上下不与专且世业丝丢两个中为主丽么义之乎乐乘也习书了事二于互五亚些交产享亮人什仁仅介仍从他代以们仰件任仿众优会传伪伯估伸似伽但位低住体何作你佳使例供侧保信俯倍倒值倾假偏做停健储像允元先光克免入全八公六兰关其具内再冒写军冠冰冲决况准减凝几凸凹出击函分切划列则创初删利别到制刷刺刻前剔剪副割力功加务劣动助势包化匙区十午半华单占卡印即卷历压厚原去参叉及双反发取受变叠口古另只可台史右叶号各合同名后向吗否含听启告员周味命和品响唱啤喜喷器噪四回因围固图圆圈土在地场址均坎坏坐块坛坦坪垂型域基堆塑塞境增声壳处备复外多夜大天太失头夹奇套奶好如妈始姿子孔字存学孩它安完定宝实客家容密察寸对寻导寿射将小少尔尘尚就尺尼局屏展属岁岩工左巧巨差己已布师希帐帧帮常幕平并幻幽广序库应底度康延建开异弃式引弦弯弹强归当录形彩影径待很得循德心志快忽态思性恢息悉您情想意感慎戏成我戒或战截户所手打执扩扭找把投抖抗折报拉拍拒拖拙拟拥择括持指按挡振捉捕损换据排探接控掩描提插摄摸撞撤播操擎支收改攻放效敏教散数整文斗料斜断斯新方旅旋无旦早时明易星映春是显晕景晶智暂暗曜曝曲更替最有服望期木未末本机杀权李杏材束条来松板极构林果架柄某染柔柠查柱柿栅标栈栏树校样核根格桃框档梁检棕森植楚概榄模横橄橙檬次欢止正此步武段每比毛毯气水求汽沙没沥油法泡波注泽洋活流浅浏浮海消涡润液淆淡深混添清渐渡渲游湿源滑滚滤漂演漫潜激火灯灰灵炸点烁烘烟热烷焙焦然照熟燃燧爆爱父片版牌牙牛物特状独率玉玛玩玫环现玻珀珊珍珠球理琥瑙瑚瑰璃瓜瓦瓷生用由甲电画界留略番白百的皇皮皱盐监盒盔盖盘盛目直相看真眨眼着睛矢知矩石码研砖砾础硬确碧碰磁示社禁禅离种科秒秘积称移程稍究空窗立竖站竞端笔符第等筒签简算管箭箱米类粉粒粗粘精糊糖糙系素索紧紫红约级纯纳纹纺线组细终绍经绑结绕绘络绝统继绪续维绿缓编缘缟缩缺网罗置羽翠翡翻考者而聊联聚肉肤肩胃背胸能脂脚脱腿膀膏臂自至致航良色节芬花苍若苯英苹范茄草荡荷获菊菜萄著葡董蒸蓝蓟蔚蔽薄薰藏虑虚虽蛮行衡衣表衰被裁装褐西要覆见观规视览觉角解触言警计订认议记许设证评识译试话该详语误请读调谢谨豆象豪贝败账质购贴费贾资赭走起超越趾跃距跟路跳踪身车轨转轮软轴轻载较辆辐辑输辨边达过迎运近返还这进远连迟述迹追退适逃逆选透逐通速逻遇道遮邮部都配酒酱酸采里重野量金针钛钟钢钥钮钻铁铜铝铰银铺链销锁错锥键锯镍镜长门闪闭问间阈阳阴阵阶阻附际限除陶随隐隔难集雕雪雾需震霍青静靛非面鞍音页顶项顺顾预领频颗题颜风饱馈首马驱验骗骤骨骼高魅鱼鲁鲑鸡鸣鸭鹿麒麟麦麻黄黑默鼠齐齿龙!(),:;?" } $bool enabled true } \ No newline at end of file diff --git a/build_scripts/scripts/external_libs.py b/build_scripts/scripts/external_libs.py index cd10f0d74..ad3405610 100644 --- a/build_scripts/scripts/external_libs.py +++ b/build_scripts/scripts/external_libs.py @@ -33,7 +33,7 @@ get_submodule("util_vmf","https://github.com/Silverlan/util_vmf.git","3080ba05280ae5b0a76ef283870864c16d1c7826") get_submodule("util_zip","https://github.com/Silverlan/util_zip.git","d9bf05a5cbf71bf53f9fbea82c7352f870989ed1") get_submodule("vfilesystem","https://github.com/Silverlan/vfilesystem.git","25c839e313b1bb1c2b4dee56c4a0298c53f546b4") -get_submodule("wgui","https://github.com/Silverlan/wgui.git","bfa72cae6258f1233c60e5fd9ecae1bbf53ee7e7") +get_submodule("wgui","https://github.com/Silverlan/wgui.git","a9359e5cc44d09f8fb6fb4d7c1f9ae099f8a89d0") get_submodule("util_unicode","https://github.com/Silverlan/util_unicode.git","344d62ac0b06db9d970b08e9cf3a1d039ed6b28a") get_submodule("cppbezierfit","https://github.com/Silverlan/cppbezierfit.git","eb08f35ad74c1124f3cd4ef3a8958cded6a04b0e") diff --git a/core/client/src/c_engine.cpp b/core/client/src/c_engine.cpp index 533e7a3c5..74dccc14d 100644 --- a/core/client/src/c_engine.cpp +++ b/core/client/src/c_engine.cpp @@ -734,15 +734,6 @@ bool CEngine::Initialize(int argc, char *argv[]) if(FindFontSet(sourceHanSans)) defaultFontSet = sourceHanSans; } - auto udmReqChars = (*lanInfo->configData)["font"]["requiredChars"]; - if(udmReqChars) { - auto *fontSet = const_cast(FindFontSet(defaultFontSet)); - if(fontSet) { - std::string reqChars; - udmReqChars(reqChars); - fontSet->requiredChars = util::Utf8String {reqChars}; - } - } } auto fail = [&]() { @@ -768,7 +759,7 @@ bool CEngine::Initialize(int argc, char *argv[]) fail(); return false; } - auto r = gui.Initialize(GetRenderResolution(), fontData->fileName, fontSet.requiredChars); + auto r = gui.Initialize(GetRenderResolution(), fontData->fileName, {"source-han-sans/SourceHanSans-VF.ttf"}); if(r != WGUI::ResultCode::Ok) { Con::cerr << "Unable to initialize GUI library: "; switch(r) { @@ -1453,7 +1444,7 @@ void CEngine::DrawScene(std::shared_ptr &rt) StartProfilingStage("RecordGUI"); StartProfilingStage("GUI"); - WGUI::GetInstance().SetLockedForDrawing(true); + WGUI::GetInstance().BeginDraw(); CallCallbacks("PreRecordGUI"); if(c_game != nullptr) c_game->PreGUIRecord(); @@ -1534,7 +1525,7 @@ void CEngine::DrawScene(std::shared_ptr &rt) CallCallbacks("PostDrawGUI"); if(c_game != nullptr) c_game->PostGUIDraw(); - WGUI::GetInstance().SetLockedForDrawing(false); + WGUI::GetInstance().EndDraw(); StopProfilingStage(); // ExecuteGUIDrawCalls } } diff --git a/core/client/src/gui/wiconsole.cpp b/core/client/src/gui/wiconsole.cpp index 69f6730ad..4d47d4962 100644 --- a/core/client/src/gui/wiconsole.cpp +++ b/core/client/src/gui/wiconsole.cpp @@ -153,7 +153,7 @@ void WIConsole::Initialize() EnableThinking(); SetSize(512, 256); - FontInfo::FontSettings settings {}; + FontSettings settings {}; settings.fontSize = 12; FontManager::LoadFont("console", "dejavu/DejaVuSansMono", settings); diff --git a/core/client/src/lua/libraries/c_lengine.cpp b/core/client/src/lua/libraries/c_lengine.cpp index c72bfda69..7bac28534 100644 --- a/core/client/src/lua/libraries/c_lengine.cpp +++ b/core/client/src/lua/libraries/c_lengine.cpp @@ -49,9 +49,8 @@ std::shared_ptr Lua::engine::create_font(lua_State *l, const std return nullptr; if(fontFileData->fontSizeAdjustment) size += *fontFileData->fontSizeAdjustment; - FontInfo::FontSettings settings {}; + FontSettings settings {}; settings.fontSize = size; - settings.requiredChars = fontSet->requiredChars ? std::make_unique(*fontSet->requiredChars) : std::unique_ptr {}; return FontManager::LoadFont(identifier.c_str(), fontFileData->fileName, settings, reload); } std::shared_ptr Lua::engine::create_font(lua_State *l, const std::string &identifier, const std::string &fontSetName, FontSetFlag features, uint32_t size) { return create_font(l, identifier, fontSetName, features, size, false); } diff --git a/core/shared/include/pragma/util/font_set.hpp b/core/shared/include/pragma/util/font_set.hpp index b6d456b87..19942caf2 100644 --- a/core/shared/include/pragma/util/font_set.hpp +++ b/core/shared/include/pragma/util/font_set.hpp @@ -32,7 +32,6 @@ struct DLLNETWORK FontSetFileData { struct DLLNETWORK FontSet { std::vector fileData; std::vector features; - std::optional requiredChars {}; FontSetFileData *FindFontFileCandidate(FontSetFlag flags); const FontSetFileData *FindFontFileCandidate(FontSetFlag flags) const; bool HasFeature(const std::string_view &feature) const; From bf4fe2406843bcf6fadfee874f6f796cdfba9588 Mon Sep 17 00:00:00 2001 From: Silverlan Date: Fri, 4 Oct 2024 07:36:41 +0200 Subject: [PATCH 02/15] feat(locale): update display names --- assets/scripts/localization/jp/language.udm | 3 +-- assets/scripts/localization/zh-cn/language.udm | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/assets/scripts/localization/jp/language.udm b/assets/scripts/localization/jp/language.udm index 495d306bc..83b59f78d 100644 --- a/assets/scripts/localization/jp/language.udm +++ b/assets/scripts/localization/jp/language.udm @@ -1,7 +1,6 @@ "jp" { - // $string displayName "日本語" - $string displayName "Japanese" + $string displayName "日本語" "font" { $array characterSetRequirements [string]["jp"] diff --git a/assets/scripts/localization/zh-cn/language.udm b/assets/scripts/localization/zh-cn/language.udm index fe13adc4a..09514ebbb 100644 --- a/assets/scripts/localization/zh-cn/language.udm +++ b/assets/scripts/localization/zh-cn/language.udm @@ -1,6 +1,6 @@ "zh-cn" { - $string displayName "Chinese (Simplified)" + $string displayName "中文 (简体)" "font" { $array characterSetRequirements [string]["zh"] From a8b85bb5773f9b53cd9c9555f597df2796eef602 Mon Sep 17 00:00:00 2001 From: Silverlan Date: Fri, 4 Oct 2024 21:05:43 +0200 Subject: [PATCH 03/15] feat(model): add flex name validity checks --- core/shared/src/model/model_flex_controller.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/shared/src/model/model_flex_controller.cpp b/core/shared/src/model/model_flex_controller.cpp index 1a0e4f27b..b02ec5a67 100644 --- a/core/shared/src/model/model_flex_controller.cpp +++ b/core/shared/src/model/model_flex_controller.cpp @@ -34,6 +34,8 @@ FlexController *Model::GetFlexController(const std::string &name) } FlexController &Model::AddFlexController(const std::string &name) { + if(name.find_first_of("/\\") != std::string::npos) + throw std::invalid_argument {"Name '" + name + "' contains illegal characters!"}; auto it = FindFlexController(name); if(it == m_flexControllers.end()) { m_flexControllers.push_back({}); @@ -93,6 +95,8 @@ Flex *Model::GetFlex(const std::string &name) } Flex &Model::AddFlex(const std::string &name) { + if(name.find_first_of("/\\") != std::string::npos) + throw std::invalid_argument {"Name '" + name + "' contains illegal characters!"}; auto it = FindFlex(name); if(it == m_flexes.end()) { m_flexes.push_back({name}); From 7dd238639903c15a70ea88daf5b9fb9a5b6f67eb Mon Sep 17 00:00:00 2001 From: Silverlan Date: Fri, 4 Oct 2024 21:13:05 +0200 Subject: [PATCH 04/15] feat(ui): add file drag callbacks --- build_scripts/scripts/external_libs.py | 4 +- core/client/include/pragma/c_engine.h | 10 ++++ .../include/pragma/clientstate/clientstate.h | 2 + core/client/include/pragma/game/c_game.h | 10 +--- core/client/include/pragma/gui/wiluabase.h | 12 +++++ core/client/src/c_engine.cpp | 49 +++++++++++++++++++ core/client/src/game/c_game_input.cpp | 31 +++--------- core/client/src/gui/wiluabase.cpp | 26 ++++++++++ core/client/src/lua/c_library.cpp | 5 +- core/client/src/lua/classes/c_lwibase.cpp | 4 ++ core/client/src/lua/libraries/c_input.cpp | 14 ++++++ core/client/src/lua/libraries/c_lgame.cpp | 6 +-- 12 files changed, 136 insertions(+), 37 deletions(-) diff --git a/build_scripts/scripts/external_libs.py b/build_scripts/scripts/external_libs.py index ad3405610..cd72cff07 100644 --- a/build_scripts/scripts/external_libs.py +++ b/build_scripts/scripts/external_libs.py @@ -10,7 +10,7 @@ os.chdir(external_libs_dir) get_submodule("alsoundsystem","https://github.com/Silverlan/alsoundsystem.git","7daad8c34ab5000fc92b6f326b08fdc81b984cfe") get_submodule("datasystem","https://github.com/Silverlan/datasystem.git","7642296ea0f8316957e1123034e87034294f8b46") -get_submodule("iglfw","https://github.com/Silverlan/iglfw.git","c5ea5319c17e206e8e418a2549a195e662f59dfd") +get_submodule("iglfw","https://github.com/Silverlan/iglfw.git","e3a165cdac0ec9a2b3ced4becc0b7beeb5cf5508") get_submodule("luasystem","https://github.com/Silverlan/luasystem.git","b36cfa22c79906270dec09a0d882e92c07a12104") get_submodule("materialsystem","https://github.com/Silverlan/materialsystem.git","b5ef761c20f5f6afa573bee079340d6da4db8bd2") get_submodule("mathutil","https://github.com/Silverlan/mathutil.git","90a6cbb229cf3b2e7af1eb9bc58b3ff22db5a611") @@ -33,7 +33,7 @@ get_submodule("util_vmf","https://github.com/Silverlan/util_vmf.git","3080ba05280ae5b0a76ef283870864c16d1c7826") get_submodule("util_zip","https://github.com/Silverlan/util_zip.git","d9bf05a5cbf71bf53f9fbea82c7352f870989ed1") get_submodule("vfilesystem","https://github.com/Silverlan/vfilesystem.git","25c839e313b1bb1c2b4dee56c4a0298c53f546b4") -get_submodule("wgui","https://github.com/Silverlan/wgui.git","a9359e5cc44d09f8fb6fb4d7c1f9ae099f8a89d0") +get_submodule("wgui","https://github.com/Silverlan/wgui.git","82e5cbce64d36d8008545cb9786b163f1c880039") get_submodule("util_unicode","https://github.com/Silverlan/util_unicode.git","344d62ac0b06db9d970b08e9cf3a1d039ed6b28a") get_submodule("cppbezierfit","https://github.com/Silverlan/cppbezierfit.git","eb08f35ad74c1124f3cd4ef3a8958cded6a04b0e") diff --git a/core/client/include/pragma/c_engine.h b/core/client/include/pragma/c_engine.h index c18d360e6..a025d263a 100644 --- a/core/client/include/pragma/c_engine.h +++ b/core/client/include/pragma/c_engine.h @@ -74,6 +74,11 @@ class DLLCLIENT CEngine : public Engine, public pragma::RenderContext { Count }; + struct DLLCLIENT DroppedFile { + DroppedFile(const std::string &fullPath); + std::string fullPath; + std::string fileName; + }; using pragma::RenderContext::DrawFrame; virtual void SetAssetMultiThreadedLoadingEnabled(bool enabled) override; @@ -109,6 +114,7 @@ class DLLCLIENT CEngine : public Engine, public pragma::RenderContext { virtual void StartDefaultGame(const std::string &map) override; virtual void EndGame() override; virtual bool IsClientConnected() override; + const std::vector &GetDroppedFiles() const; bool IsWindowFocused() const; bool IsValidAxisInput(float axisInput) const; void GetMappedKeys(const std::string &cmd, std::vector &keys, uint32_t maxKeys = 1); @@ -156,6 +162,8 @@ class DLLCLIENT CEngine : public Engine, public pragma::RenderContext { void ScrollInput(prosper::Window &window, Vector2 offset); void OnWindowFocusChanged(prosper::Window &window, bool bFocus); void OnFilesDropped(prosper::Window &window, std::vector &files); + void OnDragEnter(prosper::Window &window); + void OnDragExit(prosper::Window &window); void OnWindowResized(prosper::Window &window, Vector2i size); bool OnWindowShouldClose(prosper::Window &window); void JoystickButtonInput(prosper::Window &window, const GLFW::Joystick &joystick, uint32_t key, GLFW::KeyState state); @@ -279,6 +287,8 @@ class DLLCLIENT CEngine : public Engine, public pragma::RenderContext { std::vector> m_gpuTimers; std::vector m_gpuExecTimes {}; + std::vector m_droppedFiles = {}; // Only contains files during OnFilesDropped-call + virtual void Think() override; virtual void Tick() override; void Input(int key, GLFW::KeyState state, GLFW::Modifier mods = {}, float magnitude = 1.f); diff --git a/core/client/include/pragma/clientstate/clientstate.h b/core/client/include/pragma/clientstate/clientstate.h index 28b842d1f..c4682f255 100644 --- a/core/client/include/pragma/clientstate/clientstate.h +++ b/core/client/include/pragma/clientstate/clientstate.h @@ -239,6 +239,8 @@ class DLLCLIENT ClientState : public NetworkState { Bool CharInput(unsigned int c); Bool ScrollInput(Vector2 offset); void OnFilesDropped(std::vector &files); + void OnDragEnter(prosper::Window &window); + void OnDragExit(prosper::Window &window); bool OnWindowShouldClose(prosper::Window &window); void OnPreedit(prosper::Window &window, const util::Utf8String &preeditString, const std::vector &blockSizes, int focusedBlock, int caret); void OnIMEStatusChanged(prosper::Window &window, bool imeEnabled); diff --git a/core/client/include/pragma/game/c_game.h b/core/client/include/pragma/game/c_game.h index f665030a2..f3ccc8e96 100644 --- a/core/client/include/pragma/game/c_game.h +++ b/core/client/include/pragma/game/c_game.h @@ -109,11 +109,6 @@ namespace util { #pragma warning(disable : 4251) class DLLCLIENT CGame : public Game { public: - struct DLLCLIENT DroppedFile { - DroppedFile(const std::string &fullPath); - std::string fullPath; - std::string fileName; - }; struct GlobalRenderSettingsBufferData { GlobalRenderSettingsBufferData(); std::shared_ptr debugBuffer = nullptr; @@ -224,6 +219,8 @@ class DLLCLIENT CGame : public Game { Bool CharInput(unsigned int c); Bool ScrollInput(Vector2 offset); void OnFilesDropped(std::vector &files); + void OnDragEnter(prosper::Window &window); + void OnDragExit(prosper::Window &window); bool OnWindowShouldClose(prosper::Window &window); void OnPreedit(prosper::Window &window, const util::Utf8String &preeditString, const std::vector &blockSizes, int focusedBlock, int caret); void OnIMEStatusChanged(prosper::Window &window, bool imeEnabled); @@ -288,7 +285,6 @@ class DLLCLIENT CGame : public Game { void RenderDebugPhysics(std::shared_ptr &drawCmd, pragma::CCameraComponent &cam); using Game::LoadNavMesh; - const std::vector &GetDroppedFiles() const; void OnReceivedRegisterNetEvent(NetPacket &packet); virtual pragma::NetEventId FindNetEvent(const std::string &name) const override; @@ -454,8 +450,6 @@ class DLLCLIENT CGame : public Game { CallbackHandle m_cbProfilingHandle = {}; std::unique_ptr> m_profilingStageManager; - std::vector m_droppedFiles = {}; // Only contains files during OnFilesDropped-call - struct DLLCLIENT MessagePacketTracker { MessagePacketTracker(); uint8_t lastInMessageId; diff --git a/core/client/include/pragma/gui/wiluabase.h b/core/client/include/pragma/gui/wiluabase.h index 0a78c0126..34965bdf2 100644 --- a/core/client/include/pragma/gui/wiluabase.h +++ b/core/client/include/pragma/gui/wiluabase.h @@ -58,6 +58,9 @@ class DLLCLIENT WILuaBase : public WIBase, public LuaObjectBase { virtual void Render(const DrawInfo &drawInfo, wgui::DrawState &drawState, const Mat4 &matDraw, const Vector2 &scale = {1.f, 1.f}, uint32_t testStencilLevel = 0u, wgui::StencilPipeline stencilPipeline = wgui::StencilPipeline::Test) override; virtual void OnCursorEntered() override; virtual void OnCursorExited() override; + virtual void OnFileDragEntered() override; + virtual void OnFileDragExited() override; + virtual util::EventReply OnFilesDropped(const std::vector &files) override; virtual void OnFocusGained() override; virtual void OnFocusKilled() override; virtual void OnRemove() override; @@ -113,6 +116,15 @@ class DLLCLIENT WILuaBase : public WIBase, public LuaObjectBase { void Lua_OnCursorExited(); static void default_OnCursorExited(lua_State *l, WILuaBase &hElement); + void Lua_OnFileDragEntered(); + static void default_OnFileDragEntered(lua_State *l, WILuaBase &hElement); + + void Lua_OnFileDragExited(); + static void default_OnFileDragExited(lua_State *l, WILuaBase &hElement); + + void Lua_OnFilesDropped(const std::vector &files); + static void default_OnFilesDropped(lua_State *l, WILuaBase &hElement, const std::vector &files); + void Lua_OnFocusGained(); static void default_OnFocusGained(lua_State *l, WILuaBase &hElement); diff --git a/core/client/src/c_engine.cpp b/core/client/src/c_engine.cpp index 74dccc14d..9d78af451 100644 --- a/core/client/src/c_engine.cpp +++ b/core/client/src/c_engine.cpp @@ -515,12 +515,56 @@ void CEngine::OnWindowFocusChanged(prosper::Window &window, bool bFocused) if(client != nullptr) client->UpdateSoundVolume(); } + +// Usually we don't allow opening external files, but we make an exception for files that have been dropped into Pragma. +static std::unordered_map g_droppedFiles; +namespace pragma { + DLLCLIENT const std::unordered_map &get_dropped_files() { return g_droppedFiles; } +}; +const std::vector &CEngine::GetDroppedFiles() const { return m_droppedFiles; } void CEngine::OnFilesDropped(prosper::Window &window, std::vector &files) { if(client == nullptr) return; + + m_droppedFiles.reserve(files.size()); + for(auto &f : files) { + if(FileManager::IsSystemFile(f) == true) { + m_droppedFiles.push_back(DroppedFile {f}); + auto path = util::Path::CreateFile(f).GetString(); + ustring::to_lower(path); + g_droppedFiles.insert(std::make_pair(ufile::get_file_from_filename(path), path)); + } + } + util::ScopeGuard g {[this]() { + m_droppedFiles.clear(); + m_droppedFiles.shrink_to_fit(); + }}; + + std::vector droppedFileNames; + droppedFileNames.reserve(m_droppedFiles.size()); + for(auto &f : m_droppedFiles) + droppedFileNames.push_back(f.fileName); + if(WGUI::GetInstance().HandleFileDrop(window, droppedFileNames)) + return; client->OnFilesDropped(files); } +void CEngine::OnDragEnter(prosper::Window &window) +{ + if(client == nullptr) + return; + if(WGUI::GetInstance().HandleFileDragEnter(window)) + return; + client->OnDragEnter(window); +} +void CEngine::OnDragExit(prosper::Window &window) +{ + if(client == nullptr) + return; + if(WGUI::GetInstance().HandleFileDragExit(window)) + return; + client->OnDragExit(window); +} bool CEngine::OnWindowShouldClose(prosper::Window &window) { if(client == nullptr) @@ -1022,6 +1066,7 @@ void CEngine::SetGPUProfilingEnabled(bool bEnabled) ++it; } } + std::shared_ptr CEngine::CreateWindow(prosper::WindowSettings &settings) { if(settings.width == 0 || settings.height == 0) @@ -1058,6 +1103,8 @@ void CEngine::InitializeWindowInputCallbacks(prosper::Window &window) window->SetScrollCallback([this, &window](GLFW::Window &glfwWindow, Vector2 offset) mutable { ScrollInput(window, offset); }); window->SetFocusCallback([this, &window](GLFW::Window &glfwWindow, bool bFocused) mutable { OnWindowFocusChanged(window, bFocused); }); window->SetDropCallback([this, &window](GLFW::Window &glfwWindow, std::vector &files) mutable { OnFilesDropped(window, files); }); + window->SetDragEnterCallback([this, &window](GLFW::Window &glfwWindow) mutable { OnDragEnter(window); }); + window->SetDragExitCallback([this, &window](GLFW::Window &glfwWindow) mutable { OnDragExit(window); }); window->SetOnShouldCloseCallback([this, &window](GLFW::Window &glfwWindow) -> bool { return OnWindowShouldClose(window); }); window->SetPreeditCallback([this, &window](GLFW::Window &glfwWindow, int preedit_count, unsigned int *preedit_string, int block_count, int *block_sizes, int focused_block, int caret) { std::vector istr; @@ -1771,6 +1818,8 @@ uint32_t CEngine::DoClearUnusedAssets(pragma::asset::Type type) const return n; } +CEngine::DroppedFile::DroppedFile(const std::string &_fullPath) : fullPath(_fullPath), fileName(ufile::get_file_from_filename(_fullPath)) {} + REGISTER_CONVAR_CALLBACK_CL(cl_render_monitor, [](NetworkState *, const ConVar &, int32_t, int32_t monitor) { auto monitors = GLFW::get_monitors(); if(monitor < monitors.size() && monitor >= 0) diff --git a/core/client/src/game/c_game_input.cpp b/core/client/src/game/c_game_input.cpp index d939d21e0..7035adb05 100644 --- a/core/client/src/game/c_game_input.cpp +++ b/core/client/src/game/c_game_input.cpp @@ -14,6 +14,9 @@ #include #include #include + +extern DLLCLIENT CEngine *c_engine; + Bool CGame::RawMouseInput(GLFW::MouseButton button, GLFW::KeyState state, GLFW::Modifier mods) { if(m_inputCallbackHandler.CallLuaEvents("OnMouseInput", static_cast(button), static_cast(state), static_cast(mods)) == util::EventReply::Handled) @@ -69,13 +72,6 @@ Bool CGame::ScrollInput(Vector2 offset) return true; } -CGame::DroppedFile::DroppedFile(const std::string &_fullPath) : fullPath(_fullPath), fileName(ufile::get_file_from_filename(_fullPath)) {} - -// Usually we don't allow opening external files, but we make an exception for files that have been dropped into Pragma. -static std::unordered_map g_droppedFiles; -namespace pragma { - DLLCLIENT const std::unordered_map &get_dropped_files() { return g_droppedFiles; } -}; bool CGame::OnWindowShouldClose(prosper::Window &window) { bool ret = true; @@ -87,29 +83,18 @@ void CGame::OnPreedit(prosper::Window &window, const util::Utf8String &preeditSt CallLuaCallbacks, int, int>("OnPreedit", &window, preeditString.cpp_str(), blockSizes, focusedBlock, caret); } void CGame::OnIMEStatusChanged(prosper::Window &window, bool imeEnabled) { CallLuaCallbacks("OnIMEStatusChanged", &window, imeEnabled); } +void CGame::OnDragEnter(prosper::Window &window) { CallLuaCallbacks("OnWindowDragEnter", &window); } +void CGame::OnDragExit(prosper::Window &window) { CallLuaCallbacks("OnWindowDragExit", &window); } void CGame::OnFilesDropped(std::vector &files) { - m_droppedFiles.reserve(files.size()); - for(auto &f : files) { - if(FileManager::IsSystemFile(f) == true) { - m_droppedFiles.push_back(DroppedFile {f}); - auto path = util::Path::CreateFile(f).GetString(); - ustring::to_lower(path); - g_droppedFiles.insert(std::make_pair(ufile::get_file_from_filename(path), path)); - } - } - util::ScopeGuard g {[this]() { - m_droppedFiles.clear(); - m_droppedFiles.shrink_to_fit(); - }}; auto *l = GetLuaState(); auto t = Lua::CreateTable(l); - for(auto i = decltype(m_droppedFiles.size()) {0}; i < m_droppedFiles.size(); ++i) { + auto &droppedFiles = c_engine->GetDroppedFiles(); + for(auto i = decltype(droppedFiles.size()) {0}; i < droppedFiles.size(); ++i) { Lua::PushInt(l, i + 1); - Lua::PushString(l, m_droppedFiles[i].fileName); + Lua::PushString(l, droppedFiles[i].fileName); Lua::SetTableValue(l, t); } auto o = luabind::object(luabind::from_stack(l, -1)); CallLuaCallbacks("OnFilesDropped", o); } -const std::vector &CGame::GetDroppedFiles() const { return m_droppedFiles; } diff --git a/core/client/src/gui/wiluabase.cpp b/core/client/src/gui/wiluabase.cpp index 0ba65a66c..23e2024e6 100644 --- a/core/client/src/gui/wiluabase.cpp +++ b/core/client/src/gui/wiluabase.cpp @@ -196,6 +196,23 @@ void WILuaBase::OnCursorExited() WIBase::OnCursorExited(); CallLuaMember("OnCursorExited"); } +void WILuaBase::OnFileDragEntered() +{ + WIBase::OnFileDragEntered(); + CallLuaMember("OnFileDragEntered"); +} +void WILuaBase::OnFileDragExited() +{ + WIBase::OnFileDragExited(); + CallLuaMember("OnFileDragExited"); +} +util::EventReply WILuaBase::OnFilesDropped(const std::vector &files) +{ + WIBase::OnFilesDropped(files); + uint32_t reply = umath::to_integral(util::EventReply::Unhandled); + CallLuaMember>("OnFilesDropped", &reply, files); + return static_cast(reply); +} void WILuaBase::OnFocusGained() { WIBase::OnFocusGained(); @@ -259,6 +276,15 @@ void WILuaBase::default_OnCursorEntered(lua_State *, WILuaBase &) {} void WILuaBase::Lua_OnCursorExited() {} void WILuaBase::default_OnCursorExited(lua_State *, WILuaBase &) {} +void WILuaBase::Lua_OnFileDragEntered() {} +void WILuaBase::default_OnFileDragEntered(lua_State *l, WILuaBase &hElement) {} + +void WILuaBase::Lua_OnFileDragExited() {} +void WILuaBase::default_OnFileDragExited(lua_State *l, WILuaBase &hElement) {} + +void WILuaBase::Lua_OnFilesDropped(const std::vector &files) {} +void WILuaBase::default_OnFilesDropped(lua_State *l, WILuaBase &hElement, const std::vector &files) {} + void WILuaBase::Lua_OnFocusGained() {} void WILuaBase::default_OnFocusGained(lua_State *, WILuaBase &) {} diff --git a/core/client/src/lua/c_library.cpp b/core/client/src/lua/c_library.cpp index bd35be08a..d140958f9 100644 --- a/core/client/src/lua/c_library.cpp +++ b/core/client/src/lua/c_library.cpp @@ -86,7 +86,7 @@ static int log(lua_State *l, spdlog::level::level_enum logLevel) { auto &el = Lua::Check<::WIBase>(l, 1); const char *msg = Lua::CheckString(l, 2); - std::string loggerName = "ui_" +el.GetClass(); + std::string loggerName = "ui_" + el.GetClass(); int32_t argOffset = 2; auto n = lua_gettop(l) - argOffset; /* number of arguments */ switch(n) { @@ -343,6 +343,9 @@ static void register_gui(Lua::Interface &lua) wiBaseWIElement.def("OnDraw", &WILuaBase::Lua_Render, &WILuaBase::default_Render); wiBaseWIElement.def("OnCursorEntered", &WILuaBase::Lua_OnCursorEntered, &WILuaBase::default_OnCursorEntered); wiBaseWIElement.def("OnCursorExited", &WILuaBase::Lua_OnCursorExited, &WILuaBase::default_OnCursorExited); + wiBaseWIElement.def("OnFileDragEntered", &WILuaBase::Lua_OnFileDragEntered, &WILuaBase::default_OnFileDragEntered); + wiBaseWIElement.def("OnFileDragExited", &WILuaBase::Lua_OnFileDragExited, &WILuaBase::default_OnFileDragExited); + wiBaseWIElement.def("OnFilesDropped", &WILuaBase::Lua_OnFilesDropped, &WILuaBase::default_OnFilesDropped); wiBaseWIElement.def("OnFocusGained", &WILuaBase::Lua_OnFocusGained, &WILuaBase::default_OnFocusGained); wiBaseWIElement.def("OnFocusKilled", &WILuaBase::Lua_OnFocusKilled, &WILuaBase::default_OnFocusKilled); wiBaseWIElement.def("OnRemove", &WILuaBase::Lua_OnRemove, &WILuaBase::default_OnRemove); diff --git a/core/client/src/lua/classes/c_lwibase.cpp b/core/client/src/lua/classes/c_lwibase.cpp index 928b3dec4..eacaaf825 100644 --- a/core/client/src/lua/classes/c_lwibase.cpp +++ b/core/client/src/lua/classes/c_lwibase.cpp @@ -544,6 +544,10 @@ void Lua::WIBase::register_class(luabind::class_<::WIBase> &classDef) "ClampToVisibleBounds", +[](const ::WIBase &el, Vector2i &pos, Vector2i &size) { el.ClampToVisibleBounds(pos, size); }); classDef.def( "DebugPrintHierarchy", +[](const ::WIBase &el) { debug_print_hierarchy(el); }); + classDef.def("IsFileHovering", &::WIBase::IsFileHovering); + classDef.def("SetFileHovering", &::WIBase::SetFileHovering); + classDef.def("GetFileDropInputEnabled", &::WIBase::GetFileDropInputEnabled); + classDef.def("SetFileDropInputEnabled", &::WIBase::SetFileDropInputEnabled); auto defDrawInfo = luabind::class_<::WIBase::DrawInfo>("DrawInfo"); defDrawInfo.add_static_constant("FLAG_NONE", umath::to_integral(::WIBase::DrawInfo::Flags::None)); diff --git a/core/client/src/lua/libraries/c_input.cpp b/core/client/src/lua/libraries/c_input.cpp index 510850fda..6b0908d91 100644 --- a/core/client/src/lua/libraries/c_input.cpp +++ b/core/client/src/lua/libraries/c_input.cpp @@ -72,6 +72,20 @@ void ClientState::OnFilesDropped(std::vector &files) return; game->OnFilesDropped(files); } +void ClientState::OnDragEnter(prosper::Window &window) +{ + auto *game = GetGameState(); + if(game == nullptr) + return; + game->OnDragEnter(window); +} +void ClientState::OnDragExit(prosper::Window &window) +{ + auto *game = GetGameState(); + if(game == nullptr) + return; + game->OnDragExit(window); +} bool ClientState::OnWindowShouldClose(prosper::Window &window) { auto *game = GetGameState(); diff --git a/core/client/src/lua/libraries/c_lgame.cpp b/core/client/src/lua/libraries/c_lgame.cpp index bb334bdc2..9f147eac3 100644 --- a/core/client/src/lua/libraries/c_lgame.cpp +++ b/core/client/src/lua/libraries/c_lgame.cpp @@ -816,12 +816,12 @@ namespace pragma { }; int Lua::game::Client::open_dropped_file(lua_State *l) { - auto &droppedFiles = c_game->GetDroppedFiles(); - const CGame::DroppedFile *pf = nullptr; + auto &droppedFiles = c_engine->GetDroppedFiles(); + const CEngine::DroppedFile *pf = nullptr; std::optional fullPath {}; if(Lua::IsString(l, 1)) { auto *fileName = Lua::CheckString(l, 1); - auto it = std::find_if(droppedFiles.begin(), droppedFiles.end(), [&fileName](const CGame::DroppedFile &f) { return (f.fileName == fileName) ? true : false; }); + auto it = std::find_if(droppedFiles.begin(), droppedFiles.end(), [&fileName](const CEngine::DroppedFile &f) { return (f.fileName == fileName) ? true : false; }); if(it == droppedFiles.end()) { auto &gDroppedFiles = pragma::get_dropped_files(); auto npath = util::Path::CreateFile(fileName).GetString(); From 5a3f748ac9ec8406b385c2408e14d304c13ed1bc Mon Sep 17 00:00:00 2001 From: Silverlan Date: Sun, 6 Oct 2024 07:31:36 +0200 Subject: [PATCH 05/15] feat(lua): add gui.Element:SetIgnoreParentAlpha, :ShouldIgnoreParentAlpha --- core/client/src/lua/classes/c_lwibase.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/client/src/lua/classes/c_lwibase.cpp b/core/client/src/lua/classes/c_lwibase.cpp index eacaaf825..6bf676896 100644 --- a/core/client/src/lua/classes/c_lwibase.cpp +++ b/core/client/src/lua/classes/c_lwibase.cpp @@ -223,6 +223,8 @@ void Lua::WIBase::register_class(luabind::class_<::WIBase> &classDef) classDef.def("SetSkinCallbacksEnabled", &::WIBase::SetSkinCallbacksEnabled); classDef.def("Remove", &::WIBase::Remove); classDef.def("RemoveSafely", &::WIBase::RemoveSafely); + classDef.def("SetIgnoreParentAlpha", &::WIBase::SetIgnoreParentAlpha); + classDef.def("ShouldIgnoreParentAlpha", &::WIBase::ShouldIgnoreParentAlpha); classDef.def("SetZPos", &::WIBase::SetZPos); classDef.def("GetZPos", &::WIBase::GetZPos); classDef.def("HasFocus", &::WIBase::HasFocus); From 468fa3bfa5e3686dc28539ed062ec7fafe0d74a2 Mon Sep 17 00:00:00 2001 From: Silverlan Date: Sun, 6 Oct 2024 07:32:35 +0200 Subject: [PATCH 06/15] feat: add support for drag-and-drop with directories --- core/client/include/pragma/c_engine.h | 2 +- core/client/src/c_engine.cpp | 41 +++++++++++++++++++++------ 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/core/client/include/pragma/c_engine.h b/core/client/include/pragma/c_engine.h index a025d263a..9eb57e923 100644 --- a/core/client/include/pragma/c_engine.h +++ b/core/client/include/pragma/c_engine.h @@ -75,7 +75,7 @@ class DLLCLIENT CEngine : public Engine, public pragma::RenderContext { Count }; struct DLLCLIENT DroppedFile { - DroppedFile(const std::string &fullPath); + DroppedFile(const std::string &rootPath, const std::string &fullPath); std::string fullPath; std::string fileName; }; diff --git a/core/client/src/c_engine.cpp b/core/client/src/c_engine.cpp index 9d78af451..dd22651a4 100644 --- a/core/client/src/c_engine.cpp +++ b/core/client/src/c_engine.cpp @@ -528,14 +528,34 @@ void CEngine::OnFilesDropped(prosper::Window &window, std::vector & return; m_droppedFiles.reserve(files.size()); - for(auto &f : files) { - if(FileManager::IsSystemFile(f) == true) { - m_droppedFiles.push_back(DroppedFile {f}); - auto path = util::Path::CreateFile(f).GetString(); - ustring::to_lower(path); - g_droppedFiles.insert(std::make_pair(ufile::get_file_from_filename(path), path)); + auto addFile = [this](const std::string &fileName, const std::string &rootPath) { + m_droppedFiles.push_back(DroppedFile {rootPath, fileName}); + auto path = util::Path::CreateFile(fileName).GetString(); + ustring::to_lower(path); + g_droppedFiles.insert(std::make_pair(ufile::get_file_from_filename(path), path)); + }; + std::function &, const std::optional &)> addFiles = nullptr; + addFiles = [this, &addFile, &addFiles](const std::vector &files, const std::optional &rootPath) { + for(auto &f : files) { + if(filemanager::is_system_file(f)) + addFile(f, rootPath ? *rootPath : ufile::get_path_from_filename(f)); + else if(filemanager::is_system_dir(f)) { + auto subRootPath = rootPath; + if(!subRootPath) + subRootPath = f; + std::vector subFiles; + std::vector subDirs; + filemanager::find_system_files(f + "/*", &subFiles, &subDirs); + for(auto &fileName : subFiles) + addFile(util::Path::CreateFile(f, fileName).GetString(), *subRootPath); + for(auto &subDir : subDirs) + subDir = util::Path::CreatePath(f, subDir).GetString(); + addFiles(subDirs, subRootPath); + } } - } + }; + addFiles(files, {}); + util::ScopeGuard g {[this]() { m_droppedFiles.clear(); m_droppedFiles.shrink_to_fit(); @@ -1818,7 +1838,12 @@ uint32_t CEngine::DoClearUnusedAssets(pragma::asset::Type type) const return n; } -CEngine::DroppedFile::DroppedFile(const std::string &_fullPath) : fullPath(_fullPath), fileName(ufile::get_file_from_filename(_fullPath)) {} +CEngine::DroppedFile::DroppedFile(const std::string &rootPath, const std::string &_fullPath) : fullPath(_fullPath) +{ + auto path = util::Path::CreateFile(fullPath); + path.MakeRelative(rootPath); + fileName = path.GetString(); +} REGISTER_CONVAR_CALLBACK_CL(cl_render_monitor, [](NetworkState *, const ConVar &, int32_t, int32_t monitor) { auto monitors = GLFW::get_monitors(); From 981e48a10288220df5263f129b7ee64701f19b3a Mon Sep 17 00:00:00 2001 From: Silverlan Date: Sun, 6 Oct 2024 07:32:52 +0200 Subject: [PATCH 07/15] build: update submodules "iglfw", "sharedutils", "wgui" --- build_scripts/scripts/external_libs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build_scripts/scripts/external_libs.py b/build_scripts/scripts/external_libs.py index cd72cff07..e3949aa69 100644 --- a/build_scripts/scripts/external_libs.py +++ b/build_scripts/scripts/external_libs.py @@ -10,14 +10,14 @@ os.chdir(external_libs_dir) get_submodule("alsoundsystem","https://github.com/Silverlan/alsoundsystem.git","7daad8c34ab5000fc92b6f326b08fdc81b984cfe") get_submodule("datasystem","https://github.com/Silverlan/datasystem.git","7642296ea0f8316957e1123034e87034294f8b46") -get_submodule("iglfw","https://github.com/Silverlan/iglfw.git","e3a165cdac0ec9a2b3ced4becc0b7beeb5cf5508") +get_submodule("iglfw","https://github.com/Silverlan/iglfw.git","0a32680dcf085f4541252110229439125e35c3c6") get_submodule("luasystem","https://github.com/Silverlan/luasystem.git","b36cfa22c79906270dec09a0d882e92c07a12104") get_submodule("materialsystem","https://github.com/Silverlan/materialsystem.git","b5ef761c20f5f6afa573bee079340d6da4db8bd2") get_submodule("mathutil","https://github.com/Silverlan/mathutil.git","90a6cbb229cf3b2e7af1eb9bc58b3ff22db5a611") get_submodule("networkmanager","https://github.com/Silverlan/networkmanager.git","981bc5809c1a768267ddace778205e1be0262730") get_submodule("panima","https://github.com/Silverlan/panima.git","08492a7bd8b214ff8472ae3288a32020aff1f60e") get_submodule("prosper","https://github.com/Silverlan/prosper.git","8e3cf2412f90842f1ab5b10427526d21ab97eba9") -get_submodule("sharedutils","https://github.com/Silverlan/sharedutils.git","af5493d8be32d29a7b131fb6b903a32222358fa4") +get_submodule("sharedutils","https://github.com/Silverlan/sharedutils.git","6d0970800dd2c937437c58f4c3fc0a4251813ae2") get_submodule("util_bsp","https://github.com/Silverlan/util_bsp.git","7c49f7b9a59b1e9776a355881aeecede8a8f9be3") get_submodule("util_formatted_text","https://github.com/Silverlan/util_formatted_text.git","3fbb26580f732d0297cd6738f28636f6a1fd1f0c") get_submodule("util_image","https://github.com/Silverlan/util_image.git","bc1af9d7a0e4e4e51550a4730d65e072ae97d592") @@ -33,7 +33,7 @@ get_submodule("util_vmf","https://github.com/Silverlan/util_vmf.git","3080ba05280ae5b0a76ef283870864c16d1c7826") get_submodule("util_zip","https://github.com/Silverlan/util_zip.git","d9bf05a5cbf71bf53f9fbea82c7352f870989ed1") get_submodule("vfilesystem","https://github.com/Silverlan/vfilesystem.git","25c839e313b1bb1c2b4dee56c4a0298c53f546b4") -get_submodule("wgui","https://github.com/Silverlan/wgui.git","82e5cbce64d36d8008545cb9786b163f1c880039") +get_submodule("wgui","https://github.com/Silverlan/wgui.git","8f79129fe88d14a34fb6fb4aa2eca5f02afe0305") get_submodule("util_unicode","https://github.com/Silverlan/util_unicode.git","344d62ac0b06db9d970b08e9cf3a1d039ed6b28a") get_submodule("cppbezierfit","https://github.com/Silverlan/cppbezierfit.git","eb08f35ad74c1124f3cd4ef3a8958cded6a04b0e") From 694e8f6e205802ce035581d38f9d9cb1866bf66c Mon Sep 17 00:00:00 2001 From: Silverlan Date: Sun, 6 Oct 2024 15:34:43 +0200 Subject: [PATCH 08/15] build: update submodule "pr_unirender" --- build_scripts/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_scripts/build.py b/build_scripts/build.py index 89c46ef23..81e113e46 100644 --- a/build_scripts/build.py +++ b/build_scripts/build.py @@ -862,7 +862,7 @@ def execbuildscript(filepath): ) add_pragma_module( name="pr_unirender", - commitSha="7356fb4ba517e999cf853e41f8ce79918e3307d2", + commitSha="7f7f629dd54204ca0eeaceeca96c4d110908db25", repositoryUrl="https://github.com/Silverlan/pr_cycles.git" ) add_pragma_module( From eff5859cd8027bc0a62ddc634570dce0c55982fb Mon Sep 17 00:00:00 2001 From: Silverlan Date: Sun, 6 Oct 2024 18:13:58 +0200 Subject: [PATCH 09/15] build: update submodules --- build_scripts/build.py | 8 ++++---- build_scripts/scripts/external_libs.py | 8 ++++---- build_scripts/scripts/modules.py | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build_scripts/build.py b/build_scripts/build.py index 81e113e46..3c3eb1321 100644 --- a/build_scripts/build.py +++ b/build_scripts/build.py @@ -825,17 +825,17 @@ def execbuildscript(filepath): if with_common_modules: add_pragma_module( name="pr_bullet", - commitSha="a64c52cf58dc667ae0c0a99ef4aa931e44f94e5e", + commitSha="be622341b5890ae2f8f1c97481ff52ddbd351cf0", repositoryUrl="https://github.com/Silverlan/pr_bullet.git" ) add_pragma_module( name="pr_audio_soloud", - commitSha="73ee6c707e47f41e06148c55aceae8eb43c34842", + commitSha="7d4361d289ff1527e4783cde65dd7e5852684975", repositoryUrl="https://github.com/Silverlan/pr_soloud.git" ) add_pragma_module( name="pr_audio_dummy", - commitSha="84e1249c296dfc6cf288c8262142170851286f48", + commitSha="1a806a1a7b2283bd8551d07e4f1d680499f68b90", repositoryUrl="https://github.com/Silverlan/pr_audio_dummy.git" ) add_pragma_module_prebuilt("Silverlan/pr_mount_external_prebuilt") @@ -891,7 +891,7 @@ def execbuildscript(filepath): if with_vr: add_pragma_module( name="pr_openvr", - commitSha="15b090a2c5c6e55cff146d6344bfb03347a3d1d4", + commitSha="2dd977344ebe8cd102cd24aa1ddcb34d696c7dda", repositoryUrl="https://github.com/Silverlan/pr_openvr.git" ) diff --git a/build_scripts/scripts/external_libs.py b/build_scripts/scripts/external_libs.py index e3949aa69..74f351ace 100644 --- a/build_scripts/scripts/external_libs.py +++ b/build_scripts/scripts/external_libs.py @@ -17,9 +17,9 @@ get_submodule("networkmanager","https://github.com/Silverlan/networkmanager.git","981bc5809c1a768267ddace778205e1be0262730") get_submodule("panima","https://github.com/Silverlan/panima.git","08492a7bd8b214ff8472ae3288a32020aff1f60e") get_submodule("prosper","https://github.com/Silverlan/prosper.git","8e3cf2412f90842f1ab5b10427526d21ab97eba9") -get_submodule("sharedutils","https://github.com/Silverlan/sharedutils.git","6d0970800dd2c937437c58f4c3fc0a4251813ae2") +get_submodule("sharedutils","https://github.com/Silverlan/sharedutils.git","cbfdabddc7bacbcb1c00bfaccda5c7b10a8fc912") get_submodule("util_bsp","https://github.com/Silverlan/util_bsp.git","7c49f7b9a59b1e9776a355881aeecede8a8f9be3") -get_submodule("util_formatted_text","https://github.com/Silverlan/util_formatted_text.git","3fbb26580f732d0297cd6738f28636f6a1fd1f0c") +get_submodule("util_formatted_text","https://github.com/Silverlan/util_formatted_text.git","c473a2bdc1ad84ef52d391226d6983ef3076958e") get_submodule("util_image","https://github.com/Silverlan/util_image.git","bc1af9d7a0e4e4e51550a4730d65e072ae97d592") get_submodule("util_pad","https://github.com/Silverlan/util_pad.git","49d78bd7725cc320fae67c6eff5c25524d1363c0") get_submodule("util_pragma_doc","https://github.com/Silverlan/util_pragma_doc.git","71b9593872633adafa8dada0797bdf4fabf74c4f") @@ -33,8 +33,8 @@ get_submodule("util_vmf","https://github.com/Silverlan/util_vmf.git","3080ba05280ae5b0a76ef283870864c16d1c7826") get_submodule("util_zip","https://github.com/Silverlan/util_zip.git","d9bf05a5cbf71bf53f9fbea82c7352f870989ed1") get_submodule("vfilesystem","https://github.com/Silverlan/vfilesystem.git","25c839e313b1bb1c2b4dee56c4a0298c53f546b4") -get_submodule("wgui","https://github.com/Silverlan/wgui.git","8f79129fe88d14a34fb6fb4aa2eca5f02afe0305") -get_submodule("util_unicode","https://github.com/Silverlan/util_unicode.git","344d62ac0b06db9d970b08e9cf3a1d039ed6b28a") +get_submodule("wgui","https://github.com/Silverlan/wgui.git","28f5feb6f72f472f77d15dc75f26e5c6672ca0ba") +get_submodule("util_unicode","https://github.com/Silverlan/util_unicode.git","70dfdefd2693c48a2d79124d5ea0ed99e4a454bf") get_submodule("cppbezierfit","https://github.com/Silverlan/cppbezierfit.git","eb08f35ad74c1124f3cd4ef3a8958cded6a04b0e") os.chdir(curDir) diff --git a/build_scripts/scripts/modules.py b/build_scripts/scripts/modules.py index c6c94d53c..814eda8f3 100644 --- a/build_scripts/scripts/modules.py +++ b/build_scripts/scripts/modules.py @@ -9,7 +9,7 @@ modules_dir = curDir +"/modules" os.chdir(modules_dir) get_submodule("interfaces","https://github.com/Silverlan/pragma_interfaces.git","48c1b84f2245324e90871924e4f606f846197818") -get_submodule("pr_audio_dummy","https://github.com/Silverlan/pr_audio_dummy.git","84e1249c296dfc6cf288c8262142170851286f48") +get_submodule("pr_audio_dummy","https://github.com/Silverlan/pr_audio_dummy.git","1a806a1a7b2283bd8551d07e4f1d680499f68b90") get_submodule("pr_curl","https://github.com/Silverlan/pr_curl.git","974c67cc76710809a9595fcfbc4167554799cd7f") get_submodule("pr_prosper_opengl","https://github.com/Silverlan/pr_prosper_opengl.git","4dcc3045f37da63456f2a3ddcf66490497b87106") get_submodule("pr_prosper_vulkan","https://github.com/Silverlan/pr_prosper_vulkan.git","f7416f9d24e79a6cdac2798d1d064c20816cbfee") From c55fd1b5c20231e50c8da336e096e036c86e8517 Mon Sep 17 00:00:00 2001 From: Silverlan Date: Sun, 6 Oct 2024 18:20:43 +0200 Subject: [PATCH 10/15] feat: update namespace --- .../client/include/pragma/asset/c_util_model.hpp | 2 +- .../entities/game/c_game_shadow_manager.hpp | 6 +++--- core/client/src/asset/c_gltf_writer.cpp | 10 +++++----- core/client/src/asset/c_util_model.cpp | 8 ++++---- core/client/src/audio/c_engine_sound.cpp | 4 ++-- .../liquid/c_liquid_surface_component.cpp | 4 ++-- .../entities/environment/lights/c_env_light.cpp | 12 ++++++------ .../lights/c_env_light_directional.cpp | 4 ++-- .../entities/environment/lights/c_env_shadow.cpp | 4 ++-- .../game/c_game_shadow_manager_renderer.cpp | 12 ++++++------ core/client/src/gui/debug/widebugshadowmap.cpp | 8 ++++---- core/client/src/lua/libraries/c_limport.cpp | 8 ++++---- .../occlusion_culling_handler.cpp | 10 +++++----- .../entities/environment/lights/env_light.h | 4 ++-- .../components/base_vehicle_component.cpp | 2 +- .../entities/environment/lights/env_light.cpp | 16 ++++++++-------- core/shared/src/lua/libraries/library.cpp | 6 +++--- core/shared/src/lua/libraries/limport.cpp | 2 +- core/shared/src/lua/libraries/lutil.cpp | 4 ++-- .../physics/phys_water_buoyancy_simulator.cpp | 2 +- 20 files changed, 64 insertions(+), 64 deletions(-) diff --git a/core/client/include/pragma/asset/c_util_model.hpp b/core/client/include/pragma/asset/c_util_model.hpp index a835a05a8..097b68973 100644 --- a/core/client/include/pragma/asset/c_util_model.hpp +++ b/core/client/include/pragma/asset/c_util_model.hpp @@ -45,7 +45,7 @@ namespace pragma::asset { bool fullExport = false; bool normalizeTextureNames = false; ImageFormat imageFormat = ImageFormat::DDS; - float scale = ::util::pragma::units_to_metres(1.f); + float scale = ::pragma::units_to_metres(1.f); bool generateAo = false; uint32_t aoResolution = 512; diff --git a/core/client/include/pragma/entities/game/c_game_shadow_manager.hpp b/core/client/include/pragma/entities/game/c_game_shadow_manager.hpp index a95e3536f..3d2e96657 100644 --- a/core/client/include/pragma/entities/game/c_game_shadow_manager.hpp +++ b/core/client/include/pragma/entities/game/c_game_shadow_manager.hpp @@ -24,7 +24,7 @@ namespace prosper { namespace Anvil { class DescriptorSet; }; -namespace util::pragma { +namespace pragma { enum class LightType : uint8_t; }; namespace pragma { @@ -54,11 +54,11 @@ namespace pragma { struct LightSourceData { std::shared_ptr drawCmd; pragma::CLightComponent *light; - util::pragma::LightType type; + pragma::LightType type; Vector3 position; float radius; }; - void RenderShadows(std::shared_ptr &drawCmd, pragma::CLightComponent &light, pragma::CLightComponent::ShadowMapType smType, util::pragma::LightType type, bool drawParticleShadows); + void RenderShadows(std::shared_ptr &drawCmd, pragma::CLightComponent &light, pragma::CLightComponent::ShadowMapType smType, pragma::LightType type, bool drawParticleShadows); bool UpdateShadowCasters(std::shared_ptr &drawCmd, pragma::CLightComponent &light, pragma::CLightComponent::ShadowMapType smType); void UpdateWorldShadowCasters(std::shared_ptr &drawCmd, pragma::CLightComponent &light); void UpdateEntityShadowCasters(std::shared_ptr &drawCmd, pragma::CLightComponent &light); diff --git a/core/client/src/asset/c_gltf_writer.cpp b/core/client/src/asset/c_gltf_writer.cpp index 56052af8e..be4191dc8 100644 --- a/core/client/src/asset/c_gltf_writer.cpp +++ b/core/client/src/asset/c_gltf_writer.cpp @@ -668,8 +668,8 @@ bool pragma::asset::GLTFWriter::Export(std::string &outErrMsg, const std::string // or something is wrong on this side. TODO: Compare the behavior with another application that supports glTF assets with camera data. camData.perspective.yfov = umath::deg_to_rad(cam.vFov); - camData.perspective.znear = util::pragma::units_to_metres(cam.zNear); - camData.perspective.zfar = util::pragma::units_to_metres(cam.zFar); + camData.perspective.znear = pragma::units_to_metres(cam.zNear); + camData.perspective.zfar = pragma::units_to_metres(cam.zFar); } } } @@ -732,9 +732,9 @@ bool pragma::asset::GLTFWriter::Export(std::string &outErrMsg, const std::string color /= colMax; intensity *= colMax; } - auto lightType = (lightSource.type == LightSource::Type::Spot) ? util::pragma::LightType::Spot : (lightSource.type == LightSource::Type::Directional) ? util::pragma::LightType::Directional : util::pragma::LightType::Point; - intensity = (lightType == util::pragma::LightType::Spot) ? ulighting::cycles::lumen_to_watt_spot(intensity, color, outerConeAngle) - : (lightType == util::pragma::LightType::Point) ? ulighting::cycles::lumen_to_watt_point(intensity, color) + auto lightType = (lightSource.type == LightSource::Type::Spot) ? pragma::LightType::Spot : (lightSource.type == LightSource::Type::Directional) ? pragma::LightType::Directional : pragma::LightType::Point; + intensity = (lightType == pragma::LightType::Spot) ? ulighting::cycles::lumen_to_watt_spot(intensity, color, outerConeAngle) + : (lightType == pragma::LightType::Point) ? ulighting::cycles::lumen_to_watt_point(intensity, color) : ulighting::cycles::lumen_to_watt_area(intensity, color); auto lightName = lightSource.name; diff --git a/core/client/src/asset/c_util_model.cpp b/core/client/src/asset/c_util_model.cpp index 8de2fd089..23388bfb3 100644 --- a/core/client/src/asset/c_util_model.cpp +++ b/core/client/src/asset/c_util_model.cpp @@ -268,7 +268,7 @@ struct OutputData { }; static std::optional import_model(ufile::IFile *optFile, const std::string &optFileName, std::string &outErrMsg, const util::Path &outputPath, bool importAsMap) { - auto scale = static_cast(util::pragma::metres_to_units(1.f)); + auto scale = static_cast(pragma::metres_to_units(1.f)); std::string fileName = optFileName; std::string absPathToFile; @@ -1308,8 +1308,8 @@ static std::optional import_model(ufile::IFile *optFile, const std:: ent->SetClassName("env_camera"); ent->SetKeyValue("fov", std::to_string(umath::rad_to_deg(cam.perspective.yfov))); - ent->SetKeyValue("farz", std::to_string(util::pragma::metres_to_units(cam.perspective.znear))); - ent->SetKeyValue("nearz", std::to_string(util::pragma::metres_to_units(cam.perspective.zfar))); + ent->SetKeyValue("farz", std::to_string(pragma::metres_to_units(cam.perspective.znear))); + ent->SetKeyValue("nearz", std::to_string(pragma::metres_to_units(cam.perspective.zfar))); ent->SetKeyValue("aspectRatio", std::to_string(cam.perspective.aspectRatio)); worldData->AddEntity(*ent); @@ -1521,7 +1521,7 @@ bool pragma::asset::export_map(const std::string &mapName, const ModelExportInfo auto radiusC = ent.GetComponent(); if(radiusC.valid()) - lightScene.range = util::pragma::units_to_metres(radiusC->GetRadius()); + lightScene.range = pragma::units_to_metres(radiusC->GetRadius()); auto spotC = ent.GetComponent(); if(spotC.valid()) { diff --git a/core/client/src/audio/c_engine_sound.cpp b/core/client/src/audio/c_engine_sound.cpp index 91a355a4c..3f19340ec 100644 --- a/core/client/src/audio/c_engine_sound.cpp +++ b/core/client/src/audio/c_engine_sound.cpp @@ -72,7 +72,7 @@ al::ISoundSystem *CEngine::InitializeSoundEngine() err = "Symbol 'initialize_audio_api' not found in library '" + location + "'!"; else { std::string errMsg; - auto success = fInitAudioAPI(util::pragma::units_to_metres(1.f), m_soundSystem, errMsg); + auto success = fInitAudioAPI(pragma::units_to_metres(1.f), m_soundSystem, errMsg); if(success == false) err = errMsg; } @@ -87,7 +87,7 @@ al::ISoundSystem *CEngine::InitializeSoundEngine() delete snd; }}; }); - al::set_world_scale(util::pragma::units_to_metres(1.0)); + al::set_world_scale(pragma::units_to_metres(1.0)); return m_soundSystem.get(); } diff --git a/core/client/src/entities/components/liquid/c_liquid_surface_component.cpp b/core/client/src/entities/components/liquid/c_liquid_surface_component.cpp index 5bdc6ee40..8570edb06 100644 --- a/core/client/src/entities/components/liquid/c_liquid_surface_component.cpp +++ b/core/client/src/entities/components/liquid/c_liquid_surface_component.cpp @@ -403,10 +403,10 @@ void CLiquidSurfaceComponent::InitializeWaterScene(const Vector3 &refPos, const fogEnabled = fogBlock->GetBool("enabled", true); fog.start = nearZ; if(fogBlock->GetFloat("start", &fog.start)) - fog.start = util::pragma::metres_to_units(fog.start); + fog.start = pragma::metres_to_units(fog.start); fog.end = farZ; if(fogBlock->GetFloat("end", &fog.end)) - fog.end = util::pragma::metres_to_units(fog.end); + fog.end = pragma::metres_to_units(fog.end); fog.density = fogBlock->GetFloat("density", 0.008f); Color color {68, 140, 200, 255}; if(fogBlock->GetColor("color", &color)) diff --git a/core/client/src/entities/environment/lights/c_env_light.cpp b/core/client/src/entities/environment/lights/c_env_light.cpp index b5b4295c5..bd3d6a629 100644 --- a/core/client/src/entities/environment/lights/c_env_light.cpp +++ b/core/client/src/entities/environment/lights/c_env_light.cpp @@ -451,9 +451,9 @@ void CLightComponent::UpdatePos() } void CLightComponent::UpdateDir() { - util::pragma::LightType lightType; + pragma::LightType lightType; GetLight(lightType); - if(lightType != util::pragma::LightType::Point) { + if(lightType != pragma::LightType::Point) { auto &rot = GetEntity().GetRotation(); auto dir = uquat::forward(rot); if(uvec::cmp(dir, reinterpret_cast(m_bufferData.direction)) == false) { @@ -690,16 +690,16 @@ void Console::commands::debug_light_sources(NetworkState *state, pragma::BasePla for(auto *l : lights) { Con::cout << "Light #" << lightId << ":" << Con::endl; Con::cout << "\tType: "; - auto type = util::pragma::LightType::Undefined; + auto type = pragma::LightType::Undefined; auto *pLight = l->GetLight(type); switch(type) { - case util::pragma::LightType::Directional: + case pragma::LightType::Directional: Con::cout << "Directional"; break; - case util::pragma::LightType::Point: + case pragma::LightType::Point: Con::cout << "Point"; break; - case util::pragma::LightType::Spot: + case pragma::LightType::Spot: Con::cout << "Spot"; break; default: diff --git a/core/client/src/entities/environment/lights/c_env_light_directional.cpp b/core/client/src/entities/environment/lights/c_env_light_directional.cpp index ca254f848..fcf79c99e 100644 --- a/core/client/src/entities/environment/lights/c_env_light_directional.cpp +++ b/core/client/src/entities/environment/lights/c_env_light_directional.cpp @@ -121,9 +121,9 @@ void CLightDirectionalComponent::Initialize() return util::EventReply::Unhandled; auto &ent = GetEntity(); auto pLightComponent = ent.GetComponent(); - auto type = util::pragma::LightType::Undefined; + auto type = pragma::LightType::Undefined; auto *pLight = pLightComponent.valid() ? pLightComponent->GetLight(type) : nullptr; - if(pLight == nullptr || type != util::pragma::LightType::Directional) + if(pLight == nullptr || type != pragma::LightType::Directional) return util::EventReply::Unhandled; auto pTrComponent = pLight->GetEntity().GetTransformComponent(); if(pTrComponent != nullptr) diff --git a/core/client/src/entities/environment/lights/c_env_shadow.cpp b/core/client/src/entities/environment/lights/c_env_shadow.cpp index c365343f8..a44fb90fd 100644 --- a/core/client/src/entities/environment/lights/c_env_shadow.cpp +++ b/core/client/src/entities/environment/lights/c_env_shadow.cpp @@ -461,9 +461,9 @@ void LightShadowRenderer::Render(const util::DrawSceneInfo &drawSceneInfo) auto rt = wpRt.lock(); m_hLight->SetShadowMapIndex(rt->index, pragma::CLightComponent::ShadowMapType::Dynamic); - //auto &shader = (type != util::pragma::LightType::Spot) ? static_cast(*m_shader.get()) : static_cast(*m_shaderSpot.get()); + //auto &shader = (type != pragma::LightType::Spot) ? static_cast(*m_shader.get()) : static_cast(*m_shaderSpot.get()); //pragma::ShaderShadowTransparent *shaderTransparent = nullptr; - //if(type != util::pragma::LightType::Spot) + //if(type != pragma::LightType::Spot) // shaderTransparent = static_cast(m_shaderTransparent.expired() == false ? m_shaderTransparent.get() : nullptr); //else // shaderTransparent = static_cast(m_shaderSpotTransparent.expired() == false ? m_shaderSpotTransparent.get() : nullptr); diff --git a/core/client/src/entities/game/c_game_shadow_manager_renderer.cpp b/core/client/src/entities/game/c_game_shadow_manager_renderer.cpp index 01b56204e..fe57db6f5 100644 --- a/core/client/src/entities/game/c_game_shadow_manager_renderer.cpp +++ b/core/client/src/entities/game/c_game_shadow_manager_renderer.cpp @@ -59,7 +59,7 @@ ShadowRenderer::ShadowRenderer() m_shadowCasters.push_back({}); auto &info = m_shadowCasters.back(); info.entity = &ent; - info.renderFlags = (m_lightSourceData.type == util::pragma::LightType::Point) ? renderFlags : 1u; // Spot-lights only have 1 layer, so we can ignore the flags + info.renderFlags = (m_lightSourceData.type == pragma::LightType::Point) ? renderFlags : 1u; // Spot-lights only have 1 layer, so we can ignore the flags auto pRenderComponent = ent.GetRenderComponent(); if(pRenderComponent) { // Make sure entity buffer data is up to date @@ -266,14 +266,14 @@ ShadowRenderer::RenderResultFlags ShadowRenderer::RenderShadows(std::shared_ptr< } static CVar cvParticleQuality = GetClientConVar("cl_render_particle_quality"); -void ShadowRenderer::RenderShadows(std::shared_ptr &drawCmd, pragma::CLightComponent &light, pragma::CLightComponent::ShadowMapType smType, util::pragma::LightType type, bool drawParticleShadows) +void ShadowRenderer::RenderShadows(std::shared_ptr &drawCmd, pragma::CLightComponent &light, pragma::CLightComponent::ShadowMapType smType, pragma::LightType type, bool drawParticleShadows) { auto hShadowMap = light.GetShadowMap(smType); if(hShadowMap.expired() || light.GetEffectiveShadowType() == pragma::BaseEnvLightComponent::ShadowType::None || UpdateShadowCasters(drawCmd, light, smType) == false) return; - auto &shader = (type != util::pragma::LightType::Spot) ? static_cast(*m_shader.get()) : static_cast(*m_shaderSpot.get()); + auto &shader = (type != pragma::LightType::Spot) ? static_cast(*m_shader.get()) : static_cast(*m_shaderSpot.get()); pragma::ShaderShadowTransparent *shaderTransparent = nullptr; - if(type != util::pragma::LightType::Spot) + if(type != pragma::LightType::Spot) shaderTransparent = static_cast(m_shaderTransparent.expired() == false ? m_shaderTransparent.get() : nullptr); else shaderTransparent = static_cast(m_shaderSpotTransparent.expired() == false ? m_shaderSpotTransparent.get() : nullptr); @@ -327,10 +327,10 @@ void ShadowRenderer::RenderShadows(std::shared_ptr &drawCmd, pragma::CLightComponent &light) { - auto type = util::pragma::LightType::Undefined; + auto type = pragma::LightType::Undefined; auto *pLight = light.GetLight(type); auto bDrawParticleShadows = (cvParticleQuality->GetInt() >= 3) ? true : false; - if(type == util::pragma::LightType::Directional) { + if(type == pragma::LightType::Directional) { RenderCSMShadows(drawCmd, static_cast(*pLight), bDrawParticleShadows); return; } diff --git a/core/client/src/gui/debug/widebugshadowmap.cpp b/core/client/src/gui/debug/widebugshadowmap.cpp index 9fd3fceac..231e141d0 100644 --- a/core/client/src/gui/debug/widebugshadowmap.cpp +++ b/core/client/src/gui/debug/widebugshadowmap.cpp @@ -52,7 +52,7 @@ void WIDebugShadowMap::DoUpdate() if(c_game == nullptr || m_lightHandle.expired()) return; auto &lightSource = *m_lightHandle; - auto type = util::pragma::LightType::Undefined; + auto type = pragma::LightType::Undefined; auto *pLight = lightSource.GetLight(type); if(pLight == nullptr) return; @@ -74,7 +74,7 @@ void WIDebugShadowMap::DoUpdate() auto pRadiusComponent = lightSource.GetEntity().GetComponent(); auto &wgui = WGUI::GetInstance(); switch(type) { - case util::pragma::LightType::Point: + case pragma::LightType::Point: { for(auto i = decltype(numLayers) {0}; i < numLayers; ++i) { auto *dt = wgui.Create(this); @@ -99,7 +99,7 @@ void WIDebugShadowMap::DoUpdate() } break; } - case util::pragma::LightType::Spot: + case pragma::LightType::Spot: { auto *dt = wgui.Create(this); dt->SetTexture(*depthTexture, barrierImageLayout, barrierImageLayout); @@ -110,7 +110,7 @@ void WIDebugShadowMap::DoUpdate() m_shadowMapImages.push_back(dt->GetHandle()); break; } - case util::pragma::LightType::Directional: + case pragma::LightType::Directional: { wLayer *= 0.5f; hLayer *= 0.5f; diff --git a/core/client/src/lua/libraries/c_limport.cpp b/core/client/src/lua/libraries/c_limport.cpp index 7332cc9ad..3dc6390a9 100644 --- a/core/client/src/lua/libraries/c_limport.cpp +++ b/core/client/src/lua/libraries/c_limport.cpp @@ -40,7 +40,7 @@ extern DLLCLIENT CGame *c_game; #if 0 static aiVector3D to_assimp_position(const Vector3 &pos) { - return aiVector3D{pos.x,pos.y,pos.z} *static_cast(util::pragma::units_to_metres(1.f)); + return aiVector3D{pos.x,pos.y,pos.z} *static_cast(pragma::units_to_metres(1.f)); } static aiVector3D to_assimp_normal(const Vector3 &dir) { @@ -95,7 +95,7 @@ static aiNode &add_node(aiNode &parentNode,uint32_t index,const std::string &nam { auto &t = ent.GetPose(); - auto scale = static_cast(util::pragma::units_to_metres(1.f)); + auto scale = static_cast(pragma::units_to_metres(1.f)); umath::ScaledTransform tScaled = t; tScaled.Scale(Vector3{scale,scale,scale}); @@ -202,8 +202,8 @@ int Lua::lib_export::export_scene(lua_State *l) auto &entCam = cam->GetEntity(); std::string name = add_node(*scene->mRootNode,camNodeIndex,"cam",cam->GetEntity()).mName.C_Str(); outCam->mAspect = cam->GetAspectRatio(); - outCam->mClipPlaneFar = ::util::pragma::units_to_metres(cam->GetFarZ()); - outCam->mClipPlaneNear = ::util::pragma::units_to_metres(cam->GetNearZ()); + outCam->mClipPlaneFar = ::pragma::units_to_metres(cam->GetFarZ()); + outCam->mClipPlaneNear = ::pragma::units_to_metres(cam->GetNearZ()); outCam->mHorizontalFOV = cam->GetFOVRad(); outCam->mName = name; } diff --git a/core/client/src/rendering/occlusion_culling/occlusion_culling_handler.cpp b/core/client/src/rendering/occlusion_culling/occlusion_culling_handler.cpp index 0d1f176f6..a4349c47a 100644 --- a/core/client/src/rendering/occlusion_culling/occlusion_culling_handler.cpp +++ b/core/client/src/rendering/occlusion_culling/occlusion_culling_handler.cpp @@ -108,9 +108,9 @@ void OcclusionCullingHandler::PerformCulling(pragma::CSceneComponent &scene, con auto &ent = light->GetEntity(); auto pToggleComponent = ent.GetComponent(); if(pToggleComponent.expired() || pToggleComponent->IsTurnedOn()) { - auto type = util::pragma::LightType::Undefined; + auto type = pragma::LightType::Undefined; auto *pLight = light->GetLight(type); - if(type == util::pragma::LightType::Directional) { + if(type == pragma::LightType::Directional) { lightsOut.insert(lightsOut.begin(), light); distances.push_back(0.f); } @@ -146,15 +146,15 @@ void OcclusionCullingHandler::PerformCulling(pragma::CSceneComponent &scene, con uint32_t numPointLights = 0; for(auto it = lightsOut.begin(); it != lightsOut.end();) { auto *light = *it; - auto type = util::pragma::LightType::Undefined; + auto type = pragma::LightType::Undefined; auto *pLight = light->GetLight(type); - if(type == util::pragma::LightType::Spot) { + if(type == pragma::LightType::Spot) { if(++numSpotLights > static_cast(GameLimits::MaxActiveShadowMaps)) it = lightsOut.erase(it); else ++it; } - else if(type == util::pragma::LightType::Point) { + else if(type == pragma::LightType::Point) { if(++numPointLights > static_cast(GameLimits::MaxActiveShadowCubeMaps)) it = lightsOut.erase(it); else diff --git a/core/shared/include/pragma/entities/environment/lights/env_light.h b/core/shared/include/pragma/entities/environment/lights/env_light.h index b240c187a..a899f078e 100644 --- a/core/shared/include/pragma/entities/environment/lights/env_light.h +++ b/core/shared/include/pragma/entities/environment/lights/env_light.h @@ -53,7 +53,7 @@ namespace pragma { void SetLight(BaseEnvLightPointComponent &light); void SetLight(BaseEnvLightDirectionalComponent &light); - BaseEntityComponent *GetLight(util::pragma::LightType &outType) const; + BaseEntityComponent *GetLight(pragma::LightType &outType) const; BaseEntityComponent *GetLight() const; virtual void Save(udm::LinkedPropertyWrapperArg udm) override; @@ -73,7 +73,7 @@ namespace pragma { virtual void InitializeLight(BaseEntityComponent &component); ComponentHandle m_hLight = {}; - util::pragma::LightType m_lightType = util::pragma::LightType::Undefined; + pragma::LightType m_lightType = pragma::LightType::Undefined; ShadowType m_shadowType = ShadowType::Full; LightFlags m_lightFlags = LightFlags::None; float m_falloffExponent = 1.f; diff --git a/core/shared/src/entities/components/base_vehicle_component.cpp b/core/shared/src/entities/components/base_vehicle_component.cpp index 76f61d2ad..9d5fa073b 100644 --- a/core/shared/src/entities/components/base_vehicle_component.cpp +++ b/core/shared/src/entities/components/base_vehicle_component.cpp @@ -135,7 +135,7 @@ float BaseVehicleComponent::GetSpeedKmh() const { if(m_physVehicle == nullptr) return 0.f; - return util::pragma::units_to_metres(m_physVehicle->GetForwardSpeed()) / 1'000.f * 60.f * 60.f; + return pragma::units_to_metres(m_physVehicle->GetForwardSpeed()) / 1'000.f * 60.f * 60.f; } void BaseVehicleComponent::InitializeSteeringWheel() diff --git a/core/shared/src/entities/environment/lights/env_light.cpp b/core/shared/src/entities/environment/lights/env_light.cpp index 964c2f056..7c474ff1a 100644 --- a/core/shared/src/entities/environment/lights/env_light.cpp +++ b/core/shared/src/entities/environment/lights/env_light.cpp @@ -133,26 +133,26 @@ void BaseEnvLightComponent::OnEntitySpawn() } void BaseEnvLightComponent::SetLight(BaseEnvLightSpotComponent &light) { - m_lightType = util::pragma::LightType::Spot; + m_lightType = pragma::LightType::Spot; if(m_lightIntensityType == LightIntensityType::Lux) SetLightIntensity(0.f, LightIntensityType::Lumen); InitializeLight(light); } void BaseEnvLightComponent::SetLight(BaseEnvLightPointComponent &light) { - m_lightType = util::pragma::LightType::Point; + m_lightType = pragma::LightType::Point; if(m_lightIntensityType == LightIntensityType::Lux) SetLightIntensity(0.f, LightIntensityType::Lumen); InitializeLight(light); } void BaseEnvLightComponent::SetLight(BaseEnvLightDirectionalComponent &light) { - m_lightType = util::pragma::LightType::Directional; + m_lightType = pragma::LightType::Directional; if(m_lightIntensityType != LightIntensityType::Lux) SetLightIntensity(0.f, LightIntensityType::Lux); InitializeLight(light); } -BaseEntityComponent *BaseEnvLightComponent::GetLight(util::pragma::LightType &outType) const +BaseEntityComponent *BaseEnvLightComponent::GetLight(pragma::LightType &outType) const { outType = m_lightType; return const_cast(m_hLight.get()); @@ -163,11 +163,11 @@ void BaseEnvLightComponent::SetLightIntensityType(LightIntensityType type) { m_l BaseEnvLightComponent::LightIntensityType BaseEnvLightComponent::GetLightIntensityType() const { return m_lightIntensityType; } void BaseEnvLightComponent::SetLightIntensity(float intensity, LightIntensityType type) { - if(m_lightType == util::pragma::LightType::Directional && type != LightIntensityType::Lux) { + if(m_lightType == pragma::LightType::Directional && type != LightIntensityType::Lux) { Con::cwar << "Attempted to use intensity type " << LightIntensityTypeToString(type) << " for a directional light source. This is not allowed!" << Con::endl; return; } - if((m_lightType == util::pragma::LightType::Point || m_lightType == util::pragma::LightType::Spot) && type == LightIntensityType::Lux) { + if((m_lightType == pragma::LightType::Point || m_lightType == pragma::LightType::Spot) && type == LightIntensityType::Lux) { Con::cwar << "Attempted to use intensity type " << LightIntensityTypeToString(type) << " for a point or spot light source. This is not allowed!" << Con::endl; return; } @@ -241,9 +241,9 @@ void BaseEnvLightComponent::SetFalloffExponent(float falloffExponent) { m_fallof float BaseEnvLightComponent::CalcDistanceFalloff(const Vector3 &lightPos, const Vector3 &point, std::optional radius) { auto dist = uvec::distance(point, lightPos); - dist = util::pragma::units_to_metres(dist); + dist = pragma::units_to_metres(dist); if(radius.has_value()) - return ulighting::calc_light_falloff(dist, util::pragma::units_to_metres(*radius)); + return ulighting::calc_light_falloff(dist, pragma::units_to_metres(*radius)); return ulighting::calc_light_falloff(dist); } diff --git a/core/shared/src/lua/libraries/library.cpp b/core/shared/src/lua/libraries/library.cpp index 2704c7461..f15b6dec5 100644 --- a/core/shared/src/lua/libraries/library.cpp +++ b/core/shared/src/lua/libraries/library.cpp @@ -291,7 +291,7 @@ void NetworkState::RegisterSharedLuaLibraries(Lua::Interface &lua) +[](const Vector3 &p, const Vector3 &d, float interocularDistance, float convergenceDistance) -> std::pair { auto pr = p; auto dr = d; - uvec::calc_spherical_stereo_transform(pr, dr, ::util::pragma::metres_to_units(interocularDistance), ::util::pragma::metres_to_units(convergenceDistance)); + uvec::calc_spherical_stereo_transform(pr, dr, ::pragma::metres_to_units(interocularDistance), ::pragma::metres_to_units(convergenceDistance)); return std::pair {pr, dr}; }), luabind::def( @@ -300,14 +300,14 @@ void NetworkState::RegisterSharedLuaLibraries(Lua::Interface &lua) pair { auto pr = p; auto dr = d; - uvec::calc_spherical_stereo_transform(pr, dr, ::util::pragma::metres_to_units(interocularDistance), ::util::pragma::metres_to_units(30.0f * 0.065f)); + uvec::calc_spherical_stereo_transform(pr, dr, ::pragma::metres_to_units(interocularDistance), ::pragma::metres_to_units(30.0f * 0.065f)); return std::pair {pr, dr}; }), luabind::def( "calc_spherical_stereo_transform", +[](const Vector3 &p, const Vector3 &d) -> std::pair { auto pr = p; auto dr = d; - uvec::calc_spherical_stereo_transform(pr, dr, ::util::pragma::metres_to_units(0.065f), ::util::pragma::metres_to_units(30.0f * 0.065f)); + uvec::calc_spherical_stereo_transform(pr, dr, ::pragma::metres_to_units(0.065f), ::pragma::metres_to_units(30.0f * 0.065f)); return std::pair {pr, dr}; })]; diff --git a/core/shared/src/lua/libraries/limport.cpp b/core/shared/src/lua/libraries/limport.cpp index f52cfb1cd..90836da0a 100644 --- a/core/shared/src/lua/libraries/limport.cpp +++ b/core/shared/src/lua/libraries/limport.cpp @@ -440,7 +440,7 @@ std::shared_ptr Lua::import::snapshot_to_assimp_scene(const pragma::Sce for(uint32_t vertIdx=0u;vertIdxverts.at(vertIdx); - aiMesh.mVertices[vertIdx] = aiVector3D{v.position.x,v.position.y,v.position.z} *static_cast(util::pragma::units_to_metres(1.0)); + aiMesh.mVertices[vertIdx] = aiVector3D{v.position.x,v.position.y,v.position.z} *static_cast(pragma::units_to_metres(1.0)); aiMesh.mNormals[vertIdx] = aiVector3D{v.normal.x,v.normal.y,v.normal.z}; aiMesh.mTextureCoords[0][vertIdx] = aiVector3D{v.uv.x,1.f -v.uv.y,0.f}; if(lightmapUvs.empty() == false) diff --git a/core/shared/src/lua/libraries/lutil.cpp b/core/shared/src/lua/libraries/lutil.cpp index e6a772245..8bb2e635a 100644 --- a/core/shared/src/lua/libraries/lutil.cpp +++ b/core/shared/src/lua/libraries/lutil.cpp @@ -1489,8 +1489,8 @@ std::string Lua::util::get_pretty_time(lua_State *l, float t) return prettyTime; } -double Lua::util::units_to_metres(double units) { return ::util::pragma::units_to_metres(units); } -double Lua::util::metres_to_units(double metres) { return ::util::pragma::metres_to_units(metres); } +double Lua::util::units_to_metres(double units) { return ::pragma::units_to_metres(units); } +double Lua::util::metres_to_units(double metres) { return ::pragma::metres_to_units(metres); } luabind::object Lua::util::read_scene_file(lua_State *l, const std::string &fileName) { auto fname = "scenes\\" + FileManager::GetCanonicalizedPath(fileName); diff --git a/core/shared/src/physics/phys_water_buoyancy_simulator.cpp b/core/shared/src/physics/phys_water_buoyancy_simulator.cpp index 67945a3ab..83cdc5f82 100644 --- a/core/shared/src/physics/phys_water_buoyancy_simulator.cpp +++ b/core/shared/src/physics/phys_water_buoyancy_simulator.cpp @@ -99,7 +99,7 @@ double pragma::physics::WaterBuoyancySimulator::CalcBuoyancy(const Quat &rorigin if(force || torque) { // Liquid density is specified in kg/m^3, we'll have to convert it to Pragma's scale - constexpr auto scale = umath::pow3(util::pragma::units_to_metres(1.0)); + constexpr auto scale = umath::pow3(pragma::units_to_metres(1.0)); auto density = liquid.density * scale; if(force != nullptr) { *force = CalcBuoyancy(density, submergedVolume, gravity, waterPlane); From 8ee67bcebc4559133eaf28a7f7b2954fd95742bc Mon Sep 17 00:00:00 2001 From: Silverlan Date: Sun, 6 Oct 2024 18:26:35 +0200 Subject: [PATCH 11/15] feat: unicode library is now imported as module --- core/client/include/pragma/c_engine.h | 4 +-- .../include/pragma/clientstate/clientstate.h | 4 +-- core/client/include/pragma/game/c_game.h | 4 ++- .../include/pragma/gui/wicommandlineentry.hpp | 2 +- core/client/include/pragma/gui/wiconsole.hpp | 4 +-- core/client/include/pragma/gui/wiframe.h | 2 +- core/client/include/pragma/gui/wikeyentry.h | 2 +- core/client/src/c_engine.cpp | 4 +-- .../src/debug/c_debug_gui_cursor_element.cpp | 3 +- core/client/src/debug/c_debugoverlay.cpp | 3 +- core/client/src/game/c_game_input.cpp | 5 +-- .../src/gui/mainmenu/wimainmenu_base.cpp | 2 +- .../src/gui/mainmenu/wimainmenu_newgame.cpp | 4 +-- core/client/src/gui/wicommandlineentry.cpp | 5 +-- core/client/src/gui/wiconsole.cpp | 8 ++--- core/client/src/gui/wifps.cpp | 3 +- core/client/src/gui/wiframe.cpp | 7 ++-- core/client/src/gui/wikeyentry.cpp | 4 +-- core/client/src/gui/winetgraph.cpp | 3 +- core/client/src/gui/wioptionslist.cpp | 2 +- core/client/src/gui/wiprogressbar.cpp | 3 +- core/client/src/gui/witable.cpp | 7 ++-- core/client/src/lua/c_library.cpp | 3 +- core/client/src/lua/classes/c_lwibase.cpp | 7 ++-- core/client/src/lua/libraries/c_input.cpp | 2 +- core/client/src/lua/libraries/c_lgui.cpp | 3 +- core/client/src/lua/libraries/c_llocale.cpp | 2 +- core/shared/include/pragma/localization.h | 23 ++++++------- core/shared/include/pragma/util/font_set.hpp | 3 +- .../shared/src/lua/libraries/localization.cpp | 32 +++++++++---------- 30 files changed, 88 insertions(+), 72 deletions(-) diff --git a/core/client/include/pragma/c_engine.h b/core/client/include/pragma/c_engine.h index 9eb57e923..0cafcb4ff 100644 --- a/core/client/include/pragma/c_engine.h +++ b/core/client/include/pragma/c_engine.h @@ -34,7 +34,7 @@ namespace pragma::debug { class GPUProfilingStage; class GPUProfiler; }; -namespace util { +namespace pragma::string { class Utf8String; }; struct InputBindingLayer; @@ -168,7 +168,7 @@ class DLLCLIENT CEngine : public Engine, public pragma::RenderContext { bool OnWindowShouldClose(prosper::Window &window); void JoystickButtonInput(prosper::Window &window, const GLFW::Joystick &joystick, uint32_t key, GLFW::KeyState state); void JoystickAxisInput(prosper::Window &window, const GLFW::Joystick &joystick, uint32_t axis, GLFW::Modifier mods, float newVal, float deltaVal); - void OnPreedit(prosper::Window &window, const util::Utf8String &preeditString, const std::vector &blockSizes, int focusedBlock, int caret); + void OnPreedit(prosper::Window &window, const pragma::string::Utf8String &preeditString, const std::vector &blockSizes, int focusedBlock, int caret); void OnIMEStatusChanged(prosper::Window &window, bool imeEnabled); float GetRawJoystickAxisMagnitude() const; // Util diff --git a/core/client/include/pragma/clientstate/clientstate.h b/core/client/include/pragma/clientstate/clientstate.h index c4682f255..cd26af2bd 100644 --- a/core/client/include/pragma/clientstate/clientstate.h +++ b/core/client/include/pragma/clientstate/clientstate.h @@ -73,7 +73,7 @@ namespace pragma::networking { namespace prosper { class RenderTarget; }; -namespace util { +namespace pragma::string { class Utf8String; }; class DLLCLIENT ClientState : public NetworkState { @@ -242,7 +242,7 @@ class DLLCLIENT ClientState : public NetworkState { void OnDragEnter(prosper::Window &window); void OnDragExit(prosper::Window &window); bool OnWindowShouldClose(prosper::Window &window); - void OnPreedit(prosper::Window &window, const util::Utf8String &preeditString, const std::vector &blockSizes, int focusedBlock, int caret); + void OnPreedit(prosper::Window &window, const pragma::string::Utf8String &preeditString, const std::vector &blockSizes, int focusedBlock, int caret); void OnIMEStatusChanged(prosper::Window &window, bool imeEnabled); Material *LoadMaterial(const std::string &path, const std::function &onLoaded, bool bReload = false); diff --git a/core/client/include/pragma/game/c_game.h b/core/client/include/pragma/game/c_game.h index f3ccc8e96..960a31bf7 100644 --- a/core/client/include/pragma/game/c_game.h +++ b/core/client/include/pragma/game/c_game.h @@ -103,6 +103,8 @@ namespace prosper { }; namespace util { struct DrawSceneInfo; +}; +namespace pragma::string { class Utf8String; }; #pragma warning(push) @@ -222,7 +224,7 @@ class DLLCLIENT CGame : public Game { void OnDragEnter(prosper::Window &window); void OnDragExit(prosper::Window &window); bool OnWindowShouldClose(prosper::Window &window); - void OnPreedit(prosper::Window &window, const util::Utf8String &preeditString, const std::vector &blockSizes, int focusedBlock, int caret); + void OnPreedit(prosper::Window &window, const pragma::string::Utf8String &preeditString, const std::vector &blockSizes, int focusedBlock, int caret); void OnIMEStatusChanged(prosper::Window &window, bool imeEnabled); // Game diff --git a/core/client/include/pragma/gui/wicommandlineentry.hpp b/core/client/include/pragma/gui/wicommandlineentry.hpp index 9b77e3039..b0ad4e7f6 100644 --- a/core/client/include/pragma/gui/wicommandlineentry.hpp +++ b/core/client/include/pragma/gui/wicommandlineentry.hpp @@ -30,7 +30,7 @@ class DLLCLIENT WICommandLineEntry : public WITextEntry { virtual void OnFocusGained() override; virtual void OnFocusKilled() override; virtual void OnTextEntered() override; - virtual void OnTextChanged(const util::Utf8String &text, bool changedByUser) override; + virtual void OnTextChanged(const pragma::string::Utf8String &text, bool changedByUser) override; void InitializeAutoCompleteList(); std::vector m_commandHistory = {}; std::function &)> m_fAutoCompleteHandler = nullptr; diff --git a/core/client/include/pragma/gui/wiconsole.hpp b/core/client/include/pragma/gui/wiconsole.hpp index 99dd62a4d..54738a8f5 100644 --- a/core/client/include/pragma/gui/wiconsole.hpp +++ b/core/client/include/pragma/gui/wiconsole.hpp @@ -17,7 +17,7 @@ class WITextEntry; class WICommandLineEntry; class WIFrame; class WISnapArea; -namespace util { +namespace pragma::string { class Utf8String; }; class DLLCLIENT WIConsole : public WIBase { @@ -45,7 +45,7 @@ class DLLCLIENT WIConsole : public WIBase { void SetFrame(WIFrame &frame); WIFrame *GetFrame(); - const util::Utf8String &GetText() const; + const pragma::string::Utf8String &GetText() const; void SetText(const std::string &text); // This will only add complete lines (lines which have // been ended with a new-line character). Anything diff --git a/core/client/include/pragma/gui/wiframe.h b/core/client/include/pragma/gui/wiframe.h index 73eae7ece..72cd27a11 100644 --- a/core/client/include/pragma/gui/wiframe.h +++ b/core/client/include/pragma/gui/wiframe.h @@ -20,7 +20,7 @@ class DLLCLIENT WIFrame : public WITransformable { WIBase *GetContents(); using WITransformable::SetSize; void SetTitle(std::string title); - const util::Utf8String &GetTitle() const; + const pragma::string::Utf8String &GetTitle() const; void SetCloseButtonEnabled(bool b); void SetDetachButtonEnabled(bool b); virtual util::EventReply MouseCallback(GLFW::MouseButton button, GLFW::KeyState state, GLFW::Modifier mods) override; diff --git a/core/client/include/pragma/gui/wikeyentry.h b/core/client/include/pragma/gui/wikeyentry.h index b4b44d9ca..4ea6d1534 100644 --- a/core/client/include/pragma/gui/wikeyentry.h +++ b/core/client/include/pragma/gui/wikeyentry.h @@ -18,7 +18,7 @@ class DLLCLIENT WIKeyEntry : public WITextEntryBase { GLFW::Key m_key; bool m_bKeyPressed; WIHandle m_hMouseTrap; - virtual void OnTextChanged(const util::Utf8String &text, bool changedByUser) override; + virtual void OnTextChanged(const pragma::string::Utf8String &text, bool changedByUser) override; void ApplyKey(GLFW::Key key); public: WIKeyEntry(); diff --git a/core/client/src/c_engine.cpp b/core/client/src/c_engine.cpp index dd22651a4..0bc101bd8 100644 --- a/core/client/src/c_engine.cpp +++ b/core/client/src/c_engine.cpp @@ -591,7 +591,7 @@ bool CEngine::OnWindowShouldClose(prosper::Window &window) return true; return client->OnWindowShouldClose(window); } -void CEngine::OnPreedit(prosper::Window &window, const util::Utf8String &preeditString, const std::vector &blockSizes, int focusedBlock, int caret) +void CEngine::OnPreedit(prosper::Window &window, const pragma::string::Utf8String &preeditString, const std::vector &blockSizes, int focusedBlock, int caret) { if(client == nullptr) return; @@ -1131,7 +1131,7 @@ void CEngine::InitializeWindowInputCallbacks(prosper::Window &window) istr.resize(preedit_count); for(auto i = decltype(preedit_count) {0u}; i < preedit_count; ++i) istr[i] = static_cast(preedit_string[i]); - util::Utf8String preeditString {istr.data(), istr.size()}; + pragma::string::Utf8String preeditString {istr.data(), istr.size()}; std::vector blockSizes; blockSizes.reserve(block_count); diff --git a/core/client/src/debug/c_debug_gui_cursor_element.cpp b/core/client/src/debug/c_debug_gui_cursor_element.cpp index 7beefcd31..df2f12801 100644 --- a/core/client/src/debug/c_debug_gui_cursor_element.cpp +++ b/core/client/src/debug/c_debug_gui_cursor_element.cpp @@ -14,12 +14,13 @@ #include #include #include -#include extern DLLCLIENT CEngine *c_engine; extern DLLCLIENT ClientState *client; extern DLLCLIENT CGame *c_game; +import pragma.string.unicode; + class GUIDebugCursorManager { public: GUIDebugCursorManager(); diff --git a/core/client/src/debug/c_debugoverlay.cpp b/core/client/src/debug/c_debugoverlay.cpp index f631bad56..a045cfebb 100644 --- a/core/client/src/debug/c_debugoverlay.cpp +++ b/core/client/src/debug/c_debugoverlay.cpp @@ -20,7 +20,8 @@ #include #include #include -#include + +import pragma.string.unicode; extern DLLCLIENT CEngine *c_engine; extern DLLCLIENT ClientState *client; diff --git a/core/client/src/game/c_game_input.cpp b/core/client/src/game/c_game_input.cpp index 7035adb05..ad2fc6f6d 100644 --- a/core/client/src/game/c_game_input.cpp +++ b/core/client/src/game/c_game_input.cpp @@ -13,7 +13,8 @@ #include #include #include -#include + +import pragma.string.unicode; extern DLLCLIENT CEngine *c_engine; @@ -78,7 +79,7 @@ bool CGame::OnWindowShouldClose(prosper::Window &window) CallLuaCallbacks("OnWindowShouldClose", &ret, &window); return ret; } -void CGame::OnPreedit(prosper::Window &window, const util::Utf8String &preeditString, const std::vector &blockSizes, int focusedBlock, int caret) +void CGame::OnPreedit(prosper::Window &window, const pragma::string::Utf8String &preeditString, const std::vector &blockSizes, int focusedBlock, int caret) { CallLuaCallbacks, int, int>("OnPreedit", &window, preeditString.cpp_str(), blockSizes, focusedBlock, caret); } diff --git a/core/client/src/gui/mainmenu/wimainmenu_base.cpp b/core/client/src/gui/mainmenu/wimainmenu_base.cpp index ffc2d15a4..b98bc5b80 100644 --- a/core/client/src/gui/mainmenu/wimainmenu_base.cpp +++ b/core/client/src/gui/mainmenu/wimainmenu_base.cpp @@ -305,7 +305,7 @@ void WIMainMenuElement::OnCursorExited() { Deselect(); } void WIMainMenuElement::SetText(std::string &text) { if(m_hText.IsValid()) { - util::Utf8String upperText {text}; + pragma::string::Utf8String upperText {text}; upperText.toUpper(); WIText *pText = static_cast(m_hText.get()); pText->SetText(upperText); diff --git a/core/client/src/gui/mainmenu/wimainmenu_newgame.cpp b/core/client/src/gui/mainmenu/wimainmenu_newgame.cpp index 4952538a2..7bbc70c44 100644 --- a/core/client/src/gui/mainmenu/wimainmenu_newgame.cpp +++ b/core/client/src/gui/mainmenu/wimainmenu_newgame.cpp @@ -43,9 +43,9 @@ void WIMainMenuNewGame::OnStartGame(GLFW::MouseButton button, GLFW::KeyState sta return; auto *pOptionsList = static_cast(m_hControlSettings.get()); std::string map; - util::Utf8String serverName; + pragma::string::Utf8String serverName; std::string gameMode; - util::Utf8String rconPassword; + pragma::string::Utf8String rconPassword; UInt32 maxPlayers = 1; if(m_hMapList.IsValid()) { auto *pMap = static_cast(m_hMapList.get()); diff --git a/core/client/src/gui/wicommandlineentry.cpp b/core/client/src/gui/wicommandlineentry.cpp index 60c3783b3..9c0df037e 100644 --- a/core/client/src/gui/wicommandlineentry.cpp +++ b/core/client/src/gui/wicommandlineentry.cpp @@ -11,7 +11,8 @@ #include #include #include -#include + +import pragma.string.unicode; LINK_WGUI_TO_CLASS(WICommandLineEntry, WICommandLineEntry); @@ -169,7 +170,7 @@ void WICommandLineEntry::SetAutocompleteEnabled(bool enabled) m_hAutoCompleteList->Remove(); } bool WICommandLineEntry::IsAutocompleteEnabled() const { return m_bAutocompleteEnabled; } -void WICommandLineEntry::OnTextChanged(const util::Utf8String &text, bool changedByUser) +void WICommandLineEntry::OnTextChanged(const pragma::string::Utf8String &text, bool changedByUser) { WITextEntry::OnTextChanged(text, changedByUser); if(m_bSkipAutoComplete) diff --git a/core/client/src/gui/wiconsole.cpp b/core/client/src/gui/wiconsole.cpp index 4d47d4962..4f091b9ad 100644 --- a/core/client/src/gui/wiconsole.cpp +++ b/core/client/src/gui/wiconsole.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +import pragma.string.unicode; extern DLLCLIENT CEngine *c_engine; extern DLLCLIENT ClientState *client; @@ -455,9 +455,9 @@ void WIConsole::SetFrame(WIFrame &frame) } WIFrame *WIConsole::GetFrame() { return static_cast(m_hFrame.get()); } -const util::Utf8String &WIConsole::GetText() const +const pragma::string::Utf8String &WIConsole::GetText() const { - static util::Utf8String s {}; + static pragma::string::Utf8String s {}; if(m_hLog.IsValid()) { auto *pTextEntry = static_cast(m_hLog.get()); if(pTextEntry == nullptr) @@ -523,7 +523,7 @@ std::string_view WIConsole::AppendText(const std::string &text) remaining = std::string_view {text}.substr(lineStartOffset, numCharsInLine); } for(auto &line : lines) { - util::Utf8String str {std::string {line}}; + pragma::string::Utf8String str {std::string {line}}; pText->AppendText(str); } diff --git a/core/client/src/gui/wifps.cpp b/core/client/src/gui/wifps.cpp index 6ac9ad40f..25c955927 100644 --- a/core/client/src/gui/wifps.cpp +++ b/core/client/src/gui/wifps.cpp @@ -8,7 +8,8 @@ #include "stdafx_client.h" #include "pragma/gui/wifps.h" #include -#include + +import pragma.string.unicode; extern DLLCLIENT CEngine *c_engine; extern DLLCLIENT ClientState *client; diff --git a/core/client/src/gui/wiframe.cpp b/core/client/src/gui/wiframe.cpp index 7a71061ac..0d161323d 100644 --- a/core/client/src/gui/wiframe.cpp +++ b/core/client/src/gui/wiframe.cpp @@ -13,7 +13,8 @@ #include #include #include -#include + +import pragma.string.unicode; LINK_WGUI_TO_CLASS(WIFrame, WIFrame); @@ -183,10 +184,10 @@ void WIFrame::SetTitle(std::string title) pText->SizeToContents(); pText->SetVisible(!title.empty()); } -const util::Utf8String &WIFrame::GetTitle() const +const pragma::string::Utf8String &WIFrame::GetTitle() const { if(!m_hTitle.IsValid()) { - static util::Utf8String emptyString {}; + static pragma::string::Utf8String emptyString {}; return emptyString; } return static_cast(m_hTitle.get())->GetText(); diff --git a/core/client/src/gui/wikeyentry.cpp b/core/client/src/gui/wikeyentry.cpp index 2d6eee9ef..3a3e74651 100644 --- a/core/client/src/gui/wikeyentry.cpp +++ b/core/client/src/gui/wikeyentry.cpp @@ -26,7 +26,7 @@ WIKeyEntry::~WIKeyEntry() m_hMouseTrap->Remove(); } -void WIKeyEntry::OnTextChanged(const util::Utf8String &text, bool changedByUser) +void WIKeyEntry::OnTextChanged(const pragma::string::Utf8String &text, bool changedByUser) { WITextEntryBase::OnTextChanged(text, changedByUser); if(!m_hText.IsValid()) @@ -47,7 +47,7 @@ void WIKeyEntry::Initialize() m_hCaret->Remove(); if(m_hText.IsValid()) { auto hThis = GetHandle(); - m_hText->AddCallback("OnTextChanged", FunctionCallback>::Create([hThis](std::reference_wrapper newText) mutable { + m_hText->AddCallback("OnTextChanged", FunctionCallback>::Create([hThis](std::reference_wrapper newText) mutable { if(!hThis.IsValid()) return; static_cast(hThis.get())->OnTextChanged(newText, false); diff --git a/core/client/src/gui/winetgraph.cpp b/core/client/src/gui/winetgraph.cpp index 5de27a961..2eb874c11 100644 --- a/core/client/src/gui/winetgraph.cpp +++ b/core/client/src/gui/winetgraph.cpp @@ -9,7 +9,8 @@ #include "pragma/gui/winetgraph.h" #include #include -#include + +import pragma.string.unicode; extern DLLCLIENT CEngine *c_engine; extern DLLCLIENT ClientState *client; diff --git a/core/client/src/gui/wioptionslist.cpp b/core/client/src/gui/wioptionslist.cpp index b475a33c3..eb7edb185 100644 --- a/core/client/src/gui/wioptionslist.cpp +++ b/core/client/src/gui/wioptionslist.cpp @@ -242,7 +242,7 @@ WITextEntry *WIOptionsList::AddTextEntry(const std::string &name, const std::str if(!cvarName.empty()) { auto hOptions = GetHandle(); pTextEntry->SetText(client->GetConVarString(cvarName)); - pTextEntry->AddCallback("OnTextChanged", FunctionCallback, bool>::Create([hOptions, cvarName](std::reference_wrapper text, bool) mutable { + pTextEntry->AddCallback("OnTextChanged", FunctionCallback, bool>::Create([hOptions, cvarName](std::reference_wrapper text, bool) mutable { if(!hOptions.IsValid()) return; hOptions.get()->m_updateCvars[cvarName] = text.get().cpp_str(); diff --git a/core/client/src/gui/wiprogressbar.cpp b/core/client/src/gui/wiprogressbar.cpp index 0cfd20025..7d0d0d6b7 100644 --- a/core/client/src/gui/wiprogressbar.cpp +++ b/core/client/src/gui/wiprogressbar.cpp @@ -12,7 +12,8 @@ #include #include #include -#include + +import pragma.string.unicode; LINK_WGUI_TO_CLASS(WIProgressBar, WIProgressBar); diff --git a/core/client/src/gui/witable.cpp b/core/client/src/gui/witable.cpp index b3cce83f3..2b26dd685 100644 --- a/core/client/src/gui/witable.cpp +++ b/core/client/src/gui/witable.cpp @@ -14,7 +14,8 @@ #include #include "pragma/gui/wiscrollcontainer.h" #include -#include + +import pragma.string.unicode; LINK_WGUI_TO_CLASS(WITable, WITable); LINK_WGUI_TO_CLASS(WITableRow, WITableRow); @@ -79,8 +80,8 @@ bool WITable::SortRows(bool bAsc, unsigned int col, const WIHandle &a, const WIH { if(a.IsValid() == false || b.IsValid() == false) return false; - const util::Utf8String *textA = nullptr; - const util::Utf8String *textB = nullptr; + const pragma::string::Utf8String *textA = nullptr; + const pragma::string::Utf8String *textB = nullptr; const WITableRow *rowA = a.get(); if(rowA != nullptr) { WITableCell *cellA = rowA->GetCell(col); diff --git a/core/client/src/lua/c_library.cpp b/core/client/src/lua/c_library.cpp index d140958f9..dd27e77b5 100644 --- a/core/client/src/lua/c_library.cpp +++ b/core/client/src/lua/c_library.cpp @@ -76,7 +76,8 @@ #include #include #include -#include + +import pragma.string.unicode; extern DLLCLIENT CGame *c_game; extern DLLCLIENT ClientState *client; diff --git a/core/client/src/lua/classes/c_lwibase.cpp b/core/client/src/lua/classes/c_lwibase.cpp index 6bf676896..5745abb7d 100644 --- a/core/client/src/lua/classes/c_lwibase.cpp +++ b/core/client/src/lua/classes/c_lwibase.cpp @@ -50,7 +50,8 @@ #include #include #include -#include + +import pragma.string.unicode; extern DLLCLIENT CEngine *c_engine; extern DLLCLIENT CGame *c_game; @@ -1374,7 +1375,7 @@ CallbackHandle Lua::WIBase::AddCallback(lua_State *l, ::WIBase &panel, std::stri } else if(name == "ontextchanged") { if(ustring::compare(panel.GetClass(), std::string {"witext"}, false)) { - hCallback = FunctionCallback>::Create([l, hPanel, o](std::reference_wrapper text) mutable { + hCallback = FunctionCallback>::Create([l, hPanel, o](std::reference_wrapper text) mutable { if(!hPanel.IsValid()) return; Lua::CallFunction( @@ -1391,7 +1392,7 @@ CallbackHandle Lua::WIBase::AddCallback(lua_State *l, ::WIBase &panel, std::stri }); } else { - hCallback = FunctionCallback, bool>::Create([l, hPanel, o](std::reference_wrapper text, bool changedByUser) mutable { + hCallback = FunctionCallback, bool>::Create([l, hPanel, o](std::reference_wrapper text, bool changedByUser) mutable { if(!hPanel.IsValid()) return; Lua::CallFunction( diff --git a/core/client/src/lua/libraries/c_input.cpp b/core/client/src/lua/libraries/c_input.cpp index 6b0908d91..8edd88fe0 100644 --- a/core/client/src/lua/libraries/c_input.cpp +++ b/core/client/src/lua/libraries/c_input.cpp @@ -93,7 +93,7 @@ bool ClientState::OnWindowShouldClose(prosper::Window &window) return false; return game->OnWindowShouldClose(window); } -void ClientState::OnPreedit(prosper::Window &window, const util::Utf8String &preeditString, const std::vector &blockSizes, int focusedBlock, int caret) +void ClientState::OnPreedit(prosper::Window &window, const pragma::string::Utf8String &preeditString, const std::vector &blockSizes, int focusedBlock, int caret) { auto *game = GetGameState(); if(game == nullptr) diff --git a/core/client/src/lua/libraries/c_lgui.cpp b/core/client/src/lua/libraries/c_lgui.cpp index d271bdcf6..dec4d45c6 100644 --- a/core/client/src/lua/libraries/c_lgui.cpp +++ b/core/client/src/lua/libraries/c_lgui.cpp @@ -24,7 +24,8 @@ #include #include #include -#include + +import pragma.string.unicode; extern DLLCLIENT CEngine *c_engine; extern DLLCLIENT ClientState *client; diff --git a/core/client/src/lua/libraries/c_llocale.cpp b/core/client/src/lua/libraries/c_llocale.cpp index 2a653cf6f..3ab5a1a8d 100644 --- a/core/client/src/lua/libraries/c_llocale.cpp +++ b/core/client/src/lua/libraries/c_llocale.cpp @@ -81,7 +81,7 @@ Lua::map Lua::Locale::get_texts(lua_State *l) } Lua::opt> Lua::Locale::parse(lua_State *l, const std::string &fileName, const std::string &lan) { - std::unordered_map texts; + std::unordered_map texts; auto res = ::Locale::ParseFile(fileName, lan, texts); if(res != ::Locale::LoadResult::Success) return Lua::nil; diff --git a/core/shared/include/pragma/localization.h b/core/shared/include/pragma/localization.h index a017d8232..8a90d6741 100644 --- a/core/shared/include/pragma/localization.h +++ b/core/shared/include/pragma/localization.h @@ -13,12 +13,13 @@ #include #include #include -#include + +import pragma.string.unicode; class Locale; struct DLLNETWORK Localization { Localization(); - std::unordered_map texts; + std::unordered_map texts; }; class DLLNETWORK Locale { @@ -37,25 +38,25 @@ class DLLNETWORK Locale { static void SetLanguage(std::string lan); static void ReloadFiles(); static bool GetRawText(const std::string &id, std::string &outText); - static bool GetRawText(const std::string &id, util::Utf8String &outText); + static bool GetRawText(const std::string &id, pragma::string::Utf8String &outText); static bool GetText(const std::string &id, std::string &outText); - static bool GetText(const std::string &id, util::Utf8String &outText); + static bool GetText(const std::string &id, pragma::string::Utf8String &outText); static bool GetText(const std::string &id, const std::vector &args, std::string &outText); - static bool GetText(const std::string &id, const std::vector &args, util::Utf8String &outText); + static bool GetText(const std::string &id, const std::vector &args, pragma::string::Utf8String &outText); static std::string GetText(const std::string &id, const std::vector &args = {}); - static util::Utf8String GetTextUtf8(const std::string &id, const std::vector &args = {}); - static bool SetLocalization(const std::string &id, const util::Utf8String &text, bool overwriteIfExists = true); + static pragma::string::Utf8String GetTextUtf8(const std::string &id, const std::vector &args = {}); + static bool SetLocalization(const std::string &id, const pragma::string::Utf8String &text, bool overwriteIfExists = true); static const std::string &GetLanguage(); static const LanguageInfo *GetLanguageInfo(); static const std::unordered_map &GetLanguages(); - static std::unordered_map &GetTexts(); + static std::unordered_map &GetTexts(); static void Poll(); static std::string DetermineSystemLanguage(); static LoadResult LoadFile(const std::string &file, const std::string &lan, Localization &outLoc); - static LoadResult ParseFile(const std::string &file, const std::string &lan, std::unordered_map &outTexts); + static LoadResult ParseFile(const std::string &file, const std::string &lan, std::unordered_map &outTexts); static std::string GetFileLocation(const std::string &file, const std::string &lan); - static bool Localize(const std::string &identifier, const std::string &lan, const std::string &category, const util::Utf8String &text); - static util::Utf8String GetUsedCharacters(); + static bool Localize(const std::string &identifier, const std::string &lan, const std::string &category, const pragma::string::Utf8String &text); + static pragma::string::Utf8String GetUsedCharacters(); // Loads all available scripts for the current language. For debugging purposes only. static void LoadAll(); diff --git a/core/shared/include/pragma/util/font_set.hpp b/core/shared/include/pragma/util/font_set.hpp index 19942caf2..6547e54c9 100644 --- a/core/shared/include/pragma/util/font_set.hpp +++ b/core/shared/include/pragma/util/font_set.hpp @@ -14,7 +14,8 @@ #include #include #include -#include + +import pragma.string.unicode; enum class FontSetFlag : uint8_t { None = 0, diff --git a/core/shared/src/lua/libraries/localization.cpp b/core/shared/src/lua/libraries/localization.cpp index 45a2373d2..6241c014f 100644 --- a/core/shared/src/lua/libraries/localization.cpp +++ b/core/shared/src/lua/libraries/localization.cpp @@ -50,7 +50,7 @@ Locale::LoadResult Locale::Load(const std::string &file, const std::string &lan, std::string Locale::GetFileLocation(const std::string &file, const std::string &lan) { return LOCALIZATION_ROOT_PATH + lan + "/texts/" + file; } -Locale::LoadResult Locale::ParseFile(const std::string &file, const std::string &lan, std::unordered_map &outTexts) +Locale::LoadResult Locale::ParseFile(const std::string &file, const std::string &lan, std::unordered_map &outTexts) { auto filePath = GetFileLocation(file, lan); auto f = FileManager::OpenFile(filePath.c_str(), "r"); @@ -139,7 +139,7 @@ const Locale::LanguageInfo *Locale::GetLanguageInfo() return nullptr; return &it->second; } -std::unordered_map &Locale::GetTexts() { return m_localization.texts; } +std::unordered_map &Locale::GetTexts() { return m_localization.texts; } const std::unordered_map &Locale::GetLanguages() { if(g_languages.empty()) { @@ -166,14 +166,14 @@ const std::unordered_map &Locale::GetLanguage } return g_languages; } -bool Locale::SetLocalization(const std::string &id, const util::Utf8String &text, bool overwriteIfExists) +bool Locale::SetLocalization(const std::string &id, const pragma::string::Utf8String &text, bool overwriteIfExists) { if(!overwriteIfExists && m_localization.texts.find(id) != m_localization.texts.end()) return false; m_localization.texts[id] = text; return true; } -bool Locale::GetText(const std::string &id, util::Utf8String &outText) { return GetText(id, {}, outText); } +bool Locale::GetText(const std::string &id, pragma::string::Utf8String &outText) { return GetText(id, {}, outText); } bool Locale::GetText(const std::string &id, std::string &outText) { return GetText(id, {}, outText); } bool Locale::GetRawText(const std::string &id, std::string &outText) { @@ -183,7 +183,7 @@ bool Locale::GetRawText(const std::string &id, std::string &outText) outText = it->second.cpp_str(); return true; } -bool Locale::GetRawText(const std::string &id, util::Utf8String &outText) +bool Locale::GetRawText(const std::string &id, pragma::string::Utf8String &outText) { auto it = m_localization.texts.find(id); if(it == m_localization.texts.end()) @@ -218,11 +218,11 @@ static void insert_arguments(const std::vector &args, TString &inOutTex } } else { - using TSubStr = std::conditional_t, std::string, std::string_view>; + using TSubStr = std::conditional_t, std::string, std::string_view>; auto innerStartPos = startPos + 1; auto innerLen = (endPos - startPos) - 1; TSubStr inner; - if constexpr(std::is_same_v) + if constexpr(std::is_same_v) inner = inOutText.substr(innerStartPos, innerLen).cpp_str(); else inner = {inOutText.c_str() + innerStartPos, innerLen}; @@ -256,13 +256,13 @@ static void insert_arguments(const std::vector &args, TString &inOutTex startPos = inOutText.find('{', endPos); } } -bool Locale::GetText(const std::string &id, const std::vector &args, util::Utf8String &outText) +bool Locale::GetText(const std::string &id, const std::vector &args, pragma::string::Utf8String &outText) { auto it = m_localization.texts.find(id); if(it == m_localization.texts.end()) return false; outText = it->second; - insert_arguments(args, outText); + insert_arguments(args, outText); return true; } bool Locale::GetText(const std::string &id, const std::vector &args, std::string &outText) @@ -285,7 +285,7 @@ std::string Locale::GetText(const std::string &id, const std::vector(args, r); return r; } -util::Utf8String Locale::GetTextUtf8(const std::string &id, const std::vector &args) +pragma::string::Utf8String Locale::GetTextUtf8(const std::string &id, const std::vector &args) { auto it = m_localization.texts.find(id); if(it == m_localization.texts.end()) { @@ -293,7 +293,7 @@ util::Utf8String Locale::GetTextUtf8(const std::string &id, const std::vector"); } auto r = it->second; - insert_arguments(args, r); + insert_arguments(args, r); return r; } std::string Locale::DetermineSystemLanguage() @@ -311,7 +311,7 @@ void Locale::LoadAll() for(auto &f : files) LoadFile(f, lan); } -util::Utf8String Locale::GetUsedCharacters() +pragma::string::Utf8String Locale::GetUsedCharacters() { std::unordered_set usedCharacters; for(auto &pair : m_localization.texts) { @@ -323,12 +323,12 @@ util::Utf8String Locale::GetUsedCharacters() for(auto c : usedCharacters) vUsedCharacters.push_back(c); std::sort(vUsedCharacters.begin(), vUsedCharacters.end()); - util::Utf8String usedCharsStr; + pragma::string::Utf8String usedCharsStr; for(auto c : vUsedCharacters) usedCharsStr += static_cast(c); return usedCharsStr; } -bool Locale::Localize(const std::string &identifier, const std::string &lan, const std::string &category, const util::Utf8String &text) +bool Locale::Localize(const std::string &identifier, const std::string &lan, const std::string &category, const pragma::string::Utf8String &text) { auto fileName = category + ".txt"; Localization loc {}; @@ -365,8 +365,8 @@ bool Locale::Localize(const std::string &identifier, const std::string &lan, con first = false; auto val = loc.texts[key]; - ustring::replace(val, "\"", "\\\""); - ustring::replace(val, "\n", "\\n"); + ustring::replace(val, "\"", "\\\""); + ustring::replace(val, "\n", "\\n"); out << key << " = \"" << val << "\""; } From 98044fe3a5bdd30b21a3fb280f4d308c6e0550fd Mon Sep 17 00:00:00 2001 From: Silverlan Date: Sun, 6 Oct 2024 20:37:11 +0200 Subject: [PATCH 12/15] build: update submodule "pr_unirender" --- build_scripts/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_scripts/build.py b/build_scripts/build.py index 3c3eb1321..e3e4038b9 100644 --- a/build_scripts/build.py +++ b/build_scripts/build.py @@ -862,7 +862,7 @@ def execbuildscript(filepath): ) add_pragma_module( name="pr_unirender", - commitSha="7f7f629dd54204ca0eeaceeca96c4d110908db25", + commitSha="b2602180ead8d811acb37c6fe6d86d75ed0fb3a7", repositoryUrl="https://github.com/Silverlan/pr_cycles.git" ) add_pragma_module( From c724c3e46f8ea8880ee8fdc3f37b2b77f1cfe57f Mon Sep 17 00:00:00 2001 From: Silverlan Date: Sun, 6 Oct 2024 21:42:01 +0200 Subject: [PATCH 13/15] build: update submodule "util_unicode" --- build_scripts/scripts/external_libs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_scripts/scripts/external_libs.py b/build_scripts/scripts/external_libs.py index 74f351ace..7bc71e45c 100644 --- a/build_scripts/scripts/external_libs.py +++ b/build_scripts/scripts/external_libs.py @@ -34,7 +34,7 @@ get_submodule("util_zip","https://github.com/Silverlan/util_zip.git","d9bf05a5cbf71bf53f9fbea82c7352f870989ed1") get_submodule("vfilesystem","https://github.com/Silverlan/vfilesystem.git","25c839e313b1bb1c2b4dee56c4a0298c53f546b4") get_submodule("wgui","https://github.com/Silverlan/wgui.git","28f5feb6f72f472f77d15dc75f26e5c6672ca0ba") -get_submodule("util_unicode","https://github.com/Silverlan/util_unicode.git","70dfdefd2693c48a2d79124d5ea0ed99e4a454bf") +get_submodule("util_unicode","https://github.com/Silverlan/util_unicode.git","5a0ac6c02f199e42d7d38d99231503cf42e26f8a") get_submodule("cppbezierfit","https://github.com/Silverlan/cppbezierfit.git","eb08f35ad74c1124f3cd4ef3a8958cded6a04b0e") os.chdir(curDir) From 024afc6955d3956452ac9c0973f6cb3e116ba9dd Mon Sep 17 00:00:00 2001 From: Silverlan Date: Sun, 6 Oct 2024 21:53:04 +0200 Subject: [PATCH 14/15] feat: util_pragma_doc library is now imported as module --- build_scripts/scripts/external_libs.py | 2 +- core/shared/src/engine_cmd.cpp | 2 +- core/shared/src/lua/lua_doc.cpp | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build_scripts/scripts/external_libs.py b/build_scripts/scripts/external_libs.py index 7bc71e45c..2e9edecb1 100644 --- a/build_scripts/scripts/external_libs.py +++ b/build_scripts/scripts/external_libs.py @@ -22,7 +22,7 @@ get_submodule("util_formatted_text","https://github.com/Silverlan/util_formatted_text.git","c473a2bdc1ad84ef52d391226d6983ef3076958e") get_submodule("util_image","https://github.com/Silverlan/util_image.git","bc1af9d7a0e4e4e51550a4730d65e072ae97d592") get_submodule("util_pad","https://github.com/Silverlan/util_pad.git","49d78bd7725cc320fae67c6eff5c25524d1363c0") -get_submodule("util_pragma_doc","https://github.com/Silverlan/util_pragma_doc.git","71b9593872633adafa8dada0797bdf4fabf74c4f") +get_submodule("util_pragma_doc","https://github.com/Silverlan/util_pragma_doc.git","cdf3c3ca57ec28adb34970a6da8be849c0d73655") get_submodule("util_smdmodel","https://github.com/Silverlan/util_smdmodel.git","10fb2d10eb62188c8b9639a62da646152277a748") get_submodule("util_sound","https://github.com/Silverlan/util_sound.git","dcc284ca1affd33c9964ff1646e7aa7cf902eb96") get_submodule("util_source2","https://github.com/Silverlan/util_source2.git","2d45b2c76921475b61647ea63aeb180b37a17d44") diff --git a/core/shared/src/engine_cmd.cpp b/core/shared/src/engine_cmd.cpp index 8d79d9af0..836ec1c7b 100644 --- a/core/shared/src/engine_cmd.cpp +++ b/core/shared/src/engine_cmd.cpp @@ -27,11 +27,11 @@ #include #include #include -#include #undef CreateFile import util_zip; +import pragma.doc; static std::optional udm_convert(const std::string &fileName) { diff --git a/core/shared/src/lua/lua_doc.cpp b/core/shared/src/lua/lua_doc.cpp index de863e1e2..be173bbc8 100644 --- a/core/shared/src/lua/lua_doc.cpp +++ b/core/shared/src/lua/lua_doc.cpp @@ -14,7 +14,8 @@ #include #include #include -#include + +import pragma.doc; extern DLLNETWORK Engine *engine; From 9803d926e1584068382303255da70d48b860dea9 Mon Sep 17 00:00:00 2001 From: Silverlan Date: Mon, 7 Oct 2024 06:20:55 +0200 Subject: [PATCH 15/15] build: update submodule "util_pragma_doc" --- build_scripts/scripts/external_libs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_scripts/scripts/external_libs.py b/build_scripts/scripts/external_libs.py index 2e9edecb1..b57ca3064 100644 --- a/build_scripts/scripts/external_libs.py +++ b/build_scripts/scripts/external_libs.py @@ -22,7 +22,7 @@ get_submodule("util_formatted_text","https://github.com/Silverlan/util_formatted_text.git","c473a2bdc1ad84ef52d391226d6983ef3076958e") get_submodule("util_image","https://github.com/Silverlan/util_image.git","bc1af9d7a0e4e4e51550a4730d65e072ae97d592") get_submodule("util_pad","https://github.com/Silverlan/util_pad.git","49d78bd7725cc320fae67c6eff5c25524d1363c0") -get_submodule("util_pragma_doc","https://github.com/Silverlan/util_pragma_doc.git","cdf3c3ca57ec28adb34970a6da8be849c0d73655") +get_submodule("util_pragma_doc","https://github.com/Silverlan/util_pragma_doc.git","88e85503b120f820143f6f4566e194b539297ffa") get_submodule("util_smdmodel","https://github.com/Silverlan/util_smdmodel.git","10fb2d10eb62188c8b9639a62da646152277a748") get_submodule("util_sound","https://github.com/Silverlan/util_sound.git","dcc284ca1affd33c9964ff1646e7aa7cf902eb96") get_submodule("util_source2","https://github.com/Silverlan/util_source2.git","2d45b2c76921475b61647ea63aeb180b37a17d44")