Skip to content

Commit 23ec296

Browse files
committed
Updated to latest commit, added few changes
1 parent 79c5509 commit 23ec296

File tree

6 files changed

+41
-36
lines changed

6 files changed

+41
-36
lines changed

extras/videoDrivers/SDL2/VideoSDL2.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@
3232

3333
#define CHECK_SDL(call) \
3434
([&]() -> bool { \
35-
if((call) == -1) \
36-
{ \
37-
PrintError(SDL_GetError()); \
38-
return false; \
39-
} \
40-
return true; \
35+
if((call) < 0) \
36+
return true; \
37+
\
38+
PrintError(SDL_GetError()); \
39+
return false; \
4140
})()
4241

4342
namespace {
@@ -249,10 +248,16 @@ bool VideoSDL2::ResizeScreen(const VideoMode& newSize, bool fullscreen)
249248
return true;
250249
}
251250

251+
#ifdef __ANDROID__
252+
void VideoSDL2::PrintError(const std::string&) const
253+
{ // Not really sure why the nowide::cerr function completely crashes on android
254+
}
255+
#else
252256
void VideoSDL2::PrintError(const std::string& msg) const
253257
{
254258
boost::nowide::cerr << msg << std::endl;
255259
}
260+
#endif
256261

257262
void VideoSDL2::ShowErrorMessage(const std::string& title, const std::string& message)
258263
{

libs/s25main/TerrainRenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ void TerrainRenderer::Draw(const Position& firstPt, const Position& lastPt, cons
802802
}
803803

804804
#if RTTR_OGL_GL4ES
805-
// Gl4ES behaves weird with GL_COMBINE. All textures are too bright. The function might not be implemented in GL4ES
805+
// Gl4ES behaves weird with GL_COMBINE. All textures are too bright and some shadows are missing. The function might not be implemented in GL4ES
806806
// at all.
807807
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
808808
#else

libs/s25main/WindowManager.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
#include "s25util/Log.h"
2828
#include "s25util/MyTime.h"
2929
#include <algorithm>
30+
#include <type_traits>
31+
3032

3133
namespace {
32-
template<typename T>
33-
constexpr T square(T x)
34+
template<typename T, std::enable_if_t<std::is_integral_v<T>, int> = 0>
35+
constexpr std::make_unsigned_t<T> square(T x)
3436
{
3537
return x * x;
3638
}
@@ -372,7 +374,7 @@ void WindowManager::Msg_LeftUp(MouseCoords mc)
372374
if(time_now - lastLeftClickTime < TOUCH_DOUBLE_CLICK_INTERVAL)
373375
{
374376
// Calculate distance between two points
375-
const PointF diff = static_cast<PointF>(mc.pos - lastLeftClickPos);
377+
const Point<int> diff = mc.pos - lastLeftClickPos;
376378
if(square(diff.x) + square(diff.y) <= square(TOUCH_MAX_DOUBLE_CLICK_DISTANCE))
377379
mc.dbl_click = true;
378380
}

libs/s25main/desktops/dskGameInterface.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,7 @@ void dskGameInterface::Msg_PaintAfter()
662662
}
663663

664664
// Draw speed indicator icon
665-
const int speedStep =
666-
static_cast<int>(SPEED_GF_LENGTHS[referenceSpeed] / 10ms) - static_cast<int>(GAMECLIENT.GetGFLength() / 10ms);
665+
const int speedStep = static_cast<int>(REFERENCE_SPEED / 10ms) - static_cast<int>(GAMECLIENT.GetGFLength() / 10ms);
667666

668667
if(speedStep != 0)
669668
{

tests/s25Main/UI/testWindowManager.cpp

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "Settings.h"
88
#include "WindowManager.h"
99
#include "desktops/Desktop.h"
10+
#include "driver/MouseCoords.h"
1011
#include "helpers/containerUtils.h"
1112
#include "ingameWindows/IngameWindow.h"
1213
#include "ingameWindows/TransmitSettingsIgwAdapter.h"
@@ -70,17 +71,11 @@ BOOST_FIXTURE_TEST_CASE(LeftClick, WMFixture)
7071
{
7172
video->tickCount_ = 0;
7273
mock::sequence s;
73-
<<<<<<< HEAD
7474
MouseCoords mc1(5, 2);
7575
mc1.ldown = true;
7676
MouseCoords mc1_u(mc1.pos);
7777
MouseCoords mc2(10, 7);
7878
mc2.ldown = true;
79-
=======
80-
MouseCoords mc1(5, 2, true);
81-
MouseCoords mc1_u(mc1.pos);
82-
MouseCoords mc2(10, 7, true);
83-
>>>>>>> 9c0b20071 (Added tests for cfg envOverride and touch dblClick)
8479
MouseCoords mc2_u(mc2.pos);
8580
MOCK_EXPECT(dsk->Msg_LeftDown).once().with(mc1).in(s).returns(true);
8681
MOCK_EXPECT(dsk->Msg_LeftUp).once().with(mc1_u).in(s).returns(true);
@@ -105,17 +100,11 @@ BOOST_FIXTURE_TEST_CASE(DblClick, WMFixture)
105100
{
106101
video->tickCount_ = 0;
107102
mock::sequence s;
108-
<<<<<<< HEAD
109103
MouseCoords mc1(5, 2);
110104
mc1.ldown = true;
111105
MouseCoords mc1_u(mc1.pos);
112106
MouseCoords mc2(6, 1);
113107
mc2.ldown = true;
114-
=======
115-
MouseCoords mc1(5, 2, true);
116-
MouseCoords mc1_u(mc1.pos);
117-
MouseCoords mc2(6, 1, true);
118-
>>>>>>> 9c0b20071 (Added tests for cfg envOverride and touch dblClick)
119108
MouseCoords mc2_u(mc2.pos);
120109
// Click with time > DOUBLE_CLICK_INTERVAL is no dbl click
121110
MOCK_EXPECT(dsk->Msg_LeftDown).once().with(mc1).in(s).returns(true);
@@ -127,13 +116,9 @@ BOOST_FIXTURE_TEST_CASE(DblClick, WMFixture)
127116
MOCK_EXPECT(dsk->Msg_LeftUp).once().with(mc2_u).in(s).returns(true);
128117
// Click on same pos with time < DOUBLE_CLICK_INTERVAL is dbl click
129118
MOCK_EXPECT(dsk->Msg_LeftDown).once().with(mc2).in(s).returns(true);
130-
<<<<<<< HEAD
131119
MouseCoords dbl_mc2(mc2.pos);
132120
dbl_mc2.dbl_click = true;
133121
MOCK_EXPECT(dsk->Msg_LeftUp).once().with(dbl_mc2).in(s).returns(true);
134-
=======
135-
MOCK_EXPECT(dsk->Msg_LeftUp).once().with(MouseCoords(mc2.pos, false, false, true)).in(s).returns(true);
136-
>>>>>>> 9c0b20071 (Added tests for cfg envOverride and touch dblClick)
137122
// No triple click
138123
MOCK_EXPECT(dsk->Msg_LeftDown).once().with(mc2).in(s).returns(true);
139124
MOCK_EXPECT(dsk->Msg_LeftUp).once().with(mc2_u).in(s).returns(true);
@@ -166,14 +151,23 @@ BOOST_FIXTURE_TEST_CASE(DblClickTouch, WMFixture)
166151
video->numTfinger_ = 1;
167152
mock::sequence s;
168153

169-
MouseCoords mc1(5, 2, true, false, false, 1);
170-
MouseCoords mc1_u(mc1.pos, false, false, false, 1);
154+
MouseCoords mc1(5, 2);
155+
mc1.ldown = true;
156+
mc1.num_tfingers = 1;
157+
MouseCoords mc1_u(mc1.pos);
158+
mc1_u.num_tfingers = 1;
171159
// Test click on distance > TOUCH_MAX_DOUBLE_CLICK_DISTANCE
172-
MouseCoords mc2(mc1.pos.x + TOUCH_MAX_DOUBLE_CLICK_DISTANCE + 1, mc1.pos.y, true, false, false, 1);
173-
MouseCoords mc2_u(mc2.pos, false, false, false, 1);
160+
MouseCoords mc2(mc1.pos.x + TOUCH_MAX_DOUBLE_CLICK_DISTANCE + 1, mc1.pos.y);
161+
mc2.ldown = true;
162+
mc2.num_tfingers = 1;
163+
MouseCoords mc2_u(mc2.pos);
164+
mc2_u.num_tfingers = 1;
174165
// Test click on distance < TOUCH_MAX_DOUBLE_CLICK_DISTANCE
175-
MouseCoords mc3(mc2.pos.x + TOUCH_MAX_DOUBLE_CLICK_DISTANCE - 1, mc2.pos.y, true, false, false, 1);
176-
MouseCoords mc3_u(mc3.pos, false, false, false, 1);
166+
MouseCoords mc3(mc2.pos.x + TOUCH_MAX_DOUBLE_CLICK_DISTANCE - 1, mc2.pos.y);
167+
mc3.ldown = true;
168+
mc3.num_tfingers = 1;
169+
MouseCoords mc3_u(mc3.pos);
170+
mc3_u.num_tfingers = 1;
177171

178172
// Set last click position on mc1
179173
MOCK_EXPECT(dsk->Msg_LeftDown).once().with(mc1).in(s).returns(true);
@@ -185,7 +179,10 @@ BOOST_FIXTURE_TEST_CASE(DblClickTouch, WMFixture)
185179

186180
// Touch position mc3 -> In range of mc -> dblclick
187181
MOCK_EXPECT(dsk->Msg_LeftDown).once().with(mc3).in(s).returns(true);
188-
MOCK_EXPECT(dsk->Msg_LeftUp).once().with(MouseCoords(mc3.pos, false, false, true, 1)).in(s).returns(true);
182+
MouseCoords range_mc3(mc3.pos);
183+
range_mc3.dbl_click = true;
184+
range_mc3.num_tfingers = 1;
185+
MOCK_EXPECT(dsk->Msg_LeftUp).once().with(range_mc3).in(s).returns(true);
189186

190187
// Try to touch 3rd time -> no dblclick -> Set last click position to mc3
191188
MOCK_EXPECT(dsk->Msg_LeftDown).once().with(mc3).in(s).returns(true);

tests/s25Main/integration/testDskGameInterface.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ BOOST_FIXTURE_TEST_CASE(Scrolling, GameInterfaceFixture)
7575
SETTINGS.interface.mapScrollMode = MapScrollMode::ScrollOpposite;
7676

7777
Position startPos(10, 15);
78-
MouseCoords mouse(startPos, false, true);
78+
//MouseCoords mouse(startPos, false, true);
79+
MouseCoords mouse(startPos);
80+
mouse.rdown = true;
7981

8082
// Regular scrolling: Right down, 2 moves, right up
8183
{

0 commit comments

Comments
 (0)