Skip to content

Commit

Permalink
Fix #194 change reticle to virtual coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
szapp committed Dec 4, 2018
1 parent 39e3d26 commit 4eb17bc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions _work/data/Scripts/Content/GFA/_intern/const.d
Expand Up @@ -64,8 +64,8 @@ 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

const int GFA_RETICLE_MIN_SIZE = 32; // Smallest reticle size in pixels
const int GFA_RETICLE_MAX_SIZE = 64; // Biggest reticle size in pixels
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_PTR = 0; // Reticle zCView
var int GFA_AimVobHasFX; // For performance: check whether FX needs to be removed

Expand Down
16 changes: 8 additions & 8 deletions _work/data/Scripts/Content/GFA/_intern/reticle.d
Expand Up @@ -54,12 +54,10 @@ func void GFA_InsertReticle(var int reticlePtr) {
size = GFA_RETICLE_MIN_SIZE;
};

// Get the screen to retrieve the center
var zCView screen; screen = _^(MEM_Game._zCSession_viewport);

if (!GFA_RETICLE_PTR) {
// Create reticle if it does not exist
GFA_RETICLE_PTR = ViewPtr_CreateCenterPxl(screen.psizex/2, screen.psizey/2, size, size);
Print_GetScreenSize(); // Necessary for Print_ToRatio
GFA_RETICLE_PTR = ViewPtr_CreateCenter(PS_VMax/2, PS_VMax/2, size, Print_ToRatio(size, PS_Y));
ViewPtr_SetTexture(GFA_RETICLE_PTR, reticle.texture);
ViewPtr_SetColor(GFA_RETICLE_PTR, reticle.color);
ViewPtr_Open(GFA_RETICLE_PTR);
Expand All @@ -76,11 +74,13 @@ func void GFA_InsertReticle(var int reticlePtr) {
};

var zCView crsHr; crsHr = _^(GFA_RETICLE_PTR);
if (crsHr.psizex != size) || (screen.psizex/2 != centerX) {
if (crsHr.vsizex != size) || (Print_Screen[PS_X]/2 != centerX) {
// Update its size and re-position it to center
var int centerX; centerX = screen.psizex/2;
ViewPtr_ResizePxl(GFA_RETICLE_PTR, size, size);
ViewPtr_MoveToPxl(GFA_RETICLE_PTR, screen.psizex/2-(size/2), screen.psizey/2-(size/2));
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 (!crsHr.isOpen) {
Expand Down
6 changes: 3 additions & 3 deletions _work/data/Scripts/Content/GFA/config/criticalHit.d
Expand Up @@ -149,9 +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
var zCView screen; screen = _^(MEM_Game._zCSession_viewport);
GFA_HITMARKER = ViewPtr_CreateCenterPxl(screen.psizex/2, screen.psizey/2, // Coordinates
GFA_RETICLE_MAX_SIZE, GFA_RETICLE_MAX_SIZE); // Dimensions
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));

// 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 4eb17bc

Please sign in to comment.