Skip to content
Permalink
Browse files

Merge remote-tracking branch 'specing/master'

# Conflicts:
#	src/downloader/lib
#	src/gui/connectwindow.cpp
  • Loading branch information
abma committed Jan 11, 2020
2 parents 7bead0c + b6fc715 commit cbe85f6c0a23794d7f7a6bc4dfae84c523871ab4
Showing with 4,750 additions and 1,237 deletions.
  1. +1 −0 .gitignore
  2. +70 −0 src/CMakeLists.txt
  3. +5 −2 src/autohost.cpp
  4. +6 −6 src/battle.cpp
  5. +1 −0 src/gui/aboutbox.cpp
  6. +1 −0 src/gui/basedataviewmodel.h
  7. +74 −9 src/gui/battlelist/battledataviewmodel.cpp
  8. +4 −0 src/gui/battlelist/battledataviewmodel.h
  9. +6 −3 src/gui/battlelist/battlelistfilter.cpp
  10. +18 −1 src/gui/battlelist/battlelisttab.cpp
  11. +2 −0 src/gui/battlelist/battlelisttab.h
  12. +69 −70 src/gui/chatpanel.cpp
  13. +18 −20 src/gui/chatpanelmenu.cpp
  14. +90 −197 src/gui/connectwindow.cpp
  15. +7 −64 src/gui/connectwindow.h
  16. +96 −0 src/gui/crashreporterdialog.cpp
  17. +34 −0 src/gui/crashreporterdialog.h
  18. +39 −10 src/gui/hosting/addbotdialog.cpp
  19. +6 −1 src/gui/hosting/addbotdialog.h
  20. +9 −6 src/gui/hosting/battlemaptab.cpp
  21. +1 −1 src/gui/hosting/battlemaptab.h
  22. +5 −3 src/gui/hosting/battlerestrictionstab.cpp
  23. +18 −14 src/gui/hosting/battleroomdataviewctrl.cpp
  24. +1 −1 src/gui/hosting/battleroomdataviewmodel.cpp
  25. +19 −11 src/gui/hosting/battleroommmoptionstab.cpp
  26. +17 −31 src/gui/hosting/battleroomtab.cpp
  27. +1 −4 src/gui/hosting/battleroomtab.h
  28. +61 −261 src/gui/hosting/hostbattledialog.cpp
  29. +5 −55 src/gui/hosting/hostbattledialog.h
  30. +8 −11 src/gui/hosting/mainjoinbattletab.cpp
  31. +0 −2 src/gui/hosting/mainjoinbattletab.h
  32. +23 −16 src/gui/hosting/mainsingleplayertab.cpp
  33. +0 −1 src/gui/hosting/mainsingleplayertab.h
  34. +2 −1 src/gui/iconscollection.cpp
  35. +5 −5 src/gui/mainchattab.cpp
  36. +8 −8 src/gui/mainwindow.cpp
  37. +1 −2 src/gui/mainwindow.h
  38. +39 −36 src/gui/mapctrl.cpp
  39. +19 −0 src/gui/options/lobbyoptionstab.cpp
  40. +2 −0 src/gui/options/lobbyoptionstab.h
  41. +1 −7 src/gui/options/mainoptionstab.cpp
  42. +0 −2 src/gui/options/mainoptionstab.h
  43. +2 −2 src/gui/options/springoptionstab.cpp
  44. +9 −5 src/gui/playback/playbackdatamodel.cpp
  45. +31 −13 src/gui/playback/playbackdataview.cpp
  46. +2 −0 src/gui/playback/playbackdataview.h
  47. +1 −1 src/gui/playback/playbackfilter.cpp
  48. +5 −10 src/gui/playback/playbacktab.cpp
  49. +0 −2 src/gui/playback/playbacktab.h
  50. +105 −53 src/gui/singleplayertab.cpp
  51. +9 −8 src/gui/singleplayertab.h
  52. +85 −72 src/gui/ui.cpp
  53. +3 −0 src/gui/ui.h
  54. +0 −1 src/gui/uiutils.cpp
  55. +1,261 −0 src/gui/wxfb/ConnectWindow.fbp
  56. +566 −0 src/gui/wxfb/CrashReporterDialog.fbp
  57. +1,368 −0 src/gui/wxfb/HostBattleDialog.fbp
  58. +22 −3 src/ibattle.cpp
  59. +19 −0 src/ibattle.h
  60. +4 −2 src/iserver.cpp
  61. +15 −1 src/log.cpp
  62. +1 −0 src/log.h
  63. +7 −7 src/playbackthread.cpp
  64. +51 −16 src/replaylist.cpp
  65. +3 −0 src/replaylist.h
  66. +78 −47 src/serverevents.cpp
  67. +2 −1 src/servermanager.cpp
  68. +10 −10 src/settings.cpp
  69. +18 −3 src/settings.h
  70. +2 −2 src/singleplayerbattle.cpp
  71. +57 −32 src/sound/alsound.cpp
  72. +151 −41 src/spring.cpp
  73. +5 −3 src/spring.h
  74. +11 −11 src/springlobbyapp.cpp
  75. +8 −4 src/springsettings/tab_abstract.cpp
  76. +3 −1 src/springsettings/tab_simple.cpp
  77. +2 −1 src/sysinfo.cpp
  78. +25 −12 src/tasserver.cpp
  79. +6 −3 src/useractions.cpp
  80. +10 −9 src/utils/slpaths.cpp
  81. +1 −0 src/utils/slpaths.h
@@ -25,6 +25,7 @@ Makefile
*.exe

# temp files
*.bak
*.swp
/po/*.gmo
/po/locale/
@@ -13,6 +13,11 @@ IF(NOT MSVC)
#FIXME: hide wxwidgets 3.0.2 error spam (should be fixed in 3.0.3)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-potentially-evaluated-expression")
endif()
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -ggdb")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -ggdb")
message(STATUS "DEBUG")
endif()
ELSE(NOT MSVC)
ADD_DEFINITIONS(-D_RC_MSVC)
ENDIF(NOT MSVC)
@@ -158,6 +163,68 @@ IF( OPTION_NOTIFY AND NOT WIN32 )
pkg_check_modules( GLIB glib-2.0 )
ENDIF( OPTION_NOTIFY AND NOT WIN32 )

#-----------------------------------------------------------------------------
# wxFormBuilder
#-----------------------------------------------------------------------------
set(wxfb_projects
ConnectWindow
CrashReporterDialog
HostBattleDialog
)

set(wxfb_src ${springlobby_SOURCE_DIR}/src/gui/wxfb)
set(wxfb_bin ${springlobby_BINARY_DIR}/src/gui/wxfb)
set(wxfb_gensrc ${wxfb_src}/pregenerated)
# For configure_file below, all .fbp should have
# property name="path" set to @WXFB_GENERATION_PATH@.
set(WXFB_GENERATION_PATH ${wxfb_bin}/generated)
file(MAKE_DIRECTORY ${WXFB_GENERATION_PATH})
set(wxFB_REQUIRED_VERSION "3.9.0")

if (IS_DIRECTORY ${wxfb_gensrc})
message(STATUS "using pre-generated wxFormBuilder GUI in ${wxfb_gensrc}")
file(COPY ${wxfb_gensrc} DESTINATION ${wxfb_bin})
else()
find_program(wxFB_EXECUTABLE NAMES wxformbuilder ONLY_CMAKE_FIND_ROOT_PATH)
if ("${wxFB_EXECUTABLE}" MATCHES "wxFB_EXECUTABLE-NOTFOUND")
message(FATAL_ERROR "couldn't find wxFormBuilder! Either install wxFB (${wxFB_REQUIRED_VERSION}) or provide pre-generated files in ${xfb_gensrc}.")
else()
message(STATUS "found wxFormBuilder: ${wxFB_EXECUTABLE}")
endif()


execute_process(COMMAND ${wxFB_EXECUTABLE} "--version"
OUTPUT_VARIABLE wxFB_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "found wxFormBuilder version: ${wxFB_VERSION}")
if (NOT ("${wxFB_VERSION}" MATCHES ".* ${wxFB_REQUIRED_VERSION}"))
message(FATAL_ERROR "wxFormBuilder is not of required version: ${wxFB_REQUIRED_VERSION}")
endif()

foreach(proj ${wxfb_projects})
message(STATUS "Processing wxFormBuilder project: ${proj}")
# configure_file monitors input for timestamp changes and output for
# content changes (checksum?). Replaces generation path.
configure_file(${wxfb_src}/${proj}.fbp ${wxfb_bin}/${proj}.fbp @ONLY)

add_custom_command(COMMAND ${wxFB_EXECUTABLE} "--generate" ${wxfb_bin}/${proj}.fbp
DEPENDS ${wxfb_bin}/${proj}.fbp
OUTPUT ${WXFB_GENERATION_PATH}/${proj}Base.cpp
${WXFB_GENERATION_PATH}/${proj}Base.h
)
endforeach()
endif()

foreach(proj ${wxfb_projects})
message(STATUS "Adding wxFormBuilder source files for: ${proj}")

list(APPEND generated_gui_cpp ${WXFB_GENERATION_PATH}/${proj}Base.cpp)
list(APPEND generated_gui_cpp ${WXFB_GENERATION_PATH}/${proj}Base.h)
endforeach()
# for gcc -I
set(generated_gui_include ${wxfb_bin}) # generated/* in source
#-----------------------------------------------------------------------------
# springlobby build
#-----------------------------------------------------------------------------

set(springlobbySrc
address.cpp
@@ -208,6 +275,7 @@ set(springlobbySrc
gui/agreementdialog.cpp
gui/chatpanelmenu.cpp
gui/chatpanel.cpp
gui/crashreporterdialog.cpp
gui/contentdownloaddialog.cpp
gui/contentsearchresultview.cpp
gui/contentsearchresultdatamodel.cpp
@@ -369,6 +437,7 @@ add_subdirectory(updater)
ADD_EXECUTABLE(springlobby WIN32 MACOSX_BUNDLE
${springlobbySrc}
${springlobby_RC_FILE}
${generated_gui_cpp}
)

target_include_directories(springlobby
@@ -418,6 +487,7 @@ target_include_directories(springlobby
PRIVATE ${springlobby_SOURCE_DIR}/src
PRIVATE ${springlobby_SOURCE_DIR}/src/downloader/lib/src
PRIVATE ${springlobby_SOURCE_DIR}/src/downloader/lib/src/lsl
PRIVATE ${generated_gui_include}
)

IF(UNIX)
@@ -2,6 +2,7 @@
#include "autohost.h"

#include <lslunitsync/unitsync.h>
#include <wx/log.h>
#include <wx/tokenzr.h>

#include "ibattle.h"
@@ -88,7 +89,8 @@ void AutoHost::OnSaidBattle(const wxString& /*unused*/, const wxString& msg)
User& u = m_battle.GetUser(user);
m_battle.RingPlayer(u);
DoAction("is ringing " + user);
} catch (...) {
} catch (const std::exception& e) {
wxLogWarning(_T("Exception: %s"), e.what());
DoAction("cannot ring " + user);
}
} else {
@@ -143,7 +145,8 @@ void AutoHost::OnSaidBattle(const wxString& /*unused*/, const wxString& msg)
m_battle.SetLocalMap(mapname);
DoAction("is switching to map " + mapname);
m_battle.SendHostInfo(IBattle::HI_Map);
} catch (...) {
} catch (const std::exception& e) {
wxLogWarning(_T("Exception: %s"), e.what());
DoAction("cannot switch to map " + mapname);
}
}
@@ -42,8 +42,8 @@ Battle::Battle(IServer& serv, int id, std::string channel_name)
, m_serv(serv)
, m_ah(*this)
, m_autolock_on_start(false)
, m_id(id)
, m_timer(NULL)
, m_id(id)
{
m_autohost_manager = nullptr;
m_opts.battleid = m_id;
@@ -110,7 +110,7 @@ void Battle::OnRequestBattleStatus()
const wxColor col = sett().GetBattleLastColour();
bs.colour = LSL::lslColor(col.Red(), col.Green(), col.Blue());
//FIXME ? bs.colour = GetFreeColour( GetMe() );
bs.side = sett().GetBattleLastSideSel(TowxString(GetHostGameName()));
bs.side = sett().GetBattleLastSideSel(TowxString(GetHostGameNameAndVersion()));
SendMyBattleStatus();
}

@@ -242,8 +242,6 @@ User& Battle::OnUserAdded(User& user)
}

m_ah.OnUserAdded(user);
if (!user.BattleStatus().IsBot() && sett().GetBattleLastAutoAnnounceDescription())
DoAction(m_opts.description);
}
// any code here may be skipped if the user was autokicked
return user;
@@ -365,7 +363,8 @@ bool Battle::ExecuteSayCommand(const std::string& cmd)
try {
User& user = GetUser(nick);
m_serv.BattleKickPlayer(m_opts.battleid, user);
} catch (assert_exception) {
} catch (const assert_exception& e) {
wxLogWarning(_T("Exception: %s"), e.what());
}
UiEvents::GetUiEventSender(UiEvents::OnBattleActionEvent).SendEvent(UiEvents::OnBattleActionData(wxString(_T(" ")), TowxString(nick + " banned")));

@@ -951,7 +950,8 @@ void Battle::FixTeamIDs(BalanceType balance_type, bool support_clans, bool stron
try {
int mapposcount = LoadMap().info.positions.size();
numcontrolteams = std::min(numcontrolteams, mapposcount);
} catch (assert_exception) {
} catch (const assert_exception& e) {
wxLogWarning(_T("Exception: %s"), e.what());
}
}

@@ -26,6 +26,7 @@ slAboutBox::slAboutBox()
info->AddDeveloper(_T("Kaot"));
info->AddDeveloper(_T("koshi"));
info->AddDeveloper(_T("semi_"));
info->AddDeveloper(_T("specing (ThinkSome)"));
info->AddDeveloper(_T("tc-"));
info->AddTranslator(_T("chaosch (simplified chinese)"));
info->AddTranslator(_T("lejocelyn (french)"));
@@ -7,6 +7,7 @@
#include <climits>
#include <set>
#include "log.h"

#define DEFAULT_COLUMN UINT_MAX


@@ -1,16 +1,27 @@
/* This file is part of the Springlobby (GPL v2 or later), see COPYING */

#include "battledataviewmodel.h"

#include <string>
#include <wx/colour.h>

#include "gui/iconscollection.h"
#include "ibattle.h"
#include "useractions.h"
#include "utils/slconfig.h"
#include "utils/slpaths.h"
#include "utils/sortutil.h"

SLCONFIG("/BattleListTab/InactiveRoomColor", "#888888", "Font color for battle rows with no active players");
SLCONFIG("/BattleListTab/UseSmartSorting", true, "Apply secondary sorting rules when sorting by game or players");
SLCONFIG("/BattleListTab/ShowGameColors", true, "Show game-specific color background on battle rows (windows only)");

BattleDataViewModel::BattleDataViewModel()
: BaseDataViewModel<IBattle>::BaseDataViewModel(COLUMN_COUNT)
{
inactive_room_colour = wxColour(cfg().ReadString(_T("/BattleListTab/InactiveRoomColor")));
use_smart_sorting = cfg().ReadBool(_T("/BattleListTab/UseSmartSorting"));
show_game_colours = cfg().ReadBool(_T("/BattleListTab/ShowGameColors"));
}

BattleDataViewModel::~BattleDataViewModel()
@@ -79,7 +90,7 @@ void BattleDataViewModel::GetValue(wxVariant& variant,
break;

case GAME:
variant = wxVariant(wxDataViewIconText(wxString(battle->GetHostGameName()), battle->GameExists(false) ? iconsCollection->ICON_EXISTS : iconsCollection->ICON_NEXISTS));
variant = wxVariant(wxDataViewIconText(wxString(battle->GetHostGameNameAndVersion()), battle->GameExists(false) ? iconsCollection->ICON_EXISTS : iconsCollection->ICON_NEXISTS));
break;

case HOST:
@@ -190,17 +201,41 @@ int BattleDataViewModel::Compare(const wxDataViewItem& itemA,
break;

case MAP:
sortingResult = battleA->GetHostMapName().compare(battleB->GetHostMapName());
sortingResult = CompareVersionStrings(battleA->GetHostMapName(), battleB->GetHostMapName());
break;

case GAME:
sortingResult = battleA->GetHostGameName().compare(battleB->GetHostGameName());
break;
case GAME: {
if (use_smart_sorting) { // game name, active players DESC, total clients DESC, game version
sortingResult = CompareVersionStrings(battleA->GetHostGameName(), battleB->GetHostGameName());

// secondary sort by players
if (0 == sortingResult) {
int playersA = battleA->GetNumPlayers() - battleA->GetSpectators();
int playersB = battleB->GetNumPlayers() - battleB->GetSpectators();
sortingResult = playersA - playersB;
sortingResult = !ascending ? sortingResult : (sortingResult * (-1)); // always DESC
}
// tertiary sort by number of contained clients
if (0 == sortingResult) {
int playersA = battleA->GetNumPlayers();
int playersB = battleB->GetNumPlayers();
sortingResult = playersA - playersB;
sortingResult = !ascending ? sortingResult : (sortingResult * (-1)); // always DESC
}
// last resort sort by game version
if (0 == sortingResult) {
// TODO: just version
sortingResult = CompareVersionStrings(battleA->GetHostGameNameAndVersion(), battleB->GetHostGameNameAndVersion());
}
} else {
sortingResult = CompareVersionStrings(battleA->GetHostGameNameAndVersion(), battleB->GetHostGameNameAndVersion());
}
} break;

case ENGINE:
sortingResult = battleA->GetEngineName().compare(battleB->GetEngineName());
sortingResult = CompareVersionStrings(battleA->GetEngineName(), battleB->GetEngineName());
if (0 == sortingResult)
sortingResult = battleA->GetEngineVersion().compare(battleB->GetEngineVersion());
sortingResult = CompareVersionStrings(battleA->GetEngineVersion(), battleB->GetEngineVersion());
break;

case SPECTATORS:
@@ -211,10 +246,25 @@ int BattleDataViewModel::Compare(const wxDataViewItem& itemA,
sortingResult = battleA->GetMaxPlayers() - battleB->GetMaxPlayers();
break;

case PLAYERS: {
case PLAYERS: { // active players, total players, game ASC
int playersA = battleA->GetNumPlayers() - battleA->GetSpectators();
int playersB = battleB->GetNumPlayers() - battleB->GetSpectators();
sortingResult = playersA - playersB;

if (use_smart_sorting) {
// First attempt tie-breaking by total client count
if (0 == sortingResult) {
int playersA = battleA->GetNumPlayers();
int playersB = battleB->GetNumPlayers();
sortingResult = playersA - playersB;
}

// secondary sort by game name and version
if (0 == sortingResult) {
sortingResult = CompareVersionStrings(battleA->GetHostGameNameAndVersion(), battleB->GetHostGameNameAndVersion());
sortingResult = ascending ? sortingResult : (sortingResult * (-1)); // always ASC
}
}
} break;

case DEFAULT_COLUMN:
@@ -226,6 +276,11 @@ int BattleDataViewModel::Compare(const wxDataViewItem& itemA,
sortingResult = 0;
}

// tie-breaker based on unique battle host name
if (0 == sortingResult) {
sortingResult = battleA->GetFounder().GetNick().compare(battleB->GetFounder().GetNick());
sortingResult = ascending ? sortingResult : (sortingResult * (-1)); // always ASC
}
//Return direct sort order or reversed depending on ascending flag
return ascending ? sortingResult : (sortingResult * (-1));
}
@@ -241,6 +296,11 @@ bool BattleDataViewModel::GetAttr(const wxDataViewItem& item,
return false;
}

// if battle has no players, set font color to light grey
if (battle->GetNumPlayers() - battle->GetSpectators() == 0) {
attr.SetColour(inactive_room_colour);
}

//If founder is cause of highlight
wxString groupName = useractions().GetGroupOfUser(battle->GetFounder().GetNick());
if (groupName != wxEmptyString) {
@@ -258,7 +318,12 @@ bool BattleDataViewModel::GetAttr(const wxDataViewItem& item,
}
}
}
return false;

if (show_game_colours) {
// if no highlight was set, use a game-dependent shade of grey as background (windows only)
attr.SetBackgroundColour(wxColour(battle->GetHostGameBackgroundColour()));
}
return true;
}

wxString BattleDataViewModel::GetColumnType(unsigned int column) const
@@ -33,6 +33,10 @@ class BattleDataViewModel : public BaseDataViewModel<IBattle>
ENGINE,
COLUMN_COUNT
};

wxColour inactive_room_colour;
bool use_smart_sorting;
bool show_game_colours;
};

#endif /* SRC_GUI_BATTLELIST_BATTLEDATAVIEWMODEL_H_ */

1 comment on commit cbe85f6

@silentwings

This comment has been minimized.

Copy link
Contributor

silentwings commented on cbe85f6 Jan 12, 2020

Amongst the useful stuff, this seems to have ninja'ed in much of what was already rejected in #913

There is a shed load of other (undocumented?) stuff and major changes here, would have been MUCH better as several smaller PRs

Please sign in to comment.
You can’t perform that action at this time.