mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
d2196eea09
Now all C++ files need to #include <util/prec.hpp>
That is why all .cpp files are touched by this commit
Many changes to installers and update checking:
- the window is now called PackagesWindow, in a new source file
- update checking is now independent from the PackagesWindow. For update checking only a list of package versions are needed (vector<PackageDependency>). This is much less information to download at each startup.
- the list of available packages is now a list of available Installers, since an installer can contain multiple packages.
- moved the logic of dependency checking etc. to data/installer
- moved the actual installation to util/io/package_manager
- moved directory iteration/creation logic to util/file_utils
- added PackageDirectory: the local and global package directory now have their own object (was part of PackageManager)
- added PackageVersion: for detecting if a package has been modified after it was installed.
- added PackageDescription: description/header of a package. Basicly the same as what Packaged provides.
- added DownloadableInstaller: where to find an insaller, what does it contain?
- added InstallablePackage: brining it all together: installer, package, status, action.
Current status: the insaller is currently broken in a few places, more on that soon.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@792 0fc631ac-6414-0410-93d0-97cfa31319b6
78 lines
2.5 KiB
C++
78 lines
2.5 KiB
C++
//+----------------------------------------------------------------------------+
|
|
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
|
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
|
|
//| License: GNU General Public License 2 or later (see file COPYING) |
|
|
//+----------------------------------------------------------------------------+
|
|
|
|
// ----------------------------------------------------------------------------- : Includes
|
|
|
|
#include <util/prec.hpp>
|
|
#include <gfx/gfx.hpp>
|
|
|
|
// ----------------------------------------------------------------------------- : Color utility functions
|
|
|
|
Color lerp(const Color& a, const Color& b, double t) {
|
|
return Color(static_cast<int>( a.Red() + (b.Red() - a.Red() ) * t ),
|
|
static_cast<int>( a.Green() + (b.Green() - a.Green()) * t ),
|
|
static_cast<int>( a.Blue() + (b.Blue() - a.Blue() ) * t ));
|
|
}
|
|
|
|
|
|
int hsl2rgbp(double t1, double t2, double t3) {
|
|
// adjust t3 to [0...1)
|
|
if (t3 < 0.0) t3 += 1;
|
|
else if (t3 > 1.0) t3 -= 1;
|
|
// determine color
|
|
if (6.0 * t3 < 1) return (int)(255 * (t1 + (t2-t1) * 6.0 * t3) );
|
|
if (2.0 * t3 < 1) return (int)(255 * (t2) );
|
|
if (3.0 * t3 < 2) return (int)(255 * (t1 + (t2-t1) * 6.0 * (2.0/3.0 - t3)) );
|
|
else return (int)(255 * (t1) );
|
|
}
|
|
Color hsl2rgb(double h, double s, double l) {
|
|
double t2 = l < 0.5 ? l * (1.0 + s) :
|
|
l * (1.0 - s) + s;
|
|
double t1 = 2.0 * l - t2;
|
|
return Color(
|
|
hsl2rgbp(t1, t2, h + 1.0/3.0),
|
|
hsl2rgbp(t1, t2, h) ,
|
|
hsl2rgbp(t1, t2, h - 1.0/3.0)
|
|
);
|
|
}
|
|
|
|
|
|
Color darken(const Color& c) {
|
|
return Color(
|
|
c.Red() * 8 / 10,
|
|
c.Green() * 8 / 10,
|
|
c.Blue() * 8 / 10
|
|
);
|
|
}
|
|
|
|
Color saturate(const Color& c, double amount) {
|
|
int r = c.Red(), g = c.Green(), b = c.Blue();
|
|
double l = (r + g + b) / 3;
|
|
return Color(
|
|
col(static_cast<int>( (r - amount * l) / (1 - amount) )),
|
|
col(static_cast<int>( (g - amount * l) / (1 - amount) )),
|
|
col(static_cast<int>( (b - amount * l) / (1 - amount) ))
|
|
);
|
|
}
|
|
|
|
|
|
void fill_image(Image& image, const Color& color) {
|
|
Byte* pos = image.GetData();
|
|
Byte* end = pos + image.GetWidth() * image.GetHeight() * 3;
|
|
Byte r = color.Red(), g = color.Green(), b = color.Blue();
|
|
if (r == g && r == b) {
|
|
// optimization: use memset
|
|
memset(pos, r, end-pos);
|
|
} else {
|
|
// fill the image
|
|
while (pos != end) {
|
|
*pos++ = r;
|
|
*pos++ = g;
|
|
*pos++ = b;
|
|
}
|
|
}
|
|
}
|