1 Star 0 Fork 0

archknight/CDDA Modifier wxWidgets

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
MainFrame.cpp 2.50 KB
一键复制 编辑 原始数据 按行查看 历史
#include "MainFrame.h"
#include <wx/wx.h>
#include <wx/aboutdlg.h>
#include <wx/dir.h>
#include <wx/file.h>
#include <wx/filename.h>
#include <wx/treectrl.h>
#include <wx/icon.h>
#include <wx/imaglist.h>
#include "cJSON.h"
#include "raw_directory_tree_data.h"
#include "json_controller.h"
MainFrame::MainFrame(wxWindow* parent)
: MainFrameBaseClass(parent)
{
this->SetIcon(wxIcon(_T("appIcon")));
wxImageList* treeImageList=new wxImageList(16, 16);
treeImageList->Add(wxIcon(_T("treeFolderIcon")));
treeImageList->Add(wxIcon(_T("treefileIcon")));
raw_dir->AssignImageList(treeImageList);
this->Connect(open_raw->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnOpenRaw), NULL, this);
}
MainFrame::~MainFrame()
{
}
void MainFrame::OnExit(wxCommandEvent& event)
{
wxUnusedVar(event);
clearAllJsons();
Close();
}
void MainFrame::OnAbout(wxCommandEvent& event)
{
wxUnusedVar(event);
wxAboutDialogInfo info;
info.SetCopyright(_("My MainFrame"));
info.SetLicence(_("GPL v2 or later"));
info.SetDescription(_("Short description goes here"));
::wxAboutBox(info);
}
void MainFrame::OnOpenRaw(wxCommandEvent& event)
{
wxUnusedVar(event);
wxDirDialog openRawDialog(this, _T("Select the raw directory"), _T("/"), wxDD_NEW_DIR_BUTTON);
if(openRawDialog.ShowModal()==wxID_OK)
{
wxTreeItemId rootId=raw_dir->AddRoot("raw", 0, -1, new RawDirectoryTreeData("raw",openRawDialog.GetPath(), -1));
scanRawDirectory(rootId, openRawDialog.GetPath());
}
}
void MainFrame::clearAllJsons()
{
}
void MainFrame::reloadAllJsons()
{
}
void MainFrame::saveAllJsons()
{
}
void MainFrame::scanRawDirectory(const wxTreeItemId& root, const wxString targetRaw)
{
wxString fileSpec(_T("*"));
int flags=wxDIR_FILES|wxDIR_DIRS;
if(wxDir::Exists(targetRaw))
{
JSONController* jc=JSONController::getInstance(targetRaw);
wxDir scanDir(targetRaw);
if(scanDir.IsOpened())
{
wxString fileName;
bool rtri=scanDir.GetFirst(&fileName, fileSpec, flags);
while(rtri)
{
wxString fullFileName(targetRaw+"\\"+fileName);
if(wxDir::Exists(fullFileName))
{
wxTreeItemId subBranch=raw_dir->AppendItem(root, fileName, 0, -1, new RawDirectoryTreeData(fileName, fullFileName, 0));
scanRawDirectory(subBranch, fullFileName);
}
else
{
wxFileName fn(fullFileName);
if(!fn.GetExt().IsSameAs(_T("bak"),true))
{
raw_dir->AppendItem(root, fileName, 1, -1, new RawDirectoryTreeData(fileName, fullFileName, 0));
}
}
rtri=scanDir.GetNext(&fileName);
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/archknight/CDDA-Modifier-wxWidgets.git
git@gitee.com:archknight/CDDA-Modifier-wxWidgets.git
archknight
CDDA-Modifier-wxWidgets
CDDA Modifier wxWidgets
master

搜索帮助