Skip to content

Commit

Permalink
v3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Elem8100 authored Aug 12, 2020
1 parent 3e7280a commit 148af57
Show file tree
Hide file tree
Showing 5 changed files with 247 additions and 127 deletions.
82 changes: 55 additions & 27 deletions Src/ChatBalloon.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
interface

uses
Windows, SysUtils, StrUtils, PXT.Sprites, Generics.Collections, Classes, WZIMGFile, Global, WzUtils,
PXT.Graphics;
Windows, SysUtils, StrUtils, PXT.Sprites, Generics.Collections, Classes, WZIMGFile, Global,
WzUtils, PXT.Graphics;

type
TBalloonInfo = record
Expand Down Expand Up @@ -45,12 +45,18 @@ TChatRingBalloon = class(TChatBalloon)
procedure TextOut(X, Y, MaxWidth, FontHeight: Integer); override;
public
procedure DoMove(const Movecount: Single); override;
procedure DoDraw; override;
procedure ReDraw;
class procedure Remove;
class var
TagNum: string;
IsUse: Boolean;
end;

implementation

uses
PXT.Types, PXT.Canvas;
PXT.Types, PXT.Canvas, MapleCharacter;

class function TChatBalloon.GetS(var Remaining: string; const Width: Integer): string;
var
Expand All @@ -75,11 +81,11 @@ class function TChatBalloon.GetS(var Remaining: string; const Width: Integer): s
begin
NextWord := Copy(Remaining, 1, Index - 1);
if PixelCount + Round(GameFont.ExtentByPixels(' ' + NextWord).Right)
{FontsAlt[3].TextWidth(' ' + NextWord)} < Width then
{FontsAlt[3].TextWidth(' ' + NextWord)} < Width then
begin
Result := Result + ' ' + NextWord;
Inc(PixelCount, Round(GameFont.ExtentByPixels(' ' + NextWord).Right)
{FontsAlt[3].TextWidth(' ' + NextWord)} - 5);
{FontsAlt[3].TextWidth(' ' + NextWord)} - 5);
Delete(Remaining, 1, Index)
end
else
Expand All @@ -102,7 +108,7 @@ class function TChatBalloon.GetS(var Remaining: string; const Width: Integer): s
else
begin
if PixelCount + Round(GameFont.ExtentByPixels(' ' + Remaining).Right)
{FontsAlt[3].TextWidth(' ' + Remaining)} < Width then
{FontsAlt[3].TextWidth(' ' + Remaining)} < Width then
begin
Result := Result + ' ' + Remaining;
Remaining := ' '
Expand Down Expand Up @@ -165,8 +171,8 @@ procedure TChatBalloon.SetStyle(BalloonStyle: Integer; Dir: string = '');
R := GetR(FontColor);
G := GetG(FontColor);
B := GetB(FontColor);

Arrow := GetData('arrow');
if Entry.Get('arrow') <> nil then
Arrow := GetData('arrow');
C := GetData('c');
E := GetData('e');
N := GetData('n');
Expand Down Expand Up @@ -216,10 +222,10 @@ function TChatBalloon.GetData(TileName: string): TBalloonInfo;
if Entry.Parent.Name = 'ChatBalloon.img' then
Result.ImageEntry := GetImgEntry('UI/ChatBalloon.img/' + IntToStr(FStyle) + '/' + TileName)
else
Result.ImageEntry := GetImgEntry('UI/ChatBalloon.img/' + Directory + '/' + IntToStr(FStyle) + '/' +
TileName);
Result.Width := Entry.Get(TileName).Canvas.Width;
Result.Height := Entry.Get(TileName).Canvas.Height;
Result.ImageEntry := GetImgEntry('UI/ChatBalloon.img/' + Directory + '/' + IntToStr(FStyle) +
'/' + TileName);
Result.Width := Entry.Get2(TileName).Canvas.Width;
Result.Height := Entry.Get2(TileName).Canvas.Height;
Result.Origin.X := Entry.Get(TileName).Get('origin').Vector.X;
Result.Origin.Y := Entry.Get(TileName).Get('origin').Vector.Y;
end;
Expand All @@ -228,7 +234,7 @@ procedure TChatBalloon.TargetEvent;
var
I, J, Cx1, Cx2, Cx3, Mid: Integer;
begin
Row := Round(GameFont.ExtentByPixels(FMsg).Right) {FontsAlt[3].TextWidth(FMsg)} div 80 + 1;
Row := Round(GameFont.ExtentByPixels(FMsg).Right) {FontsAlt[3].TextWidth(FMsg)} div 80 + 1;
OffH := Row * C.Height + C.Origin.Y + S.Height;
Cx1 := 0;
Cx2 := 0;
Expand All @@ -237,16 +243,18 @@ procedure TChatBalloon.TargetEvent;
for I := 1 to Col + 1 do
begin
Cx1 := Cx1 + Part1[I - 1].Width;
GameCanvas.Draw(Images[Part1[I].ImageEntry], Cx1 - NW.Origin.X - Mid + 70, -Part1[I].Origin.Y - OffH + 500);
GameCanvas.Draw(Images[Part1[I].ImageEntry], Cx1 - NW.Origin.X - Mid + 70, -Part1[I].Origin.Y -
OffH + 500);
Cx2 := Cx2 + Part2[I - 1].Width;
for J := 0 to Row - 1 do
GameCanvas.Draw(Images[Part2[I].ImageEntry], Cx2 - W.Origin.X - Mid + 70, -Part2[I].Origin.Y + (J * C.Height)
- OffH + 500);
GameCanvas.Draw(Images[Part2[I].ImageEntry], Cx2 - W.Origin.X - Mid + 70, -Part2[I].Origin.Y +
(J * C.Height) - OffH + 500);
Cx3 := Cx3 + Part3[I - 1].Width;
GameCanvas.Draw(Images[Part3[I].ImageEntry], Cx3 - SW.Origin.X - Mid + 70, -Part3[I].Origin.Y + (J * C.Height)
- OffH + 500);
GameCanvas.Draw(Images[Part3[I].ImageEntry], Cx3 - SW.Origin.X - Mid + 70, -Part3[I].Origin.Y +
(J * C.Height) - OffH + 500);
end;
GameCanvas.Draw(Images[Arrow.ImageEntry], 70, Arrow.Origin.Y + (J * C.Height) - OffH + 500);
if Entry.Get('arrow') <> nil then
GameCanvas.Draw(Images[Arrow.ImageEntry], 70, Arrow.Origin.Y + (J * C.Height) - OffH + 500);
{
I2 :=0;
for I := 0 to Length(FMsg) div MaxChars+1 do
Expand Down Expand Up @@ -276,19 +284,39 @@ procedure TChatRingBalloon.TextOut(X, Y, MaxWidth, FontHeight: Integer);
GameFont.Draw(Point2f(X - 5, Y + I * 13), GetS(FMsg, 80), ARGB(255, R, G, B));
end;

procedure TChatRingBalloon.ReDraw;
begin
GameCanvas.DrawTarget(TargetTexture, 150, 512,
procedure
begin
TargetEvent;
end);
end;

procedure TChatRingBalloon.DoDraw;
begin
GameCanvas.Draw(TargetTexture, Round(X - 70 - Engine.WorldX), Round(Y - 500 - Engine.WorldY));
end;

procedure TChatRingBalloon.DoMove;
begin
Inc(Counter);
if FMsg <> '' then
GameCanvas.DrawTarget(TargetTexture, 150, 512,
procedure
begin
TargetTexture.Clear;
TargetEvent;
end);
if Counter > 5000 then
if Counter > 1000 then
Dead;
X := Round(Player.X);
Y := Round(Player.Y - 80);
Z := Player.Z + 1;
end;

class procedure TChatRingBalloon.Remove;
begin
for var Iter in SpriteEngine.SpriteList do
if Iter is TChatRingBalloon then
begin
Iter.Dead;
var s := Iter;
s := nil;
end;
end;

end.
Expand Down
60 changes: 57 additions & 3 deletions Src/ChatRingFormUnit.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,56 @@ object ChatRingForm: TChatRingForm
Font.Height = -13
Font.Name = 'Tahoma'
Font.Style = []
KeyPreview = True
OldCreateOrder = False
Scaled = False
OnActivate = FormActivate
OnClick = FormClick
OnCreate = FormCreate
OnKeyDown = FormKeyDown
PixelsPerInch = 120
TextHeight = 16
object Label1: TLabel
Left = 14
Top = 43
Width = 40
Height = 16
Caption = 'Search'
end
object Label2: TLabel
Left = 24
Top = 8
Width = 40
Height = 18
Caption = 'Using:'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
object Label3: TLabel
Left = 70
Top = 8
Width = 5
Height = 18
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
object ChatRingGrid: TAdvStringGrid
AlignWithMargins = True
Left = 4
Top = 36
Top = 66
Width = 328
Height = 535
Height = 505
Cursor = crDefault
Margins.Left = 4
Margins.Top = 36
Margins.Top = 66
Margins.Right = 10
Margins.Bottom = 8
Align = alClient
Expand All @@ -42,6 +78,7 @@ object ChatRingForm: TChatRingForm
ScrollBars = ssVertical
TabOrder = 0
HoverRowCells = [hcNormal, hcSelected]
OnClickCell = ChatRingGridClickCell
ActiveCellFont.Charset = DEFAULT_CHARSET
ActiveCellFont.Color = clWindowText
ActiveCellFont.Height = -11
Expand Down Expand Up @@ -157,4 +194,21 @@ object ChatRingForm: TChatRingForm
35
35)
end
object Edit1: TEdit
Left = 60
Top = 40
Width = 101
Height = 24
TabOrder = 1
OnChange = Edit1Change
end
object Button1: TButton
Left = 240
Top = 38
Width = 73
Height = 25
Caption = 'Remove'
TabOrder = 2
OnClick = Button1Click
end
end
59 changes: 55 additions & 4 deletions Src/ChatRingFormUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@ interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, AdvObj, BaseGrid, AdvGrid;
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, AdvObj, BaseGrid, AdvGrid, Vcl.StdCtrls;

type
TChatRingForm = class(TForm)
ChatRingGrid: TAdvStringGrid;
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Label2: TLabel;
Label3: TLabel;
procedure FormActivate(Sender: TObject);
procedure ChatRingGridClickCell(Sender: TObject; ARow, ACol: Integer);
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
private
HasShow: Boolean;
{ Private declarations }
Expand All @@ -25,7 +36,29 @@ implementation
{$R *.dfm}

uses
NameTag, WZIMGFile, WZDirectory, WzUtils, Global, StrUtils;
NameTag, WZIMGFile, WZDirectory, WzUtils, Global, StrUtils, ChatBalloon;

procedure TChatRingForm.Button1Click(Sender: TObject);
begin
ActiveControl := nil;
TChatRingBalloon.IsUse := False;
Label3.Caption := '';
end;

procedure TChatRingForm.ChatRingGridClickCell(Sender: TObject; ARow, ACol: Integer);
begin
TChatRingBalloon.IsUse := True;
TChatRingBalloon.TagNum := GetImgEntry('Character.WZ/Ring/' + ChatRingGrid.Cells[1, ARow] + '.img'
+ '/info/chatBalloon').Data;
Label3.Caption := ChatRingGrid.Cells[3, ARow];

ActiveControl := nil;
end;

procedure TChatRingForm.Edit1Change(Sender: TObject);
begin
ChatRingGrid.NarrowDown(Trim(Edit1.Text));
end;

procedure TChatRingForm.FormActivate(Sender: TObject);
begin
Expand All @@ -52,8 +85,8 @@ procedure TChatRingForm.FormActivate(Sender: TObject);
ChatRingGrid.RowCount := RowCount + 1;
ChatRingGrid.Cells[1, RowCount] := ID;
if HasImgEntry('String.wz/Eqp.img/Eqp/Ring/' + IDToInt(ID)) then
ChatRingGrid.Cells[3, RowCount] := GetImgEntry('String.wz/Eqp.img/Eqp/Ring/' + IDToInt(ID)).Get('Name',
'');
ChatRingGrid.Cells[3, RowCount] := GetImgEntry('String.wz/Eqp.img/Eqp/Ring/' + IDToInt(ID)).Get
('Name', '');

var Entry := GetImgEntry('Character.WZ/Ring/' + img.Name + '/info/icon', True);
if Entry <> nil then
Expand All @@ -69,5 +102,23 @@ procedure TChatRingForm.FormActivate(Sender: TObject);

end;

procedure TChatRingForm.FormClick(Sender: TObject);
begin
ActiveControl := nil;
end;

procedure TChatRingForm.FormCreate(Sender: TObject);
begin

Left := ((Screen.Width - Width) div 2) + 400;
Top := (Screen.Height - Height) div 2;
end;

procedure TChatRingForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_MENU then
Key := 0;
end;

end.

Loading

0 comments on commit 148af57

Please sign in to comment.