Skip to content

Commit

Permalink
Merge branch 'change_disp_scene'
Browse files Browse the repository at this point in the history
  • Loading branch information
ePi5131 committed Jul 8, 2023
2 parents 1b2f33b + 3ea347c commit 9030cc5
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 0 deletions.
5 changes: 5 additions & 0 deletions patch.aul.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ https://scrapbox.io/ePi5131/patch.aul
・高さ4097以上の描画が正常に行えないことがあるのを修正
・幅0のバッファにYCA<->RGBA色変換を行って例外になることがあるのを修正
・グループ制御とカメラ制御を併用しているシーンを呼び出すと起こる不具合を修正
・Shiftを押しながらシーン切り替えをすると範囲選択がされることがあるのを修正
・シーン切り替え時に拡張編集のウィンドウタイトル部分が変わらないのを修正

追加
・コンソールの表示
Expand Down Expand Up @@ -235,6 +237,7 @@ https://scrapbox.io/ePi5131/patch.aul
"shared_cache" : boolean, ; 一部キャッシュは共有メモリ(システムの設定のキャッシュサイズの部分)を使用するように変更 (既定値: true)
"yc_rgb_cvt" : boolean, ; 改行のみのテキストで一部スクリプトを使うとエラーが発生するのを修正 (既定値: true)
"group_camera_scene" : boolean, ; グループ制御とカメラ制御を併用しているシーンを呼び出すと起こる不具合を修正 (既定値: true)
"change_disp_scene" : boolean, ; シーン切り替え時のバグを修正 (既定値: true)
"undo" : boolean, ; 元に戻す 関連のバグ修正 (既定値: true)
"undo.redo" : boolean, ; やり直す を追加 (既定値: true)
"console" : boolean, ; コンソール (既定値: true)
Expand Down Expand Up @@ -493,3 +496,5 @@ Lua追加要素詳細
幅0のバッファにYCA<->RGBA色変換を行って例外になることがあるのを修正
グループ制御とカメラ制御を併用しているシーンを呼び出すと起こる不具合を修正
ディスプレイスメントマップのコード最適化
Shiftを押しながらシーン切り替えをすると範囲選択がされることがあるのを修正
シーン切り替え時に拡張編集のウィンドウタイトル部分が変わらないのを修正
6 changes: 6 additions & 0 deletions patch/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ class Config2 {
#ifdef PATCH_SWITCH_GROUP_CAMERA_SCENE
patch::group_camera_scene.switch_load(cr);
#endif
#ifdef PATCH_SWITCH_CHANGE_DISP_SCENE
patch::change_disp_scene.switch_load(cr);
#endif

#ifdef PATCH_SWITCH_UNDO
patch::undo.switch_load(cr);
Expand Down Expand Up @@ -578,6 +581,9 @@ class Config2 {
#ifdef PATCH_SWITCH_GROUP_CAMERA_SCENE
patch::group_camera_scene.switch_store(switch_);
#endif
#ifdef PATCH_SWITCH_CHANGE_DISP_SCENE
patch::change_disp_scene.switch_store(switch_);
#endif

#ifdef PATCH_SWITCH_UNDO
patch::undo.switch_store(switch_);
Expand Down
3 changes: 3 additions & 0 deletions patch/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ void init_t::InitAtExeditLoad() {
#ifdef PATCH_SWITCH_GROUP_CAMERA_SCENE
patch::group_camera_scene.init();
#endif
#ifdef PATCH_SWITCH_CHANGE_DISP_SCENE
patch::change_disp_scene.init();
#endif

patch::setting_dialog();

Expand Down
1 change: 1 addition & 0 deletions patch/macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
#define PATCH_SWITCH_SHARED_CACHE shared_cache
#define PATCH_SWITCH_YC_RGB_CVT ycrgbcvt
#define PATCH_SWITCH_GROUP_CAMERA_SCENE group_camera_scene
#define PATCH_SWITCH_CHANGE_DISP_SCENE change_dispscene

#define PATCH_SWITCH_UNDO undo
#ifdef PATCH_SWITCH_UNDO
Expand Down
9 changes: 9 additions & 0 deletions patch/offset_address.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ namespace OFS {
constexpr i32 filter_change_framerate_ptr = 0x080b28;
constexpr i32 filter_clipping_and_resize_ptr = 0x07ad58;

constexpr i32 ini_shiftselect = 0x086398;

constexpr i32 str_dot_avi = 0x0745fc; // ".avi"

}
Expand All @@ -42,6 +44,9 @@ namespace OFS {
constexpr i32 exedit_hwnd = 0x177a44;
constexpr i32 settingdialog_hwnd = 0x1539c8;

constexpr i32 tl_title = 0x0a4cfc;


constexpr i32 blend_yca_normal_func = 0x007df0;
constexpr i32 blend_yc_normal_func = 0x007f20;

Expand Down Expand Up @@ -125,6 +130,10 @@ namespace OFS {
constexpr i32 GetCache = 0x00cff0;
constexpr i32 CreateCache = 0x00cd00;
constexpr i32 GetOrCreateCache = 0x04d7d0;
constexpr i32 frame_cursor = 0x1a5304;
constexpr i32 frame_n = 0x14d3a0;
constexpr i32 double_framerate = 0x0a4068;
constexpr i32 double_framerate_scale = 0x0a4060;

constexpr i32 exedit_edit_open = 0x03ac30;

Expand Down
1 change: 1 addition & 0 deletions patch/patch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,4 @@
#include "patch_rendering.hpp"
#include "patch_yc_rgb_cvt.hpp"
#include "patch_group_camera_scene.hpp"
#include "patch_change_disp_scene.hpp"
2 changes: 2 additions & 0 deletions patch/patch.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<ClInclude Include="offset_address.hpp" />
<ClInclude Include="overwrite_resource.hpp" />
<ClInclude Include="patch.hpp" />
<ClInclude Include="patch_change_disp_scene.hpp" />
<ClInclude Include="resource.h" />
<ClInclude Include="scope_exit.hpp" />
<ClInclude Include="stopwatch.hpp" />
Expand Down Expand Up @@ -273,6 +274,7 @@
<ClCompile Include="patch_aviutl_wndproc_override.cpp">
<Filter>feature</Filter>
</ClCompile>
<ClCompile Include="patch_change_disp_scene.cpp" />
<ClCompile Include="patch_exception_log.cpp">
<Filter>feature</Filter>
</ClCompile>
Expand Down
52 changes: 52 additions & 0 deletions patch/patch_change_disp_scene.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include "patch_change_disp_scene.hpp"

#ifdef PATCH_SWITCH_CHANGE_DISP_SCENE
namespace patch {

void update_title() {
char title[64];
int frame = *(int*)(GLOBAL::exedit_base + OFS::ExEdit::frame_cursor);
int frame_n = *(int*)(GLOBAL::exedit_base + OFS::ExEdit::frame_n);
frame = std::clamp(frame, 0, frame_n - 1);

double framerate = *(double*)(GLOBAL::exedit_base + OFS::ExEdit::double_framerate);
double framerate_scale = *(double*)(GLOBAL::exedit_base + OFS::ExEdit::double_framerate_scale);
int centisecond = (int)(100.0 / framerate * (double)frame * framerate_scale);
char* tl_title = (char*)(GLOBAL::exedit_base + OFS::ExEdit::tl_title);
wsprintfA(title, tl_title, centisecond / 360000, (centisecond % 360000) / 6000, (centisecond % 6000) / 100, centisecond % 100, frame + 1, frame_n);

SetWindowTextA(*(HWND*)(GLOBAL::exedit_base + OFS::ExEdit::exedit_hwnd), title);
}

int __cdecl change_disp_scene_t::set_frame_wrap(AviUtl::EditHandle* editp, int frame) {

int* ini_shiftselect = (int*)(GLOBAL::aviutl_base + OFS::AviUtl::ini_shiftselect);
int tmp_shiftselect = *ini_shiftselect;
*ini_shiftselect = 0;

auto a_exfunc = (AviUtl::ExFunc*)(GLOBAL::aviutl_base + OFS::AviUtl::exfunc);
int ret = a_exfunc->set_frame(editp, frame);

update_title();

*ini_shiftselect = tmp_shiftselect;

return ret;
}
} // namespace patch
#endif // ifdef PATCH_SWITCH_CHANGE_DISP_SCENE
94 changes: 94 additions & 0 deletions patch/patch_change_disp_scene.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once
#include "macro.h"

#ifdef PATCH_SWITCH_CHANGE_DISP_SCENE

#include <exedit.hpp>

#include "global.hpp"
#include "offset_address.hpp"
#include "restorable_patch.hpp"

#include "config_rw.hpp"

namespace patch {
// init at exedit load
/* シーン切り替え時のバグを修正
  ・Shiftを押しながらシーン切り替えをすると範囲選択がされる(システムの設定>フレーム移動時にSHIFTキーを押している時は範囲選択移動にする の影響)
 ・拡張編集のウィンドウキャプションが変わらない
*/
inline class change_disp_scene_t {
static int __cdecl set_frame_wrap(AviUtl::EditHandle* editp, int frame);

bool enabled = true;
bool enabled_i;

inline static const char key[] = "change_disp_scene";

inline static int last_id = -1;

public:

void init() {
enabled_i = enabled;

if (!enabled_i)return;
{
/*
1002be69 8b4e60 mov ecx,dword ptr [esi+60]
1002be6c 52 push edx
1002be6d 57 push edi
1002be6e ff5124 call dword ptr [ecx+24]
1002be71
1002be69 52 push edx
1002be6a 57 push edi
1002be6b 90 nop
1002be6c e8XxXxXxXx call new_func
1002be71
*/

OverWriteOnProtectHelper h(GLOBAL::exedit_base + 0x02be69, 8);
h.store_i32(0, '\x52\x57\x90\xe8');
h.replaceNearJmp(4, &set_frame_wrap);

}


}
void switching(bool flag) {
enabled = flag;
}

bool is_enabled() { return enabled; }
bool is_enabled_i() { return enabled_i; }

void switch_load(ConfigReader& cr) {
cr.regist(key, [this](json_value_s* value) {
ConfigReader::load_variable(value, enabled);
});
}

void switch_store(ConfigWriter& cw) {
cw.append(key, enabled);
}

} change_disp_scene;
} // namespace patch
#endif // ifdef PATCH_SWITCH_CHANGE_DISP_SCENE

0 comments on commit 9030cc5

Please sign in to comment.