-
Notifications
You must be signed in to change notification settings - Fork 1
/
AGE_AboutDialog.cpp
169 lines (151 loc) · 5.34 KB
/
AGE_AboutDialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#include "AGE_AboutDialog.h"
#include "icons/AppIcon64.xpm"
#include <filesystem>
const wxString AGE_AboutDialog::AGE_VER = "2020.3.30.martin";
AGE_AboutDialog::AGE_AboutDialog(wxWindow *parent, const wxFont &font)
: wxDialog(parent, -1, "About Advanced Genie Editor", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxNO_DEFAULT)
{
SetFont(font);
SolidText *Title = new SolidText(this, "Advanced Genie Editor\nVersion "+AGE_VER+"\nGPLv3 2011 - 2020\n\nDevelopers:\nMikko \"Tapsa\" P, since 2.0b\nApre - genieutils, 2.1a to 3.1\nEstien Nifo aka StSB77, 1.0a to 2.0a");
wxStaticBitmap *Image = new wxStaticBitmap(this, wxID_ANY, wxBitmap(AppIcon64_xpm));
SolidText *Credits = new SolidText(this, "Credits:\nYkkrosh - GeniEd 1 source code\nScenario_t_c - GeniEd 2 source code\nAlexandra \"Taichi San\", DarkRain654 - data file research\nDiGiT, JustTesting1234, AOHH - genie file structure\nCysion, Kris, Sarthos - important help\nBF_Tanks - some help\nDonnieboy, Sarn, chab - tooltip texts\ngagman - new icon");
wxHyperlinkCtrl *AoKHThread = new wxHyperlinkCtrl(this, wxID_ANY, "Age of Kings Heaven AGE forum topic", "http://aok.heavengames.com/cgi-bin/forums/display.cgi?action=st&fn=9&tn=44059&st=recent&f=9,44059,0,365", wxDefaultPosition, wxDefaultSize, wxNO_BORDER | wxHL_CONTEXTMENU | wxHL_ALIGN_LEFT);
//UPXInfo = new SolidText(this, "Compressed with:");
//UPXLink = new wxHyperlinkCtrl(this, wxID_ANY, "The Ultimate Packer for eXecutables", "http://upx.sourceforge.net", wxDefaultPosition, wxDefaultSize, wxNO_BORDER | wxHL_CONTEXTMENU | wxHL_ALIGN_LEFT);
wxBoxSizer *MainRight = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *MainAbout = new wxBoxSizer(wxVERTICAL);
MainRight->Add(Title, 1, wxEXPAND);
MainRight->Add(Image);
MainAbout->Add(MainRight, 0, wxALL, 10);
MainAbout->Add(Credits, 0, wxALL - wxUP, 10);
MainAbout->Add(AoKHThread, 0, wxALL - wxUP, 10);
//MainAbout->Add(UPXInfo);
//MainAbout->Add(UPXLink);
SetSizerAndFit(MainAbout);
}
namespace GG
{
size_t cache_depth = 42;
LRU_SLP<int, genie::SlpFilePtr> slp_cache_resnum;
LRU_SLP<string, genie::SlpFilePtr> slp_cache_resname;
LRU_SLP<string, genie::SmpFilePtr> smp_cache_resname;
void LoadPalettes(vector<vector<genie::Color>> &palettes, const string &path)
{
if(wxEmptyString == path)
return;
wxString list;
{
wxFFile config(path);
if(config.IsOpened())
{
config.ReadAll(&list);
}
else wxMessageBox("Failed to load " + path);
}
palettes.resize(1);
wxArrayString lines = wxStringTokenize(list, '\n');
long avail_num = 1;
for(const wxString &line: lines)
{
int splitter = line.find(',');
if(wxNOT_FOUND != splitter)
{
long pal_num;
if(line.Left(splitter).ToCLong(&pal_num))
{
while(++avail_num <= pal_num)
{
palettes.push_back(vector<genie::Color>());
}
try
{
genie::PalFile pal;
int cut = path.rfind('\\');
pal.load(path.substr(0, ++cut) + string(line(++splitter, -1)));
palettes.push_back(pal.getColors());
}
catch(const std::ios_base::failure&){}
}
}
}
}
// Need to use basic string for SFML and genieutils uses it too...
string LoadSound(wxArrayString &folders, const string &filename, int resnum)
{
for(auto &f: folders)
{
string folder(f), sound = folder + filename;
if(!wxFileName(sound).FileExists())
sound = folder + std::to_string(resnum) + ".wav";
if(wxFileName(sound).FileExists())
{
return sound;
}
}
return "";
}
std::shared_ptr<unsigned char[]> LoadSound(vector<genie::DrsFile*> &datafiles, int resnum)
{
for(auto &file: datafiles)
{
std::shared_ptr<unsigned char[]> sound = file->getWavPtr(resnum);
if(sound)
{
return sound;
}
}
return 0;
}
genie::SlpFilePtr LoadSLP(genie::DrsFile &pack, int resnum)
{
genie::SlpFilePtr slp = pack.getSlpFile(resnum);
if(slp)
{
// Takes care of unloading excess SLPs.
slp_cache_resnum.put(resnum, slp);
}
return slp;
}
genie::SlpFilePtr LoadSLP(const string &filename)
{
genie::SlpFilePtr slp = slp_cache_resname.use(filename);
if(!slp)
{
if (!std::filesystem::exists(filename))
{
return genie::SlpFilePtr();
}
try
{
slp.reset(new genie::SlpFile(std::filesystem::file_size(filename)));
slp->load(string(filename.c_str()));
slp->freelock();
slp_cache_resname.put(filename, slp);
}
catch(const std::ios_base::failure&)
{
return genie::SlpFilePtr();
}
}
return slp;
}
genie::SmpFilePtr LoadSMP(const std::string &filename)
{
genie::SmpFilePtr smp = smp_cache_resname.use(filename);
if(!smp)
{
try
{
smp.reset(new genie::SmpFile());
smp->load(filename);
smp->freelock();
smp_cache_resname.put(filename, smp);
}
catch(const std::ios_base::failure&)
{
return genie::SmpFilePtr();
}
}
return smp;
}
}