Skip to content

Commit

Permalink
[GUI] Remove Battle.net and History import tabs
Browse files Browse the repository at this point in the history
Ever since Blizzard updated their World of Warcraft site with the
new layout, the Battle.net import tab stopped functioning properly.

This is an opportune time to remove it completely, and let people
use the newer Import widget instead. This also should solve some
crashing issues associated with GPU drivers and Chrome, since the
relatively complex (multimediae-y) WoW site no longer loads when
the program starts.

Saving the History tab in imports no longer made sense, since it
was based on the Battle.net import urls.
  • Loading branch information
navv1234 committed Jul 12, 2017
1 parent 13a9c8c commit a8340e5
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 176 deletions.
56 changes: 0 additions & 56 deletions qt/sc_ImportThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,61 +18,6 @@
// Import
// ==========================================================================

void SC_ImportThread::importBattleNet()
{
QString region, server, character;
QUrl qurl = url;

{
QStringList parts = qurl.host().split( '.' );

if ( parts.size() )
{
if ( parts[ parts.size() - 1 ].length() == 2 )
region = parts[ parts.size() - 1 ];
else
{
for ( QStringList::size_type i = 0; i < parts.size(); ++i )
{
if ( parts[ i ].length() == 2 )
{
region = parts[ i ];
break;
}
}
}
}
}

{
QStringList parts = qurl.path().split( '/' );
for ( QStringList::size_type i = 0, n = parts.size(); i + 2 < n; ++i )
{
if ( parts[ i ] == "character" )
{
server = parts[ i + 1 ];
character = parts[ i + 2 ];
break;
}
}
}

if ( region.isEmpty() || server.isEmpty() || character.isEmpty() )
{
sim -> errorf( "Unable to determine Server and Character information!\n" );
}
else
{
// Windows 7 64bit somehow cannot handle straight toStdString() conversion, so
// do it in a silly way as a workaround for now.
std::string talents = active_spec.toStdString(),
cpp_r = region.toUtf8().constData(),
cpp_s = server.toUtf8().constData(),
cpp_c = character.toUtf8().constData();
player = bcp_api::download_player( sim, cpp_r, cpp_s, cpp_c, talents );
}
}

void SC_ImportThread::start( sim_t* s, const QString& reg, const QString& rea, const QString& cha, const QString& spe )
{
mainWindow -> soloChar -> start( 50 );
Expand Down Expand Up @@ -110,7 +55,6 @@ void SC_ImportThread::run()
sim -> parse_option( "apikey", api.toUtf8().constData() );
switch ( tab )
{
case TAB_BATTLE_NET: importBattleNet(); break;
case TAB_IMPORT_NEW: importWidget(); break;
default: assert( 0 ); break;
}
Expand Down
95 changes: 2 additions & 93 deletions qt/sc_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,6 @@ void SC_MainWindow::loadHistory()
std::string cache_file_str = cache_file.toStdString();
http::cache_load( cache_file_str.c_str() );

QVariant history = settings.value( "user_data/historyList" );
if ( history.isValid() )
{
QList<QVariant> a = history.toList();
for ( int i = 0; i < a.size(); ++i )
{
const QVariant& entry = a.at( i );
if ( entry.isValid() )
{
QString s = entry.toString();
historyList -> addItem( new QListWidgetItem( s ) );
}
}
}
optionsTab -> decodeOptions();
importTab -> automationTab -> decodeSettings();
spellQueryTab -> decodeSettings();
Expand Down Expand Up @@ -238,12 +224,6 @@ void SC_MainWindow::saveHistory()
settings.setValue( "simulateHistory", simulateHist );
// end simulate tab history

QList<QVariant> history;
int count = historyList -> count();
for ( int i = 0; i < count; i++ )
history.append( QVariant( historyList -> item( i ) -> text() ) );
settings.setValue( "historyList", history );

settings.endGroup();

optionsTab -> encodeOptions();
Expand Down Expand Up @@ -394,7 +374,6 @@ void SC_MainWindow::createOptionsTab()
optionsTab = new SC_OptionsTab( this );
mainTab -> addTab( optionsTab, tr( "Options" ) );

connect( optionsTab, SIGNAL( armory_region_changed( const QString& ) ), this, SLOT( armoryRegionChanged( const QString& ) ) );
connect( optionsTab, SIGNAL( armory_region_changed( const QString& ) ),
newBattleNetView -> widget(), SLOT( armoryRegionChangedIn( const QString& ) ) );

Expand All @@ -410,27 +389,16 @@ void SC_MainWindow::createImportTab()
newBattleNetView = new BattleNetImportWindow( this, true );
importTab -> addTab( newBattleNetView, tr( "Import" ) );

battleNetView = new SC_WebView( this, importTab );
battleNetView -> setUrl( QUrl( "http://us.battle.net/wow/en" ) );
battleNetView -> enableMouseNavigation();
battleNetView -> disableKeyboardNavigation();
importTab -> addTab( battleNetView, tr( "Battle.Net" ) );

SC_SampleProfilesTab* bisTab = new SC_SampleProfilesTab( this );
connect( bisTab -> tree, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( bisDoubleClicked( QTreeWidgetItem*, int ) ) );
importTab -> addTab( bisTab, tr( "Sample Profiles" ) );

historyList = new QListWidget();
historyList -> setSortingEnabled( true );
importTab -> addTab( historyList, tr( "History" ) );

recentlyClosedTabImport = new SC_RecentlyClosedTabWidget( this, QBoxLayout::LeftToRight );
recentlyClosedTabModel = recentlyClosedTabImport -> getModel();
importTab -> addTab( recentlyClosedTabImport, tr( "Recently Closed" ) );

importTab -> addTab( importTab -> automationTab, tr( "Automation" ) );
importTab -> addTab( importTab -> addonTab, tr("Simc Addon") );
connect( historyList, SIGNAL( itemDoubleClicked( QListWidgetItem* ) ), this, SLOT( historyDoubleClicked( QListWidgetItem* ) ) );
connect( importTab, SIGNAL( currentChanged( int ) ), this, SLOT( importTabChanged( int ) ) );
connect( recentlyClosedTabImport, SIGNAL( restoreTab( QWidget*, const QString&, const QString&, const QIcon& ) ),
this, SLOT( simulateTabRestored( QWidget*, const QString&, const QString&, const QIcon& ) ) );
Expand Down Expand Up @@ -531,12 +499,7 @@ void SC_MainWindow::updateWebView( SC_WebView* wv )
visibleWebView = wv;
if ( cmdLine != 0 ) // can be called before widget is setup
{
if ( visibleWebView == battleNetView )
{
cmdLine -> setBattleNetLoadProgress( visibleWebView -> progress, "%p%", "" );
cmdLine -> setCommandLineText( TAB_BATTLE_NET, visibleWebView -> url_to_show );
}
else if ( visibleWebView == helpView )
if ( visibleWebView == helpView )
{
cmdLine -> setHelpViewProgress( visibleWebView -> progress, "%p%", "" );
cmdLine -> setCommandLineText( TAB_HELP, visibleWebView -> url_to_show );
Expand Down Expand Up @@ -783,20 +746,6 @@ void SC_MainWindow::importFinished()
label.replace( QString( ".api" ), QString( "" ) );
label.replace( QString( "https"), QString( "http" ) );
}
bool found = false;
for ( int i = 0; i < historyList -> count() && !found; i++ )
{
if ( historyList -> item( i ) -> text() == label )
found = true;
}

if ( !found )
{
QListWidgetItem* item = new QListWidgetItem( label );
historyList -> addItem( item );
historyList -> sortItems();
}

deleteSim( import_sim ); import_sim = 0;
}
else
Expand Down Expand Up @@ -1275,7 +1224,6 @@ void SC_MainWindow::saveResults()
void SC_MainWindow::closeEvent( QCloseEvent* e )
{
saveHistory();
battleNetView -> stop();
QCoreApplication::quit();
e -> accept();
}
Expand All @@ -1297,24 +1245,7 @@ void SC_MainWindow::cmdLineTextEdited( const QString& s )

void SC_MainWindow::cmdLineReturnPressed()
{
if ( mainTab -> currentTab() == TAB_IMPORT )
{
if ( cmdLine -> commandLineText().count( "battle.net" ) ||
cmdLine -> commandLineText().count( "battlenet.com" ) )
{
battleNetView -> setUrl( QUrl::fromUserInput( cmdLine -> commandLineText() ) );
cmdLine -> setCommandLineText( TAB_BATTLE_NET, cmdLine -> commandLineText() );
importTab -> setCurrentTab( TAB_BATTLE_NET );
}
else
{
if ( !sim ) cmdLine -> mainButtonClicked();
}
}
else
{
if ( !sim ) cmdLine -> mainButtonClicked();
}
if ( !sim ) cmdLine -> mainButtonClicked();
}

void SC_MainWindow::mainButtonClicked( bool /* checked */ )
Expand All @@ -1329,7 +1260,6 @@ void SC_MainWindow::mainButtonClicked( bool /* checked */ )
case TAB_IMPORT:
switch ( importTab -> currentTab() )
{
case TAB_BATTLE_NET: startImport( TAB_BATTLE_NET, cmdLine -> commandLineText() ); break;
case TAB_RECENT: recentlyClosedTabImport -> restoreCurrentlySelected(); break;
default: break;
}
Expand Down Expand Up @@ -1369,12 +1299,6 @@ void SC_MainWindow::importButtonClicked()
{
switch ( importTab -> currentTab() )
{
case TAB_BATTLE_NET:
{
soloChar -> start( 50 );
startImport( TAB_BATTLE_NET, cmdLine -> commandLineText( TAB_BATTLE_NET ) );
break;
}
case TAB_RECENT: recentlyClosedTabImport -> restoreCurrentlySelected(); break;
case TAB_AUTOMATION:
{
Expand Down Expand Up @@ -1496,7 +1420,6 @@ void SC_MainWindow::importTabChanged( int index )
{
if ( index == TAB_BIS ||
index == TAB_CUSTOM ||
index == TAB_HISTORY ||
index == TAB_AUTOMATION ||
index == TAB_RECENT ||
index == TAB_ADDON ||
Expand Down Expand Up @@ -1545,18 +1468,6 @@ void SC_MainWindow::resultsTabCloseRequest( int index )
}
}

void SC_MainWindow::historyDoubleClicked( QListWidgetItem* item )
{
QString text = item -> text();
QString url = text.section( ' ', 1, 1, QString::SectionSkipEmpty );

if ( url.count( "battle.net" ) || url.count( "battlenet.com" ) )
{
battleNetView -> setUrl( url );
importTab -> setCurrentIndex( TAB_BATTLE_NET );
}
}

void SC_MainWindow::bisDoubleClicked( QTreeWidgetItem* item, int /* col */ )
{
QString profile = item -> text( 1 );
Expand All @@ -1577,8 +1488,6 @@ void SC_MainWindow::bisDoubleClicked( QTreeWidgetItem* item, int /* col */ )

void SC_MainWindow::armoryRegionChanged( const QString& region )
{
battleNetView -> stop();
battleNetView -> setUrl( "http://" + region + ".battle.net/wow/en" );
}

void SC_MainWindow::simulateTabRestored( QWidget*, const QString&, const QString&, const QIcon& )
Expand Down
6 changes: 0 additions & 6 deletions qt/simulationcraftqt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ enum main_tabs_e
enum import_tabs_e
{
TAB_IMPORT_NEW = 0,
TAB_BATTLE_NET,
TAB_BIS,
TAB_HISTORY,
TAB_RECENT,
TAB_AUTOMATION,
TAB_ADDON,
Expand Down Expand Up @@ -706,10 +704,8 @@ class SC_MainWindow : public QWidget
#endif

BattleNetImportWindow* newBattleNetView;
SC_WebView* battleNetView;
SC_WebView* helpView;
SC_WebView* visibleWebView;
QListWidget* historyList;
SC_TextEdit* overridesText;
SC_TextEdit* logText;
QPushButton* backButton;
Expand Down Expand Up @@ -830,7 +826,6 @@ private slots:
void importTabChanged( int index );
void resultsTabChanged( int index );
void resultsTabCloseRequest( int index );
void historyDoubleClicked( QListWidgetItem* item );
void bisDoubleClicked( QTreeWidgetItem* item, int col );
void armoryRegionChanged( const QString& region );
void simulateTabRestored( QWidget* tab, const QString& title, const QString& tooltip, const QIcon& icon );
Expand Down Expand Up @@ -1258,7 +1253,6 @@ class SC_ImportThread : public QThread
player_t* player;
QString region, realm, character, spec; // New import uses these

void importBattleNet();
void importWidget();

void start( sim_t* s, int t, const QString& u, const QString& sources, const QString& spec, const QString& role, const QString& apikey )
Expand Down
15 changes: 0 additions & 15 deletions qt/util/sc_mainwindowcommandline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,6 @@ int SC_MainWindowCommandLine::getImportingProgress()
return getProgressBarProgressForState( PROGRESSBAR_IMPORTING );
}

void SC_MainWindowCommandLine::setBattleNetLoadProgress( int value,
QString format,
QString toolTip )
{
updateProgress( PROGRESSBAR_BATTLE_NET, value, format, toolTip );
}

int SC_MainWindowCommandLine::getBattleNetProgress()
{
return getProgressBarProgressForState( PROGRESSBAR_BATTLE_NET );
}

void SC_MainWindowCommandLine::setHelpViewProgress( int value, QString format,
QString toolTip )
{
Expand Down Expand Up @@ -382,9 +370,6 @@ void SC_MainWindowCommandLine::initCommandLineBuffers()
// log has its own buffer (for save file name)
setText( state, CMDLINE_TAB_LOG, TEXTEDIT_CMDLINE,
&commandLineBuffer_TAB_LOG );
// battlenet has its own buffer (for url)
setText( state, CMDLINE_TAB_BATTLE_NET, TEXTEDIT_CMDLINE,
&commandLineBuffer_TAB_BATTLE_NET );
// help has its own buffer (for url)
setText( state, CMDLINE_TAB_HELP, TEXTEDIT_CMDLINE,
&commandLineBuffer_TAB_HELP );
Expand Down
6 changes: 0 additions & 6 deletions qt/util/sc_mainwindowcommandline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ class SC_MainWindowCommandLine : public QWidget
CMDLINE_TAB_PAPERDOLL,
#endif
CMDLINE_TAB_IMPORT_NEW,
CMDLINE_TAB_BATTLE_NET,
CMDLINE_TAB_BIS,
CMDLINE_TAB_HISTORY,
CMDLINE_TAB_RECENT,
CMDLINE_TAB_AUTOMATION,
CMDLINE_TAB_ADDON,
Expand Down Expand Up @@ -87,7 +85,6 @@ class SC_MainWindowCommandLine : public QWidget
PROGRESSBAR_IDLE,
PROGRESSBAR_SIMULATING,
PROGRESSBAR_IMPORTING,
PROGRESSBAR_BATTLE_NET,
PROGRESSBAR_HELP,
PROGRESSBAR_STATE_COUNT
};
Expand All @@ -111,7 +108,6 @@ class SC_MainWindowCommandLine : public QWidget

// CommandLine buffers
QString commandLineBuffer_DEFAULT; // different buffers for different tabs
QString commandLineBuffer_TAB_BATTLE_NET;
QString commandLineBuffer_TAB_RESULTS;
QString commandLineBuffer_TAB_HELP;
QString commandLineBuffer_TAB_LOG;
Expand All @@ -129,8 +125,6 @@ class SC_MainWindowCommandLine : public QWidget
int getSimulatingProgress();
void setImportingProgress( int value, QString format, QString toolTip );
int getImportingProgress();
void setBattleNetLoadProgress( int value, QString format, QString toolTip );
int getBattleNetProgress();
void setHelpViewProgress( int value, QString format, QString toolTip );
int getHelpViewProgress();
QString commandLineText();
Expand Down

0 comments on commit a8340e5

Please sign in to comment.