File size: 5,880 Bytes
4d3af08 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
#NoTrayIcon
FileEncoding, UTF-8-RAW
#SingleInstance OFF
SetFormat, float, 0.10
#NoTrayIcon
file_path = %1%
Loop {
if (file_path == "") {
default_path := GetDefaultPath()
FileSelectFile, file_path, 3, %default_path%, .menuファイルを選択してください, メニューファイル(*.menu)
}
if (ErrorLevel == 1) {
ExitApp
}
if (FileExist(file_path) == "") {
Msgbox, ファイルが存在しません
file_path := ""
}
else {
break
}
}
file := FileOpen(file_path, "r")
if (file.Read(file.ReadChar()) != "CM3D2_MENU") {
MsgBox, これはカスタムメイド3D2のメニューファイルではありません
ExitApp
}
data := Object()
version := file.ReadInt()
path := ReadString(file)
name := ReadString(file)
category := ReadString(file)
setumei := ReadString(file)
end_pos := file.ReadInt() + file.tell() - 1
Loop, 9999 {
index := A_Index
local_size := file.ReadChar()
Loop, %local_size% {
data[index, A_Index] := ReadString(file)
}
data_size := index
if (end_pos <= file.tell()) {
break
}
}
file.Close()
SplitPath, file_path, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
Gui, Add, Text, xm0 ym0 W400 H20 Center, %A_Space%%OutFileName%
Gui, Add, Text, x+0 yp+0 W100 H20 Center, コピペ用
Gui, Add, Edit, x+0 yp+0 W100 H20 ReadOnly, 《改行》
Gui, Add, Text, xm0 y+0 W100 H20 Center, %A_Space%%A_Space%ファイルバージョン
Gui, Add, Edit, x+0 yp+0 W100 H20 VGversion, %version%
Gui, Add, Text, x+0 yp+0 W50 H20 Center, %A_Space%%A_Space%名前
Gui, Add, Edit, x+0 yp+0 W350 H20 VGname, %name%
Gui, Add, Text, xm0 y+0 W100 H20 Center, %A_Space%%A_Space%カテゴリ
Gui, Add, Edit, x+0 yp+0 W100 H20 VGcategory, %category%
Gui, Add, Text, x+0 yp+0 W50 H20 Center, %A_Space%%A_Space%説明
Gui, Add, Edit, x+0 yp+0 W350 H20 VGsetumei, %setumei%
Gui, Add, Text, xm0 y+0 W100 H20 Center, %A_Space%%A_Space%txtパス
Gui, Add, Edit, x+0 yp+0 W500 H20 VGpath, %path%
Gui, Add, TreeView, xm0 W600 R32 -ReadOnly
Gui, Add, Button, xm0 y+5 W100 H20 GUtilAdd, 新規親
Gui, Add, Button, x+0 yp+0 W100 H20 GUtilAddChild, 新規子
Gui, Add, Button, x+300 yp+0 W100 H20 GUtilDel, 削除
Gui, Add, Button, xm0 y+5 W600 H50 GMySubmit, 上書き保存
Loop, %data_size% {
index := A_Index
id := TV_Add(data[index, 1], 0, "Expand")
local_size := data[index].MaxIndex()
Loop, %local_size% {
if (A_Index == 1) {
continue
}
TV_Add(data[index, A_Index], id)
}
}
Gui, Show, AutoSize
return
GetStringLength(string) {
count = 0
Loop, Parse, string
{
if (RegExMatch(A_LoopField, "^[^\x01-\x7E]$") != 0) {
count += 3
}
else {
count += 1
}
}
return count
}
ReadString(file, size=-1) {
if (size <= -1) {
size := 0
chars := Object()
Loop {
char := file.ReadUChar()
chars[A_Index] := char
if (char < 128) {
break
}
}
num := GetMaxIndex(chars)
Loop, %num% {
char := chars[A_Index]
multi := 256 ** (A_Index - 1)
size += char * multi
if (1 < A_Index) {
size -= (multi / 2) * (char + 1)
}
}
}
string := ""
count = 0
Loop, 9999 {
if (size <= count) {
break
}
s := file.Read(1)
string := string . s
count += GetStringLength(s)
if (GetStringLength(s) == 0) {
pos := file.Pos
MsgBox, ファイルの読み込みに失敗しました(場所: %pos%)`n終了します
ExitApp
}
}
return string
}
WriteString(file, string) {
len := GetStringLength(string)
if (128 <= len) {
temp := Mod(len, 128) + 128
file.WriteChar(temp)
temp := Floor(len / 128)
file.WriteChar(temp)
}
else {
file.WriteChar(len)
}
file.Write(string)
}
GetMaxIndex(obj) {
value := obj.MaxIndex()
if (value == "") {
return 0
}
return value
}
GetDefaultPath() {
RegRead, path, HKEY_CURRENT_USER, Software\KISS\カスタムメイド3D2, InstallPath
if (ErrorLevel == 0) {
path = %path%GameData\
}
else {
path := A_ScriptDir
}
return path
}
UtilAdd:
InputBox, new_name, , 新規親の名前を入力してください
if (ErrorLevel == 0){
TV_Add(new_name, 0, "Expand")
}
return
UtilAddChild:
parent := TV_GetSelection()
if (parent == 0) {
MsgBox, 項目を選択してください
return
}
if (TV_GetParent(parent) != 0) {
parent := TV_GetParent(parent)
}
InputBox, new_name, , 新規子の名前を入力してください
if (ErrorLevel == 0){
TV_Add(new_name, parent, "Expand")
}
return
UtilDel:
selected := TV_GetSelection()
if (selected == 0) {
MsgBox, 項目を選択してください
return
}
TV_Delete(selected)
return
MySubmit:
Gui, Submit, NoHide
temp_file := FileOpen(file_path . ".temp", "w")
parent_id = 0
Loop {
parent_id := TV_GetNext(parent_id)
if (parent_id == 0) {
break
}
TV_GetText(name, parent_id)
child_id := TV_GetChild(parent_id)
childs := Object()
if (child_id != 0) {
Loop {
TV_GetText(string, child_id)
childs[A_Index] := string
child_id := TV_GetNext(child_id)
if (child_id == 0) {
break
}
}
}
max := childs.MaxIndex()
if (max == "") {
temp_file.WriteChar(1)
}
else {
temp_file.WriteChar(max + 1)
}
WriteString(temp_file, name)
Loop, %max% {
string := childs[A_Index]
WriteString(temp_file, string)
}
}
temp_file.WriteChar(0)
temp_file.close()
temp_file := FileOpen(file_path . ".temp", "r")
file := FileOpen(file_path, "w")
file.WriteChar(10)
file.Write("CM3D2_MENU")
file.WriteInt(Gversion)
WriteString(file, Gpath)
WriteString(file, Gname)
WriteString(file, Gcategory)
WriteString(file, Gsetumei)
file.WriteInt(temp_file.Length)
temp_file.RawRead(data, temp_file.Length)
file.RawWrite(data, temp_file.Length)
file.close()
temp_file.close()
FileDelete, %file_path%.temp
SplitPath, file_path, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
MsgBox, %OutFileName%を上書きしました
return
GuiEscape:
GuiClose:
ExitApp
return
|