Small refactor

This commit is contained in:
korenkonder
2023-07-08 04:05:24 +03:00
parent 8c82683cfd
commit 43c8e7c79b
7 changed files with 34 additions and 11 deletions
+1
View File
@@ -616,6 +616,7 @@ void post_process::draw_lens_ghost(render_texture* rt) {
void post_process::init_fbo(int32_t render_width, int32_t render_height,
int32_t sprite_width, int32_t sprite_height, int32_t screen_width, int32_t screen_height) {
if (this->render_width == render_width && this->render_height == render_height
&& this->sprite_width == sprite_width && this->sprite_height == sprite_height
&& this->screen_width == screen_width && this->screen_height == screen_height)
return;
+7 -7
View File
@@ -1287,8 +1287,8 @@ namespace pv_db {
const char* eyes_base_adjust_type;
if (kv.read("eyes_base_adjust_type", eyes_base_adjust_type))
for (int32_t i = EYES_BASE_ADJUST_NONE; i < EYES_BASE_ADJUST_MAX; i++)
if (!strcmp(eyes_base_adjust_type, eyes_base_adjust_type_names[i])) {
for (int32_t i = 0; i < EYES_BASE_ADJUST_MAX; i++)
if (!str_utils_compare(eyes_base_adjust_type, eyes_base_adjust_type_names[i])) {
pv->eyes_base_adjust_type = (::eyes_base_adjust_type)i;
break;
}
@@ -1407,8 +1407,8 @@ namespace pv_db {
const char* level;
if (kv.read("level", level))
for (int32_t k = PV_LV_00_0; k < PV_LV_MAX; k++)
if (!strcmp(level, pv_level_names[k])) {
for (int32_t k = 0; k < PV_LV_MAX; k++)
if (!str_utils_compare(level, pv_level_names[k])) {
d.level = (pv_level)k;
break;
}
@@ -1947,11 +1947,11 @@ namespace pv_db {
const char* type;
if (kv.read(frame_texture_type_names[i], type)) {
if (!strcmp(type, "PRE_PP"))
if (!str_utils_compare(type, "PRE_PP"))
frame_texture.type = PV_FRAME_TEXTURE_PRE_PP;
else if (!strcmp(type, "POST_PP"))
else if (!str_utils_compare(type, "POST_PP"))
frame_texture.type = PV_FRAME_TEXTURE_POST_PP;
else if (!strcmp(type, "FB"))
else if (!str_utils_compare(type, "FB"))
frame_texture.type = PV_FRAME_TEXTURE_FB;
else
frame_texture.type = PV_FRAME_TEXTURE_POST_PP;
+6
View File
@@ -11,4 +11,10 @@
#define PV_DEBUG (1)
#define DATA_EDIT (0)
#if BAKE_PNG || BAKE_VIDEO
#define BAKE_BASE_WIDTH (1920)
#define BAKE_BASE_HEIGHT (1080)
#define BAKE_RES_SCALE (2)
#endif
#endif
+2 -1
View File
@@ -3450,7 +3450,8 @@ void struc_751::sub_1403011A0() {
/*if (sub_1406A0510())
field_20 = 0;*/
if (!(uint16_t)field_18)
extern bool disable_cursor;
if (disable_cursor || !(uint16_t)field_18)
return;
if (stru_1409D6390[(uint16_t)field_18 - 1].field_0 != 0x49) {
+3
View File
@@ -32,6 +32,7 @@ extern ImGuiContext* imgui_context;
extern lock_cs imgui_context_lock;
extern bool disable_input_state_update;
extern bool disable_cursor;
namespace Input {
struct Key {
@@ -211,6 +212,8 @@ namespace Input {
if (IsKeyTapped(GLFW_KEY_F3))
disable_input_state_update ^= true;
else if (IsKeyTapped(GLFW_KEY_F3, GLFW_MOD_CONTROL))
disable_cursor ^= true;
if (!window_handle || window_handle != GetForegroundWindow() || !disable_input_state_update)
return;
+9
View File
@@ -5,6 +5,7 @@
#include "input_state.hpp"
#include "../CRE/render_context.hpp"
#include "config.hpp"
#include "input.hpp"
/*
@@ -69,6 +70,7 @@ static bool sub_140190A30(struc_794* a1, int32_t index);
InputState* input_state;
bool disable_input_state_update = false;
bool disable_cursor = false;
extern render_context* rctx_ptr;
@@ -604,10 +606,17 @@ static bool sub_140190A30(struc_794* a1, int32_t index) {
}
}
#if BAKE_PNG || BAKE_VIDEO
int32_t x_offset = 0;
int32_t y_offset = 0;
float_t x_scale = 1280.0f / (float_t)BAKE_BASE_WIDTH;
float_t y_scale = 720.0f / (float_t)BAKE_BASE_HEIGHT;
#else
int32_t x_offset = rctx_ptr->post_process.screen_x_offset;
int32_t y_offset = rctx_ptr->post_process.screen_y_offset;
float_t x_scale = 1280.0f / (float_t)rctx_ptr->post_process.sprite_width;
float_t y_scale = 720.0f / (float_t)rctx_ptr->post_process.sprite_height;
#endif
a1->field_30[8] = (int32_t)((float_t)(Input::pos.x - x_offset) * x_scale);
a1->field_30[9] = (int32_t)((float_t)(Input::pos.y - y_offset) * y_scale);
+6 -3
View File
@@ -149,8 +149,10 @@ static const char* application_name = "ReDIVA";
static int32_t old_scale_index;
static int32_t scale_index;
static vec2i old_internal_res;
static vec2i old_internal_2d_res;
static vec2i old_internal_3d_res;
vec2i internal_res;
vec2i internal_2d_res;
vec2i internal_3d_res;
static int32_t old_width;
@@ -444,8 +446,9 @@ static bool render_init(render_init_struct* ris) {
res_window_set(RESOLUTION_MODE_HD);
#if BAKE_PNG || BAKE_VIDEO
width = 1920;
height = 1080;
width = BAKE_BASE_WIDTH;
height = BAKE_BASE_HEIGHT;
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
#endif
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
@@ -1315,7 +1318,7 @@ static void render_resize_fb(render_context* rctx, bool change_fb) {
res_width = round(res_height * aspect);
#if BAKE_PNG || BAKE_VIDEO
vec2i internal_res = { (int32_t)res_width * 2, (int32_t)res_height * 2};
vec2i internal_res = { (int32_t)res_width * BAKE_RES_SCALE, (int32_t)res_height * BAKE_RES_SCALE };
internal_2d_res = vec2i::clamp(internal_res, 1, sv_max_texture_size);
internal_3d_res.x = (int32_t)roundf((float_t)internal_res.x);
internal_3d_res.y = (int32_t)roundf((float_t)internal_res.y);