• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修訂81592854ffbe85605746675762b6d0f867feb957 (tree)
時間2021-04-14 23:08:26
作者majiponi <majiponi@yaho...>
Commitermajiponi

Log Message

Now you can save project via -o switch.

Change Summary

差異

--- a/aus.vcxproj
+++ b/aus.vcxproj
@@ -161,6 +161,7 @@
161161 </ItemDefinitionGroup>
162162 <ItemGroup>
163163 <ClInclude Include="apihook.h" />
164+ <ClInclude Include="command.h" />
164165 <ClInclude Include="core.h" />
165166 <ClInclude Include="parser.h" />
166167 <ClInclude Include="filter.h" />
@@ -170,6 +171,7 @@
170171 </ItemGroup>
171172 <ItemGroup>
172173 <ClCompile Include="apihook.cpp" />
174+ <ClCompile Include="command.cpp" />
173175 <ClCompile Include="core.cpp" />
174176 <ClCompile Include="parser.cpp" />
175177 <ClCompile Include="stdafx.cpp">
--- a/aus.vcxproj.filters
+++ b/aus.vcxproj.filters
@@ -36,6 +36,9 @@
3636 <ClInclude Include="parser.h">
3737 <Filter>ヘッダー ファイル</Filter>
3838 </ClInclude>
39+ <ClInclude Include="command.h">
40+ <Filter>ヘッダー ファイル</Filter>
41+ </ClInclude>
3942 </ItemGroup>
4043 <ItemGroup>
4144 <ClCompile Include="stdafx.cpp">
@@ -53,6 +56,9 @@
5356 <ClCompile Include="parser.cpp">
5457 <Filter>ソース ファイル</Filter>
5558 </ClCompile>
59+ <ClCompile Include="command.cpp">
60+ <Filter>ソース ファイル</Filter>
61+ </ClCompile>
5662 </ItemGroup>
5763 <ItemGroup>
5864 <None Include="aus.def">
--- /dev/null
+++ b/command.cpp
@@ -0,0 +1,125 @@
1+#include "stdafx.h"
2+#include <commdlg.h>
3+#include <algorithm>
4+#include <typeinfo>
5+
6+#include "apihook.h"
7+#include "ui.h"
8+
9+namespace
10+{
11+ HWND getExeditWindow();
12+
13+ union{
14+ int scene_no;
15+ struct{ unsigned int cx, cy, fps, freq; }* videoinfo;
16+ const char* path;
17+ bool transparent;
18+ } dlgdata;
19+}
20+
21+namespace AviUtlCommand
22+{
23+ void CreateProject(size_t cx, size_t cy, size_t fps, size_t freq)
24+ {
25+ HMODULE ex = GetModuleHandleA("exedit.auf");
26+ if(!ex) return;
27+
28+ std::remove_pointer<decltype(dlgdata.videoinfo)>::type data{ cx, cy, fps, freq };
29+ dlgdata.videoinfo = &data;
30+
31+ IATModifier hook1{ "user32.dll", "DialogBoxParamA", static_cast<decltype(DialogBoxParamA)*>([](HINSTANCE, LPCSTR, HWND, DLGPROC proc, LPARAM) -> INT_PTR {
32+ proc(nullptr, WM_COMMAND, IDOK, 0);
33+ return IDOK;
34+ }), ex };
35+ IATModifier hook2{ "user32.dll", "GetDlgItemInt", static_cast<decltype(GetDlgItemInt)*>([](HWND, int id, BOOL*, BOOL) -> UINT {
36+ if(id == 171) return dlgdata.videoinfo->cx;
37+ if(id == 172) return dlgdata.videoinfo->cy;
38+ return dlgdata.videoinfo->freq;
39+ }), ex };
40+ IATModifier hook3{ "user32.dll", "GetDlgItemTextA", static_cast<decltype(GetDlgItemTextA)*>([](HWND, int, char* buf, int nmax) -> UINT {
41+ return sprintf_s(buf, nmax, "%d", dlgdata.videoinfo->fps);
42+ }), ex };
43+
44+ SendMessageA(getExeditWindow(), WM_COMMAND, 1030, 0xFFFFFFFF);
45+ }
46+
47+ void OpenExoFile(const char* path)
48+ {
49+ dlgdata.path = path;
50+ IATModifier hook3{ "comdlg32.dll", "GetOpenFileNameA", static_cast<decltype(GetOpenFileNameA)*>([](LPOPENFILENAMEA pofn) -> BOOL {
51+ strcpy_s(pofn->lpstrFile, pofn->nMaxFile, dlgdata.path);
52+ return TRUE;
53+ }), GetModuleHandleA(nullptr) };
54+
55+ SendMessageA(getExeditWindow(), WM_COMMAND, 1037, 0xFFFFFFFF);
56+ }
57+
58+ void Quit()
59+ {
60+ PostMessageA(AviUtlUI::GetMainWindow(), WM_CLOSE, 0, 0);
61+ }
62+
63+ void SaveProject(const char* path)
64+ {
65+ dlgdata.path = path;
66+ IATModifier hook3{ "comdlg32.dll", "GetSaveFileNameA", static_cast<decltype(GetSaveFileNameA)*>([](LPOPENFILENAMEA pofn) -> BOOL {
67+ strcpy_s(pofn->lpstrFile, pofn->nMaxFile, dlgdata.path);
68+ return TRUE;
69+ }), GetModuleHandleA(nullptr) };
70+
71+ SendMessageA(AviUtlUI::GetMainWindow(), WM_COMMAND, 1023, 0xFFFFFFFF);
72+ }
73+
74+ void SwitchScene(size_t n)
75+ {
76+ HMODULE ex = GetModuleHandleA("exedit.auf");
77+ if(!ex || n < 0 || n >= 50) return;
78+
79+ dlgdata.scene_no = n;
80+ IATModifier hook1{ "user32.dll", "DialogBoxParamA", static_cast<decltype(DialogBoxParamA)*>([](HINSTANCE, LPCSTR, HWND, DLGPROC proc, LPARAM) -> INT_PTR {
81+ proc(nullptr, WM_COMMAND, MAKEWPARAM(190, LBN_SELCHANGE), 0);
82+ return dlgdata.scene_no;
83+ }), ex };
84+ IATModifier hook2{ "user32.dll", "SendDlgItemMessageA", static_cast<decltype(SendDlgItemMessageA)*>([](HWND, int, UINT, WPARAM, LPARAM) -> LRESULT {
85+ return dlgdata.scene_no;
86+ }), ex };
87+
88+ SendMessageA(getExeditWindow(), WM_LBUTTONDOWN, MK_LBUTTON, 0);
89+ }
90+
91+ void TransparentScene(bool b)
92+ {
93+ HMODULE ex = GetModuleHandleA("exedit.auf");
94+ if(!ex) return;
95+
96+ dlgdata.transparent = b;
97+ IATModifier hook1{ "user32.dll", "DialogBoxParamA", static_cast<decltype(DialogBoxParamA)*>([](HINSTANCE, LPCSTR, HWND, DLGPROC proc, LPARAM) -> INT_PTR {
98+ proc(nullptr, WM_COMMAND, IDOK, 0);
99+ return IDOK;
100+ }), ex };
101+ IATModifier hook2{ "user32.dll", "IsDlgButtonChecked", static_cast<decltype(IsDlgButtonChecked)*>([](HWND, int) -> UINT {
102+ return dlgdata.transparent ? BST_CHECKED : BST_UNCHECKED;
103+ }), ex };
104+
105+ SendMessageA(getExeditWindow(), WM_COMMAND, 1096, 0xFFFFFFFF);
106+ }
107+
108+}
109+
110+namespace
111+{
112+ HWND getExeditWindow()
113+ {
114+ HWND ret = nullptr;
115+ EnumThreadWindows(GetCurrentThreadId(), static_cast<WNDENUMPROC>([](HWND hwnd, LPARAM data) -> BOOL {
116+ static constexpr char head[] = "拡張編集";
117+ char buf[16];
118+ GetWindowTextA(hwnd, buf, std::size(buf));
119+ if(std::memcmp(buf, head, sizeof(head)-1)) return TRUE;
120+ *reinterpret_cast<HWND*>(data) = hwnd;
121+ return FALSE;
122+ }), reinterpret_cast<LPARAM>(&ret));
123+ return ret;
124+ }
125+}
--- /dev/null
+++ b/command.h
@@ -0,0 +1,11 @@
1+#pragma once
2+
3+namespace AviUtlCommand
4+{
5+ void CreateProject(size_t cx, size_t cy, size_t fps, size_t freq);
6+ void OpenExoFile(const char* path);
7+ void Quit();
8+ void SaveProject(const char* path);
9+ void SwitchScene(size_t n);
10+ void TransparentScene(bool b);
11+}
--- a/core.cpp
+++ b/core.cpp
@@ -1,5 +1,7 @@
11 #include "stdafx.h"
22 #include <utility>
3+#include "command.h"
4+#include "core.h"
35 #include "parser.h"
46 #include "ui.h"
57
@@ -16,7 +18,7 @@ namespace
1618 size_t offset;
1719 void* proc;
1820 size_t bytes;
19- } patch[4];
21+ } patch[5];
2022 };
2123
2224 BOOL init(FILTER*);
@@ -26,13 +28,18 @@ namespace
2628 void Reload1();
2729 void Reset1();
2830 void Loader1();
29- constexpr patchdata makeVer2Patch(size_t, size_t);
31+ void Save1();
32+ constexpr patchdata makeVer2Patch(size_t, size_t, size_t);
3033 void Socket(void*, const char*);
3134 void ClearBuffer2();
3235 void Reload2();
3336 void Reset2();
3437 void Loader2();
38+ void Save2();
3539 size_t recalc(size_t, size_t, const char*);
40+ bool is_aup_path(const char*);
41+ void ModifyReturnAddress(size_t);
42+
3643 inline const IMAGE_NT_HEADERS32* getNtHeaders(HMODULE);
3744 inline DWORD getTimeStamp(HMODULE);
3845 inline size_t getTextSectionSize(HMODULE);
@@ -50,12 +57,13 @@ namespace
5057 constexpr size_t bufsize = 0x1000;
5158 }
5259
60+
5361 extern "C" const FILTER_DLL* CALLBACK GetFilterTable()
5462 {
5563 static constexpr FILTER_DLL filter = {
5664 FILTER_FLAG_ALWAYS_ACTIVE | FILTER_FLAG_NO_CONFIG | FILTER_FLAG_IMPORT,
5765 0, 0, const_cast<char*>("Script Engine"), 0, nullptr, nullptr, 0, 0, 0, nullptr, nullptr, nullptr,
58- init, nullptr, nullptr, wndproc, nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr
66+ init, nullptr, nullptr, AviUtlUI::WndProc, nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr
5967 };
6068 return &filter;
6169 }
@@ -67,12 +75,12 @@ namespace
6775 const patchdata* p = getpatch();
6876 if(!p) return FALSE;
6977
70- addmenu();
78+ AviUtlUI::AddMenu();
7179 applypatch(p);
7280 return TRUE;
7381 }
7482
75- constexpr patchdata makeVer1Patch(size_t offset_engine, size_t offset_parser)
83+ constexpr patchdata makeVer1Patch(size_t offset_engine, size_t offset_saver, size_t offset_parser)
7684 {
7785 return { offset_parser + 0x48, offset_parser + 0x40,
7886 { offset_engine, nullptr },
@@ -80,7 +88,8 @@ namespace
8088 { offset_engine + 0x2D, ClearBuffer1, 5 },
8189 { offset_parser + 0x07, Reload1, 6 },
8290 { offset_parser + 0x2E, Reset1, 5 },
83- { offset_engine + 0x47, Loader1, 5 }
91+ { offset_engine + 0x47, Loader1, 5 },
92+ { offset_saver + 0x7D3, Save1, 7 }
8493 }
8594 };
8695 }
@@ -136,7 +145,7 @@ namespace
136145 lea edx, [esp+12]
137146 push edx
138147 push edx
139- call ScriptParser
148+ call SubParser
140149 add esp, 4
141150 xor ecx, ecx
142151 pop edx
@@ -149,7 +158,38 @@ namespace
149158 }
150159 }
151160
152- constexpr patchdata makeVer2Patch(size_t offset_engine, size_t offset_parser)
161+ __declspec(naked) void Save1()
162+ {
163+ __asm{
164+ lea eax, [ebp+0x108]
165+ push eax
166+ call is_aup_path
167+ add esp, 4
168+ test eax, eax
169+ jne SAVE_AUP
170+ mov eax, [esp]
171+ cmp [ebp+0x4BC498], 2
172+ jl SAVE_AVI
173+ add eax, 8
174+ mov [esp], eax
175+ ret
176+ SAVE_AVI:
177+ add eax, 0x110
178+ mov [esp], eax
179+ ret
180+ SAVE_AUP:
181+ mov eax, [esp]
182+ add eax, 0x6A
183+ mov [esp], eax
184+ lea eax, [ebp+0x108]
185+ push eax
186+ call AviUtlCommand::SaveProject
187+ add esp, 4
188+ ret
189+ }
190+ }
191+
192+ constexpr patchdata makeVer2Patch(size_t offset_engine, size_t offset_saver, size_t offset_parser)
153193 {
154194 return { offset_parser + 0x64, offset_parser + 0x5E,
155195 { offset_engine, Socket },
@@ -157,7 +197,8 @@ namespace
157197 { offset_engine + 0x42D, ClearBuffer2, 7 },
158198 { offset_parser + 0x20, Reload2, 5 },
159199 { offset_parser + 0x48, Reset2, 8 },
160- { offset_engine + 0x450, Loader2, 7 }
200+ { offset_engine + 0x450, Loader2, 7 },
201+ { offset_saver + 0xAE9, Save2, 7 }
161202 }
162203 };
163204 }
@@ -216,7 +257,7 @@ namespace
216257 lea edx, [esp+44Ch]
217258 push edx
218259 push edx
219- call ScriptParser
260+ call SubParser
220261 add esp, 4
221262 xor ecx, ecx
222263 pop edx
@@ -226,6 +267,42 @@ namespace
226267 }
227268 }
228269
270+ __declspec(naked) void Save2()
271+ {
272+ __asm{
273+ lea eax, [ebx+0x108]
274+ push eax
275+ call is_aup_path
276+ add esp, 4
277+ test eax, eax
278+ jne SAVE_AUP
279+ mov eax, [esp]
280+ cmp dword ptr [ebx+004BC498h],2
281+ mov dword ptr [esp+3Ch],edx
282+ jl SAVE_AVI
283+ add eax, 12
284+ mov [esp], eax
285+ ret
286+ SAVE_AVI:
287+ add eax, 0x19F
288+ mov [esp], eax
289+ ret
290+ SAVE_AUP:
291+// mov eax, [esp]
292+// add eax, 0x11C
293+// mov [esp], eax
294+ lea eax, [ebx+0x108]
295+ push eax
296+ call AviUtlCommand::SaveProject
297+ add esp, 4
298+ xor eax, eax
299+ push 0x11C
300+ call ModifyReturnAddress
301+ add esp, 4
302+ ret
303+ }
304+ }
305+
229306 void applypatch(const patchdata* p)
230307 {
231308 HMODULE base = GetModuleHandleA(nullptr);
@@ -256,6 +333,26 @@ namespace
256333 return offset;
257334 }
258335
336+ bool is_aup_path(const char* path)
337+ {
338+ static constexpr char ext[] = ".aup";
339+ static constexpr size_t extlen = sizeof(ext) - 1;
340+
341+ size_t len = std::strlen(path);
342+ return len > extlen && !_strcmpi(path + len - extlen, ext);
343+ }
344+
345+ void ModifyReturnAddress(size_t off)
346+ {
347+ _asm{
348+ push eax
349+ mov eax, [ebp+12]
350+ add eax, off
351+ mov [ebp+12], eax
352+ pop eax
353+ }
354+ }
355+
259356 inline const IMAGE_NT_HEADERS32* getNtHeaders(HMODULE base)
260357 {
261358 const IMAGE_DOS_HEADER* dos = reinterpret_cast<const IMAGE_DOS_HEADER*>(base);
@@ -274,15 +371,15 @@ namespace
274371
275372 const patchdata* getpatch()
276373 {
277- static constexpr patchdata VER_0_99_k = makeVer1Patch(0xC7F0, 0x22A80);
278- static constexpr patchdata VER_0_99_k2 = makeVer1Patch(0xC830, 0x22BF0);
279- static constexpr patchdata VER_0_99_l = makeVer1Patch(0xC8F0, 0x22DC0);
280- static constexpr patchdata VER_0_99_m = makeVer1Patch(0xC950, 0x22EA0);
281- static constexpr patchdata VER_1_00 = makeVer1Patch(0xC990, 0x22F70);
282-
283- static constexpr patchdata VER_1_10_rc1 = makeVer2Patch(0xF910, 0x2C010);
284- static constexpr patchdata VER_1_10_rc2 = makeVer2Patch(0xFAE0, 0x2C1E0);
285- static constexpr patchdata VER_1_10 = makeVer2Patch(0xFA20, 0x2C0F0);
374+ static constexpr patchdata VER_0_99_k = makeVer1Patch(0xC7F0, 0x14F60, 0x22A80);
375+ static constexpr patchdata VER_0_99_k2 = makeVer1Patch(0xC830, 0x14F90, 0x22BF0);
376+ static constexpr patchdata VER_0_99_l = makeVer1Patch(0xC8F0, 0x15120, 0x22DC0);
377+ static constexpr patchdata VER_0_99_m = makeVer1Patch(0xC950, 0x151B0, 0x22EA0);
378+ static constexpr patchdata VER_1_00 = makeVer1Patch(0xC990, 0x15260, 0x22F70);
379+
380+ static constexpr patchdata VER_1_10_rc1 = makeVer2Patch(0xF910, 0x1A0A0, 0x2C010);
381+ static constexpr patchdata VER_1_10_rc2 = makeVer2Patch(0xFAE0, 0x1A270, 0x2C1E0);
382+ static constexpr patchdata VER_1_10 = makeVer2Patch(0xFA20, 0x1A1A0, 0x2C0F0);
286383
287384 switch(getTimeStamp(GetModuleHandleA(nullptr))){
288385 case 0x4F01F831: return &VER_0_99_k;
--- a/parser.cpp
+++ b/parser.cpp
@@ -4,187 +4,74 @@
44 #include <typeinfo>
55
66 #include "apihook.h"
7+#include "command.h"
8+#include "core.h"
79 #include "parser.h"
810 #include "ui.h"
911
1012 namespace
1113 {
12- void quit();
13- void save(const char* path);
14-
15- void newproject(size_t cx, size_t cy, size_t fps, size_t freq);
16- void openexo(const char* path);
17- void switchscene(size_t n);
18- void transparentscene(bool b);
19-
20- HWND getExeditWindow();
21-
2214 bool is_comment(const char*);
2315 bool is_loading_script(const char*);
2416 size_t starts_with(const char*, const char*);
2517 size_t ends_with(const char*, const char*);
18+ bool has_argument(const char*);
2619 const char* skiparg(const char*);
27-
28-
29- union{
30- int scene_no;
31- struct{ unsigned int cx, cy, fps, freq; }* videoinfo;
32- const char* path;
33- bool transparent;
34- } dlgdata;
3520 }
3621
37-BOOL ScriptParser(const char* script)
22+bool SubParser(const char* script)
3823 {
39- OutputDebugStringA(script);
40- OutputDebugStringA("\r\n");
41-
42- if(is_comment(script)) return FALSE;
43- if(is_loading_script(script)) return FALSE;
24+ if(is_comment(script)) return false;
25+ if(is_loading_script(script)) return false;
4426
4527 size_t match;
4628 if(match = starts_with(script, "exedit ")){
4729 HMODULE base = GetModuleHandleA("exedit.auf");
48- if(!base) return FALSE;
30+ if(!base) return false;
4931
5032 script += match;
5133
5234 unsigned int params[4];
5335 if(sscanf_s(script, "new %u, %u, %u, %u", &params[0], &params[1], &params[2], &params[3]) == 4){
54- newproject(params[0], params[1], params[2], params[3]);
55- return FALSE;
36+ AviUtlCommand::CreateProject(params[0], params[1], params[2], params[3]);
37+ return false;
5638 }
5739 else if(match = starts_with(script, "openexo ")){
5840 script += match;
59- openexo(script);
60- return FALSE;
41+ AviUtlCommand::OpenExoFile(script);
42+ return false;
6143 }
6244 else if(sscanf_s(script, "switchscene #%u", &params[0]) == 1){
63- switchscene(params[0]);
64- return FALSE;
45+ AviUtlCommand::SwitchScene(params[0]);
46+ return false;
6547 }
6648 else if(match = starts_with(script, "transparentscene ")){
6749 script += match;
68- transparentscene(script[0] != 'f');
69- return FALSE;
50+ AviUtlCommand::TransparentScene(script[0] != 'f');
51+ return false;
7052 }
7153 }
7254 else{
7355 script = skiparg(script);
74- if(script[0] == '-' && script[1] == 'q'){
75- quit();
76- return FALSE;
56+ if((script[0] == '-' || script[0] == '/') && (script[1] == 'q' || script[1] == 'Q')){
57+ script += 2;
58+ if(!has_argument(script)){
59+ AviUtlCommand::Quit();
60+ return false;
61+ }
7762 }
78- else if(script[0] == '-' && script[1] == 's'){
63+ else if((script[0] == '-' || script[0] == '/') && (script[1] == 'o' || script[1] == 'O')){
7964 script += 2;
8065 while(*script == ' ') script++;
81- save(script);
82- return FALSE;
66+ AviUtlCommand::SaveProject(script);
67+ return false;
8368 }
8469 }
85- return TRUE;
70+ return true;
8671 }
8772
8873 namespace
8974 {
90- void quit()
91- {
92- PostMessageA(getmainwindow(), WM_CLOSE, 0, 0);
93- }
94-
95- void save(const char* path)
96- {
97- dlgdata.path = path;
98- IATModifier hook3{ "comdlg32.dll", "GetSaveFileNameA", static_cast<decltype(GetSaveFileNameA)*>([](LPOPENFILENAMEA pofn) -> BOOL {
99- strcpy_s(pofn->lpstrFile, pofn->nMaxFile, dlgdata.path);
100- return TRUE;
101- }), GetModuleHandleA(nullptr) };
102-
103- SendMessageA(getmainwindow(), WM_COMMAND, 1023, 0xFFFFFFFF);
104- }
105-
106- void newproject(size_t cx, size_t cy, size_t fps, size_t freq)
107- {
108- HMODULE ex = GetModuleHandleA("exedit.auf");
109- if(!ex) return;
110-
111- std::remove_pointer<decltype(dlgdata.videoinfo)>::type data{ cx, cy, fps, freq };
112- dlgdata.videoinfo = &data;
113-
114- IATModifier hook1{ "user32.dll", "DialogBoxParamA", static_cast<decltype(DialogBoxParamA)*>([](HINSTANCE, LPCSTR, HWND, DLGPROC proc, LPARAM) -> INT_PTR {
115- proc(nullptr, WM_COMMAND, IDOK, 0);
116- return IDOK;
117- }), ex };
118- IATModifier hook2{ "user32.dll", "GetDlgItemInt", static_cast<decltype(GetDlgItemInt)*>([](HWND, int id, BOOL*, BOOL) -> UINT {
119- if(id == 171) return dlgdata.videoinfo->cx;
120- if(id == 172) return dlgdata.videoinfo->cy;
121- return dlgdata.videoinfo->freq;
122- }), ex };
123- IATModifier hook3{ "user32.dll", "GetDlgItemTextA", static_cast<decltype(GetDlgItemTextA)*>([](HWND, int, char* buf, int nmax) -> UINT {
124- return sprintf_s(buf, nmax, "%d", dlgdata.videoinfo->fps);
125- }), ex };
126-
127- SendMessageA(getExeditWindow(), WM_COMMAND, 1030, 0xFFFFFFFF);
128- }
129-
130- void openexo(const char* path)
131- {
132- dlgdata.path = path;
133- IATModifier hook3{ "comdlg32.dll", "GetOpenFileNameA", static_cast<decltype(GetOpenFileNameA)*>([](LPOPENFILENAMEA pofn) -> BOOL {
134- strcpy_s(pofn->lpstrFile, pofn->nMaxFile, dlgdata.path);
135- return TRUE;
136- }), GetModuleHandleA(nullptr) };
137-
138- SendMessageA(getExeditWindow(), WM_COMMAND, 1037, 0xFFFFFFFF);
139- }
140-
141- void switchscene(size_t n)
142- {
143- HMODULE ex = GetModuleHandleA("exedit.auf");
144- if(!ex || n < 0 || n >= 50) return;
145-
146- dlgdata.scene_no = n;
147- IATModifier hook1{ "user32.dll", "DialogBoxParamA", static_cast<decltype(DialogBoxParamA)*>([](HINSTANCE, LPCSTR, HWND, DLGPROC proc, LPARAM) -> INT_PTR {
148- proc(nullptr, WM_COMMAND, MAKEWPARAM(190, LBN_SELCHANGE), 0);
149- return dlgdata.scene_no;
150- }), ex };
151- IATModifier hook2{ "user32.dll", "SendDlgItemMessageA", static_cast<decltype(SendDlgItemMessageA)*>([](HWND, int, UINT, WPARAM, LPARAM) -> LRESULT {
152- return dlgdata.scene_no;
153- }), ex };
154-
155- SendMessageA(getExeditWindow(), WM_LBUTTONDOWN, MK_LBUTTON, 0);
156- }
157-
158- void transparentscene(bool b)
159- {
160- HMODULE ex = GetModuleHandleA("exedit.auf");
161- if(!ex) return;
162-
163- dlgdata.transparent = b;
164- IATModifier hook1{ "user32.dll", "DialogBoxParamA", static_cast<decltype(DialogBoxParamA)*>([](HINSTANCE, LPCSTR, HWND, DLGPROC proc, LPARAM) -> INT_PTR {
165- proc(nullptr, WM_COMMAND, IDOK, 0);
166- return IDOK;
167- }), ex };
168- IATModifier hook2{ "user32.dll", "IsDlgButtonChecked", static_cast<decltype(IsDlgButtonChecked)*>([](HWND, int) -> UINT {
169- return dlgdata.transparent ? BST_CHECKED : BST_UNCHECKED;
170- }), ex };
171-
172- SendMessageA(getExeditWindow(), WM_COMMAND, 1096, 0xFFFFFFFF);
173- }
174-
175- HWND getExeditWindow()
176- {
177- HWND ret = nullptr;
178- EnumThreadWindows(GetCurrentThreadId(), static_cast<WNDENUMPROC>([](HWND hwnd, LPARAM data) -> BOOL {
179- char buf[16];
180- GetWindowTextA(hwnd, buf, std::size(buf));
181- if(!starts_with(buf, "拡張編集")) return TRUE;
182- *reinterpret_cast<HWND*>(data) = hwnd;
183- return FALSE;
184- }), reinterpret_cast<LPARAM>(&ret));
185- return ret;
186- }
187-
18875 bool is_comment(const char* str)
18976 {
19077 return str[0] == ';';
@@ -210,7 +97,7 @@ namespace
21097 size_t starts_with(const char* str, const char* pat)
21198 {
21299 size_t n = std::strlen(pat);
213- if(!std::strncmp(pat, str, n)) return n;
100+ if(!_strnicmp(pat, str, n)) return n;
214101 return 0;
215102 }
216103
@@ -218,10 +105,16 @@ namespace
218105 {
219106 size_t m = std::strlen(str);
220107 size_t n = std::strlen(pat);
221- if(m >= n && !std::strncmp(pat, str + m - n, n)) return n;
108+ if(m >= n && !_strnicmp(pat, str + m - n, n)) return n;
222109 return 0;
223110 }
224111
112+ bool has_argument(const char* script)
113+ {
114+ while(*script == ' ') script++;
115+ return !!*script;
116+ }
117+
225118 const char* skiparg(const char* script)
226119 {
227120 while(*script == ' ') script++;
--- a/parser.h
+++ b/parser.h
@@ -1,5 +1,3 @@
11 #pragma once
22
3-#include <windows.h>
4-
5-BOOL ScriptParser(const char*);
3+bool SubParser(const char*);
--- a/ui.cpp
+++ b/ui.cpp
@@ -9,41 +9,56 @@ namespace
99 int findmenu(HMENU, const char*, HMENU*);
1010 }
1111
12-HWND getmainwindow()
12+namespace AviUtlUI
1313 {
14- HWND ret = nullptr;
15- EnumThreadWindows(GetCurrentThreadId(), static_cast<WNDENUMPROC>([](HWND hwnd, LPARAM data) -> BOOL {
16- char buf[16];
17- GetClassNameA(hwnd, buf, std::size(buf));
18- if(_strcmpi(buf, "AviUtl")) return TRUE;
14+ HWND GetMainWindow()
15+ {
16+ HWND ret = nullptr;
17+ EnumThreadWindows(GetCurrentThreadId(), static_cast<WNDENUMPROC>([](HWND hwnd, LPARAM data) -> BOOL {
18+ char buf[16];
19+ GetClassNameA(hwnd, buf, std::size(buf));
20+ if(_strcmpi(buf, "AviUtl")) return TRUE;
1921
20- *reinterpret_cast<HWND*>(data) = hwnd;
21- return FALSE;
22- }), reinterpret_cast<LPARAM>(&ret));
22+ *reinterpret_cast<HWND*>(data) = hwnd;
23+ return FALSE;
24+ }), reinterpret_cast<LPARAM>(&ret));
2325
24- while(HWND owner = GetWindow(ret, GW_OWNER)) ret = owner;
26+ while(HWND owner = GetWindow(ret, GW_OWNER)) ret = owner;
2527
26- return ret;
27-}
28+ return ret;
29+ }
2830
29-void addmenu()
30-{
31- HMENU file = GetSubMenu(GetMenu(getmainwindow()), 0);
32- HMENU imp = nullptr;
33- findmenu(file, "インポート", &imp);
34- const int delpos = findmenu(imp, "Script Engine", nullptr);
35- if(delpos < 0) return;
36- const int inspos = findmenu(file, "AVI出力 (Ctrl+S)", nullptr);
37- if(inspos < 0) return;
31+ void AddMenu()
32+ {
33+ HMENU file = GetSubMenu(GetMenu(GetMainWindow()), 0);
34+ HMENU imp = nullptr;
35+ findmenu(file, "インポート", &imp);
36+ const int delpos = findmenu(imp, "Script Engine", nullptr);
37+ if(delpos < 0) return;
38+ const int inspos = findmenu(file, "AVI出力 (Ctrl+S)", nullptr);
39+ if(inspos < 0) return;
40+
41+ UINT id = GetMenuItemID(imp, delpos);
42+ DeleteMenu(imp, delpos, MF_BYPOSITION);
3843
39- UINT id = GetMenuItemID(imp, delpos);
40- DeleteMenu(imp, delpos, MF_BYPOSITION);
44+ const MENUITEMINFOA load { sizeof(load), MIIM_ID | MIIM_TYPE, MFT_STRING, MFS_ENABLED, id, nullptr, nullptr, nullptr, 0, const_cast<char*>("スクリプト読み込み"), 0, nullptr };
45+ InsertMenuItemA(file, inspos, TRUE, &load);
46+
47+ constexpr MENUITEMINFOA sep { sizeof(sep), MIIM_TYPE, MFT_SEPARATOR, MFS_DEFAULT, 0, nullptr, nullptr, nullptr, 0, nullptr, 0, nullptr };
48+ InsertMenuItemA(file, inspos + 1, TRUE, &sep);
49+ }
4150
42- const MENUITEMINFOA load { sizeof(load), MIIM_ID | MIIM_TYPE, MFT_STRING, MFS_ENABLED, id, nullptr, nullptr, nullptr, 0, const_cast<char*>("スクリプト読み込み"), 0, nullptr };
43- InsertMenuItemA(file, inspos, TRUE, &load);
51+ BOOL WndProc(HWND hwnd, UINT msg, WPARAM, LPARAM, void* editp, FILTER*)
52+ {
53+ if(msg == WM_FILTER_IMPORT){
54+ char path[MAX_PATH] = "";
55+ OPENFILENAMEA ofn{ sizeof(ofn), hwnd, nullptr, "Script Files(*.aus)\0*.aus\0\0", nullptr, 0, 1, path, std::size(path), nullptr, 0, "", nullptr, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, 0, 0, "aus", 0, nullptr, nullptr, nullptr, 0, 0 };
56+ if(!GetOpenFileNameA(&ofn)) return FALSE;
4457
45- constexpr MENUITEMINFOA sep { sizeof(sep), MIIM_TYPE, MFT_SEPARATOR, MFS_DEFAULT, 0, nullptr, nullptr, nullptr, 0, nullptr, 0, nullptr };
46- InsertMenuItemA(file, inspos + 1, TRUE, &sep);
58+ LoadScript(path, editp);
59+ }
60+ return FALSE;
61+ }
4762 }
4863
4964 namespace
@@ -65,15 +80,3 @@ namespace
6580 return -1;
6681 }
6782 }
68-
69-BOOL wndproc(HWND hwnd, UINT msg, WPARAM, LPARAM, void* editp, FILTER*)
70-{
71- if(msg == WM_FILTER_IMPORT){
72- char path[MAX_PATH] = "";
73- OPENFILENAMEA ofn{ sizeof(ofn), hwnd, nullptr, "Script Files(*.aus)\0*.aus\0\0", nullptr, 0, 1, path, std::size(path), nullptr, 0, "", nullptr, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, 0, 0, "aus", 0, nullptr, nullptr, nullptr, 0, 0 };
74- if(!GetOpenFileNameA(&ofn)) return FALSE;
75-
76- LoadScript(path, editp);
77- }
78- return FALSE;
79-}
--- a/ui.h
+++ b/ui.h
@@ -3,7 +3,10 @@
33 #include <windows.h>
44 #include "filter.h"
55
6-HWND getmainwindow();
6+namespace AviUtlUI
7+{
8+ HWND GetMainWindow();
79
8-void addmenu();
9-BOOL wndproc(HWND, UINT, WPARAM, LPARAM, void*, FILTER*);
10+ void AddMenu();
11+ BOOL WndProc(HWND, UINT, WPARAM, LPARAM, void*, FILTER*);
12+}