Add slider to change crosshair size and a core option for the Libretro core (#1304)
This commit is contained in:
parent
665ef86cf0
commit
78a874d20e
|
@ -93,6 +93,7 @@ std::array<Option<int>, 4> CrosshairColor {
|
|||
Option<int>("rend.CrossHairColor3"),
|
||||
Option<int>("rend.CrossHairColor4"),
|
||||
};
|
||||
Option<int> CrosshairSize("rend.CrosshairSize", 40);
|
||||
Option<int> SkipFrame("ta.skip");
|
||||
Option<int> MaxThreads("pvr.MaxThreads", 3);
|
||||
Option<int> AutoSkipFrame("pvr.AutoSkipFrame", 0);
|
||||
|
|
|
@ -456,6 +456,7 @@ extern Option<bool> PerStripSorting;
|
|||
extern Option<bool> DelayFrameSwapping; // Delay swapping frame until FB_R_SOF matches FB_W_SOF
|
||||
extern Option<bool> WidescreenGameHacks;
|
||||
extern std::array<Option<int>, 4> CrosshairColor;
|
||||
extern Option<int> CrosshairSize;
|
||||
extern Option<int> SkipFrame;
|
||||
extern Option<int> MaxThreads;
|
||||
extern Option<int> AutoSkipFrame; // 0: none, 1: some, 2: more
|
||||
|
|
|
@ -172,11 +172,11 @@ void DX11Overlay::draw(u32 width, u32 height, bool vmu, bool crosshair)
|
|||
|
||||
auto [x, y] = getCrosshairPosition(i);
|
||||
#ifdef LIBRETRO
|
||||
float halfWidth = LIGHTGUN_CROSSHAIR_SIZE / 2.f / config::ScreenStretching * 100.f * config::RenderResolution / 480.f;
|
||||
float halfHeight = LIGHTGUN_CROSSHAIR_SIZE / 2.f * config::RenderResolution / 480.f;
|
||||
float halfWidth = lightgun_crosshair_size / 2.f / config::ScreenStretching * 100.f * config::RenderResolution / 480.f;
|
||||
float halfHeight = lightgun_crosshair_size / 2.f * config::RenderResolution / 480.f;
|
||||
x /= config::ScreenStretching / 100.f;
|
||||
#else
|
||||
float halfWidth = XHAIR_WIDTH * settings.display.uiScale / 2.f;
|
||||
float halfWidth = config::CrosshairSize * settings.display.uiScale / 2.f;
|
||||
float halfHeight = halfWidth;
|
||||
#endif
|
||||
D3D11_VIEWPORT vp{};
|
||||
|
|
|
@ -118,7 +118,7 @@ void D3DOverlay::draw(u32 width, u32 height, bool vmu, bool crosshair)
|
|||
continue;
|
||||
|
||||
auto [x, y] = getCrosshairPosition(i);
|
||||
float halfWidth = XHAIR_WIDTH * settings.display.uiScale / 2.f;
|
||||
float halfWidth = config::CrosshairSize * settings.display.uiScale / 2.f;
|
||||
RECT rect { (long) (x - halfWidth), (long) (y - halfWidth), (long) (x + halfWidth), (long) (y + halfWidth) };
|
||||
D3DCOLOR color = (config::CrosshairColor[i] & 0xFF00FF00)
|
||||
| ((config::CrosshairColor[i] >> 16) & 0xFF)
|
||||
|
|
|
@ -919,8 +919,8 @@ void DrawGunCrosshair(u8 port, int width, int height)
|
|||
if (lightgun_params[port].offscreen || lightgun_params[port].colour == 0)
|
||||
return;
|
||||
|
||||
float w = (float)LIGHTGUN_CROSSHAIR_SIZE * 4.f / 3.f / gl.ofbo.aspectRatio * config::RenderResolution / 480.f;
|
||||
float h = (float)LIGHTGUN_CROSSHAIR_SIZE * config::RenderResolution / 480.f;
|
||||
float w = lightgun_crosshair_size * 4.f / 3.f / gl.ofbo.aspectRatio * config::RenderResolution / 480.f;
|
||||
float h = lightgun_crosshair_size * config::RenderResolution / 480.f;
|
||||
auto [x, y] = getCrosshairPosition(port);
|
||||
x -= w / 2;
|
||||
y -= h / 2;
|
||||
|
|
|
@ -144,9 +144,9 @@ void OpenGLDriver::displayCrosshairs()
|
|||
|
||||
ImVec2 pos;
|
||||
std::tie(pos.x, pos.y) = getCrosshairPosition(i);
|
||||
pos.x -= (XHAIR_WIDTH * settings.display.uiScale) / 2.f;
|
||||
pos.y += (XHAIR_WIDTH * settings.display.uiScale) / 2.f;
|
||||
ImVec2 pos_b(pos.x + XHAIR_WIDTH * settings.display.uiScale, pos.y - XHAIR_HEIGHT * settings.display.uiScale);
|
||||
pos.x -= (config::CrosshairSize * settings.display.uiScale) / 2.f;
|
||||
pos.y += (config::CrosshairSize * settings.display.uiScale) / 2.f;
|
||||
ImVec2 pos_b(pos.x + config::CrosshairSize * settings.display.uiScale, pos.y - config::CrosshairSize * settings.display.uiScale);
|
||||
|
||||
ImGui::GetWindowDrawList()->AddImage(crosshairTexId, pos, pos_b, ImVec2(0, 1), ImVec2(1, 0), config::CrosshairColor[i]);
|
||||
}
|
||||
|
|
|
@ -1700,6 +1700,7 @@ static void gui_display_settings()
|
|||
ImGui::Spacing();
|
||||
header("Dreamcast Devices");
|
||||
{
|
||||
bool is_there_any_xhair = false;
|
||||
for (int bus = 0; bus < MAPLE_PORTS; bus++)
|
||||
{
|
||||
ImGui::Text("Device %c", bus + 'A');
|
||||
|
@ -1790,10 +1791,15 @@ static void gui_display_settings()
|
|||
config::CrosshairColor[bus] = 0;
|
||||
}
|
||||
}
|
||||
is_there_any_xhair |= enabled;
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
}
|
||||
{
|
||||
DisabledScope scope(!is_there_any_xhair);
|
||||
OptionSlider("Crosshair Size", config::CrosshairSize, 10, 100);
|
||||
}
|
||||
OptionCheckbox("Per Game VMU A1", config::PerGameVmu, "When enabled, each game has its own VMU on port 1 of controller A.");
|
||||
}
|
||||
|
||||
|
|
|
@ -48,9 +48,6 @@ void push_vmu_screen(int bus_id, int bus_port, u8* buffer);
|
|||
const u32 *getCrosshairTextureData();
|
||||
std::pair<float, float> getCrosshairPosition(int playerNum);
|
||||
|
||||
constexpr int XHAIR_WIDTH = 40;
|
||||
constexpr int XHAIR_HEIGHT = 40;
|
||||
|
||||
static inline bool crosshairsNeeded()
|
||||
{
|
||||
if (config::CrosshairColor[0] == 0 && config::CrosshairColor[1] == 0
|
||||
|
|
|
@ -210,12 +210,12 @@ void VulkanOverlay::Draw(vk::CommandBuffer commandBuffer, vk::Extent2D viewport,
|
|||
auto [x, y] = getCrosshairPosition(i);
|
||||
|
||||
#ifdef LIBRETRO
|
||||
float w = LIGHTGUN_CROSSHAIR_SIZE * scaling / config::ScreenStretching * 100.f;
|
||||
float h = LIGHTGUN_CROSSHAIR_SIZE * scaling;
|
||||
float w = lightgun_crosshair_size * scaling / config::ScreenStretching * 100.f;
|
||||
float h = lightgun_crosshair_size * scaling;
|
||||
x /= config::ScreenStretching / 100.f;
|
||||
#else
|
||||
float w = XHAIR_WIDTH * scaling;
|
||||
float h = XHAIR_HEIGHT * scaling;
|
||||
float w = config::CrosshairSize * scaling;
|
||||
float h = config::CrosshairSize * scaling;
|
||||
#endif
|
||||
x -= w / 2;
|
||||
y -= h / 2;
|
||||
|
|
|
@ -609,6 +609,9 @@ static bool set_variable_visibility(void)
|
|||
{
|
||||
option_display.visible = lightgunSettingsShown;
|
||||
|
||||
option_display.key = CORE_OPTION_NAME "_lightgun_crosshair_size_scaling";
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display);
|
||||
|
||||
for (unsigned i = 0; i < 4; i++)
|
||||
{
|
||||
char key[256];
|
||||
|
@ -911,6 +914,12 @@ static void update_variables(bool first_startup)
|
|||
else
|
||||
allow_service_buttons = false;
|
||||
|
||||
var.key = CORE_OPTION_NAME "_lightgun_crosshair_size_scaling";
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
lightgun_crosshair_size = (float)LIGHTGUN_CROSSHAIR_SIZE * std::stof(var.value) / 100.f;
|
||||
else
|
||||
lightgun_crosshair_size = (float)LIGHTGUN_CROSSHAIR_SIZE;
|
||||
|
||||
char key[256];
|
||||
key[0] = '\0';
|
||||
|
||||
|
|
|
@ -878,6 +878,44 @@ struct retro_core_option_v2_definition option_defs_us[] = {
|
|||
},
|
||||
"disabled"
|
||||
},
|
||||
{
|
||||
CORE_OPTION_NAME "_lightgun_crosshair_size_scaling",
|
||||
"Gun Crosshair Size Scaling",
|
||||
NULL,
|
||||
"",
|
||||
NULL,
|
||||
"input",
|
||||
{
|
||||
{ "50%", NULL },
|
||||
{ "60%", NULL },
|
||||
{ "70%", NULL },
|
||||
{ "80%", NULL },
|
||||
{ "90%", NULL },
|
||||
{ "100%", NULL },
|
||||
{ "110%", NULL },
|
||||
{ "120%", NULL },
|
||||
{ "130%", NULL },
|
||||
{ "140%", NULL },
|
||||
{ "150%", NULL },
|
||||
{ "160%", NULL },
|
||||
{ "170%", NULL },
|
||||
{ "180%", NULL },
|
||||
{ "190%", NULL },
|
||||
{ "200%", NULL },
|
||||
{ "210%", NULL },
|
||||
{ "220%", NULL },
|
||||
{ "230%", NULL },
|
||||
{ "240%", NULL },
|
||||
{ "250%", NULL },
|
||||
{ "260%", NULL },
|
||||
{ "270%", NULL },
|
||||
{ "280%", NULL },
|
||||
{ "290%", NULL },
|
||||
{ "300%", NULL },
|
||||
{ NULL, NULL },
|
||||
},
|
||||
"100%",
|
||||
},
|
||||
{
|
||||
CORE_OPTION_NAME "_lightgun1_crosshair",
|
||||
"Gun Crosshair 1 Display",
|
||||
|
|
|
@ -112,6 +112,7 @@ u8 lightgun_palette[LIGHTGUN_COLORS_COUNT*3] =
|
|||
};
|
||||
|
||||
lightgun_params_t lightgun_params[4];
|
||||
float lightgun_crosshair_size = (float)LIGHTGUN_CROSSHAIR_SIZE;
|
||||
|
||||
std::pair<float, float> getCrosshairPosition(int playerNum)
|
||||
{
|
||||
|
|
|
@ -111,3 +111,4 @@ struct lightgun_params_t {
|
|||
extern u8 lightgun_palette[LIGHTGUN_COLORS_COUNT*3];
|
||||
extern u8 lightgun_img_crosshair[LIGHTGUN_CROSSHAIR_SIZE*LIGHTGUN_CROSSHAIR_SIZE];
|
||||
extern lightgun_params_t lightgun_params[4] ;
|
||||
extern float lightgun_crosshair_size;
|
||||
|
|
Loading…
Reference in New Issue