Skip to content

Commit

Permalink
fix(capslockx): cfg dir
Browse files Browse the repository at this point in the history
cfg dir
  • Loading branch information
snomiao committed May 12, 2024
1 parent 0ef49e2 commit 5bb72c1
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 19 deletions.
53 changes: 42 additions & 11 deletions Core/CapsLockX-i18n.ahk
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
; - [Language Codes \| AutoHotkey v1]( https://www.autohotkey.com/docs/v1/misc/Languages.htm )

global CLX_Lang := CLX_Config("Core", "Language", "auto", "语言切换")
global CLX_i18nConfigPath := "Core/lang.ini"

清洗为_UTF16_WITH_BOM_型编码(CLX_i18nConfigPath)

; Hans
LCID_7804 := "Chinese" ; zh
Expand All @@ -25,8 +28,13 @@ t(s)

; for dev, autotranslate
; run node "prompts/translate-en.md"
lang := "en"
if ( CLX_Lang == "auto" ) {

lang := CLX_Lang
if (!lang) {
lang:="auto"
}
if ( lang == "auto" ) {
lang := "en"
if (A_Language == "7804") {
lang := "zh"
}
Expand Down Expand Up @@ -58,25 +66,34 @@ t(s)
lang := "ja"
}
}
clx_i18n_TranslateByAsync(lang, key)
return CLX_ConfigGet("lang-" lang, key, key)
return i18n_translated(lang, key)
}
clx_i18n_TranslateByAsync(lang, key){
translated := CLX_ConfigGet("lang-" lang, key, "")

i18n_translated(lang, key){
; user translation
translated := CLX_ConfigGet("lang-" . lang, key, "")
if (translated) {
return
return translated
}
; system
translated := CLX_i18n_ConfigGet("lang-" . lang, key, "")
if (translated) {
return translated
}
question := key . "`n`nTranslate to " . lang

; TrayTip, % "CapsLockX i18n [" . lang "]", % key "-->" lang,
question := key . "`n`nTranslate to " . lang

global brainstorm_origin
endpoint := brainstorm_origin "/ai/chat?ret=text"
if (!brainstorm_origin){
brainstorm_origin := CLX_Config("BrainStorm", "Website", "https://brainstorm.snomiao.com")
}
endpoint := brainstorm_origin . "/ai/chat?ret=text"
xhr := ComObjCreate("Msxml2.XMLHTTP")
xhr.Open("POST", endpoint)
xhr.setRequestHeader("Authorization", "Bearer " . brainstormApiKey)
xhr.onreadystatechange := Func("brainstorm_translatePostResult").Bind(lang, key, xhr)
xhr.Send(question)
return "…[" . key . "]"
}
brainstorm_translatePostResult(lang, key, xhr){
if (xhr.readyState != 4)
Expand All @@ -101,5 +118,19 @@ brainstorm_translatePostResult(lang, key, xhr){
i18n_changeLanguage(lang := "auto")
{
CLX_Lang := lang
if (!lang) {
lang:="auto"
}
CLX_ConfigSet("Core", "Language", lang)
}
}
CLX_i18n_ConfigGet(field, varName, defaultValue)
{
global CLX_ConfigChangedTickCount
CLX_ConfigChangedTickCount := A_TickCount
global CLX_i18nConfigPath
IniRead, content, %CLX_i18nConfigPath%, %field%, %varName%, %defaultValue%
if (content == "ERROR") {
return ""
}
return content
}
7 changes: 4 additions & 3 deletions Core/CapslockX-Config.ahk
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
; 保存为 save with UTF8 with DOM

; 用户创建目录
ConfigDir_Portable := "./User"
ConfigDir_Portable := "./User"
ConfigDir_UserProfile := USERPROFILE . "/.CapsLockX"
ConfigDir_AppData := APPDATA . "/CapsLockX"
ConfigDir_AppData := APPDATA . "/CapsLockX"

; 默认值
LaunchConfigDir := ConfigDir_AppData
Expand Down Expand Up @@ -34,6 +34,7 @@ CLX_ConfigChangedTickCount := A_TickCount
; msgbox 清洗为_UTF16_WITH_BOM_型编码2

CLX_Config("_NOTICE_", "ENCODING_USING", "UTF16_LE", "")

; 基本设定
; [Core]
global T_XKeyAsSpace := CLX_Config("Core", "T_XKeyAsSpace", 1, ("使用 Space 作为引导键(默认启用,游戏玩家可在 .user.ignore.txt 里配置忽略游戏窗口)"))
Expand Down Expand Up @@ -73,7 +74,7 @@ CLX_ConfigSet(field, varName, setValue, comment := "")
if (comment) {
; IniDelete, %CLX_ConfigPath%, %field%, %varName%#注释
; IniWrite, %comment%, %CLX_ConfigPath%, %field%, %varName%#注释
IniSave( comment, CLX_ConfigPath, field, varName . "#注释" )
IniSave( comment, CLX_ConfigPath, field, varName . "#" )
}
; IniDelete, %CLX_ConfigPath%, %field%, %varName%
; IniWrite, %content%, %CLX_ConfigPath%, %field%, %varName%
Expand Down
2 changes: 0 additions & 2 deletions Core/lang-en.ini

This file was deleted.

Binary file added Core/lang.ini
Binary file not shown.
7 changes: 4 additions & 3 deletions Modules/CLX-Settings.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ CLX_Exit()
CLX_ConfigWindow()
{
Gui, Destroy
; TODO update this to web view
; TODO: update this to web view
; webview2 needs windows 10, but CLX still want support win7, so maybe other way to do this
Gui, Add, Text, , % t("你可以按 'CapsLockX +, ' (CLX+逗号) 打开此窗口")
Gui, Add, Text, , % t("当前 CLX_ConfigDir") . CLX_ConfigDir
Gui, Add, Text, , % t("当前配置目录") . CLX_ConfigDir
Gui, Add, Text, , % t("CLX脚本交流群: QQ群 100949388 、 Telegram 群 https://t.me/capslockx 、微信群: 添加 @snomiao 拉你")
Gui, Add, Text, , % t("CapsLockX 版本: ") . CLX_VersionName
Gui, Add, Text, , % t("作者: 雪星 ( Snowstar Miao <[email protected]> )")
Gui, Add, Button, Default w120 gButton确认, % t("确定")
Gui, Add, Button, w120 gButtonLanguageSwitch, % t("切换語言") . "`n" . t("Current Language") . ": " . CLX_Lang
Gui, Add, Button, w120 gButtonLanguageSwitch, % t("'切换語言'") . "`n" . t("'Current Language'") . ": " . CLX_Lang
Gui, Add, Button, w120 gButton打开BUG反馈与建议页面, % t("打开BUG反馈与建议页面")
Gui, Add, Button, w120 gButton打开官方文档, % t("打开官方文档")
Gui, Add, Button, w120 gButton添加开机自动启动, % t("添加开机自动启动")
Expand Down
53 changes: 53 additions & 0 deletions Tools/DeprecatedModules/CLX-Cursor.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
;
; 模块:在增强模式下,用另一套鼠标指针
; 贡献者: @冰封 QQ: 124702759
;
;鼠标特征值
Return

SetCursor(code, curFile)
{
;加载CapsLock增强的标指针
hIcon := DllCall("LoadCursorFromFile", "Str", curFile)
DllCall("SetSystemCursor", "UInt", hIcon, "Int", code)
}

UpdateCapsCursor(s)
{
if (!s) {
;恢复默认指针
SPI_SETCURSORS := 0x57
DllCall( "SystemParametersInfo", "UInt", SPI_SETCURSORS, "UInt", 0, "UInt", 0, "UInt", 0)
Return
}

PATH_CURSOR := "数据/cursor"
; OCR_APPSTARTING := 32650
SetCursor(32650, PATH_CURSOR "/APPSTARTING.cur") ;AppStarting.cur")
; OCR_NORMAL := 32512
SetCursor(32512, PATH_CURSOR "/NORMAL.cur") ;正常选择.cur")
; OCR_CROSS := 32515
SetCursor(32515, PATH_CURSOR "/CROSS.cur") ;精确选择.cur")
; OCR_HAND := 32649
SetCursor(32649, PATH_CURSOR "/HAND.cur") ;链接选择.cur")
; OCR_HELP := 32651
SetCursor(32651, PATH_CURSOR "/HELP.cur") ;帮助选择.cur")
; OCR_IBEAM := 32513
SetCursor(32513, PATH_CURSOR "/IBEAM.cur") ;文本选择.cur")
; OCR_NO := 32648
SetCursor(32648, PATH_CURSOR "/NO.cur") ;不可用.cur")
; OCR_SIZEALL := 32646
SetCursor(32646, PATH_CURSOR "/SIZEALL.cur") ;移动.cur")
; OCR_SIZENESW := 32643
SetCursor(32643, PATH_CURSOR "/SIZENESW.cur") ;沿对角线调整大小2.cur")
; OCR_SIZENS := 32645
SetCursor(32645, PATH_CURSOR "/SIZENS.cur") ;垂直调整大小.cur")
; OCR_SIZENWSE := 32642
SetCursor(32642, PATH_CURSOR "/SIZENWSE.cur") ;沿对角线调整大小1.cur")
; OCR_SIZEWE := 32644
SetCursor(32644, PATH_CURSOR "/SIZEWE.cur") ;水平调整大小.cur")
; OCR_UP := 32516
SetCursor(32516, PATH_CURSOR "/UP.cur") ;候选.cur")
; OCR_WAIT := 32514
SetCursor(32514, PATH_CURSOR "/WAIT.cur") ;忙.cur")
}

0 comments on commit 5bb72c1

Please sign in to comment.