Skip to content
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

Remove old Rect, Point and Size classes #3316

Merged
merged 14 commits into from
May 4, 2021
2 changes: 1 addition & 1 deletion VisualStudio/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)..\src\engine;$(MSBuildThisFileDirectory)..\src\fheroes2\gui;$(MSBuildThisFileDirectory)..\src\fheroes2\maps;$(MSBuildThisFileDirectory)..\src\fheroes2\kingdom;$(MSBuildThisFileDirectory)..\src\fheroes2\campaign;$(MSBuildThisFileDirectory)..\src\fheroes2\game;$(MSBuildThisFileDirectory)..\src\fheroes2\dialog;$(MSBuildThisFileDirectory)..\src\fheroes2\system;$(MSBuildThisFileDirectory)..\src\fheroes2\spell;$(MSBuildThisFileDirectory)..\src\fheroes2\monster;$(MSBuildThisFileDirectory)..\src\fheroes2\castle;$(MSBuildThisFileDirectory)..\src\fheroes2\agg;$(MSBuildThisFileDirectory)..\src\fheroes2\heroes;$(MSBuildThisFileDirectory)..\src\fheroes2\resource;$(MSBuildThisFileDirectory)..\src\fheroes2\ai;$(MSBuildThisFileDirectory)..\src\fheroes2\army;$(MSBuildThisFileDirectory)..\src\fheroes2\battle;$(MSBuildThisFileDirectory)..\src\fheroes2\pocketpc;$(MSBuildThisFileDirectory)..\src\fheroes2\objects;$(MSBuildThisFileDirectory)..\src\fheroes2\world;$(MSBuildThisFileDirectory)..\src\fheroes2\image;$(MSBuildThisFileDirectory)..\src\thirdparty\libsmacker;$(MSBuildThisFileDirectory)packages\installed\zlib\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WITH_ZLIB;WITH_MIXER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatSpecificWarningsAsErrors>4100;4189;4309;4319;4592;4715;4800</TreatSpecificWarningsAsErrors>
<TreatSpecificWarningsAsErrors>4018;4100;4189;4309;4319;4592;4715;4800</TreatSpecificWarningsAsErrors>
</ClCompile>
<ResourceCompile>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)..\src\fheroes2\system;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Expand Down
2 changes: 0 additions & 2 deletions fheroes2-vs2015.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@
<ClCompile Include="src\engine\logging.cpp" />
<ClCompile Include="src\engine\pal.cpp" />
<ClCompile Include="src\engine\rand.cpp" />
<ClCompile Include="src\engine\rect.cpp" />
<ClCompile Include="src\engine\screen.cpp" />
<ClCompile Include="src\engine\sdlnet.cpp" />
<ClCompile Include="src\engine\serialize.cpp" />
Expand Down Expand Up @@ -397,7 +396,6 @@
<ClInclude Include="src\engine\palette_h2.h" />
<ClInclude Include="src\engine\pathfinding.h" />
<ClInclude Include="src\engine\rand.h" />
<ClInclude Include="src\engine\rect.h" />
<ClInclude Include="src\engine\screen.h" />
<ClInclude Include="src\engine\sdlnet.h" />
<ClInclude Include="src\engine\serialize.h" />
Expand Down
2 changes: 0 additions & 2 deletions fheroes2-vs2019.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@
<ClCompile Include="src\engine\logging.cpp" />
<ClCompile Include="src\engine\pal.cpp" />
<ClCompile Include="src\engine\rand.cpp" />
<ClCompile Include="src\engine\rect.cpp" />
<ClCompile Include="src\engine\screen.cpp" />
<ClCompile Include="src\engine\sdlnet.cpp" />
<ClCompile Include="src\engine\serialize.cpp" />
Expand Down Expand Up @@ -398,7 +397,6 @@
<ClInclude Include="src\engine\palette_h2.h" />
<ClInclude Include="src\engine\pathfinding.h" />
<ClInclude Include="src\engine\rand.h" />
<ClInclude Include="src\engine\rect.h" />
<ClInclude Include="src\engine\screen.h" />
<ClInclude Include="src\engine\sdlnet.h" />
<ClInclude Include="src\engine\serialize.h" />
Expand Down
42 changes: 21 additions & 21 deletions src/engine/localevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,18 +280,18 @@ void LocalEvent::CloseVirtualKeyboard()
#endif
}

const Point & LocalEvent::GetMousePressLeft( void ) const
const fheroes2::Point & LocalEvent::GetMousePressLeft( void ) const
{
return mouse_pl;
}

void LocalEvent::SetMouseOffsetX( int16_t x )
void LocalEvent::SetMouseOffsetX( int32_t x )
{
SetModes( MOUSE_OFFSET );
mouse_st.x = x;
}

void LocalEvent::SetMouseOffsetY( int16_t y )
void LocalEvent::SetMouseOffsetY( int32_t y )
{
SetModes( MOUSE_OFFSET );
mouse_st.y = y;
Expand Down Expand Up @@ -1288,8 +1288,8 @@ void LocalEvent::HandleTouchEvent( const SDL_TouchFingerEvent & event )
_emulatedPointerPosY
= static_cast<double>( screenResolution.height * event.y - windowRect.y ) * ( static_cast<double>( gameSurfaceRes.height ) / windowRect.height );

mouse_cu.x = static_cast<int16_t>( _emulatedPointerPosX );
mouse_cu.y = static_cast<int16_t>( _emulatedPointerPosY );
mouse_cu.x = static_cast<int32_t>( _emulatedPointerPosX );
mouse_cu.y = static_cast<int32_t>( _emulatedPointerPosY );

if ( ( modes & MOUSE_MOTION ) && redraw_cursor_func ) {
if ( modes & MOUSE_OFFSET )
Expand Down Expand Up @@ -1422,8 +1422,8 @@ void LocalEvent::ProcessControllerAxisMotion()
if ( _controllerLeftXAxis != 0 || _controllerLeftYAxis != 0 ) {
SetModes( MOUSE_MOTION );

const int16_t xSign = ( _controllerLeftXAxis > 0 ) - ( _controllerLeftXAxis < 0 );
const int16_t ySign = ( _controllerLeftYAxis > 0 ) - ( _controllerLeftYAxis < 0 );
const int32_t xSign = ( _controllerLeftXAxis > 0 ) - ( _controllerLeftXAxis < 0 );
const int32_t ySign = ( _controllerLeftYAxis > 0 ) - ( _controllerLeftYAxis < 0 );

_emulatedPointerPosX += pow( std::abs( _controllerLeftXAxis ), CONTROLLER_AXIS_SPEEDUP ) * xSign * deltaTime * _controllerPointerSpeed;
_emulatedPointerPosY += pow( std::abs( _controllerLeftYAxis ), CONTROLLER_AXIS_SPEEDUP ) * ySign * deltaTime * _controllerPointerSpeed;
Expand All @@ -1440,8 +1440,8 @@ void LocalEvent::ProcessControllerAxisMotion()
else if ( _emulatedPointerPosY >= display.height() )
_emulatedPointerPosY = display.height() - 1;

mouse_cu.x = static_cast<int16_t>( _emulatedPointerPosX );
mouse_cu.y = static_cast<int16_t>( _emulatedPointerPosY );
mouse_cu.x = static_cast<int32_t>( _emulatedPointerPosX );
mouse_cu.y = static_cast<int32_t>( _emulatedPointerPosY );

if ( ( modes & MOUSE_MOTION ) && redraw_cursor_func ) {
if ( modes & MOUSE_OFFSET )
Expand Down Expand Up @@ -1627,7 +1627,7 @@ bool LocalEvent::MouseClickLeft( void )
return false;
}

bool LocalEvent::MouseClickLeft( const Rect & rt )
bool LocalEvent::MouseClickLeft( const fheroes2::Rect & rt )
{
if ( ( modes & MOUSE_CLICKED ) && SDL_BUTTON_LEFT == mouse_button && ( rt & mouse_pl ) && ( rt & mouse_rl ) ) {
ResetModes( MOUSE_CLICKED );
Expand All @@ -1649,7 +1649,7 @@ bool LocalEvent::MouseClickMiddle( void )
return false;
}

bool LocalEvent::MouseClickMiddle( const Rect & rt )
bool LocalEvent::MouseClickMiddle( const fheroes2::Rect & rt )
{
if ( ( modes & MOUSE_CLICKED ) && SDL_BUTTON_MIDDLE == mouse_button && ( rt & mouse_pm ) && ( rt & mouse_rm ) ) {
ResetModes( MOUSE_CLICKED );
Expand All @@ -1671,7 +1671,7 @@ bool LocalEvent::MouseClickRight( void )
return false;
}

bool LocalEvent::MouseClickRight( const Rect & rt )
bool LocalEvent::MouseClickRight( const fheroes2::Rect & rt )
{
if ( ( modes & MOUSE_CLICKED ) && SDL_BUTTON_RIGHT == mouse_button && ( rt & mouse_pr ) && ( rt & mouse_rr ) ) {
ResetModes( MOUSE_CLICKED );
Expand Down Expand Up @@ -1700,32 +1700,32 @@ bool LocalEvent::MouseWheelDn( void ) const
#endif
}

bool LocalEvent::MousePressLeft( const Rect & rt ) const
bool LocalEvent::MousePressLeft( const fheroes2::Rect & rt ) const
{
return MousePressLeft() && ( rt & mouse_pl );
}

bool LocalEvent::MousePressMiddle( const Rect & rt ) const
bool LocalEvent::MousePressMiddle( const fheroes2::Rect & rt ) const
{
return MousePressMiddle() && ( rt & mouse_pm );
}

bool LocalEvent::MousePressRight( const Rect & rt ) const
bool LocalEvent::MousePressRight( const fheroes2::Rect & rt ) const
{
return MousePressRight() && ( rt & mouse_pr );
}

bool LocalEvent::MouseReleaseLeft( const Rect & rt ) const
bool LocalEvent::MouseReleaseLeft( const fheroes2::Rect & rt ) const
{
return MouseReleaseLeft() && ( rt & mouse_rl );
}

bool LocalEvent::MouseReleaseMiddle( const Rect & rt ) const
bool LocalEvent::MouseReleaseMiddle( const fheroes2::Rect & rt ) const
{
return MouseReleaseMiddle() && ( rt & mouse_rm );
}

bool LocalEvent::MouseReleaseRight( const Rect & rt ) const
bool LocalEvent::MouseReleaseRight( const fheroes2::Rect & rt ) const
{
return MouseReleaseRight() && ( rt & mouse_rr );
}
Expand All @@ -1736,17 +1736,17 @@ void LocalEvent::ResetPressLeft( void )
mouse_pl.y = -1;
}

bool LocalEvent::MouseWheelUp( const Rect & rt ) const
bool LocalEvent::MouseWheelUp( const fheroes2::Rect & rt ) const
{
return MouseWheelUp() && ( rt & mouse_cu );
}

bool LocalEvent::MouseWheelDn( const Rect & rt ) const
bool LocalEvent::MouseWheelDn( const fheroes2::Rect & rt ) const
{
return MouseWheelDn() && ( rt & mouse_cu );
}

bool LocalEvent::MouseCursor( const Rect & rt ) const
bool LocalEvent::MouseCursor( const fheroes2::Rect & rt ) const
{
return rt & mouse_cu;
}
Expand Down
80 changes: 40 additions & 40 deletions src/engine/localevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include <string>

#include "rect.h"
#include "math_base.h"
#include "timing.h"
#include "types.h"

Expand Down Expand Up @@ -183,8 +183,8 @@ class LocalEvent
void SetGlobalFilterMouseEvents( void ( *pf )( s32, s32 ) );
void SetGlobalFilterKeysEvents( void ( *pf )( int, int ) );
void SetGlobalFilter( bool );
void SetMouseOffsetX( int16_t );
void SetMouseOffsetY( int16_t );
void SetMouseOffsetX( int32_t );
void SetMouseOffsetY( int32_t );

static void SetStateDefaults( void );
static void SetState( u32 type, bool enable );
Expand All @@ -194,55 +194,55 @@ class LocalEvent

bool MouseMotion( void ) const;

const Point & GetMouseCursor( void ) const
const fheroes2::Point & GetMouseCursor( void ) const
{
return mouse_cu;
}

const Point & GetMousePressLeft( void ) const;
const fheroes2::Point & GetMousePressLeft( void ) const;

void ResetPressLeft( void );
void ResetPressLeft();

bool MouseClickLeft( void );
bool MouseClickMiddle( void );
bool MouseClickRight( void );
bool MouseClickLeft();
bool MouseClickMiddle();
bool MouseClickRight();

bool MouseClickLeft( const Rect & rt );
bool MouseClickMiddle( const Rect & rt );
bool MouseClickRight( const Rect & rt );
bool MouseClickLeft( const fheroes2::Rect & rt );
bool MouseClickMiddle( const fheroes2::Rect & rt );
bool MouseClickRight( const fheroes2::Rect & rt );

bool MouseWheelUp( void ) const;
bool MouseWheelDn( void ) const;
bool MouseWheelUp() const;
bool MouseWheelDn() const;

bool MousePressLeft( void ) const;
bool MousePressLeft( const Rect & rt ) const;
bool MousePressMiddle( void ) const;
bool MousePressMiddle( const Rect & rt ) const;
bool MousePressRight( void ) const;
bool MousePressRight( const Rect & rt ) const;
bool MousePressLeft() const;
bool MousePressLeft( const fheroes2::Rect & rt ) const;
bool MousePressMiddle() const;
bool MousePressMiddle( const fheroes2::Rect & rt ) const;
bool MousePressRight() const;
bool MousePressRight( const fheroes2::Rect & rt ) const;

bool MouseReleaseLeft( void ) const;
bool MouseReleaseLeft( const Rect & rt ) const;
bool MouseReleaseMiddle( void ) const;
bool MouseReleaseMiddle( const Rect & rt ) const;
bool MouseReleaseRight( void ) const;
bool MouseReleaseRight( const Rect & rt ) const;
bool MouseReleaseLeft() const;
bool MouseReleaseLeft( const fheroes2::Rect & rt ) const;
bool MouseReleaseMiddle() const;
bool MouseReleaseMiddle( const fheroes2::Rect & rt ) const;
bool MouseReleaseRight() const;
bool MouseReleaseRight( const fheroes2::Rect & rt ) const;

bool MouseWheelUp( const Rect & rt ) const;
bool MouseWheelDn( const Rect & rt ) const;
bool MouseWheelUp( const fheroes2::Rect & rt ) const;
bool MouseWheelDn( const fheroes2::Rect & rt ) const;

bool MouseCursor( const Rect & rt ) const;
bool MouseCursor( const fheroes2::Rect & rt ) const;

bool KeyPress( void ) const;
bool KeyPress() const;
bool KeyPress( KeySym key ) const;

bool KeyHold() const
{
return ( modes & KEY_HOLD ) != 0;
}

KeySym KeyValue( void ) const;
int KeyMod( void ) const;
KeySym KeyValue() const;
int KeyMod() const;

void RegisterCycling( void ( *preRenderDrawing )() = nullptr, void ( *postRenderDrawing )() = nullptr ) const;

Expand Down Expand Up @@ -311,17 +311,17 @@ class LocalEvent
int mouse_state;
int mouse_button;

Point mouse_st; // mouse offset for pocketpc
fheroes2::Point mouse_st; // mouse offset for pocketpc

Point mouse_pl; // press left
Point mouse_pm; // press middle
Point mouse_pr; // press right
fheroes2::Point mouse_pl; // press left
fheroes2::Point mouse_pm; // press middle
fheroes2::Point mouse_pr; // press right

Point mouse_rl; // release left
Point mouse_rm; // release middle
Point mouse_rr; // release right
fheroes2::Point mouse_rl; // release left
fheroes2::Point mouse_rm; // release middle
fheroes2::Point mouse_rr; // release right

Point mouse_cu; // point cursor
fheroes2::Point mouse_cu; // point cursor

fheroes2::Point mouse_wm; // wheel movement

Expand Down
5 changes: 5 additions & 0 deletions src/engine/math_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ namespace fheroes2
return output;
}

PointBase2D<_TypePoint> getPosition() const
{
return PointBase2D<_TypePoint>( x, y );
}

_TypePoint x;
_TypePoint y;
_TypeSize width;
Expand Down
Loading