Skip to content

Commit

Permalink
Adjust reticle by pixel value
Browse files Browse the repository at this point in the history
  • Loading branch information
szapp committed Dec 9, 2018
1 parent 7967ef2 commit 439b2bf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 31 deletions.
5 changes: 2 additions & 3 deletions _work/data/Scripts/Content/GFA/_intern/const.d
Expand Up @@ -64,10 +64,9 @@ 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
const int GFA_RETICLE_MIN_SIZE = 32; // Reticle size in pixels (at its smallest)
const int GFA_RETICLE_MAX_SIZE = 64; // Reticle size in pixels (at its biggest)
const int GFA_RETICLE_PTR = 0; // Reticle zCView
var int GFA_AimVobHasFX; // For performance: check whether FX needs to be removed

Expand Down
15 changes: 10 additions & 5 deletions _work/data/Scripts/Content/GFA/_intern/init.d
Expand Up @@ -157,9 +157,9 @@ func void GFA_InitFeatureFreeAiming() {
MEM_SetGothOpt("GFA", "showFocusWhenNotAiming", "0");
};

if (!MEM_GothOptExists("GFA", "scaleReticleWithResolution")) {
// Add INI-entry, if not set (enable by default)
MEM_SetGothOpt("GFA", "scaleReticleWithResolution", "1");
if (!MEM_GothOptExists("GFA", "reticleSizePx")) {
// Add INI-entry, if not set
MEM_SetGothOpt("GFA", "reticleSizePx", IntToString(GFA_RETICLE_MAX_SIZE));
};

if (GOTHIC_BASE_VERSION == 2) {
Expand Down Expand Up @@ -333,8 +333,13 @@ 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"));
// Set the reticle size in pixels
GFA_RETICLE_MAX_SIZE = STR_ToInt(MEM_GetGothOpt("GFA", "reticleSizePx"));
if (GFA_RETICLE_MAX_SIZE < GFA_RETICLE_MIN_SIZE) {
GFA_RETICLE_MAX_SIZE = GFA_RETICLE_MIN_SIZE;
MEM_SetGothOpt("GFA", "reticleSizePx", IntToString(GFA_RETICLE_MAX_SIZE));
};
GFA_RETICLE_MIN_SIZE = GFA_RETICLE_MAX_SIZE/2;

// Reset/reinitialize free aiming settings every time to prevent crashes
if (GFA_Flags & GFA_RANGED) || (GFA_Flags & GFA_SPELLS) {
Expand Down
20 changes: 5 additions & 15 deletions _work/data/Scripts/Content/GFA/_intern/reticle.d
Expand Up @@ -56,12 +56,8 @@ func void GFA_InsertReticle(var int reticlePtr) {

if (!GFA_RETICLE_PTR) {
// Create reticle if it does not exist
Print_GetScreenSize(); // Necessary for Print_ToRatio
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);
};
Print_GetScreenSize(); // Necessary for Print_Screen
GFA_RETICLE_PTR = ViewPtr_CreateCenterPxl(Print_Screen[PS_X]/2, Print_Screen[PS_Y]/2, size, size);
ViewPtr_SetTexture(GFA_RETICLE_PTR, reticle.texture);
ViewPtr_SetColor(GFA_RETICLE_PTR, reticle.color);
ViewPtr_Open(GFA_RETICLE_PTR);
Expand All @@ -79,17 +75,11 @@ func void GFA_InsertReticle(var int reticlePtr) {

if (csize != size) || (Print_Screen[PS_X]/2 != centerX) {
// Update its size and re-position it to center
Print_GetScreenSize(); // Necessary for Print_ToRatio
Print_GetScreenSize(); // Necessary for Print_Screen
var int csize; csize = size;
var int centerX; centerX = Print_Screen[PS_X]/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);
};
ViewPtr_ResizePxl(GFA_RETICLE_PTR, size, size);
ViewPtr_MoveToPxl(GFA_RETICLE_PTR, Print_Screen[PS_X]/2-size/2, Print_Screen[PS_Y]/2-size/2);
};

var zCView crsHr; crsHr = _^(GFA_RETICLE_PTR);
Expand Down
11 changes: 3 additions & 8 deletions _work/data/Scripts/Content/GFA/config/criticalHit.d
Expand Up @@ -149,14 +149,9 @@ func void GFA_GetCriticalHit(var C_Npc target, var string bone, var C_Item weapo
// Shooter-like hit marker
if (!GFA_HITMARKER) {
// Create it (if it does not exist) in the center of the screen
Print_GetScreenSize(); // Necessary for Print_ToRatio
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);
};
Print_GetScreenSize(); // Necessary for Print_Screen
GFA_HITMARKER = ViewPtr_CreateCenterPxl(Print_Screen[PS_X]/2, Print_Screen[PS_Y]/2, // Coordinates
GFA_RETICLE_MAX_SIZE, GFA_RETICLE_MAX_SIZE); // Size

// Get 7th frame of animated texture as static texture
ViewPtr_SetTexture(GFA_HITMARKER, GFA_AnimateReticleByPercent(RETICLE_TRI_IN, 100, 7));
Expand Down

0 comments on commit 439b2bf

Please sign in to comment.