Commit 33260590 authored by cvet's avatar cvet

Defines elimination.

git-svn-id: https://xp-dev.com/svn/fonline_sdk@811 71b6ff52-6597-447a-9a87-58edf7a03249
parent 2803d37b
This diff is collapsed.
......@@ -70,7 +70,7 @@ class FixedDropMenu : Gui::IDropMenu
int x = __MouseX + 20; // Todo: rework to actual cursor size
int y = __MouseY + 20;
int activeIndex = PressedOffsetY / ButtonHeight;
activeIndex = CLAMP( activeIndex, 0, int( ShowButtons.length() ) - 1 );
activeIndex = Math::Clamp( activeIndex, 0, int( ShowButtons.length() ) - 1 );
for( uint i = 0; i < ShowButtons.length(); i++ )
{
DropButton button = ShowButtons[ i ];
......@@ -101,7 +101,7 @@ class FixedDropMenu : Gui::IDropMenu
CollectShowButtons( true );
int activeIndex = PressedOffsetY / ButtonHeight;
activeIndex = CLAMP( activeIndex, 0, int( ShowButtons.length() ) - 1 );
activeIndex = Math::Clamp( activeIndex, 0, int( ShowButtons.length() ) - 1 );
DropButton dropButton = ShowButtons[ activeIndex ];
ShowButtons.clear();
......
......@@ -546,7 +546,7 @@ interface IDropMenu
bool IsHit( int x, int y )
{
return Active && !_IsNotHittable && _Width > 0 && _Height > 0 &&
IS_COLLISION( x, y, _AbsolutePosX, _AbsolutePosY, _Width, _Height ) && !_IsCropped( x, y );
Math::IsCollision( x, y, _AbsolutePosX, _AbsolutePosY, _Width, _Height ) && !_IsCropped( x, y );
}
bool _IsCropped( int x, int y )
......@@ -555,7 +555,7 @@ interface IDropMenu
while( obj !is null )
{
Panel panel = cast< Panel >( obj );
if( panel !is null && panel._CropContent && !IS_COLLISION( x, y, obj._AbsolutePosX, obj._AbsolutePosY, obj._Width, obj._Height ) )
if( panel !is null && panel._CropContent && !Math::IsCollision( x, y, obj._AbsolutePosX, obj._AbsolutePosY, obj._Width, obj._Height ) )
return true;
obj = obj.Parent;
}
......@@ -1321,7 +1321,7 @@ interface IDropMenu
}
}
#define PASSWORD_SHOW_TIME ( 1000 )
const int PasswordShowTime = 1000;
/*EXPORT*/ class TextInput : Text
{
uint get_InputLength() final { return _InputLength; }
......@@ -1370,7 +1370,7 @@ interface IDropMenu
text = "";
for( uint i = 0; i < rawText.length(); i++ )
text += _PasswordChar;
if( GetTick() - _PasswordTime <= PASSWORD_SHOW_TIME )
if( GetTick() - _PasswordTime <= PasswordShowTime )
text[ text.length() - 1 ] = rawText[ text.length() - 1 ];
}
if( _CarriagePos != -1 && _IsFocused )
......@@ -2353,7 +2353,7 @@ interface IDropMenu
}
}
#define CONSOLE_DATA_PREFIX "console_"
const string ConsoleDataPrefix = "console_";
/*EXPORT*/ class Console : TextInput
{
bool get_DisableDeactivation() final { return _DisableDeactivation; }
......@@ -2432,7 +2432,7 @@ interface IDropMenu
string name = ( GetChosen() !is null ? GetChosen().Name : "" );
string actualStorageName = "";
if( !_HistoryStorageName.isEmpty() && !name.isEmpty() )
actualStorageName = CONSOLE_DATA_PREFIX + name + _HistoryStorageName;
actualStorageName = ConsoleDataPrefix + name + _HistoryStorageName;
if( _HistoryActualStorageName != actualStorageName )
{
......
......@@ -56,7 +56,7 @@ void ModuleInit()
}
// //////////////////////////////////////////////////////////////////////////////////////////////////
// Mouse behaviours. Button states look in _client_defines.fos, Mouse buttons.
// Mouse behaviours. Button states look in ClientCore.fos, Mouse buttons.
// Return true to disable engine events.
void OnMouseDown( int button ) // Engine callback
{
......@@ -82,7 +82,7 @@ void OnMouseMove( int offsetX, int offsetY ) // Engine callback
}
// //////////////////////////////////////////////////////////////////////////////////////////////////
// Keyboard behaviours. Key codes look in _client_defines.fos DirectInput keyboard scan codes.
// Keyboard behaviours. Key codes look in ClientCore.fos, DirectInput keyboard scan codes.
// Return true to disable engine events.
void OnKeyDown( uint8 key, string text ) // Engine callback
{
......
// FOS Common Sort -7
#define IS_COLLISION # ( x1, y1, x2, y2, w, h )( ( x1 ) >= ( x2 ) && ( x1 ) < ( x2 ) + ( w ) && ( y1 ) >= ( y2 ) && ( y1 ) < ( y2 ) + ( h ) )
#define POW2 # (a) ( ( a ) * ( a ) )
#define POW3 # (a) ( ( a ) * ( a ) * ( a ) )
#define POW \
# ( x, y ) for( int ___i = 1, ___j = x; ___i < y; ___i++ ) \
x *= ___j
#define MIN # ( a, b )( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
#define MAX # ( a, b )( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
#define CLAMP # ( x, low, high )( ( ( x ) > ( high ) ) ? ( high ) : ( ( ( x ) < ( low ) ) ? ( low ) : ( x ) ) )
#define ABS # (val) ( ( ( val ) > 0 ) ? ( val ) : -( val ) )
#define DISTANCE # ( x1, y1, x2, y2 )( sqrt( POW2( ( x1 ) - ( x2 ) ) + POW2( ( y1 ) - ( y2 ) ) ) )
#define MAKEWORD # ( a, b )( uint16( ( uint8( a ) ) | ( uint16( uint8( b ) ) ) << 8 ) )
#define MAKELONG # ( a, b )( int32( ( uint16( a ) ) | ( uint32( uint16( b ) ) ) << 16 ) )
#define LOWORD # (l) ( uint16( l ) )
#define HIWORD # (l) ( uint16( ( uint32( l ) >> 16 ) & 0xFFFF ) )
#define LOBYTE # (w) ( uint8( w ) )
#define HIBYTE # (w) ( uint8( ( uint16( w ) >> 8 ) & 0xFF ) )
#define LBS_TO_GRAMM # (lbs) ( ( lbs ) * 453 )
#define NUMERICAL_NUMBER # (num) ( ( ( num ) % 2 ) != 0 ? ( num ) * ( ( num ) / 2 + 1 ) : ( num ) * ( num ) / 2 + ( num ) / 2 )
// FOS Common
int Pow2( int x )
{
return x * x;
}
float Pow2F( float x )
{
return x * x;
}
int Pow3( int x )
{
return x * x * x;
}
float Pow3F( float x )
{
return x * x * x;
}
int Min( int x, int y )
{
return x < y ? x : y;
}
float MinF( float x, float y )
{
return x < y ? x : y;
}
int Max( int x, int y )
{
return x > y ? x : y;
}
float MaxF( float x, float y )
{
return x > y ? x : y;
}
int Clamp( int x, int min, int max )
{
return x > max ? max : ( x < min ? min : x );
}
float ClampF( float x, float min, float max )
{
return x > max ? max : ( x < min ? min : x );
}
int Abs( int x )
{
return x > 0 ? x : -x;
}
float AbsF( float x )
{
return x > 0 ? x : -x;
}
int Distance( int x1, int y1, int x2, int y2 )
{
return int( sqrt( Pow2( x1 - x2 ) + Pow2( y1 - y2 ) ) );
}
float DistanceF( float x1, float y1, float x2, float y2 )
{
return float( sqrt( Pow2F( x1 - x2 ) + Pow2F( y1 - y2 ) ) );
}
bool IsCollision( int x1, int y1, int x2, int y2, int w, int h )
{
return x1 >= x2 && x1 < x2 + w && y1 >= y2 && y1 < y2 + h;
}
int LbsToGramm( int lbs )
{
return lbs * 453;
}
int NumericalNumber( int num )
{
return num % 2 != 0 ? num * num / 2 + 1 : num * num / 2 + num / 2;
}
......@@ -25,6 +25,10 @@
/*EXPORT*/ uint RealMonth( uint value ) { return value * Globals.TimeMultiplier * 2592000; }
/*EXPORT*/ uint RealYear( uint value ) { return value * Globals.TimeMultiplier * 31536000; }
#define IS_MORNING # (hour) ( ( hour ) >= 7 && ( hour ) <= 11 ) // 5 hours
#define IS_AFTERNOON # (hour) ( ( hour ) >= 12 && ( hour ) <= 21 ) // 10 hours
#define IS_NIGHT # (hour) ( ( hour ) >= 22 || ( hour ) <= 6 ) // 9 hours
#define SECOND_TICKS # (x) ( ( x ) * 1000 )
#define MINUTE_TICKS # (x) ( ( x ) * 60000 )
#define HOUR_TICKS # (x) ( ( x ) * 3600000 )
......
......@@ -44,13 +44,13 @@ class Tween
int get_Dist()
{
return int( sqrt( POW2( ( end ? x2 : x1 ) - x3 ) + POW2( ( end ? y2 : y1 ) - y3 ) ) );
return int( sqrt( Math::Pow2( ( end ? x2 : x1 ) - x3 ) + Math::Pow2( ( end ? y2 : y1 ) - y3 ) ) );
}
int get_Percent()
{
int dist = Dist;
return dist > 0 ? MIN( ( GetTick() - startTick ) * pps / 1000 * 100 / Dist, 100 ) : 100;
return dist > 0 ? Math::Min( ( GetTick() - startTick ) * pps / 1000 * 100 / Dist, 100 ) : 100;
}
private bool end;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment