void SjViewSettingsPage::UpdateSkinList(const wxString& selSkin)
{
	m_skinChangeFromMe++;

	m_listCtrl->Freeze();
	m_listCtrl->DeleteAllItems();

	if( m_skinEnumerator )
	{
		delete m_skinEnumerator;
		m_skinEnumerator = NULL;
	}

	m_skinEnumerator = new SjSkinEnumerator();
	if( m_skinEnumerator )
	{
		int currSkinIndex, new_i;
		for( currSkinIndex = 0; currSkinIndex < m_skinEnumerator->GetCount(); currSkinIndex++ )
		{
			SjSkinEnumeratorItem* currSkin = m_skinEnumerator->GetSkin(currSkinIndex);
			wxListItem      item;
			item.m_mask     = wxLIST_MASK_IMAGE | wxLIST_MASK_TEXT | wxLIST_MASK_DATA;
			item.m_itemId   = currSkinIndex;
			item.m_text     = currSkin->m_name;
			item.m_data     = currSkinIndex;
			item.m_image    = SJ_ICON_SKIN_FILE;
			new_i = m_listCtrl->InsertItem(item);

			if( currSkin->m_url == selSkin )
			{
				m_listCtrl->SetItemState(new_i, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
			}
		}

		wxSize size = m_listCtrl->GetClientSize();
		m_listCtrl->SetColumnWidth(0, size.x-8);
	}

	m_listCtrl->Thaw();

	m_skinChangeFromMe--;
}
void getFleetData(wxListCtrl& listCtrl)
{
	DataPoll poll;

	string data = poll.getFleetData(1, LogInHandler::mUsername, LogInHandler::mPassword);
	if(!poll.getState())
	{
		return;
	}

	istringstream input(data);

	jsonxx::Object o;

	assert(jsonxx::Object::parse(input, o));
	assert(o.has<jsonxx::Array>("data"));

	long long int profit = 0;
	double distance = 0,
	       velocity = 0;
	stringstream sstream;

	string finalString;

	//wxString tempHabitable;

	for(int i = 0; i < o.get<jsonxx::Array>("data").size(); ++i)
	{
		profit = o.get<jsonxx::Array>("data").get<jsonxx::Object>(i).get<jsonxx::number>("profit");
		velocity = o.get<jsonxx::Array>("data").get<jsonxx::Object>(i).get<jsonxx::number>("velocity");
		distance = o.get<jsonxx::Array>("data").get<jsonxx::Object>(i).get<jsonxx::number>("distance");
		cout << profit;
		cout << endl;
		int minutesToTarget = floor(distance / velocity);
		if(velocity == 0)
		{
			minutesToTarget = 0;
		}
		wxString sProfit;
		sProfit << profit;
		//wxString sProfit(wxT("4"), wxConvUTF8);
		wxString sVelocity;
		sVelocity << velocity;
		wxString sDistance;
		sDistance << distance;
		wxString sMinToTarget;
		sMinToTarget << minutesToTarget;

		wxString tempName(o.get<jsonxx::Array>("data").get<jsonxx::Object>(i).get<string>("name").c_str(), wxConvUTF8);

		wxString tempStatus(o.get<jsonxx::Array>("data").get<jsonxx::Object>(i).get<string>("status").c_str(), wxConvUTF8);

		//bool y = o.get<jsonxx::Array>("data").get<jsonxx::Object>(i).get<bool>("hasHabitable");

		//if(y)
		//	tempHabitable = wxString("Yes");
		//else
		//	tempHabitable = wxString("No");

		wxListItem item;

		item.SetId(i);

		long index = listCtrl.InsertItem(item);

		listCtrl.SetItem(index, 0, tempName);
		listCtrl.SetItem(index, 1, tempStatus);
		listCtrl.SetItem(index, 2, sProfit);
		listCtrl.SetItem(index, 3, sDistance);
		listCtrl.SetItem(index, 4, sVelocity);
		listCtrl.SetItem(index, 5, sMinToTarget);

		//listCtrl.SetItem(index, 2, tempHabitable);

		sstream.str("");
	}
}
Beispiel #3
0
void SjMyMusicConfigPage::InitPage(const wxString& selSourceUrl)
{
	// create index list
	m_listOfSources.Clear();
	m_listOfSources.DeleteContents(TRUE);

	SjModuleList* list = g_mainFrame->m_moduleSystem.GetModules(SJ_MODULETYPE_SCANNER);
	wxASSERT(list);

	SjModuleList::Node* moduleNode = list->GetFirst();
	SjScannerModule*    scannerModule;
	while( moduleNode )
	{
		scannerModule = (SjScannerModule*)moduleNode->GetData();
		wxASSERT(scannerModule);
		wxASSERT(scannerModule->IsLoaded());

		long sourceCount = scannerModule->GetSourceCount();
		long currSourceIndex;
		for( currSourceIndex = 0; currSourceIndex < sourceCount; currSourceIndex++ )
		{
			SjSettingsSourceItem* item = new SjSettingsSourceItem(scannerModule, currSourceIndex, scannerModule->GetSourceUrl(currSourceIndex), scannerModule->GetSourceIcon(currSourceIndex));
			m_listOfSources.Append(item);
		}

		// next
		moduleNode = moduleNode->GetNext();
	}

	// get list control
	m_listCtrl->Freeze();
	m_listCtrl->DeleteAllItems();

	// go through all search directories
	SjSettingsSourceItem*           item;
	SjSettingsSourceItemList::Node* itemnode = m_listOfSources.GetFirst();
	int                             i = 0;
	wxString                        sourceNotes;
	while( itemnode )
	{
		item = itemnode->GetData();
		wxASSERT(item);

		wxListItem listitem;
		listitem.m_mask     = wxLIST_MASK_IMAGE | wxLIST_MASK_TEXT | wxLIST_MASK_DATA;
		listitem.m_itemId   = i;
		listitem.m_text     = item->GetUrl();
		listitem.SetData((void*)item);
		listitem.m_image    = item->GetScannerModule()->GetSourceIcon(item->GetIndex());

		sourceNotes = item->GetScannerModule()->GetSourceNotes(item->GetIndex());
		if( !sourceNotes.IsEmpty() )
		{
			listitem.m_text.Append(" (");
			listitem.m_text.Append(sourceNotes);
			listitem.m_text.Append(')');
		}

		m_listCtrl->InsertItem(listitem);

		itemnode = itemnode->GetNext();
		i++;
	}

	m_listCtrl->SortItems(ListCtrlCompareFunction, m_currSortCol);

	m_listCtrl->Thaw();

	// select the correct item
	// (should be done after SortItems() on GTK this may remove the selection ...)
	int i_cnt = m_listCtrl->GetItemCount();
	for( i = 0; i < i_cnt; i ++ )
	{
		item = (SjSettingsSourceItem*)m_listCtrl->GetItemData(i);
		if( item->GetUrl() == selSourceUrl ) {
			m_listCtrl->SetItemState(i, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
			break;
		}
	}

	UpdateButtons();
}