Browse Source

🎨 Format source

pull/1310/head
Anders Jenbo 5 years ago
parent
commit
a2656637e4
  1. 2
      DiabloUI/diabloui.h
  2. 28
      Source/engine.h
  3. 6
      Source/init.cpp
  4. 1
      Source/mpqapi.h
  5. 3
      Source/render.cpp
  6. 3
      SourceS/file_util.h
  7. 21
      SourceS/paths.cpp
  8. 1
      SourceS/storm_full.h
  9. 15
      SourceT/appfat_test.cpp
  10. 33
      SourceT/automap_test.cpp
  11. 6
      SourceT/codec_test.cpp
  12. 6
      SourceT/control_test.cpp
  13. 3
      SourceT/cursor_test.cpp
  14. 6
      SourceT/dead_test.cpp
  15. 6
      SourceT/doom_test.cpp
  16. 10
      SourceT/drlg_l1_test.cpp
  17. 3
      SourceT/drlg_l2_test.cpp
  18. 9
      SourceT/drlg_l3_test.cpp
  19. 6
      SourceT/drlg_l4_test.cpp
  20. 3
      SourceT/pack_test.cpp
  21. 3
      SourceX/DiabloUI/diabloui.cpp
  22. 12
      SourceX/DiabloUI/fonts.cpp
  23. 8
      SourceX/DiabloUI/scrollbar.cpp
  24. 2
      SourceX/DiabloUI/selconn.h
  25. 2
      SourceX/DiabloUI/selgame.h
  26. 3
      SourceX/DiabloUI/selhero.cpp
  27. 2
      SourceX/DiabloUI/selok.h
  28. 2
      SourceX/DiabloUI/selyesno.h
  29. 2
      SourceX/controls/axis_direction.cpp
  30. 16
      SourceX/controls/game_controls.cpp
  31. 3
      SourceX/controls/modifier_hints.cpp
  32. 6
      SourceX/controls/plrctrls.cpp
  33. 3
      SourceX/platform/ctr/keyboard.cpp
  34. 2
      SourceX/thread.cpp

2
DiabloUI/diabloui.h

@ -29,6 +29,6 @@ int UiSelectGame(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_in
int UiSelectProvider(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, _SNETVERSIONDATA *file_info, int *type);
BOOL UiCreatePlayerDescription(_uiheroinfo *info, Uint32 mode, char (*desc)[128]);
void UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, Uint32 type);
}
} // namespace dvl
#endif /* __DIABLOUI_H__ */

28
Source/engine.h

@ -105,27 +105,43 @@ struct CelOutputBuffer {
*
* Only use this if the buffer owns its data.
*/
void Free() {
void Free()
{
SDL_FreeSurface(this->surface);
this->surface = NULL;
}
int w() const { return region.w; }
int h() const { return region.h; }
int w() const
{
return region.w;
}
int h() const
{
return region.h;
}
BYTE *at(int x, int y) const
{
return static_cast<BYTE *>(surface->pixels) + region.x + x + surface->pitch * (region.y + y);
}
BYTE *begin() const { return at(0, 0); }
BYTE *end() const { return at(0, region.h); }
BYTE *begin() const
{
return at(0, 0);
}
BYTE *end() const
{
return at(0, region.h);
}
/**
* @brief Line width of the raw underlying byte buffer.
* May be wider than its logical width (for power-of-2 alignment).
*/
int pitch() { return surface->pitch; }
int pitch()
{
return surface->pitch;
}
bool in_bounds(Sint16 x, Sint16 y) const
{

6
Source/init.cpp

@ -150,7 +150,8 @@ void init_archives()
paths.reserve(5);
paths.push_back(GetBasePath());
paths.push_back(GetPrefPath());
if (paths[0] == paths[1]) paths.pop_back();
if (paths[0] == paths[1])
paths.pop_back();
#ifdef __linux__
paths.push_back("/usr/share/diasurgical/devilutionx/");
@ -193,8 +194,7 @@ void init_archives()
hfopt1_mpq = init_test_access(paths, "hfopt1.mpq", "DiabloInstall", 8600, FS_PC);
hfopt2_mpq = init_test_access(paths, "hfopt2.mpq", "DiabloInstall", 8610, FS_PC);
if (gbIsHellfire && (hfmonk_mpq == NULL || hfmusic_mpq == NULL || hfvoice_mpq == NULL))
{
if (gbIsHellfire && (hfmonk_mpq == NULL || hfmusic_mpq == NULL || hfvoice_mpq == NULL)) {
UiErrorOkDialog("Some Hellfire MPQs are missing", "Not all Hellfire MPQs were found.\nPlease copy all the hf*.mpq files.");
app_fatal(NULL);
}

1
Source/mpqapi.h

@ -40,7 +40,6 @@ typedef struct _BLOCKENTRY {
Uint32 flags;
} _BLOCKENTRY;
void mpqapi_remove_hash_entry(const char *pszName);
void mpqapi_remove_hash_entries(BOOL (*fnGetName)(DWORD, char *));
BOOL mpqapi_write_file(const char *pszName, const BYTE *pbData, DWORD dwLen);

3
Source/render.cpp

@ -431,7 +431,8 @@ inline void DoRenderLine(BYTE *dst, BYTE *src, int n, BYTE *tbl, DWORD mask)
}
DVL_ATTRIBUTE_ALWAYS_INLINE
inline void RenderLine(BYTE *dst_begin, BYTE *dst_end, BYTE **dst, BYTE **src, int n, BYTE *tbl, DWORD mask) {
inline void RenderLine(BYTE *dst_begin, BYTE *dst_end, BYTE **dst, BYTE **src, int n, BYTE *tbl, DWORD mask)
{
#ifdef NO_OVERDRAW
if (*dst >= dst_begin && *dst <= dst_end)
#endif

3
SourceS/file_util.h

@ -32,7 +32,8 @@ inline bool FileExists(const char *path)
return ::access(path, F_OK) == 0;
#else
FILE *file = std::fopen(path, "rb");
if (file == NULL) return false;
if (file == NULL)
return false;
std::fclose(file);
return true;
#endif

21
SourceS/paths.cpp

@ -24,7 +24,8 @@ std::string *configPath = NULL;
std::string *ttfPath = NULL;
std::string *ttfName = NULL;
void AddTrailingSlash(std::string *path) {
void AddTrailingSlash(std::string *path)
{
#ifdef _WIN32
if (!path->empty() && path->back() != '\\')
*path += '\\';
@ -34,7 +35,8 @@ void AddTrailingSlash(std::string *path) {
#endif
}
std::string *FromSDL(char *s) {
std::string *FromSDL(char *s)
{
std::string *result = new std::string(s != NULL ? s : "");
if (s != NULL) {
SDL_free(s);
@ -50,16 +52,19 @@ std::string *FromSDL(char *s) {
const std::string &GetBasePath()
{
#ifdef __vita__
if (basePath == NULL) basePath = new std::string(GetPrefPath());
if (basePath == NULL)
basePath = new std::string(GetPrefPath());
#else
if (basePath == NULL) basePath = FromSDL(SDL_GetBasePath());
if (basePath == NULL)
basePath = FromSDL(SDL_GetBasePath());
#endif
return *basePath;
}
const std::string &GetPrefPath()
{
if (prefPath == NULL) prefPath = FromSDL(SDL_GetPrefPath("diasurgical", "devilution"));
if (prefPath == NULL)
prefPath = FromSDL(SDL_GetPrefPath("diasurgical", "devilution"));
return *prefPath;
}
@ -86,14 +91,16 @@ const std::string &GetTtfName()
void SetBasePath(const char *path)
{
if (basePath == NULL) basePath = new std::string;
if (basePath == NULL)
basePath = new std::string;
*basePath = path;
AddTrailingSlash(basePath);
}
void SetPrefPath(const char *path)
{
if (prefPath == NULL) prefPath = new std::string;
if (prefPath == NULL)
prefPath = new std::string;
*prefPath = path;
AddTrailingSlash(prefPath);
}

1
SourceS/storm_full.h

@ -4,6 +4,5 @@ namespace dvl {
extern "C" {
extern DWORD nLastError;
}
} // namespace dvl

15
SourceT/appfat_test.cpp

@ -1,22 +1,27 @@
#include <gtest/gtest.h>
#include "all.h"
TEST(Appfat, app_fatal) {
TEST(Appfat, app_fatal)
{
EXPECT_EXIT(dvl::app_fatal("test"), ::testing::ExitedWithCode(1), "test");
}
TEST(Appfat, ErrDlg) {
TEST(Appfat, ErrDlg)
{
EXPECT_EXIT(dvl::ErrDlg("Title", "Unknown error", "appfat.cpp", 7), ::testing::ExitedWithCode(1), "Unknown error\n\nThe error occurred at: appfat.cpp line 7");
}
TEST(Appfat, FileErrDlg) {
TEST(Appfat, FileErrDlg)
{
EXPECT_EXIT(dvl::FileErrDlg("devilution/image.cl2"), ::testing::ExitedWithCode(1), "devilution/image.cl2");
}
TEST(Appfat, InsertCDDlg) {
TEST(Appfat, InsertCDDlg)
{
EXPECT_EXIT(dvl::InsertCDDlg(), ::testing::ExitedWithCode(1), "diabdat.mpq");
}
TEST(Appfat, DirErrorDlg) {
TEST(Appfat, DirErrorDlg)
{
EXPECT_EXIT(dvl::DirErrorDlg("/"), ::testing::ExitedWithCode(1), "Unable to write to location:\n/");
}

33
SourceT/automap_test.cpp

@ -1,7 +1,8 @@
#include <gtest/gtest.h>
#include "all.h"
TEST(Automap, InitAutomap) {
TEST(Automap, InitAutomap)
{
dvl::InitAutomapOnce();
EXPECT_EQ(dvl::automapflag, false);
EXPECT_EQ(dvl::AutoMapScale, 50);
@ -12,14 +13,16 @@ TEST(Automap, InitAutomap) {
EXPECT_EQ(dvl::AmLine4, 2);
}
TEST(Automap, StartAutomap) {
TEST(Automap, StartAutomap)
{
dvl::StartAutomap();
EXPECT_EQ(dvl::AutoMapXOfs, 0);
EXPECT_EQ(dvl::AutoMapYOfs, 0);
EXPECT_EQ(dvl::automapflag, true);
}
TEST(Automap, AutomapUp) {
TEST(Automap, AutomapUp)
{
dvl::AutoMapXOfs = 1;
dvl::AutoMapYOfs = 1;
dvl::AutomapUp();
@ -27,7 +30,8 @@ TEST(Automap, AutomapUp) {
EXPECT_EQ(dvl::AutoMapYOfs, 0);
}
TEST(Automap, AutomapDown) {
TEST(Automap, AutomapDown)
{
dvl::AutoMapXOfs = 1;
dvl::AutoMapYOfs = 1;
dvl::AutomapDown();
@ -35,7 +39,8 @@ TEST(Automap, AutomapDown) {
EXPECT_EQ(dvl::AutoMapYOfs, 2);
}
TEST(Automap, AutomapLeft) {
TEST(Automap, AutomapLeft)
{
dvl::AutoMapXOfs = 1;
dvl::AutoMapYOfs = 1;
dvl::AutomapLeft();
@ -43,7 +48,8 @@ TEST(Automap, AutomapLeft) {
EXPECT_EQ(dvl::AutoMapYOfs, 2);
}
TEST(Automap, AutomapRight) {
TEST(Automap, AutomapRight)
{
dvl::AutoMapXOfs = 1;
dvl::AutoMapYOfs = 1;
dvl::AutomapRight();
@ -51,7 +57,8 @@ TEST(Automap, AutomapRight) {
EXPECT_EQ(dvl::AutoMapYOfs, 0);
}
TEST(Automap, AutomapZoomIn) {
TEST(Automap, AutomapZoomIn)
{
dvl::AutoMapScale = 50;
dvl::AutomapZoomIn();
EXPECT_EQ(dvl::AutoMapScale, 55);
@ -62,7 +69,8 @@ TEST(Automap, AutomapZoomIn) {
EXPECT_EQ(dvl::AmLine4, 2);
}
TEST(Automap, AutomapZoomIn_Max) {
TEST(Automap, AutomapZoomIn_Max)
{
dvl::AutoMapScale = 195;
dvl::AutomapZoomIn();
dvl::AutomapZoomIn();
@ -74,7 +82,8 @@ TEST(Automap, AutomapZoomIn_Max) {
EXPECT_EQ(dvl::AmLine4, 8);
}
TEST(Automap, AutomapZoomOut) {
TEST(Automap, AutomapZoomOut)
{
dvl::AutoMapScale = 200;
dvl::AutomapZoomOut();
EXPECT_EQ(dvl::AutoMapScale, 195);
@ -85,7 +94,8 @@ TEST(Automap, AutomapZoomOut) {
EXPECT_EQ(dvl::AmLine4, 7);
}
TEST(Automap, AutomapZoomOut_Min) {
TEST(Automap, AutomapZoomOut_Min)
{
dvl::AutoMapScale = 55;
dvl::AutomapZoomOut();
dvl::AutomapZoomOut();
@ -97,7 +107,8 @@ TEST(Automap, AutomapZoomOut_Min) {
EXPECT_EQ(dvl::AmLine4, 2);
}
TEST(Automap, AutomapZoomReset) {
TEST(Automap, AutomapZoomReset)
{
dvl::AutoMapScale = 50;
dvl::AutoMapXOfs = 1;
dvl::AutoMapYOfs = 1;

6
SourceT/codec_test.cpp

@ -1,10 +1,12 @@
#include <gtest/gtest.h>
#include "all.h"
TEST(Codec, codec_get_encoded_len) {
TEST(Codec, codec_get_encoded_len)
{
EXPECT_EQ(dvl::codec_get_encoded_len(50), 72);
}
TEST(Codec, codec_get_encoded_len_eq) {
TEST(Codec, codec_get_encoded_len_eq)
{
EXPECT_EQ(dvl::codec_get_encoded_len(128), 136);
}

6
SourceT/control_test.cpp

@ -1,7 +1,8 @@
#include <gtest/gtest.h>
#include "all.h"
TEST(Control, SetSpell) {
TEST(Control, SetSpell)
{
dvl::pnumlines = 1;
dvl::pinfoflag = true;
dvl::pSpell = dvl::SPL_FIREBOLT;
@ -15,7 +16,8 @@ TEST(Control, SetSpell) {
EXPECT_EQ(dvl::force_redraw, 255);
}
TEST(Control, ClearPanel) {
TEST(Control, ClearPanel)
{
dvl::pnumlines = 1;
dvl::pinfoflag = true;
dvl::ClearPanel();

3
SourceT/cursor_test.cpp

@ -1,7 +1,8 @@
#include <gtest/gtest.h>
#include "all.h"
TEST(Cursor, SetCursor) {
TEST(Cursor, SetCursor)
{
int i = dvl::ICURS_SPIKED_CLUB + dvl::CURSOR_FIRSTITEM;
dvl::SetCursor_(i);
EXPECT_EQ(dvl::pcurs, i);

6
SourceT/dead_test.cpp

@ -1,12 +1,14 @@
#include <gtest/gtest.h>
#include "all.h"
TEST(Dead, AddDead) {
TEST(Dead, AddDead)
{
dvl::AddDead(21, 48, 8, dvl::DIR_W);
EXPECT_EQ(dvl::dDead[21][48], 8 + (dvl::DIR_W << 5));
}
TEST(Dead, AddDead_OOB) {
TEST(Dead, AddDead_OOB)
{
dvl::AddDead(21, 48, MAXDEAD + 1, dvl::DIR_W);
EXPECT_EQ(dvl::dDead[21][48], 0 + (dvl::DIR_W << 5));
}

6
SourceT/doom_test.cpp

@ -1,12 +1,14 @@
#include <gtest/gtest.h>
#include "all.h"
TEST(Doom, doom_get_frame_from_time) {
TEST(Doom, doom_get_frame_from_time)
{
dvl::DoomQuestState = 1200 * 8 + 548;
EXPECT_EQ(dvl::doom_get_frame_from_time(), 8);
}
TEST(Doom, doom_get_frame_from_time_max) {
TEST(Doom, doom_get_frame_from_time_max)
{
dvl::DoomQuestState = 1200 * 30 + 1;
EXPECT_EQ(dvl::doom_get_frame_from_time(), 31);
}

10
SourceT/drlg_l1_test.cpp

@ -1,23 +1,25 @@
#include <gtest/gtest.h>
#include "all.h"
TEST(Drlg_l1, DRLG_Init_Globals_4flag) {
TEST(Drlg_l1, DRLG_Init_Globals_4flag)
{
dvl::lightflag = false;
dvl::light4flag = true;
dvl::DRLG_Init_Globals();
EXPECT_EQ(dvl::dLight[0][0], 3);
}
TEST(Drlg_l1, DRLG_Init_Globals_noflag) {
TEST(Drlg_l1, DRLG_Init_Globals_noflag)
{
dvl::lightflag = false;
dvl::light4flag = false;
dvl::DRLG_Init_Globals();
EXPECT_EQ(dvl::dLight[0][0], 15);
}
TEST(Drlg_l1, DRLG_Init_Globals) {
TEST(Drlg_l1, DRLG_Init_Globals)
{
dvl::lightflag = true;
dvl::DRLG_Init_Globals();
EXPECT_EQ(dvl::dLight[0][0], 0);
}

3
SourceT/drlg_l2_test.cpp

@ -1,7 +1,8 @@
#include <gtest/gtest.h>
#include "all.h"
TEST(Drlg_l2, InitDungeon) {
TEST(Drlg_l2, InitDungeon)
{
dvl::InitDungeon();
EXPECT_EQ(dvl::predungeon[0][0], 32);
EXPECT_EQ(dvl::dflags[0][0], 0);

9
SourceT/drlg_l3_test.cpp

@ -1,7 +1,8 @@
#include <gtest/gtest.h>
#include "all.h"
TEST(Drlg_l3, AddFenceDoors_x) {
TEST(Drlg_l3, AddFenceDoors_x)
{
memset(dvl::dungeon, 0, sizeof(dvl::dungeon));
dvl::dungeon[5][5] = 7;
dvl::dungeon[5 - 1][5] = 130;
@ -10,7 +11,8 @@ TEST(Drlg_l3, AddFenceDoors_x) {
EXPECT_EQ(dvl::dungeon[5][5], 146);
}
TEST(Drlg_l3, AddFenceDoors_y) {
TEST(Drlg_l3, AddFenceDoors_y)
{
memset(dvl::dungeon, 0, sizeof(dvl::dungeon));
dvl::dungeon[5][5] = 7;
dvl::dungeon[5][5 - 1] = 130;
@ -19,7 +21,8 @@ TEST(Drlg_l3, AddFenceDoors_y) {
EXPECT_EQ(dvl::dungeon[5][5], 147);
}
TEST(Drlg_l3, AddFenceDoors_no) {
TEST(Drlg_l3, AddFenceDoors_no)
{
memset(dvl::dungeon, 0, sizeof(dvl::dungeon));
dvl::dungeon[5][5] = 7;
dvl::dungeon[5 - 1][5] = 130;

6
SourceT/drlg_l4_test.cpp

@ -1,14 +1,16 @@
#include <gtest/gtest.h>
#include "all.h"
TEST(Drlg_l4, IsDURWall) {
TEST(Drlg_l4, IsDURWall)
{
EXPECT_EQ(dvl::IsDURWall(25), true);
EXPECT_EQ(dvl::IsDURWall(28), true);
EXPECT_EQ(dvl::IsDURWall(23), true);
EXPECT_EQ(dvl::IsDURWall(20), false);
}
TEST(Drlg_l4, IsDLLWall) {
TEST(Drlg_l4, IsDLLWall)
{
EXPECT_EQ(dvl::IsDLLWall(27), true);
EXPECT_EQ(dvl::IsDLLWall(26), true);
EXPECT_EQ(dvl::IsDLLWall(22), true);

3
SourceT/pack_test.cpp

@ -105,7 +105,6 @@ static void CompareItems(const dvl::ItemStruct *item1, const TestItemStruct *ite
ASSERT_EQ(item1->IDidx, item2->IDidx);
}
const dvl::PkItemStruct PackedDiabloItems[] = {
// clang-format off
// iSeed, iCreateInfo, idx, bId, bDur, bMDur, bCh, bMCh, wValue, dwBuff
@ -233,7 +232,6 @@ TEST(pack, UnPackItem_diablo)
}
}
TEST(pack, UnPackItem_diablo_unique_bug)
{
dvl::PkItemStruct pkItemBug = { 6, 911, 14, 5, 60, 60, 0, 0, 0, 0 }; // Veil of Steel - with morph bug
@ -466,7 +464,6 @@ TEST(pack, UnPackItem_empty)
ASSERT_EQ(id._itype, dvl::ITYPE_NONE);
}
TEST(pack, PackItem_empty)
{
dvl::PkItemStruct is;

3
SourceX/DiabloUI/diabloui.cpp

@ -276,7 +276,8 @@ void UiFocusNavigation(SDL_Event *event)
break;
}
if (HandleMenuAction(GetMenuAction(*event))) return;
if (HandleMenuAction(GetMenuAction(*event)))
return;
#ifndef USE_SDL1
if (event->type == SDL_MOUSEWHEEL) {

12
SourceX/DiabloUI/fonts.cpp

@ -53,7 +53,8 @@ void UnloadArtFonts()
FontTables[AFT_HUGE] = NULL;
}
void LoadTtfFont() {
void LoadTtfFont()
{
if (!TTF_WasInit()) {
if (TTF_Init() == -1) {
SDL_Log("TTF_Init: %s", TTF_GetError());
@ -64,8 +65,7 @@ void LoadTtfFont() {
std::string ttf_font_path = GetTtfPath() + GetTtfName();
#ifdef __linux__
if (!FileExists(ttf_font_path.c_str()))
{
if (!FileExists(ttf_font_path.c_str())) {
ttf_font_path = "/usr/share/fonts/truetype/" + GetTtfName();
}
#endif
@ -79,13 +79,15 @@ void LoadTtfFont() {
TTF_SetFontHinting(font, TTF_HINTING_MONO);
}
void UnloadTtfFont() {
void UnloadTtfFont()
{
if (font && TTF_WasInit())
TTF_CloseFont(font);
font = NULL;
}
void FontsCleanup() {
void FontsCleanup()
{
TTF_Quit();
}

8
SourceX/DiabloUI/scrollbar.cpp

@ -6,16 +6,18 @@ Art ArtScrollBarBackground;
Art ArtScrollBarThumb;
Art ArtScrollBarArrow;
void LoadScrollBar() {
void LoadScrollBar()
{
LoadArt("ui_art\\sb_bg.pcx", &ArtScrollBarBackground);
LoadArt("ui_art\\sb_thumb.pcx", &ArtScrollBarThumb);
LoadArt("ui_art\\sb_arrow.pcx", &ArtScrollBarArrow, 4);
}
void UnloadScrollBar() {
void UnloadScrollBar()
{
ArtScrollBarArrow.Unload();
ArtScrollBarThumb.Unload();
ArtScrollBarBackground.Unload();
}
} // namespace
} // namespace dvl

2
SourceX/DiabloUI/selconn.h

@ -4,4 +4,4 @@ void selconn_Esc();
void selconn_Focus(int value);
void selconn_Select(int value);
}
} // namespace dvl

2
SourceX/DiabloUI/selgame.h

@ -19,4 +19,4 @@ void selgame_Password_Init(int value);
void selgame_Password_Select(int value);
void selgame_Password_Esc();
}
} // namespace dvl

3
SourceX/DiabloUI/selhero.cpp

@ -350,7 +350,8 @@ void selhero_ClassSelector_Focus(int value)
selhero_SetStats();
}
static bool shouldPrefillHeroName() {
static bool shouldPrefillHeroName()
{
#if defined __3DS__
return false;
#elif defined(PREFILL_PLAYER_NAME)

2
SourceX/DiabloUI/selok.h

@ -8,4 +8,4 @@ void selok_Free();
void selok_Select(int value);
void selok_Esc();
}
} // namespace dvl

2
SourceX/DiabloUI/selyesno.h

@ -8,4 +8,4 @@ void selyesno_Free();
void selyesno_Select(int value);
void selyesno_Esc();
}
} // namespace dvl

2
SourceX/controls/axis_direction.cpp

@ -52,4 +52,4 @@ AxisDirection AxisDirectionRepeater::Get(AxisDirection axis_direction)
return axis_direction;
}
} // namespace
} // namespace dvl

16
SourceX/controls/game_controls.cpp

@ -79,7 +79,8 @@ bool HandleStartAndSelect(const ControllerButtonEvent &ctrl_event, GameAction *a
if (in_game_menu && (start_is_down || select_is_down) && !ctrl_event.up) {
// If both are down, do nothing because `both_received` will trigger soon.
if (start_is_down && select_is_down) return true;
if (start_is_down && select_is_down)
return true;
*action = GameActionSendKey { DVL_VK_ESCAPE, ctrl_event.up };
return true;
}
@ -168,8 +169,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrl_event, Gam
case ControllerButton_BUTTON_DPAD_RIGHT:
if (IsControllerButtonPressed(ControllerButton_BUTTON_BACK))
*action = GameActionSendKey { DVL_VK_F8, ctrl_event.up };
else
if (!ctrl_event.up)
else if (!ctrl_event.up)
*action = GameAction(GameActionType_TOGGLE_INVENTORY);
return true;
case ControllerButton_BUTTON_DPAD_DOWN:
@ -181,8 +181,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrl_event, Gam
case ControllerButton_BUTTON_DPAD_LEFT:
if (IsControllerButtonPressed(ControllerButton_BUTTON_BACK))
*action = GameActionSendKey { DVL_VK_F5, ctrl_event.up };
else
if (!ctrl_event.up)
else if (!ctrl_event.up)
*action = GameAction(GameActionType_TOGGLE_CHARACTER_INFO);
return true;
default:
@ -241,7 +240,8 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrl_event, Gam
// Bottom button: Closes menus or opens quick spell book if nothing is open.
if (ctrl_event.button == ControllerButton_BUTTON_A) { // Bottom button
if (ctrl_event.up) return true;
if (ctrl_event.up)
return true;
if (IsControllerButtonPressed(ControllerButton_BUTTON_BACK))
*action = GameActionSendKey { DVL_VK_F7, ctrl_event.up };
else if (invflag)
@ -309,10 +309,8 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrl_event, Gam
}
}
// DPad navigation is handled separately for these.
if (gmenu_is_active() || questlog || stextflag != STORE_NONE)
{
if (gmenu_is_active() || questlog || stextflag != STORE_NONE) {
switch (ctrl_event.button) {
case ControllerButton_BUTTON_DPAD_UP:
case ControllerButton_BUTTON_DPAD_DOWN:

3
SourceX/controls/modifier_hints.cpp

@ -123,8 +123,7 @@ void DrawSelectModifierMenu(CelOutputBuffer out)
{
if (!select_modifier_active)
return;
if (sgOptions.Controller.bDpadHotkeys)
{
if (sgOptions.Controller.bDpadHotkeys) {
static const CircleMenuHint kDpad(/*is_dpad=*/true, /*top=*/"F6", /*right=*/"F8", /*bottom=*/"F7", /*left=*/"F5");
DrawCircleMenuHint(out, kDpad, PANEL_LEFT + kCircleMarginX, PANEL_TOP - kCirclesTop);
}

6
SourceX/controls/plrctrls.cpp

@ -862,7 +862,8 @@ HandleLeftStickOrDPadFn GetLeftStickOrDPadGameUIHandler()
return NULL;
}
void ProcessLeftStickOrDPadGameUI() {
void ProcessLeftStickOrDPadGameUI()
{
HandleLeftStickOrDPadFn handler = GetLeftStickOrDPadGameUIHandler();
if (handler != NULL)
handler(GetLeftStickOrDpadDirection(true));
@ -1010,8 +1011,7 @@ void HandleRightStickMotion()
// cursor position events.
static int lastMouseSetTick = 0;
const int now = SDL_GetTicks();
if (now - lastMouseSetTick > 0)
{
if (now - lastMouseSetTick > 0) {
SetCursorPos(x, y);
lastMouseSetTick = now;
}

3
SourceX/platform/ctr/keyboard.cpp

@ -16,8 +16,7 @@ const char* ctr_vkbdInput(const char *hintText, const char *inText, char *outTex
SwkbdButton button = swkbdInputText(&swkbd, mybuf, sizeof(mybuf));
if (button == SWKBD_BUTTON_CONFIRM)
{
if (button == SWKBD_BUTTON_CONFIRM) {
strcpy(outText, mybuf);
return 0;
}

2
SourceX/thread.cpp

@ -75,4 +75,4 @@ int WaitForEvent(event_emul *e)
return ret;
}
}
} // namespace dvl

Loading…
Cancel
Save