From f7988299eb0142766f28b81589a7c9e21f33d200 Mon Sep 17 00:00:00 2001 From: szapp Date: Tue, 4 Dec 2018 22:45:56 +0100 Subject: [PATCH] Add INI setting for scaling the reticle --- _work/data/Scripts/Content/GFA/_intern/const.d | 1 + _work/data/Scripts/Content/GFA/_intern/init.d | 8 ++++++++ .../data/Scripts/Content/GFA/_intern/reticle.d | 17 +++++++++++++---- .../Scripts/Content/GFA/config/criticalHit.d | 9 +++++++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/_work/data/Scripts/Content/GFA/_intern/const.d b/_work/data/Scripts/Content/GFA/_intern/const.d index 0d56cb2..c6fc282 100644 --- a/_work/data/Scripts/Content/GFA/_intern/const.d +++ b/_work/data/Scripts/Content/GFA/_intern/const.d @@ -64,6 +64,7 @@ const int GFA_MAX_DIST = 5000; // Distance for shoo var int GFA_AimRayInterval; // Perform trace ray every x ms (change in ini-file) var int GFA_AimRayPrevCalcTime; // Time of last trace ray calculation var int GFA_NoAimNoFocus; // Remove focus when not aiming (change in ini-file) +var int GFA_ScaleReticleWithResolution; // Scale reticle relative to the screen resolution (ini) const int GFA_RETICLE_MIN_SIZE = 200; // Smallest reticle size in virtual coordinates const int GFA_RETICLE_MAX_SIZE = 400; // Biggest reticle size in virtual coordinates diff --git a/_work/data/Scripts/Content/GFA/_intern/init.d b/_work/data/Scripts/Content/GFA/_intern/init.d index dbaca33..93aa821 100644 --- a/_work/data/Scripts/Content/GFA/_intern/init.d +++ b/_work/data/Scripts/Content/GFA/_intern/init.d @@ -157,6 +157,11 @@ func void GFA_InitFeatureFreeAiming() { MEM_SetGothOpt("GFA", "showFocusWhenNotAiming", "0"); }; + if (!MEM_GothOptExists("GFA", "scaleReticleWithResolution")) { + // Add INI-entry, if not set (disable by default) + MEM_SetGothOpt("GFA", "scaleReticleWithResolution", "0"); + }; + if (GOTHIC_BASE_VERSION == 2) { if (GFA_Flags & GFA_RANGED) { if (!MEM_GothOptExists("GFA", "overwriteControlSchemeRanged")) { @@ -328,6 +333,9 @@ func void GFA_InitAlways() { // Remove focus when not aiming: Prevent using bow/spell as enemy detector GFA_NoAimNoFocus = !STR_ToInt(MEM_GetGothOpt("GFA", "showFocusWhenNotAiming")); + // Scale the reticle relative to the screen resolution + GFA_ScaleReticleWithResolution = STR_ToInt(MEM_GetGothOpt("GFA", "scaleReticleWithResolution")); + // Reset/reinitialize free aiming settings every time to prevent crashes if (GFA_Flags & GFA_RANGED) || (GFA_Flags & GFA_SPELLS) { // On level change, Gothic does not maintain the focus instances (see Focus.d), nor does it reinitialize them. diff --git a/_work/data/Scripts/Content/GFA/_intern/reticle.d b/_work/data/Scripts/Content/GFA/_intern/reticle.d index 57beb40..505b981 100644 --- a/_work/data/Scripts/Content/GFA/_intern/reticle.d +++ b/_work/data/Scripts/Content/GFA/_intern/reticle.d @@ -57,7 +57,11 @@ func void GFA_InsertReticle(var int reticlePtr) { if (!GFA_RETICLE_PTR) { // Create reticle if it does not exist Print_GetScreenSize(); // Necessary for Print_ToRatio - GFA_RETICLE_PTR = ViewPtr_CreateCenter(PS_VMax/2, PS_VMax/2, size, Print_ToRatio(size, PS_Y)); + if (GFA_ScaleReticleWithResolution) { + GFA_RETICLE_PTR = ViewPtr_CreateCenter(PS_VMax/2, PS_VMax/2, size, Print_ToRatio(size, PS_Y)); + } else { + GFA_RETICLE_PTR = ViewPtr_CreateCenterPxl(Print_Screen[PS_X]/2, Print_Screen[PS_Y]/2, size/6, size/6); + }; ViewPtr_SetTexture(GFA_RETICLE_PTR, reticle.texture); ViewPtr_SetColor(GFA_RETICLE_PTR, reticle.color); ViewPtr_Open(GFA_RETICLE_PTR); @@ -78,9 +82,14 @@ func void GFA_InsertReticle(var int reticlePtr) { // Update its size and re-position it to center Print_GetScreenSize(); // Necessary for Print_ToRatio var int centerX; centerX = Print_Screen[PS_X]/2; - var int sizey; sizey = Print_ToRatio(size, PS_Y); - ViewPtr_Resize(GFA_RETICLE_PTR, size, sizey); - ViewPtr_MoveTo(GFA_RETICLE_PTR, PS_VMax/2-size/2, PS_VMax/2-sizey/2); + if (GFA_ScaleReticleWithResolution) { + var int sizey; sizey = Print_ToRatio(size, PS_Y); + ViewPtr_Resize(GFA_RETICLE_PTR, size, sizey); + ViewPtr_MoveTo(GFA_RETICLE_PTR, PS_VMax/2-size/2, PS_VMax/2-sizey/2); + } else { + ViewPtr_ResizePxl(GFA_RETICLE_PTR, size/6, size/6); + ViewPtr_MoveToPxl(GFA_RETICLE_PTR, Print_Screen[PS_X]/2-size/6/2, Print_Screen[PS_Y]/2-size/6/2); + }; }; if (!crsHr.isOpen) { diff --git a/_work/data/Scripts/Content/GFA/config/criticalHit.d b/_work/data/Scripts/Content/GFA/config/criticalHit.d index f2fd56f..91412bf 100644 --- a/_work/data/Scripts/Content/GFA/config/criticalHit.d +++ b/_work/data/Scripts/Content/GFA/config/criticalHit.d @@ -150,8 +150,13 @@ func void GFA_GetCriticalHit(var C_Npc target, var string bone, var C_Item weapo if (!GFA_HITMARKER) { // Create it (if it does not exist) in the center of the screen Print_GetScreenSize(); // Necessary for Print_ToRatio - GFA_HITMARKER = ViewPtr_CreateCenter(PS_VMax/2, PS_VMax/2, // Coordinates. Dimensions below - GFA_RETICLE_MAX_SIZE, Print_ToRatio(GFA_RETICLE_MAX_SIZE, PS_Y)); + if (GFA_ScaleReticleWithResolution) { + GFA_HITMARKER = ViewPtr_CreateCenter(PS_VMax/2, PS_VMax/2, + GFA_RETICLE_MAX_SIZE, Print_ToRatio(GFA_RETICLE_MAX_SIZE, PS_Y)); + } else { + GFA_HITMARKER = ViewPtr_CreateCenterPxl(Print_Screen[PS_X]/2, Print_Screen[PS_Y]/2, + GFA_RETICLE_MAX_SIZE/6, GFA_RETICLE_MAX_SIZE/6); + }; // Get 7th frame of animated texture as static texture ViewPtr_SetTexture(GFA_HITMARKER, GFA_AnimateReticleByPercent(RETICLE_TRI_IN, 100, 7));