Skip to content

Commit 46a4d72

Browse files
committed
console + updater
1 parent cfa3540 commit 46a4d72

28 files changed

Lines changed: 415 additions & 52 deletions

File tree

backend/config_editor/parser.go

Lines changed: 103 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,45 @@ package config_editor
22

33
import (
44
"log"
5+
"strings"
56

67
"gopkg.in/ini.v1"
78
)
89

910
type GameConfig struct {
10-
file *ini.File
11-
path string
11+
file *ini.File
12+
path string
13+
keyMap map[string]map[string]string // section -> key -> originalKey
1214
}
1315

1416
// Загрузка INI с сохранением структуры и комментариев
1517
func (c *GameConfig) Load(path string) error {
18+
// Устанавливаем имя дефолтной секции в пустую строку ПЕРЕД загрузкой,
19+
// чтобы ключи без секции попадали в секцию "" (а не "DEFAULT").
20+
// При сохранении, если имя секции совпадает с DefaultSection, заголовок не пишется.
21+
ini.DefaultSection = ""
22+
1623
cfg, err := ini.LoadSources(ini.LoadOptions{
1724
PreserveSurroundedQuote: true, // не трогать кавычки, если появятся
1825
SpaceBeforeInlineComment: true, // сохранить inline-комментарии
1926
AllowBooleanKeys: true,
20-
// Insensitive: true,
27+
// Insensitive: true, // Мы реализуем свою нечувствительность
2128
}, path)
2229
if err != nil {
2330
return err
2431
}
2532
c.file = cfg
2633
c.path = path
34+
c.keyMap = make(map[string]map[string]string)
2735

28-
ini.DefaultSection = ""
36+
// Строим карту ключей
37+
for _, section := range cfg.Sections() {
38+
secNameLower := strings.ToLower(section.Name())
39+
c.keyMap[secNameLower] = make(map[string]string)
40+
for _, key := range section.Keys() {
41+
c.keyMap[secNameLower][strings.ToLower(key.Name())] = key.Name()
42+
}
43+
}
2944

3045
return nil
3146
}
@@ -36,25 +51,103 @@ func (c *GameConfig) Get(section, key string) string {
3651
return ""
3752
}
3853

54+
// 1. Пытаемся найти точное совпадение
3955
sec, err := c.file.GetSection(section)
40-
if err != nil {
56+
if err == nil && sec.HasKey(key) {
57+
return sec.Key(key).String()
58+
}
59+
60+
// 2. Если не нашли, ищем через карту (case-insensitive)
61+
secNameLower := strings.ToLower(section)
62+
keyLower := strings.ToLower(key)
63+
64+
// Ищем реальное имя секции
65+
var realSectionName string
66+
67+
// Сначала проверяем, может секция с таким именем есть (но ключ не нашли выше)
68+
if s, err := c.file.GetSection(section); err == nil {
69+
realSectionName = s.Name()
70+
} else {
71+
// Если нет, ищем перебором (так как keyMap хранит только lower case ключи секций)
72+
for _, s := range c.file.Sections() {
73+
if strings.EqualFold(s.Name(), section) {
74+
realSectionName = s.Name()
75+
break
76+
}
77+
}
78+
}
79+
80+
if realSectionName == "" {
4181
return "not found section"
4282
}
4383

44-
k := sec.Key(key)
45-
if k == nil {
46-
return "not found key"
84+
// Теперь ищем ключ в этой секции
85+
sec, _ = c.file.GetSection(realSectionName)
86+
87+
// Проверяем маппинг ключа
88+
if mapping, ok := c.keyMap[secNameLower]; ok {
89+
if realKey, ok := mapping[keyLower]; ok {
90+
return sec.Key(realKey).String()
91+
}
92+
}
93+
94+
// Если в мапе нет, но вдруг он есть в файле (добавили динамически?)
95+
if sec.HasKey(key) {
96+
return sec.Key(key).String()
4797
}
4898

49-
return k.String() // если значения нет → вернётся ""
99+
return "not found key"
50100
}
51101

52102
// Обновить значение
53103
func (c *GameConfig) Set(section, key, value string) {
54104
if c.file == nil {
55105
return
56106
}
57-
c.file.Section(section).Key(key).SetValue(value)
107+
108+
secNameLower := strings.ToLower(section)
109+
keyLower := strings.ToLower(key)
110+
111+
// 1. Определяем реальное имя секции
112+
var realSection *ini.Section
113+
if s, err := c.file.GetSection(section); err == nil {
114+
realSection = s
115+
} else {
116+
for _, s := range c.file.Sections() {
117+
if strings.EqualFold(s.Name(), section) {
118+
realSection = s
119+
break
120+
}
121+
}
122+
}
123+
124+
// Если секции нет - создаем (с тем именем, которое передали)
125+
if realSection == nil {
126+
realSection, _ = c.file.NewSection(section)
127+
// Обновляем мапу
128+
if c.keyMap == nil {
129+
c.keyMap = make(map[string]map[string]string)
130+
}
131+
c.keyMap[secNameLower] = make(map[string]string)
132+
}
133+
134+
// 2. Определяем реальное имя ключа
135+
realKeyName := key // По умолчанию - как передали
136+
137+
if mapping, ok := c.keyMap[secNameLower]; ok {
138+
if existingKey, ok := mapping[keyLower]; ok {
139+
realKeyName = existingKey
140+
}
141+
}
142+
143+
// 3. Устанавливаем значение
144+
realSection.Key(realKeyName).SetValue(value)
145+
146+
// 4. Обновляем мапу (на случай если это новый ключ)
147+
if c.keyMap[secNameLower] == nil {
148+
c.keyMap[secNameLower] = make(map[string]string)
149+
}
150+
c.keyMap[secNameLower][keyLower] = realKeyName
58151
}
59152

60153
// Сохранить обратно в файл

backend/utils/launch.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,22 @@ import (
99
"os/exec"
1010
"path/filepath"
1111
"strings"
12+
13+
"github.com/wailsapp/wails/v3/pkg/application"
1214
)
1315

14-
type Utils struct{}
16+
type Utils struct {
17+
window *application.WebviewWindow
18+
}
19+
20+
func NewUtils(window *application.WebviewWindow) *Utils {
21+
return &Utils{
22+
window: window,
23+
}
24+
}
1525

16-
func NewUtils() *Utils {
17-
return &Utils{}
26+
func (u *Utils) OpenDevTools() {
27+
u.window.OpenDevTools()
1828
}
1929

2030
// Открыть папку в проводнике

build/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ info:
1111
description: "Legend of DotA Config Editor" # The application description
1212
copyright: "(c) 2025, phphacker" # Copyright text
1313
comments: "LoD Config Editor" # Comments
14-
version: "0.9.7" # The application version
14+
version: "0.9.8" # The application version
1515

1616
# iOS build configuration (uncomment to customise iOS project generation)
1717
# Note: Keys under `ios` OVERRIDE values under `info` when set.
@@ -21,7 +21,7 @@ info:
2121
# # The display name shown under the app icon (CFBundleDisplayName/CFBundleName)
2222
# displayName: "My Product"
2323
# # The app version to embed in Info.plist (CFBundleShortVersionString/CFBundleVersion)
24-
# version: "0.9.7"
24+
# version: "0.9.8"
2525
# # The company/organisation name for templates and project settings
2626
# company: "My Company"
2727
# # Additional comments to embed in Info.plist metadata

build/windows/info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
},
55
"info": {
66
"0000": {
7-
"ProductVersion": "0.9.7.0",
7+
"ProductVersion": "0.9.8.0",
88
"CompanyName": "phphacker",
99
"FileDescription": "Legend of DotA Config Editor",
1010
"LegalCopyright": "© 2025, phphacker",

build/windows/wails.exe.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
3-
<assemblyIdentity type="win32" name="com.phphacker.lodconfigeditor" version="0.9.7.0" processorArchitecture="*"/>
3+
<assemblyIdentity type="win32" name="com.phphacker.lodconfigeditor" version="0.9.8.0" processorArchitecture="*"/>
44
<dependency>
55
<dependentAssembly>
66
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>

frontend/bindings/lce/backend/utils/utils.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ export function LaunchGameExe(path, ...args) {
3737
return $Call.ByID(270520792, path, args);
3838
}
3939

40+
/**
41+
* @returns {$CancellablePromise<void>}
42+
*/
43+
export function OpenDevTools() {
44+
return $Call.ByID(3153944503);
45+
}
46+
4047
/**
4148
* @param {string} path
4249
* @returns {$CancellablePromise<void>}
8.75 KB
Loading

frontend/public/htk_icons/Scan.png

8.61 KB
Loading

0 commit comments

Comments
 (0)