#pragma once #include #include "Emu/GameInfo.h" struct Column { u32 pos; u32 width; bool shown; wxArrayString data; const wxString name; const u32 def_pos; const u32 def_width; Column(const u32 _def_pos, const u32 _def_width, const wxString& _name) : def_pos(_def_pos) , def_width(_def_width) , pos(_def_pos) , width(_def_width) , shown(true) , name(_name) { data.Clear(); } }; struct ColumnsArr { ArrayF m_columns; ColumnsArr() { Init(); } ArrayF* GetSortedColumnsByPos() { static ArrayF& arr = *new ArrayF(); arr.ClearF(); for(u32 pos=0; pos& columns = *GetSortedColumnsByPos(); for(u32 c=0; c& game_data) { m_col_name->data.Clear(); m_col_serial->data.Clear(); m_col_fw->data.Clear(); m_col_app_ver->data.Clear(); m_col_category->data.Clear(); m_col_path->data.Clear(); if(m_columns.GetCount() == 0) return; for(uint i=0; idata.Add(game.name); m_col_serial->data.Add(game.serial); m_col_fw->data.Add(game.fw); m_col_app_ver->data.Add(game.app_ver); m_col_category->data.Add(game.category); m_col_path->data.Add(game.root); } } void Show(wxListView* list) { list->DeleteAllColumns(); ArrayF& c_col = *GetSortedColumnsByPos(); for(u32 i=0, c=0; iInsertColumn(c++, c_col[i].name, 0, c_col[i].width); } } void ShowData(wxListView* list) { list->DeleteAllItems(); for(int c=0; cGetColumnCount(); ++c) { Column* col = GetColumnByPos(c); if(!col) { ConLog.Error("Columns loaded with error!"); return; } for(u32 i=0; idata.GetCount(); ++i) { if(list->GetItemCount() <= (int)i) list->InsertItem(i, wxEmptyString); list->SetItem(i, c, col->data[i]); } } } void LoadSave(bool isLoad, const wxString& path, wxListView* list = NULL) { if(isLoad) Init(); else if(list) { for(int c=0; cGetColumnCount(); ++c) { Column* col = GetColumnByPos(c); if(col) col->width = list->GetColumnWidth(c); } } #define ADD_COLUMN(v, dv, t, n, isshown) \ { \ IniEntry ini; \ ini.Init(m_columns[i].name + "_" + n, path); \ if(isLoad) m_columns[i].v = ini.LoadValue(dv); \ else if(isshown ? m_columns[i].shown : 1) \ { \ ini.SetValue(m_columns[i].v); \ ini.Save(); \ } \ } for(u32 i=0; i m_game_data; ColumnsArr m_columns; public: GameViewer(wxWindow* parent); ~GameViewer(); void DoResize(wxSize size); void LoadGames(); void LoadPSF(); void ShowData(); void SaveSettings(); void LoadSettings(); void Refresh(); private: virtual void DClick(wxListEvent& event); };