示例#1
0
// Update the column content of the item at _Index
void CGameListCtrl::UpdateItemAtColumn(long _Index, int column)
{
	GameListItem& rISOFile = *m_ISOFiles[_Index];

	switch(column)
	{
		case COLUMN_PLATFORM:
		{
			SetItemColumnImage(_Index, COLUMN_PLATFORM,
			                   m_PlatformImageIndex[rISOFile.GetPlatform()]);
			break;
		}
		case COLUMN_BANNER:
		{
			int ImageIndex = -1;

			if (rISOFile.GetBitmap().IsOk())
				ImageIndex = m_imageListSmall->Add(rISOFile.GetBitmap());

			SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex);
			break;
		}
		case COLUMN_TITLE:
		{
			wxString name = StrToWxStr(rISOFile.GetName());
			int disc_number = rISOFile.GetDiscNumber() + 1;

			if (disc_number > 1 &&
			    name.Lower().find(wxString::Format("disc %i", disc_number)) == std::string::npos &&
			    name.Lower().find(wxString::Format("disc%i", disc_number)) == std::string::npos)
			{
				name = wxString::Format(_("%s (Disc %i)"), name.c_str(), disc_number);
			}

			SetItem(_Index, COLUMN_TITLE, name, -1);
			break;
		}
		case COLUMN_MAKER:
			SetItem(_Index, COLUMN_MAKER, StrToWxStr(rISOFile.GetCompany()), -1);
			break;
		case COLUMN_FILENAME:
			SetItem(_Index, COLUMN_FILENAME,
			        wxFileNameFromPath(StrToWxStr(rISOFile.GetFileName())), -1);
			break;
		case COLUMN_EMULATION_STATE:
			SetItemColumnImage(_Index, COLUMN_EMULATION_STATE,
			                   m_EmuStateImageIndex[rISOFile.GetEmuState()]);
			break;
		case COLUMN_COUNTRY:
			SetItemColumnImage(_Index, COLUMN_COUNTRY,
			                   m_FlagImageIndex[rISOFile.GetCountry()]);
			break;
		case COLUMN_SIZE:
			SetItem(_Index, COLUMN_SIZE, NiceSizeFormat(rISOFile.GetFileSize()), -1);
			break;
		case COLUMN_ID:
			SetItem(_Index, COLUMN_ID, rISOFile.GetUniqueID(), -1);
			break;
	}
}
示例#2
0
void CGameListCtrl::InsertItemInReportView(long _Index)
{
    // When using wxListCtrl, there is no hope of per-column text colors.
    // But for reference, here are the old colors that were used: (BGR)
    // title: 0xFF0000
    // company: 0x007030
    int ImageIndex = -1;

    GameListItem& rISOFile = *m_ISOFiles[_Index];

    // Insert a first row with nothing in it, that will be used as the Index
    long ItemIndex = InsertItem(_Index, wxEmptyString);

    // Insert the platform's image in the first (visible) column
    SetItemColumnImage(_Index, COLUMN_PLATFORM, m_PlatformImageIndex[rISOFile.GetPlatform()]);

    if (rISOFile.GetBitmap().IsOk())
        ImageIndex = m_imageListSmall->Add(rISOFile.GetBitmap());

    // Set the game's banner in the second column
    SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex);

    int SelectedLanguage = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;

    // Is this sane?
    if  (rISOFile.GetPlatform() == GameListItem::WII_WAD)
    {
        SelectedLanguage = SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.LNG");
    }

    std::string const name = rISOFile.GetName(SelectedLanguage);
    SetItem(_Index, COLUMN_TITLE, StrToWxStr(name), -1);

    // We show the company string on GameCube only
    // On Wii we show the description instead as the company string is empty
    std::string const notes = (rISOFile.GetPlatform() == GameListItem::GAMECUBE_DISC) ?
                              rISOFile.GetCompany() : rISOFile.GetDescription(SelectedLanguage);
    SetItem(_Index, COLUMN_NOTES, StrToWxStr(notes), -1);

    // Emulation state
    SetItemColumnImage(_Index, COLUMN_EMULATION_STATE, m_EmuStateImageIndex[rISOFile.GetEmuState()]);

    // Country
    SetItemColumnImage(_Index, COLUMN_COUNTRY, m_FlagImageIndex[rISOFile.GetCountry()]);

    // File size
    SetItem(_Index, COLUMN_SIZE, NiceSizeFormat(rISOFile.GetFileSize()), -1);

    // Game ID
    SetItem(_Index, COLUMN_ID, rISOFile.GetUniqueID(), -1);

    // Background color
    SetBackgroundColor();

    // Item data
    SetItemData(_Index, ItemIndex);
}
示例#3
0
void CGameListCtrl::InsertItemInReportView(long _Index)
{
	// When using wxListCtrl, there is no hope of per-column text colors.
	// But for reference, here are the old colors that were used: (BGR)
	// title: 0xFF0000
	// company: 0x007030
	int ImageIndex = -1;

	GameListItem& rISOFile = *m_ISOFiles[_Index];

	// Insert a first row with nothing in it, that will be used as the Index
	long ItemIndex = InsertItem(_Index, wxEmptyString);

	// Insert the platform's image in the first (visible) column
	SetItemColumnImage(_Index, COLUMN_PLATFORM, m_PlatformImageIndex[rISOFile.GetPlatform()]);

	if (rISOFile.GetBitmap().IsOk())
		ImageIndex = m_imageListSmall->Add(rISOFile.GetBitmap());

	// Set the game's banner in the second column
	SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex);

	wxString name = StrToWxStr(rISOFile.GetName());

	int disc_number = rISOFile.GetDiscNumber() + 1;
	if (disc_number > 1 && name.Lower().find(wxString::Format("disc %i", disc_number)) == std::string::npos
	                    && name.Lower().find(wxString::Format("disc%i", disc_number)) == std::string::npos)
	{
		name = wxString::Format(_("%s (Disc %i)"), name.c_str(), disc_number);
	}

	SetItem(_Index, COLUMN_TITLE, name, -1);
	SetItem(_Index, COLUMN_MAKER, StrToWxStr(rISOFile.GetCompany()), -1);

	// Emulation state
	SetItemColumnImage(_Index, COLUMN_EMULATION_STATE, m_EmuStateImageIndex[rISOFile.GetEmuState()]);

	// Country
	SetItemColumnImage(_Index, COLUMN_COUNTRY, m_FlagImageIndex[rISOFile.GetCountry()]);

	// File size
	SetItem(_Index, COLUMN_SIZE, NiceSizeFormat(rISOFile.GetFileSize()), -1);

	// Game ID
	SetItem(_Index, COLUMN_ID, rISOFile.GetUniqueID(), -1);

	// Background color
	SetBackgroundColor();

	// Item data
	SetItemData(_Index, ItemIndex);
}
示例#4
0
void CGameListCtrl::InsertItemInReportView(long _Index)
{
	// When using wxListCtrl, there is no hope of per-column text colors.
	// But for reference, here are the old colors that were used: (BGR)
	// title: 0xFF0000
	// company: 0x007030
	int ImageIndex = -1;

#ifdef _WIN32
		wxCSConv SJISConv(*(wxCSConv*)wxConvCurrent);
		static bool validCP932 = ::IsValidCodePage(932) != 0;
		if (validCP932)
		{
			SJISConv = wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS));
		}
		else
		{
			WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932");
		}
#else
		// on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS)
		// it returns CP-932, in order to use iconv we need to use CP932
		wxCSConv SJISConv(wxT("CP932"));
#endif

	GameListItem& rISOFile = *m_ISOFiles[_Index];
	m_gamePath.append(rISOFile.GetFileName() + '\n');

	// Insert a first row with nothing in it, that will be used as the Index
	long ItemIndex = InsertItem(_Index, wxEmptyString);

	// Insert the platform's image in the first (visible) column
	SetItemColumnImage(_Index, COLUMN_PLATFORM, m_PlatformImageIndex[rISOFile.GetPlatform()]);

	if (rISOFile.GetImage().IsOk())
		ImageIndex = m_imageListSmall->Add(rISOFile.GetImage());

	// Set the game's banner in the second column
	SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex);
	
	std::wstring wstring_name;
	const std::wstring& wstring_description = rISOFile.GetDescription();
	std::string company;

	wxString name;
	wxString description;

	// We show the company string on Gamecube only
	// On Wii we show the description instead as the company string is empty
	if (rISOFile.GetPlatform() == GameListItem::GAMECUBE_DISC)
		company = rISOFile.GetCompany().c_str();
	int SelectedLanguage = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;
	switch (rISOFile.GetCountry())
	{
	case DiscIO::IVolume::COUNTRY_TAIWAN:
	case DiscIO::IVolume::COUNTRY_JAPAN:
		{
			rISOFile.GetName(wstring_name, -1);
			name = wxString(rISOFile.GetName(0).c_str(), SJISConv);
			m_gameList.append(StringFromFormat("%s (J)\n", (const char *)name.c_str()));
			description = wxString(company.size() ?	company.c_str() :
								rISOFile.GetDescription(0).c_str(),	SJISConv);
		}
		break;
	case DiscIO::IVolume::COUNTRY_USA:
		SelectedLanguage = 0;
	default:
		{
			wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252));
			rISOFile.GetName(wstring_name, SelectedLanguage);

			name = wxString(rISOFile.GetName(SelectedLanguage).c_str(), WindowsCP1252);
			m_gameList.append(StringFromFormat("%s (%c)\n",
						rISOFile.GetName(SelectedLanguage).c_str(),
						(rISOFile.GetCountry() == DiscIO::IVolume::COUNTRY_USA) ? 'U' : 'E'));
			description = wxString(company.size() ?	company.c_str() :
					rISOFile.GetDescription(SelectedLanguage).c_str(), WindowsCP1252);
		}
		break;
	}

	if (wstring_name.length())
		name = wstring_name.c_str();
	if (wstring_description.length())
		description = wstring_description.c_str();
		
	SetItem(_Index, COLUMN_TITLE, name, -1);
	SetItem(_Index, COLUMN_NOTES, description, -1);

	// Emulation state
	SetItemColumnImage(_Index, COLUMN_EMULATION_STATE, m_EmuStateImageIndex[rISOFile.GetEmuState()]);

	// Country
	SetItemColumnImage(_Index, COLUMN_COUNTRY, m_FlagImageIndex[rISOFile.GetCountry()]);

	// File size
	SetItem(_Index, COLUMN_SIZE, NiceSizeFormat(rISOFile.GetFileSize()), -1);

	// Background color
	SetBackgroundColor();

	// Item data
	SetItemData(_Index, ItemIndex);
}
示例#5
0
/*
    Takes a server structure and adds it to the list control
    if insert is 1, then add an item to the list, otherwise it will
    update the current item with new data
*/
void LstOdaServerList::AddServerToList(const Server &s, 
                                        wxInt32 index, 
                                        bool insert)
{
    wxFileConfig ConfigInfo;
    wxInt32 PQGood, PQPlayable, PQLaggy;
    
    wxInt32 i = 0;
    wxListItem li;
    
    wxUint64 Ping = 0;
    wxString GameType = wxT("");
    size_t WadCount = 0;
    
    li.m_mask = wxLIST_MASK_TEXT;

    if (insert)
    {
        li.m_itemId = ALCInsertItem();
    }
    else
    {
        // All cells must be cleared on a "replace" operation, otherwise if the 
        // server failed to respond a second time 'round, we would end up with 
        // some stale data (which is highly dependent on the response check 
        // below)
        ClearItemCells(index);
        
        li.m_itemId = index;
    }
       
    // Address column
    li.m_col = serverlist_field_address;    
    li.m_text = stdstr_towxstr(s.GetAddress());

    SetItem(li);

    // break here so atleast we have an ip address to go by
    if (s.GotResponse() == false)
        return;

    // Server name column
    li.m_col = serverlist_field_name;
    li.m_text = stdstr_towxstr(s.Info.Name);
       
    SetItem(li);
      
    // Ping column
    Ping = s.GetPing();

    li.m_col = serverlist_field_ping;
    li.m_text = wxString::Format(_T("%llu"), Ping);

    SetItem(li);

    // Number of players, Maximum players column
    // TODO: acquire max players, max clients and spectators from these 2 and
    // create some kind of graphical column maybe
    li.m_col = serverlist_field_players;
    li.m_text = wxString::Format(_T("%d/%d"),s.Info.Players.size(),s.Info.MaxClients);
    
    // Colour the entire text column (wx/windows bug - exploited) if there are
    // players
    // TODO: Allow the user to select prefered colours
    if (s.Info.Players.size())
        li.SetTextColour(wxColor(0,192,0));

    SetItem(li); 
    
    // WAD files column
    WadCount = s.Info.Wads.size();
    
    // build a list of pwads
    if (WadCount)
    {
        // pwad list
        std::string wadlist;
        std::string pwad;
            
        for (i = 2; i < WadCount; ++i)
        {
            pwad = s.Info.Wads[i].Name.substr(0, s.Info.Wads[i].Name.find('.'));
            
            wadlist.append(pwad);
            wadlist.append(" ");
        }
            
        li.m_col = serverlist_field_wads;
        li.m_text = stdstr_towxstr(wadlist);
    
        SetItem(li);
    }

    // Map name column
    li.m_col = serverlist_field_map;
    li.m_text = stdstr_towxstr(s.Info.CurrentMap).Upper();
    
    SetItem(li);
       
    // Game type column
    switch (s.Info.GameType)
    {
        case GT_Cooperative:
        {
            // Detect a single player server
            if (s.Info.MaxPlayers > 1)
                GameType = wxT("Cooperative");
            else
                GameType = wxT("Single Player");
        }
        break;
        
        case GT_Deathmatch:
        {
            GameType = wxT("Deathmatch");
        }
        break;
        
        case GT_TeamDeathmatch:
        {
            GameType = wxT("Team Deathmatch");
        }
        break;
        
        case GT_CaptureTheFlag:
        {
            GameType = wxT("Capture The Flag");
        }
        break;
        
        default:
        {
            GameType = wxT("Unknown");
        }
        break;
    }
    
    li.m_col = serverlist_field_type;
    li.m_text = GameType;
    
    SetItem(li);

    // IWAD column
    if (WadCount)
    {
        std::string iwad;
        iwad = s.Info.Wads[1].Name.substr(0, s.Info.Wads[1].Name.find('.'));
        
        li.m_col = serverlist_field_iwad;
        li.m_text = stdstr_towxstr(iwad);
    }
    
    SetItem(li);
    
    // Icons
    // -----
    
    // Padlock icon for passworded servers
    SetItemColumnImage(li.m_itemId, serverlist_field_name, 
        (s.Info.PasswordHash.length() ? ImageList_Padlock : -1));
    
    ConfigInfo.Read(wxT("IconPingQualityGood"), &PQGood, 150);
    ConfigInfo.Read(wxT("IconPingQualityPlayable"), &PQPlayable, 300);
    ConfigInfo.Read(wxT("IconPingQualityLaggy"), &PQLaggy, 350);
    
    // Coloured bullets for ping quality
    if (Ping < PQGood)
    {
        SetItemColumnImage(li.m_itemId, serverlist_field_ping, 
            ImageList_PingGreen);
    }
    else if (Ping < PQPlayable)
    {
        SetItemColumnImage(li.m_itemId, serverlist_field_ping, 
            ImageList_PingOrange);
    }
    else if (Ping < PQLaggy)
    {
        SetItemColumnImage(li.m_itemId, serverlist_field_ping, 
            ImageList_PingRed);
    }
    else
    {
        SetItemColumnImage(li.m_itemId, serverlist_field_ping, 
            ImageList_PingGray);
    }
}
示例#6
0
void CGameListCtrl::InsertItemInReportView(long _Index)
{
	// When using wxListCtrl, there is no hope of per-column text colors.
	// But for reference, here are the old colors that were used: (BGR)
	// title: 0xFF0000
	// company: 0x007030
	int ImageIndex = -1;

	GameListItem& rISOFile = *m_ISOFiles[_Index];

	// Insert a first row with nothing in it, that will be used as the Index
	long ItemIndex = InsertItem(_Index, wxEmptyString);

	// Insert the platform's image in the first (visible) column
	SetItemColumnImage(_Index, COLUMN_PLATFORM, m_PlatformImageIndex[rISOFile.GetPlatform()]);

	if (rISOFile.GetBitmap().IsOk())
		ImageIndex = m_imageListSmall->Add(rISOFile.GetBitmap());

	// Set the game's banner in the second column
	SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex);

	int SelectedLanguage = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;

	// Is this sane?
	if  (rISOFile.GetPlatform() == GameListItem::WII_WAD)
	{
		SelectedLanguage = SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.LNG");
	}

	std::string name = rISOFile.GetName(SelectedLanguage);

	std::ifstream titlestxt;
	OpenFStream(titlestxt, File::GetUserPath(D_LOAD_IDX) + "titles.txt", std::ios::in);

	if (titlestxt.is_open() && rISOFile.GetUniqueID().size() > 3)
	{
		while (!titlestxt.eof())
		{
			std::string line;

			if (!std::getline(titlestxt, line) && titlestxt.eof())
				break;

			if (line.substr(0,rISOFile.GetUniqueID().size()) == rISOFile.GetUniqueID())
			{
				name = line.substr(rISOFile.GetUniqueID().size() + 3);
				break;
			}
		}
		titlestxt.close();
	}

	std::string GameIni[3];
	GameIni[0] = File::GetUserPath(D_GAMESETTINGS_IDX) + rISOFile.GetUniqueID() + ".ini";
	GameIni[1] = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + rISOFile.GetUniqueID() + std::to_string(rISOFile.GetRevision()) + ".ini";
	GameIni[2] = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + rISOFile.GetUniqueID() + ".ini";
	std::string title;
	IniFile gameini;
	for (int i = 0; i < 3; ++i)
	{
		if (File::Exists(GameIni[i]))
		{
			gameini.Load(GameIni[i]);
			if (gameini.GetIfExists("EmuState", "Title", &title))
			{
				name = title;
				break;
			}
		}
	}

	SetItem(_Index, COLUMN_TITLE, StrToWxStr(name), -1);

	// We show the company string on GameCube only
	// On Wii we show the description instead as the company string is empty
	std::string const notes = (rISOFile.GetPlatform() == GameListItem::GAMECUBE_DISC) ?
		rISOFile.GetCompany() : rISOFile.GetDescription(SelectedLanguage);
	SetItem(_Index, COLUMN_NOTES, StrToWxStr(notes), -1);

	// Emulation state
	SetItemColumnImage(_Index, COLUMN_EMULATION_STATE, m_EmuStateImageIndex[rISOFile.GetEmuState()]);

	// Country
	SetItemColumnImage(_Index, COLUMN_COUNTRY, m_FlagImageIndex[rISOFile.GetCountry()]);

	// File size
	SetItem(_Index, COLUMN_SIZE, NiceSizeFormat(rISOFile.GetFileSize()), -1);

	// Game ID
	SetItem(_Index, COLUMN_ID, rISOFile.GetUniqueID(), -1);

	// Background color
	SetBackgroundColor();

	// Item data
	SetItemData(_Index, ItemIndex);
}
示例#7
0
bool wxListCtrl::SetItemImage(long item, int image, int WXUNUSED(selImage))
{
    return SetItemColumnImage(item, 0, image);
}