Skip to content

Added mteFunctions version check #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 40 additions & 6 deletions trunk/Edit Scripts/mteFunctions.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
A set of useful functions for use in TES5Edit scripts.

**LIST OF INCLUDED FUNCTIONS**
- [CheckMteVersion]: compares a required version of mteFunctions to the current one.
- [GetVersionString]: gets TES5Edit's version as a string.
- [ColorToInt]: gets an integer value representing a color from a TColor record.
- [ElementTypeString]: uses ElementType and outputs a string.
Expand All @@ -28,6 +29,7 @@
Returns the path of the first file matching the given filename, if it is found.
- [SanitizeFileName]: removes characters not allowed in filenames from a string.
- [BoolToStr]: converts a boolean value to a string.
- [StrToBool]: converts a string into a boolean value;
- [TimeStr]: returns a time string from a TDateTime.
- [FileDateTimeStr]: returns a filename-safe DateTime string from a TDateTime.
- [ReverseString]: reverses a string.
Expand Down Expand Up @@ -145,6 +147,7 @@
unit mteFunctions;

const
Ver=1.0;
bethesdaFiles = 'Skyrim.esm'#13'Update.esm'#13'Dawnguard.esm'#13'HearthFires.esm'#13
'Dragonborn.esm'#13'Fallout3.esm'#13'FalloutNV.esm'#13'Oblivion.esm'#13
'Skyrim.Hardcoded.keep.this.with.the.exe.and.otherwise.ignore.it.I.really.mean.it.dat'#13
Expand All @@ -160,6 +163,22 @@

var
sFiles, sGroups, sRecords: string;

{
CheckMteVersion
Compares an input float to the current version of mteFunctions.
If the input is greater than or equal to the current version then return true otherwise return False.

Example usage:
if CheckMteVersion(1.0) then
AddMessage('Up-to-date')
else
raise Exception.Create('Please update your version of mteFunctions.pas');
}
function CheckMteVersion(flt: float): Boolean;
begin
Result := flt >= Ver;
end;

{
GetVersionString:
Expand Down Expand Up @@ -742,6 +761,21 @@ function BoolToStr(b: boolean): string;
Result := 'False';
end;

{
StrToBool:
Converts a case-insensive "True" or a "1" string into a bool.
Any other input will result in False

Example usage:
s := 'TruE';
if StrToBool(s) then
AddMessage('True');
}
function StrToBool(s: string): Boolean;
begin
result := (LowerCase(s) = 'true') OR (s = '1');
end;

{
ReverseString:
Reverses a string.
Expand Down Expand Up @@ -2472,7 +2506,7 @@ function CheckedToBool(cbs: TCheckBoxState): boolean;
code more compact.

Example usage:
group := ConstructGroup(frm, frm, 8, 8, 300, 300, 'My Group');
group := ConstructGroup(frm, frm, 8, 8, 300, 300, 'My Group', '');
}
function ConstructGroup(h, p: TObject; top, left, height,
width: Integer; caption, t: string): TGroupBox;
Expand Down Expand Up @@ -2501,7 +2535,7 @@ function ConstructGroup(h, p: TObject; top, left, height,
Shortened version of ConstructGroup

Example usage:
group := cGroup(frm, frm, 8, 8, 300, 300, 'My Group');
group := cGroup(frm, frm, 8, 8, 300, 300, 'My Group', '';
}
function cGroup(h, p: TObject; top, left, height,
width: Integer; caption, t: string): TGroupBox;
Expand Down Expand Up @@ -2708,7 +2742,7 @@ function cScrollBox(h, p: TObject; height: Integer;

Example usage:
cb1 := ConstructCheckBox(frm, pnlBottom, 8, 8, 160,
'Remove persistent references', cbChecked);
'Remove persistent references', cbChecked, '');
}
function ConstructCheckBox(h, p: TObject; top, left, width: Integer;
s: String; state: TCheckBoxState; t: string): TCheckBox;
Expand Down Expand Up @@ -2736,7 +2770,7 @@ function ConstructCheckBox(h, p: TObject; top, left, width: Integer;

Example usage:
cb1 := cCheckBox(frm, pnlBottom, 8, 8, 160,
'Remove persistent references', cbChecked);
'Remove persistent references', cbChecked, '');
}
function cCheckBox(h, p: TObject; top, left, width: Integer;
s: String; state: TCheckBoxState; t: string): TCheckBox;
Expand All @@ -2751,7 +2785,7 @@ function cCheckBox(h, p: TObject; top, left, width: Integer;

Example usage:
lbl3 := ConstructLabel(frm, pnlBottom, 65, 8, 0, 0,
'Reference removal options:');
'Reference removal options:', '');
}
function ConstructLabel(h, p: TObject; top, left, height,
width: Integer; s, t: String): TLabel;
Expand Down Expand Up @@ -2783,7 +2817,7 @@ function ConstructLabel(h, p: TObject; top, left, height,

Example usage:
lbl3 := cLabel(frm, pnlBottom, 65, 8, 0, 0,
'Reference removal options:');
'Reference removal options:', '');
}
function cLabel(h, p: TObject; top, left, height,
width: Integer; s, t: String): TLabel;
Expand Down