示例#1
0
bool UITextEditor::Finalise(void)
{
    if (m_template)
        return true;

    if (!m_textWidget)
    {
        UIWidget *text = FindChildByName("text");
        if (text && text->Type() == UIText::kUITextType)
            m_textWidget = static_cast<UIText*>(text);
    }

    if (!m_cursor && m_textWidget)
    {
        m_cursor = FindChildByName("cursor", true);
        if (m_cursor)
        {
            connect(this, SIGNAL(Selected()),   m_cursor, SLOT(Show()));
            connect(this, SIGNAL(Deselected()), m_cursor, SLOT(Hide()));
            if (!m_selected)
                m_cursor->Hide();
        }
    }

    UpdateCursor();

    return UIWidget::Finalise();
}
示例#2
0
Opt<Item> InventoryComponent::SetSelectedItem( ItemType::Type type, int32_t Id, bool force /*= false */ )
{
    auto selectedItem(mItems[type].GetSelectedItem());
    if (force || !selectedItem.IsValid() || selectedItem->CanSwitch())
    {
        if (selectedItem.IsValid())
        {
            selectedItem->Deselected();
        }
        selectedItem = mItems[type].SetSelectedItem(Id);
        if (selectedItem.IsValid())
        {
            selectedItem->Selected();
        }
    }
    return selectedItem;
}
void PlaybackTab::OnWatch(wxCommandEvent& /*unused*/)
{
	const StoredGame* storedGame = m_replay_dataview->GetSelectedItem();

	if (storedGame == nullptr) {
		Deselected();
		return;
	}

	const int m_sel_replay_id = storedGame->id;

	wxString type = m_isreplay ? _("replay") : _("savegame");
	wxLogMessage(_T( "Watching %s %d " ), type.c_str(), m_sel_replay_id);
	StoredGame& rep = replaylist().GetPlaybackById(m_sel_replay_id);
	if (ui().NeedsDownload(&rep.battle)) {
		return;
	}

	rep.battle.GetMe().SetNick(STD_STRING(cfg().ReadString("/Spring/DefaultName")));
	rep.battle.StartSpring();
}
示例#4
0
void PlaybackTab<PlaybackTraits>::OnDelete( wxCommandEvent& /*unused*/ )
{
	int sel_index = m_replay_listctrl->GetSelectedIndex();
	if ( sel_index >= 0 ) {
		try {
			const PlaybackType& rep = *m_replay_listctrl->GetSelectedData();
			int m_sel_replay_id = rep.id;
			int index = m_replay_listctrl->GetIndexFromData( &rep );
			wxLogMessage( _T( "Deleting replay %d " ), m_sel_replay_id );
			wxString fn = rep.Filename;
			if ( !playbacklist<ListType>().DeletePlayback( m_sel_replay_id ) )
				customMessageBoxNoModal( SL_MAIN_ICON, _( "Could not delete Replay: " ) + fn,
				                         _( "Error" ) );
			else {
				RemovePlayback( index ); // Deselect is called in there too
			}
		} catch ( std::runtime_error ) {
			return;
		}
	} else {
		Deselected();
	}
}
示例#5
0
void PlaybackTab<PlaybackTraits>::Deselect()
{
	m_replay_listctrl->SelectNone();
	Deselected();
}
示例#6
0
void PlaybackTab<PlaybackTraits>::OnDeselect( wxListEvent& /*unused*/ )
{
	Deselected();
}
示例#7
0
void PlaybackTab<PlaybackTraits>::OnWatch( wxCommandEvent& /*unused*/ )
{
	if ( m_replay_listctrl->GetSelectedIndex() != -1 ) {
		int m_sel_replay_id = m_replay_listctrl->GetSelectedData()->id;

		wxString type = PlaybackTraits::IsReplayType ? _( "replay" ) : _( "savegame" ) ;
		wxLogMessage( _T( "Watching %s %d " ), type.c_str(), m_sel_replay_id );
		try {
			PlaybackType& rep = playbacklist<ListType>().GetPlaybackById( m_sel_replay_id );

			std::map<wxString, wxString> versionlist = sett().GetSpringVersionList();
			if ( versionlist.size() == 0 ) {
				wxLogWarning( _T( "can't get spring version from any unitsync" ) );
				customMessageBox( SL_MAIN_ICON,  _( "Couldn't get your spring versions from any unitsync library." ), _( "Spring error" ), wxICON_EXCLAMATION | wxOK );
				AskForceWatch( rep );
				return;
			}
			bool versionfound = false;
			for ( std::map<wxString, wxString>::const_iterator itor = versionlist.begin(); itor != versionlist.end(); itor++ ) {
				if ( itor->second == rep.SpringVersion ) {
					if ( sett().GetCurrentUsedSpringIndex() != itor->first ) {
						wxLogMessage( _T( "%s requires version: %s, switching to profile: %s" ), type.c_str(), rep.SpringVersion.c_str(), itor->first.c_str() );
						sett().SetUsedSpringIndex( itor->first );
						usync().AddReloadEvent(); // request an unitsync reload
					}
					versionfound = true;
				}
			}
			if ( !ReplayTraits::IsReplayType )
                versionfound = true; // quick hack to bypass spring version check
			if ( !versionfound ) {
				wxString message = wxString::Format( _( "No compatible installed spring version has been found, this %s requires version: %s\n" ), type.c_str(), rep.SpringVersion.c_str() );
				message << _( "Your current installed versions are:" );
				for ( std::map<wxString, wxString>::const_iterator itor = versionlist.begin(); itor != versionlist.end(); itor++ ) message << _T( " " ) << itor->second;
				customMessageBox( SL_MAIN_ICON, message, _( "Spring error" ), wxICON_EXCLAMATION | wxOK );
				wxLogWarning ( _T( "no spring version supported by this replay found" ) );
				AskForceWatch( rep );
				return;
			}
			rep.battle.GetMe().SetNick( usync().GetDefaultNick() );
			bool watchable = rep.battle.MapExists() && rep.battle.ModExists();
			if ( watchable )
				rep.battle.StartSpring();
			else {
#ifdef NO_TORRENT_SYSTEM
				wxString downloadProc = _( "Do you want me to take you to the download page?" );
#else
				wxString downloadProc = _( "Should i try to download it for you?\nYou can see the progress in the \"Download Manager\" tab." );
#endif

				OfflineBattle& battle = rep.battle;

				if ( !battle.ModExists() ) {
					if ( customMessageBox( SL_MAIN_ICON, _( "You need to download the game before you can watch this replay.\n\n" ) + downloadProc, _( "Game not available" ), wxYES_NO | wxICON_QUESTION ) == wxYES ) {
						wxString modhash = battle.GetHostModHash();
						wxString modname = battle.GetHostModName();
						ui().DownloadMod ( modhash, modname );
					}
					else {
						AskForceWatch( rep );
					}
					return;
				}

				if ( !battle.MapExists() ) {
					if ( customMessageBox( SL_MAIN_ICON, _( " I couldn't find the map to be able to watch this replay\nThis can be caused by tasclient writing broken map hash value\nIf you're sure you have the map, press no\nYou need to download the map to be able to watch this replay.\n\n" ) + downloadProc, _( "Map not available" ), wxYES_NO | wxICON_QUESTION ) == wxYES ) {
						wxString maphash = battle.GetHostMapHash();
						wxString mapname = battle.GetHostMapName();
						ui().DownloadMap ( maphash, mapname );
					}
					else {
						AskForceWatch( rep );
					}
				}
			}
		} catch ( std::runtime_error ) {
			return;
		}
	} else {
		Deselected();
	}
}
void PlaybackTab::Deselect()
{
	m_replay_dataview->UnselectAll();
	Deselected();
}