Skip to content

Commit

Permalink
Allow Negative Offsets To Be Entered For Crosshairs
Browse files Browse the repository at this point in the history
  • Loading branch information
Deaod committed May 26, 2024
1 parent 930ff16 commit a36fa66
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Classes/IGPlus_CrosshairSettingsContent.uc
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ function Created() {
Edit_OffsetX.SetDelayedNotify(true);
Edit_OffsetX.SetNumericOnly(true);
Edit_OffsetX.SetNumericFloat(false);
Edit_OffsetX.SetNumericNegative(true);
Edit_OffsetX.EditBoxWidthFraction = (1.0/3.0);
Edit_OffsetX.EditBoxWidth = 50;

Expand All @@ -217,6 +218,7 @@ function Created() {
Edit_OffsetY.SetDelayedNotify(true);
Edit_OffsetY.SetNumericOnly(true);
Edit_OffsetY.SetNumericFloat(false);
Edit_OffsetY.SetNumericNegative(true);
Edit_OffsetY.EditBoxWidthFraction = (1.0/3.0);
Edit_OffsetY.EditBoxWidth = 50;

Expand Down
43 changes: 43 additions & 0 deletions Classes/IGPlus_EditBox.uc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
class IGPlus_EditBox extends UWindowEditBox;

var bool bNumericNegative;

function KeyType(int Key, float MouseX, float MouseY) {
if (bCanEdit == false || bKeyDown == false)
return;

if (bControlDown)
return;

if (bAllSelected)
Clear();

bAllSelected = False;

if (bNumericOnly) {
if (Key >= 0x30 && Key <= 0x39)
Insert(Key);
if (bNumericNegative) {
if (Key == 0x2D && Left(Value, 1) != "-") {
Value = "-"$Value;
CaretOffset += 1;

if (bDelayedNotify)
bChangePending = true;
else
Notify(DE_Change);
} else if (Key == 0x2B && Left(Value, 1) == "-") {
Value = Mid(Value, 1);
CaretOffset -= 1;

if (bDelayedNotify)
bChangePending = true;
else
Notify(DE_Change);
}
}
} else {
if (Key >= 0x20 && Key < 0x80)
Insert(Key);
}
}
16 changes: 16 additions & 0 deletions Classes/IGPlus_EditControl.uc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,28 @@ var float EditBoxMinWidth;
var float EditBoxMaxWidth;
var float EditBoxWidthFraction;

function Created() {
Super.Created();

EditBox = IGPlus_EditBox(CreateWindow(class'IGPlus_EditBox', 0, 0, WinWidth, WinHeight));
EditBox.NotifyOwner = Self;
EditBox.bSelectOnFocus = True;

EditBoxWidth = WinWidth / 2;

SetEditTextColor(LookAndFeel.EditBoxTextColor);
}

function AfterCreate() {
EditBoxWidthFraction = FClamp(EditBoxWidth / WinWidth, 0.05, 0.95);
EditBoxMinWidth = WinWidth * EditBoxWidthFraction;
EditBoxMaxWidth = WinWidth * EditBoxWidthFraction;
}

function SetNumericNegative(bool bEnable) {
IGPlus_EditBox(EditBox).bNumericNegative = bEnable;
}

function MouseLeave() {
Super.MouseLeave();
if(HelpText != "") ToolTip("");
Expand Down
1 change: 1 addition & 0 deletions Classes/IGPlus_SettingsContent.uc
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,7 @@ function Created() {
Cmb_HitMarkerColorMode.AddItem(HitMarkerColorModeTeamColor);
Edit_HitMarkerSize = CreateEdit(ECT_Integer, HitMarkerSizeText, HitMarkerSizeHelp, , 64);
Edit_HitMarkerOffset = CreateEdit(ECT_Integer, HitMarkerOffsetText, HitMarkerOffsetHelp, , 64);
Edit_HitMarkerOffset.SetNumericNegative(true);
Edit_HitMarkerDuration = CreateEdit(ECT_Real, HitMarkerDurationText, HitMarkerDurationHelp, , 64);
Edit_HitMarkerDecayExponent = CreateEdit(ECT_Real, HitMarkerDecayExponentText, HitMarkerDecayExponentHelp, , 64);
Chk_EnableHitMarker = CreateCheckbox(EnableHitMarkerText, EnableHitMarkerHelp);
Expand Down

0 comments on commit a36fa66

Please sign in to comment.