Skip to content

Commit

Permalink
bring back zoom hack
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Auto committed Oct 29, 2023
1 parent 33b6df2 commit 78546ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/game_api/game_api.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "game_api.hpp"

#include "render_api.hpp"
#include "search.hpp"
#include "state.hpp"

GameAPI* GameAPI::get()
{
Expand All @@ -11,7 +13,8 @@ GameAPI* GameAPI::get()

float GameAPI::get_current_zoom()
{
return renderer->current_zoom + renderer->current_zoom_offset;
auto state = State::get().ptr();
return renderer->current_zoom + get_layer_transition_zoom_offset(state->camera_layer);
}

float GameAPI::get_target_zoom()
Expand Down
9 changes: 9 additions & 0 deletions src/game_api/render_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void render_loading(size_t param_1)
}

std::optional<TEXTURE> g_forced_lut_textures[2]{};
float g_layer_zoom_offset[2];

using RenderLayer = void(const std::vector<Illumination*>&, uint8_t, const Camera&, const char**, const char**);
RenderLayer* g_render_layer_trampoline{nullptr};
Expand All @@ -72,6 +73,9 @@ void render_layer(const std::vector<Illumination*>& lightsources, uint8_t layer,
if (trigger_vanilla_render_layer_callbacks(ON::RENDER_PRE_LAYER, layer))
return;

auto game_api = GameAPI::get();
g_layer_zoom_offset[layer] = game_api->renderer->current_zoom_offset;

// The lhs and rhs LUTs are blended in the shader, but we don't know where that value is CPU side so we can only override
// with a single LUT for now
if (g_forced_lut_textures[layer])
Expand Down Expand Up @@ -106,6 +110,11 @@ void render_game(StateMemory* state)
trigger_vanilla_render_callbacks(ON::RENDER_POST_GAME);
}

float get_layer_transition_zoom_offset(uint8_t l)
{
return g_layer_zoom_offset[l];
}

void RenderAPI::set_lut(TEXTURE texture_id, uint8_t layer)
{
g_forced_lut_textures[layer] = texture_id;
Expand Down
1 change: 1 addition & 0 deletions src/game_api/render_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ void init_render_api_hooks();
bool& get_journal_enabled();
void on_open_journal_chapter(JournalUI* journal_ui, uint8_t chapter, bool instant, bool play_sound);
void render_draw_depth(Layer* layer, uint8_t draw_depth, float bbox_left, float bbox_bottom, float bbox_right, float bbox_top);
float get_layer_transition_zoom_offset(uint8_t layer);

struct HudInventory
{
Expand Down

0 comments on commit 78546ae

Please sign in to comment.