исправил оповещения, теперь работают четко
This commit is contained in:
+93
-25
@@ -4,7 +4,7 @@ interface
|
||||
|
||||
uses
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes,
|
||||
System.Variants, fOBS,
|
||||
System.Variants, fOBS, System.RegularExpressions, Math,
|
||||
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, fFontSettings,
|
||||
fColorSettings, FMX.StdCtrls, FMX.Edit, FMX.Controls.Presentation,
|
||||
FMX.ListBox, FMX.EditBox, FMX.SpinBox, FMX.Colors, uRecords;
|
||||
@@ -44,6 +44,9 @@ type
|
||||
{ Private declarations }
|
||||
function GetColorFromColorPanel(aColor: TAlphaColor): string;
|
||||
function GetColorFromCCB(aColor: TAlphaColor): string;
|
||||
|
||||
function GetColorFromRGBA(const s: string): TAlphaColor;
|
||||
function GetColorFromHex(const s: string): TAlphaColor;
|
||||
public
|
||||
{ Public declarations }
|
||||
isEdit: boolean;
|
||||
@@ -60,6 +63,33 @@ uses uGeneral;
|
||||
|
||||
{$R *.fmx}
|
||||
|
||||
function TfCreateNotify.GetColorFromRGBA(const s: string): TAlphaColor;
|
||||
var
|
||||
Match: TMatch;
|
||||
r, g, b: Integer;
|
||||
a: Double;
|
||||
Rec: TAlphaColorRec;
|
||||
begin
|
||||
Match := TRegEx.Match(s, 'rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)');
|
||||
if Match.Success then
|
||||
begin
|
||||
r := StrToInt(Match.Groups[1].Value);
|
||||
g := StrToInt(Match.Groups[2].Value);
|
||||
b := StrToInt(Match.Groups[3].Value);
|
||||
a := StrToFloat(Match.Groups[4].Value, TFormatSettings.Invariant);
|
||||
|
||||
// Çàïîëíÿåì ñòðóêòóðó âðó÷íóþ
|
||||
Rec.R := Byte(r);
|
||||
Rec.G := Byte(g);
|
||||
Rec.B := Byte(b);
|
||||
Rec.A := Round(a * 255);
|
||||
|
||||
Result := Rec.Color;
|
||||
end
|
||||
else
|
||||
raise Exception.CreateFmt('Íåâåðíûé ôîðìàò rgba: %s', [s]);
|
||||
end;
|
||||
|
||||
function TfCreateNotify.GetColorFromColorPanel(aColor: TAlphaColor): string;
|
||||
var
|
||||
Color: TAlphaColor;
|
||||
@@ -80,6 +110,47 @@ begin
|
||||
result := Format('rgba(%d, %d, %d, %.2f)', [r, G, B, A], FS);
|
||||
end;
|
||||
|
||||
function TfCreateNotify.GetColorFromCCB(aColor: TAlphaColor): string;
|
||||
var
|
||||
Color: TAlphaColor;
|
||||
r, G, B: Byte;
|
||||
begin
|
||||
Color := aColor;
|
||||
r := TAlphaColorRec(Color).r;
|
||||
G := TAlphaColorRec(Color).G;
|
||||
B := TAlphaColorRec(Color).B;
|
||||
result := Format('#%.2X%.2X%.2X', [r, G, B]);
|
||||
end;
|
||||
|
||||
function TfCreateNotify.GetColorFromHex(const s: string): TAlphaColor;
|
||||
var
|
||||
Hex: string;
|
||||
r, g, b: Integer;
|
||||
Rec: TAlphaColorRec;
|
||||
begin
|
||||
// Óáèðàåì âîçìîæíûé ñèìâîë #
|
||||
Hex := s.Trim;
|
||||
if Hex.StartsWith('#') then
|
||||
Hex := Hex.Substring(1);
|
||||
|
||||
// Îæèäàåì ðîâíî 6 ñèìâîëîâ (RRGGBB)
|
||||
if Length(Hex) <> 6 then
|
||||
raise Exception.CreateFmt('Íåâåðíûé HEX öâåò: %s', [s]);
|
||||
|
||||
// Ïàðñèì êîìïîíåíòû
|
||||
r := StrToInt('$' + Copy(Hex, 1, 2));
|
||||
g := StrToInt('$' + Copy(Hex, 3, 2));
|
||||
b := StrToInt('$' + Copy(Hex, 5, 2));
|
||||
|
||||
// Çàïîëíÿåì ñòðóêòóðó
|
||||
Rec.R := Byte(r);
|
||||
Rec.G := Byte(g);
|
||||
Rec.B := Byte(b);
|
||||
Rec.A := 255; // ïîëíàÿ íåïðîçðà÷íîñòü
|
||||
|
||||
Result := Rec.Color;
|
||||
end;
|
||||
|
||||
procedure TfCreateNotify.setRecord(aRec: TOBSNotify);
|
||||
var
|
||||
SavedColor: TAlphaColor;
|
||||
@@ -97,19 +168,21 @@ begin
|
||||
|
||||
fCreateNotify.frColorSettings1.sbStyleBlockBorderSize.Value := SolidBorder;
|
||||
fCreateNotify.frColorSettings1.sbStyleBlockPadding.Value := Paddings;
|
||||
fCreateNotify.frColorSettings1.ccbStyleBorderColor.ItemIndex := ColorBorder;
|
||||
fCreateNotify.frColorSettings1.ccbBColor.ItemIndex := ColorBackground;
|
||||
fCreateNotify.frColorSettings1.ccbStyleBorderColor.Color := GetColorFromHex(ColorBorder);
|
||||
fCreateNotify.frColorSettings1.ccbBColor.Color := GetColorFromHex(ColorBackground);
|
||||
fCreateNotify.frColorSettings1.cpStyleBlockColor.Color:=GetColorFromRGBA(ColorBlock);
|
||||
|
||||
fCreateNotify.edtESTitle.Text := HeaderText;
|
||||
fCreateNotify.frFontSettings2.ccbFontColor.ItemIndex := HeaderColorFont;
|
||||
fCreateNotify.frFontSettings2.ccbFontColor.Color := GetColorFromHex(HeaderColorFont);
|
||||
fCreateNotify.frFontSettings2.sbFontSize.Value := HeaderSizeFont;
|
||||
fCreateNotify.frFontSettings2.cbFontStyleDefault.ItemIndex :=
|
||||
HeaderStyleFont;
|
||||
fCreateNotify.frFontSettings2.cbFontStyleDefault.Items.IndexOf(HeaderStyleFont);
|
||||
|
||||
fCreateNotify.edtESMessage.Text := MessText;
|
||||
fCreateNotify.frFontSettings3.ccbFontColor.ItemIndex := MessColorFont;
|
||||
fCreateNotify.frFontSettings3.ccbFontColor.Color := GetColorFromHex(MessColorFont);
|
||||
fCreateNotify.frFontSettings3.sbFontSize.Value := MessSizeFont;
|
||||
fCreateNotify.frFontSettings3.cbFontStyleDefault.ItemIndex := MessStyleFont;
|
||||
fCreateNotify.frFontSettings3.cbFontStyleDefault.ItemIndex :=
|
||||
fCreateNotify.frFontSettings3.cbFontStyleDefault.Items.IndexOf(MessStyleFont);
|
||||
|
||||
fCreateNotify.sbTimeMsg.Value := TimeMess;
|
||||
fCreateNotify.cbEventsType.ItemIndex := TypeEvent;
|
||||
@@ -132,18 +205,18 @@ begin
|
||||
(frColorSettings1.cpStyleBlockColor.Color);
|
||||
SolidBorder := round(frColorSettings1.sbStyleBlockBorderSize.Value);
|
||||
Paddings := round(frColorSettings1.sbStyleBlockPadding.Value);
|
||||
ColorBorder := frColorSettings1.ccbStyleBorderColor.ItemIndex;
|
||||
ColorBackground := frColorSettings1.ccbBColor.ItemIndex;
|
||||
ColorBorder := GetColorFromCCB(frColorSettings1.ccbStyleBorderColor.Color);
|
||||
ColorBackground := GetColorFromCCB(frColorSettings1.ccbBColor.Color);
|
||||
|
||||
HeaderText := edtESTitle.Text;
|
||||
HeaderColorFont := frFontSettings2.ccbFontColor.ItemIndex;
|
||||
HeaderColorFont := GetColorFromCCB(frFontSettings2.ccbFontColor.Color);
|
||||
HeaderSizeFont := round(frFontSettings2.sbFontSize.Value);
|
||||
HeaderStyleFont := frFontSettings2.cbFontStyleDefault.ItemIndex;
|
||||
HeaderStyleFont := frFontSettings2.cbFontStyleDefault.Text;
|
||||
|
||||
MessText := edtESMessage.Text;
|
||||
MessColorFont := frFontSettings3.ccbFontColor.ItemIndex;
|
||||
MessColorFont := GetColorFromCCB(frFontSettings3.ccbFontColor.color);
|
||||
MessSizeFont := round(frFontSettings3.sbFontSize.Value);
|
||||
MessStyleFont := frFontSettings3.cbFontStyleDefault.ItemIndex;
|
||||
MessStyleFont := frFontSettings3.cbFontStyleDefault.Text;
|
||||
|
||||
TimeMess := round(sbTimeMsg.Value);
|
||||
TypeEvent := cbEventsType.ItemIndex;
|
||||
@@ -159,22 +232,13 @@ end;
|
||||
|
||||
|
||||
|
||||
function TfCreateNotify.GetColorFromCCB(aColor: TAlphaColor): string;
|
||||
var
|
||||
Color: TAlphaColor;
|
||||
r, G, B: Byte;
|
||||
begin
|
||||
Color := aColor;
|
||||
r := TAlphaColorRec(Color).r;
|
||||
G := TAlphaColorRec(Color).G;
|
||||
B := TAlphaColorRec(Color).B;
|
||||
result := Format('#%.2X%.2X%.2X', [r, G, B]);
|
||||
end;
|
||||
|
||||
|
||||
procedure TfCreateNotify.btnESTestClick(Sender: TObject);
|
||||
var
|
||||
se: TStyleEvent;
|
||||
i: Integer;
|
||||
ws:TEventWebServers;
|
||||
begin
|
||||
|
||||
se.Title := edtESTitle.Text;
|
||||
@@ -195,8 +259,12 @@ begin
|
||||
se.RequireInteraction := True;
|
||||
for i := 0 to TTW_Bot.frOBS1.EventWebServers.Count - 1 do
|
||||
begin
|
||||
TTW_Bot.frOBS1.EventWebServers[i].WebServerChat.AddMessage(se);
|
||||
if TTW_Bot.frOBS1.EventWebServers[i].port = oldPort then
|
||||
ws:=TTW_Bot.frOBS1.EventWebServers[i];
|
||||
|
||||
|
||||
end;
|
||||
ws.WebServerChat.addMessage(se);
|
||||
end;
|
||||
|
||||
procedure TfCreateNotify.cbEventsTypeChange(Sender: TObject);
|
||||
|
||||
Reference in New Issue
Block a user