|
@@ -29,7 +29,11 @@ uses
|
|
var
|
|
var
|
|
dirRes : UTF8String {$IFNDEF MACOSX} = '../data/' {$ENDIF};
|
|
dirRes : UTF8String {$IFNDEF MACOSX} = '../data/' {$ENDIF};
|
|
|
|
|
|
- fntMain, fntEdit: Byte;
|
|
|
|
|
|
+ // Ru: íîìåðà øðèôòîâ. Âñÿ ðàáîòà ñî øðèôòàìè ïðîèñõîäèò èìåííî îò ýòèõ íîìåðîâ.
|
|
|
|
+ fntMain, fntEdit: LongWord;
|
|
|
|
+
|
|
|
|
+ // Ru: íîìåð öâåòà. Ðàáîòà ñ öâåòîì ïðîèñõîäèò èìåííî îò ýòîãî íîìåðà.
|
|
|
|
+ EditColor: LongWord;
|
|
|
|
|
|
joyCount : Integer;
|
|
joyCount : Integer;
|
|
// RU: ñòðîêà äëÿ ïîëó÷åíèÿ çíà÷åíèÿ èç ïîëÿ ââîäà
|
|
// RU: ñòðîêà äëÿ ïîëó÷åíèÿ çíà÷åíèÿ èç ïîëÿ ââîäà
|
|
@@ -44,7 +48,7 @@ var
|
|
{$Else}
|
|
{$Else}
|
|
// RU: ïðÿìîóãîëüíèê, îïèñûâàþùèé ïîëå ââîäà
|
|
// RU: ïðÿìîóãîëüíèê, îïèñûâàþùèé ïîëå ââîäà
|
|
// EN: rectangle describing the input field
|
|
// EN: rectangle describing the input field
|
|
- myRect: zglTRect;
|
|
|
|
|
|
+ myRect: zglTRect2D;
|
|
|
|
|
|
// "ïåðåïèñü" ïîëåé ââîäà äëÿ òîãî, ÷òîá çíàòü ñ êàêèì ïîëåì ðàáîòàåì
|
|
// "ïåðåïèñü" ïîëåé ââîäà äëÿ òîãî, ÷òîá çíàòü ñ êàêèì ïîëåì ðàáîòàåì
|
|
|
|
|
|
@@ -63,17 +67,16 @@ begin
|
|
// Òåêñò áóäåò âûâåäåí ïîâåðõ òîãî, ÷òî âû òóò íàðèñóåòå.
|
|
// Òåêñò áóäåò âûâåäåí ïîâåðõ òîãî, ÷òî âû òóò íàðèñóåòå.
|
|
// EN: displacement and rotation will be done prior to performing the procedure. I am showing you how to draw a frame.
|
|
// EN: displacement and rotation will be done prior to performing the procedure. I am showing you how to draw a frame.
|
|
// The text will be drawn on top of what you draw here.
|
|
// The text will be drawn on top of what you draw here.
|
|
- pr2d_Rect(- 2, - 1, myRect.W + 5, myRect.H, cl_white, PR2D_FILL);
|
|
|
|
|
|
+ pr2d_Rect(- 2, - 1, myRect.W + 5, myRect.H, cl_white{$IfDef OLD_METHODS}, 128{$EndIf}, PR2D_FILL);
|
|
end;
|
|
end;
|
|
{$EndIf}
|
|
{$EndIf}
|
|
|
|
|
|
procedure Init;
|
|
procedure Init;
|
|
{$IfNDef OLD_METHODS}
|
|
{$IfNDef OLD_METHODS}
|
|
var
|
|
var
|
|
- TextColor: zglTColor;
|
|
|
|
|
|
+ EScale: Word;
|
|
{$EndIf}
|
|
{$EndIf}
|
|
begin
|
|
begin
|
|
- SetAndAddDefaultColor;
|
|
|
|
fntMain := font_LoadFromFile(dirRes + 'font.zfi');
|
|
fntMain := font_LoadFromFile(dirRes + 'font.zfi');
|
|
{$IfNDef OLD_METHODS}
|
|
{$IfNDef OLD_METHODS}
|
|
// RU: Çàãðóæàåì äàííûå î øðèôòå.
|
|
// RU: Çàãðóæàåì äàííûå î øðèôòå.
|
|
@@ -83,6 +86,12 @@ begin
|
|
// EN: set font sizes
|
|
// EN: set font sizes
|
|
setFontTextScale(15, fntMain);
|
|
setFontTextScale(15, fntMain);
|
|
setFontTextScale(20, fntEdit);
|
|
setFontTextScale(20, fntEdit);
|
|
|
|
+ // RU: ðàçìåð øðèôòà ïîëÿ ââîäà (äëÿ ïîíèìàíèÿ ÷òî ïðîèñõîäèò). Èçìåíÿÿ ðàçìåð øðèôòà, ìû äîëæíû ìåíÿòü è
|
|
|
|
+ // ðàçìåðû ïîëÿ ââîäà - myRect â äàííîì ñëó÷àå. Ñàìè îíè íå èçìåíÿòñÿ.
|
|
|
|
+ // EN: the font size of the input field (to understand what's going on). By changing the font size,
|
|
|
|
+ // we must also change the size of the input field - myRect in this case. They themselves will not change.
|
|
|
|
+ EScale := 20;
|
|
|
|
+ setFontTextScale(EScale, fntEdit);
|
|
// RU: óêàçûâàåì ðàçìåðû ïîëÿ ââîäà
|
|
// RU: óêàçûâàåì ðàçìåðû ïîëÿ ââîäà
|
|
// EN: specify the size of the input field
|
|
// EN: specify the size of the input field
|
|
myRect.X := 200;
|
|
myRect.X := 200;
|
|
@@ -92,22 +101,25 @@ begin
|
|
// RU: óêàçûâàåì òî÷êó âðàùåíèÿ, â äàííîì ñëó÷àå öåíòð ïîëÿ ââîäà(ïî íåîáõîäèìîñòè) è óãîë ïîâîðîòà(íàïðèìåð 45)
|
|
// RU: óêàçûâàåì òî÷êó âðàùåíèÿ, â äàííîì ñëó÷àå öåíòð ïîëÿ ââîäà(ïî íåîáõîäèìîñòè) è óãîë ïîâîðîòà(íàïðèìåð 45)
|
|
// EN: specify the point of rotation, in this case the center of the input field (if necessary) and the angle of rotation (for example 45)
|
|
// EN: specify the point of rotation, in this case the center of the input field (if necessary) and the angle of rotation (for example 45)
|
|
SetOfRotateAngleAndPoint(myRect.x + myRect.W / 2, myRect.y + myRect.H / 2, 30);
|
|
SetOfRotateAngleAndPoint(myRect.x + myRect.W / 2, myRect.y + myRect.H / 2, 30);
|
|
- // RU: óêàçûâàåì öâåò òåêñòà
|
|
|
|
- // EN: specify the color of the text
|
|
|
|
- TextColor.R := 0.1;
|
|
|
|
- TextColor.G := 0.5;
|
|
|
|
- TextColor.B := 0.3;
|
|
|
|
- TextColor.A := 1; // max = 1, min = 0
|
|
|
|
- // RU: ïåðåäà¸ì öâåò â äàííûå ìåíåäæåðà
|
|
|
|
- // EN: transfer the color to the manager data
|
|
|
|
- SetColorElementText(@TextColor);
|
|
|
|
|
|
+ // RU: óêàçûâàåì öâåò òåêñòà (äîáàâëÿåì íîâûé íîìåð öâåòà, õîòÿ äàííàÿ ôóíêöèÿ âàì âîçâðàòèò öâåò, åñëè îí óæå áûë ïðîïèñàí).
|
|
|
|
+ // EN: specify the color of the text (we add a new color number, although this function will return the color to you if it
|
|
|
|
+ // has already been assigned).
|
|
|
|
+ EditColor := Color_FindOrAdd($208055FF);
|
|
|
|
+ // Ru: óñòàíàâëèâàåì öâåòà ïî óìîë÷àíèþ äëÿ âñåõ ýëåìåíòîâ API. Ýòè öâåòà áóäóò çàäåéñòâîâàíû òîëüêî ïðè ñîçäàíèè
|
|
|
|
+ // îïðåäåë¸ííîãî ýëåìåíòà. Äëÿ èçìåíåíèÿ öâåòà â ñàìîì (óæå ñîçäàííîì) ýëåìåíòå, íè ÷åãî íå ïðèëàãàåòñÿ.
|
|
|
|
+ // Äàëüíåéøèå èçìåíèíÿ ýòèõ çíà÷åíèé öâåòà, íè êàê íå ñêàæåòñÿ íà óæå ñîçäàííûõ ýëåìåíòàõ.
|
|
|
|
+ // En: set default colors for all API elements. These colors will only be used when creating a specific element.
|
|
|
|
+ // To change the color in the (already created) element itself, nothing is attached. Further changes to these
|
|
|
|
+ // color values will not affect the already created elements in any way.
|
|
|
|
+ SetEditColor(fntEdit, EditColor, 1);
|
|
|
|
+
|
|
// RU: ñîçäà¸ì ñàìî ïîëå ââîäà ñ äàííûìè óêàçàííûìè âûøå
|
|
// RU: ñîçäà¸ì ñàìî ïîëå ââîäà ñ äàííûìè óêàçàííûìè âûøå
|
|
// EN: create the input field itself with the data specified above
|
|
// EN: create the input field itself with the data specified above
|
|
myEdit := CreateEdit(myRect, fntEdit, 20, @EditCont);
|
|
myEdit := CreateEdit(myRect, fntEdit, 20, @EditCont);
|
|
|
|
|
|
// RU: êîððåêòèðóåì êóðñîð.
|
|
// RU: êîððåêòèðóåì êóðñîð.
|
|
// EN: adjust the cursor
|
|
// EN: adjust the cursor
|
|
-// CorrectEditCursor(myEdit, 3);
|
|
|
|
|
|
+ CorrectEditCursor(myEdit, 3);
|
|
|
|
|
|
// RU: çàäà¸ì î÷èñòêó ýêðàíà çàäàííûì öâåòîì
|
|
// RU: çàäà¸ì î÷èñòêó ýêðàíà çàäàííûì öâåòîì
|
|
// EN: set the screen to clear with a specified color
|
|
// EN: set the screen to clear with a specified color
|
|
@@ -131,6 +143,10 @@ var
|
|
w : Single;
|
|
w : Single;
|
|
{$EndIf}
|
|
{$EndIf}
|
|
begin
|
|
begin
|
|
|
|
+ // Ru: áàëóåìñÿ öâåòîì øðèôòà.
|
|
|
|
+ // En: indulge in the color of the font.
|
|
|
|
+ setTextColor(Get_Color(cl_Blue));
|
|
|
|
+
|
|
text_Draw(fntMain, 0, 0, 'Escape - Exit');
|
|
text_Draw(fntMain, 0, 0, 'Escape - Exit');
|
|
|
|
|
|
// RU: Êîîðäèíàòû ìûøè ìîæíî ïîëó÷èòü ïðè ïîìîùè ôóíêöèé mouse_X è mouse_Y.
|
|
// RU: Êîîðäèíàòû ìûøè ìîæíî ïîëó÷èòü ïðè ïîìîùè ôóíêöèé mouse_X è mouse_Y.
|
|
@@ -160,15 +176,20 @@ begin
|
|
// EN: Show the state of axes and buttons of first joystick in the system.
|
|
// EN: Show the state of axes and buttons of first joystick in the system.
|
|
text_Draw(fntMain, 400, 360, 'JOYSTICK ( Found: ' + u_IntToStr(joyCount) + ' )', TEXT_HALIGN_CENTER);
|
|
text_Draw(fntMain, 400, 360, 'JOYSTICK ( Found: ' + u_IntToStr(joyCount) + ' )', TEXT_HALIGN_CENTER);
|
|
|
|
|
|
- text_Draw(fntMain, 100, 400, 'Axis X: ' + u_FloatToStr(joy_AxisPos(0, JOY_AXIS_X)));
|
|
|
|
- text_Draw(fntMain, 100, 420, 'Axis Y: ' + u_FloatToStr(joy_AxisPos(0, JOY_AXIS_Y)));
|
|
|
|
- text_Draw(fntMain, 100, 440, 'Axis Z: ' + u_FloatToStr(joy_AxisPos(0, JOY_AXIS_Z)));
|
|
|
|
- text_Draw(fntMain, 100, 460, 'Axis R: ' + u_FloatToStr(joy_AxisPos(0, JOY_AXIS_R)));
|
|
|
|
- text_Draw(fntMain, 100, 480, 'Axis U: ' + u_FloatToStr(joy_AxisPos(0, JOY_AXIS_U)));
|
|
|
|
- text_Draw(fntMain, 100, 500, 'Axis V: ' + u_FloatToStr(joy_AxisPos(0, JOY_AXIS_V)));
|
|
|
|
- text_Draw(fntMain, 100, 520, 'POVX: ' + u_FloatToStr(joy_AxisPos(0, JOY_POVX)));
|
|
|
|
- text_Draw(fntMain, 100, 540, 'POVY: ' + u_FloatToStr(joy_AxisPos(0, JOY_POVY)));
|
|
|
|
|
|
+ setTextColor(Get_Color(cl_Black));
|
|
|
|
+ text_Draw( fntMain, 100, 400, 'Axis X: ' + u_FloatToStr( joy_AxisPos( 0, JOY_AXIS_X ) ) );
|
|
|
|
+ text_Draw( fntMain, 100, 420, 'Axis Y: ' + u_FloatToStr( joy_AxisPos( 0, JOY_AXIS_Y ) ) );
|
|
|
|
+ setTextColor(Get_Color(cl_Black05));
|
|
|
|
+ text_Draw( fntMain, 100, 440, 'Axis Z: ' + u_FloatToStr( joy_AxisPos( 0, JOY_AXIS_Z ) ) );
|
|
|
|
+ setTextColor(Get_Color(cl_Green));
|
|
|
|
+ text_Draw( fntMain, 100, 460, 'Axis R: ' + u_FloatToStr( joy_AxisPos( 0, JOY_AXIS_R ) ) );
|
|
|
|
+ text_Draw( fntMain, 100, 480, 'Axis U: ' + u_FloatToStr( joy_AxisPos( 0, JOY_AXIS_U ) ) );
|
|
|
|
+ setTextColor(Get_Color(cl_Green05));
|
|
|
|
+ text_Draw( fntMain, 100, 500, 'Axis V: ' + u_FloatToStr( joy_AxisPos( 0, JOY_AXIS_V ) ) );
|
|
|
|
+ text_Draw( fntMain, 100, 520, 'POVX: ' + u_FloatToStr( joy_AxisPos( 0, JOY_POVX ) ) );
|
|
|
|
+ text_Draw( fntMain, 100, 540, 'POVY: ' + u_FloatToStr( joy_AxisPos( 0, JOY_POVY ) ) );
|
|
|
|
|
|
|
|
+ setTextColor(Get_Color(cl_Red05));
|
|
text_Draw(fntMain, 400, 400, 'Button1: ' + u_BoolToStr(joy_Down(0, 0)));
|
|
text_Draw(fntMain, 400, 400, 'Button1: ' + u_BoolToStr(joy_Down(0, 0)));
|
|
text_Draw(fntMain, 400, 420, 'Button2: ' + u_BoolToStr(joy_Down(0, 1)));
|
|
text_Draw(fntMain, 400, 420, 'Button2: ' + u_BoolToStr(joy_Down(0, 1)));
|
|
text_Draw(fntMain, 400, 440, 'Button3: ' + u_BoolToStr(joy_Down(0, 2)));
|
|
text_Draw(fntMain, 400, 440, 'Button3: ' + u_BoolToStr(joy_Down(0, 2)));
|
|
@@ -187,23 +208,22 @@ begin
|
|
text_Draw(fntMain, 550, 540, 'Button16: ' + u_BoolToStr(joy_Down(0, 15)));
|
|
text_Draw(fntMain, 550, 540, 'Button16: ' + u_BoolToStr(joy_Down(0, 15)));
|
|
end;
|
|
end;
|
|
|
|
|
|
-
|
|
|
|
|
|
+{$IfDef OLD_METHODS}
|
|
procedure Timer;
|
|
procedure Timer;
|
|
begin
|
|
begin
|
|
-(* // ðàññêîììåòèðîâàòü, åñëè õîòèòå èñïîëüçîâàòü ñòàðûé ñïîñîá
|
|
|
|
if lineAlpha > 5 Then
|
|
if lineAlpha > 5 Then
|
|
DEC(lineAlpha, 10)
|
|
DEC(lineAlpha, 10)
|
|
else
|
|
else
|
|
lineAlpha := 255;
|
|
lineAlpha := 255;
|
|
- *)
|
|
|
|
end;
|
|
end;
|
|
|
|
+{$EndIf}
|
|
|
|
|
|
procedure KeyMouseEvent;
|
|
procedure KeyMouseEvent;
|
|
begin
|
|
begin
|
|
{$IfDef OLD_METHODS}
|
|
{$IfDef OLD_METHODS}
|
|
// RU: Ïðîâåðèòü íàæàòà ëè ëåâàÿ êíîïêà ìûøè â ïðåäåëàõ inputRect è íà÷àòü îòñëåæèâàòü ââîä òåêñòà.
|
|
// RU: Ïðîâåðèòü íàæàòà ëè ëåâàÿ êíîïêà ìûøè â ïðåäåëàõ inputRect è íà÷àòü îòñëåæèâàòü ââîä òåêñòà.
|
|
// EN: Check if left mouse button was pressed inside inputRect and start to track text input.
|
|
// EN: Check if left mouse button was pressed inside inputRect and start to track text input.
|
|
- if mBClickCanClick(M_BLEFT_CLICK) and col2d_PointInRect(mouseX, mouseY, inputRect) Then
|
|
|
|
|
|
+ if mouseBClick(M_BLEFT) and col2d_PointInRect(mouseX, mouseY, inputRect) Then
|
|
begin
|
|
begin
|
|
trackInput := TRUE;
|
|
trackInput := TRUE;
|
|
key_BeginReadText(userInput, 24);
|
|
key_BeginReadText(userInput, 24);
|
|
@@ -233,7 +253,7 @@ end;
|
|
|
|
|
|
Begin
|
|
Begin
|
|
{$IfDef OLD_METHODS}
|
|
{$IfDef OLD_METHODS}
|
|
- TimeStart := timer_Add(@Timer, 16, Start);
|
|
|
|
|
|
+ TimeStart := timer_Add(@Timer, 16, t_Start);
|
|
{$EndIf}
|
|
{$EndIf}
|
|
|
|
|
|
zgl_Reg(SYS_EVENTS, @KeyMouseEvent);
|
|
zgl_Reg(SYS_EVENTS, @KeyMouseEvent);
|