Skip to content

Commit

Permalink
Remove reticle from game saves
Browse files Browse the repository at this point in the history
  • Loading branch information
szapp committed Sep 16, 2018
1 parent fb108a3 commit f207213
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions _work/data/Scripts/Content/GFA/_intern/const.d
Expand Up @@ -32,10 +32,10 @@
const string GFA_VERSION = "Gothic Free Aim v1.0.1";
const int GFA_LEGO_FLAGS = LeGo_HookEngine // For initializing all hooks
| LeGo_ConsoleCommands // For console commands and debugging
| LeGo_View // For drawing reticle
| LeGo_Random // For scattering and other uses of random numbers
| LeGo_Draw3D // For debug visualizations (may be removed)
| LeGo_FrameFunctions; // For hitmarker in config (may be removed)
| LeGo_FrameFunctions // For hitmarker in config (may be removed)
| LeGo_View; // For hitmarker in config (may be removed)

var int GFA_Flags; // Flags for initialization of GFA
const int GFA_RANGED = 1<<0; // Free aiming for ranged combat (bow and crossbow)
Expand Down Expand Up @@ -69,7 +69,7 @@ var int GFA_AimRayPrevCalcTime; // Time of last trac

const int GFA_RETICLE_MIN_SIZE = 32; // Smallest reticle size in pixels
const int GFA_RETICLE_MAX_SIZE = 64; // Biggest reticle size in pixels
var int GFA_ReticleHndl; // Handle of the reticle
const int GFA_RETICLE_PTR = 0; // Reticle zCView
var int GFA_AimVobHasFX; // For performance: check whether FX needs to be removed

const string GFA_CAMERA = "CamModGFA"; // CCamSys_Def script instance
Expand Down
30 changes: 15 additions & 15 deletions _work/data/Scripts/Content/GFA/_intern/reticle.d
Expand Up @@ -26,8 +26,8 @@
* Hide the reticle. This function is called from various functions to ensure that the reticle disappears.
*/
func void GFA_RemoveReticle() {
if (Hlp_IsValidHandle(GFA_ReticleHndl)) {
View_Close(GFA_ReticleHndl);
if (GFA_RETICLE_PTR) {
ViewPtr_Close(GFA_RETICLE_PTR);
};
};

Expand Down Expand Up @@ -57,35 +57,35 @@ func void GFA_InsertReticle(var int reticlePtr) {
// Get the screen to retrieve the center
var zCView screen; screen = _^(MEM_Game._zCSession_viewport);

if (!Hlp_IsValidHandle(GFA_ReticleHndl)) {
if (!GFA_RETICLE_PTR) {
// Create reticle if it does not exist
GFA_ReticleHndl = View_CreateCenterPxl(screen.psizex/2, screen.psizey/2, size, size);
View_SetTexture(GFA_ReticleHndl, reticle.texture);
View_SetColor(GFA_ReticleHndl, reticle.color);
View_Open(GFA_ReticleHndl);
GFA_RETICLE_PTR = ViewPtr_CreateCenterPxl(screen.psizex/2, screen.psizey/2, size, size);
ViewPtr_SetTexture(GFA_RETICLE_PTR, reticle.texture);
ViewPtr_SetColor(GFA_RETICLE_PTR, reticle.color);
ViewPtr_Open(GFA_RETICLE_PTR);
} else {
// If the reticle already exists adjust it to the new texture, size and color
if (!Hlp_StrCmp(View_GetTexture(GFA_ReticleHndl), reticle.texture)) {
if (!Hlp_StrCmp(ViewPtr_GetTexture(GFA_RETICLE_PTR), reticle.texture)) {
// Update its texture
View_SetTexture(GFA_ReticleHndl, reticle.texture);
ViewPtr_SetTexture(GFA_RETICLE_PTR, reticle.texture);
};

if (View_GetColor(GFA_ReticleHndl) != reticle.color) {
if (ViewPtr_GetColor(GFA_RETICLE_PTR) != reticle.color) {
// Update its color
View_SetColor(GFA_ReticleHndl, reticle.color);
ViewPtr_SetColor(GFA_RETICLE_PTR, reticle.color);
};

var zCView crsHr; crsHr = _^(getPtr(GFA_ReticleHndl));
var zCView crsHr; crsHr = _^(GFA_RETICLE_PTR);
if (crsHr.psizex != size) || (screen.psizex/2 != centerX) {
// Update its size and re-position it to center
var int centerX; centerX = screen.psizex/2;
View_ResizePxl(GFA_ReticleHndl, size, size);
View_MoveToPxl(GFA_ReticleHndl, screen.psizex/2-(size/2), screen.psizey/2-(size/2));
ViewPtr_ResizePxl(GFA_RETICLE_PTR, size, size);
ViewPtr_MoveToPxl(GFA_RETICLE_PTR, screen.psizex/2-(size/2), screen.psizey/2-(size/2));
};

if (!crsHr.isOpen) {
// Show the reticle if it is not visible
View_Open(GFA_ReticleHndl);
ViewPtr_Open(GFA_RETICLE_PTR);
};
};
} else {
Expand Down

0 comments on commit f207213

Please sign in to comment.