mirror of
https://github.com/clangen/musikcube.git
synced 2024-12-28 15:16:43 +00:00
Completed about box with cool fading logo and a text scroller with the credits :-) Have fun!
This commit is contained in:
parent
f25b682747
commit
39591913ca
BIN
data/resources/logo.png
Normal file
BIN
data/resources/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
@ -37,6 +37,7 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pch.hpp"
|
||||
#include <core/Common.h>
|
||||
#include <cube/dialog/HelpAboutView.hpp>
|
||||
#include <core/LibraryFactory.h>
|
||||
#include <win32cpp/Label.hpp>
|
||||
@ -45,6 +46,10 @@
|
||||
#include <win32cpp/BarLayout.hpp>
|
||||
#include <win32cpp/EditView.hpp>
|
||||
|
||||
// GDI+ for loading the image
|
||||
#include <atlbase.h>
|
||||
#include <gdiplus.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using namespace musik::cube::dialog;
|
||||
@ -61,6 +66,9 @@ const int anim_h = 300;
|
||||
( ( (B) >> 3 ) ) \
|
||||
))
|
||||
|
||||
#define extract_r(C) ( ( (C) >> 11 & 0x1F ) << 3 )
|
||||
#define extract_g(C) ( ( ( (C) >> 5 ) & 0x3F ) << 2 )
|
||||
#define extract_b(C) ( ( (C) & 0x1F ) << 3 )
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -99,6 +107,85 @@ void HelpAboutView::DrawingThread(HWND hwnd, BITMAPINFO* bmi)
|
||||
// Start time of animation
|
||||
unsigned long time_start = ::GetTickCount();
|
||||
|
||||
// Init GDI*
|
||||
Gdiplus::GdiplusStartupInput gp_si;
|
||||
ULONG_PTR gp_tok;
|
||||
Gdiplus::GdiplusStartup(&gp_tok, &gp_si, NULL);
|
||||
|
||||
// Load logo
|
||||
Gdiplus::Bitmap* gp_logo = Gdiplus::Bitmap::FromFile(
|
||||
(musik::core::GetApplicationDirectory() + _T("resources\\logo.png")).c_str()
|
||||
);
|
||||
|
||||
// Convert logo to correct format
|
||||
unsigned int
|
||||
logo_width = gp_logo->GetWidth(),
|
||||
logo_height = gp_logo->GetHeight();
|
||||
unsigned int
|
||||
*logo = new unsigned int[logo_width * logo_height],
|
||||
*plogo = logo;
|
||||
BYTE
|
||||
*logo_alpha = new BYTE[logo_width * logo_height],
|
||||
*plogo_alpha = logo_alpha;
|
||||
|
||||
for(int y=0; y<logo_height; y++) {
|
||||
for(int x=0; x<logo_width; x++) {
|
||||
Gdiplus::Color col;
|
||||
gp_logo->GetPixel(x, y, &col);
|
||||
|
||||
*plogo = anim_color(col.GetRed(), col.GetGreen(), col.GetBlue());
|
||||
++plogo;
|
||||
|
||||
*plogo_alpha = col.GetAlpha();
|
||||
++plogo_alpha;
|
||||
}
|
||||
}
|
||||
|
||||
// Create font for text scroller
|
||||
HFONT font = ::CreateFont(
|
||||
14,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
FW_NORMAL,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
ANSI_CHARSET,
|
||||
OUT_DEFAULT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS,
|
||||
ANTIALIASED_QUALITY | CLEARTYPE_QUALITY,
|
||||
DEFAULT_PITCH,
|
||||
_T("Courier New")
|
||||
);
|
||||
|
||||
// Define Texts here, there are played in this order
|
||||
uistring texts[] = {
|
||||
_T("--+ musikCube 2 | milestone 2 +--"),
|
||||
_T("created by"),
|
||||
_T("avatar"),
|
||||
_T("doep"),
|
||||
_T("bjorn"),
|
||||
_T("jooles"),
|
||||
_T("naaina"),
|
||||
_T("mC2 are copyright (c) mC2 Team 2007-2008"),
|
||||
_T("win32cpp are copyright (c) Casey Langen 2007-2008"),
|
||||
_T("mC2 wouldn't be possible without these projects:"),
|
||||
_T("tuniac (http://tuniac.sf.net)"),
|
||||
_T("boost (http://www.boost.org)"),
|
||||
_T("sqlite3 (http://www.sqlite.org)"),
|
||||
_T("taglib (http://developer.kde.org/~wheeler/taglib)")
|
||||
};
|
||||
|
||||
RECT cr;
|
||||
::GetClientRect(hwnd, &cr);
|
||||
|
||||
RECT textrect;
|
||||
textrect.left = 0;
|
||||
textrect.top = 200;
|
||||
textrect.right = cr.right;
|
||||
textrect.bottom = 220;
|
||||
|
||||
// Start drawing loop
|
||||
while(anim_running) {
|
||||
// Calc current time
|
||||
@ -149,16 +236,88 @@ void HelpAboutView::DrawingThread(HWND hwnd, BITMAPINFO* bmi)
|
||||
wy[i] += sy[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Display logo
|
||||
float alpha = 0.7 + 0.3 * sin(0.3 * time * 3.1415);
|
||||
int lx = 127, ly = 40;
|
||||
for(int y=0; y<logo_height; y++) {
|
||||
// blackit is true in order to create the black noisy stripes
|
||||
bool blackit = false;
|
||||
if(
|
||||
(
|
||||
(alpha >= 0.4 && alpha <= 0.42) ||
|
||||
(alpha >= 0.71 && alpha <= 0.714)
|
||||
) && !(y % (1 + (rand() % logo_height)))) {
|
||||
blackit = true;
|
||||
}
|
||||
|
||||
for(int x=0; x<logo_width; x++) {
|
||||
unsigned short* cp = &screen[(lx + x) + ((ly + y) * anim_w)];
|
||||
|
||||
unsigned short
|
||||
c = logo[x + y * logo_width],
|
||||
s = *cp;
|
||||
|
||||
BYTE a = logo_alpha[x + y * logo_width];
|
||||
|
||||
if(blackit) c = 0, a = 0;
|
||||
|
||||
double ac = alpha * ((double)a / 255.0f);
|
||||
|
||||
unsigned int
|
||||
r = (extract_r(c) * ac) + (extract_r(s) * (1.0 - ac)),
|
||||
g = (extract_g(c) * ac) + (extract_g(s) * (1.0 - ac)),
|
||||
b = (extract_b(c) * ac) + (extract_b(s) * (1.0 - ac));
|
||||
|
||||
*cp = anim_color(r, g, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Blit surface
|
||||
HDC hdc = ::GetDC(hwnd);
|
||||
::SetDIBitsToDevice(hdc, 0, 0, anim_w, anim_h, 0, 0, 0, anim_h, (void*)screen, bmi, DIB_RGB_COLORS);
|
||||
|
||||
// Draw text
|
||||
{
|
||||
static unsigned int textidx = 0;
|
||||
|
||||
::SetBkMode(hdc, TRANSPARENT);
|
||||
::SetTextColor(hdc, 0xDDDDAA);
|
||||
::SelectObject(hdc, font);
|
||||
|
||||
static float tdlast = 0.0f;
|
||||
|
||||
float td = time - tdlast;
|
||||
if(td > 2.5f) {
|
||||
|
||||
if(textidx+1 == sizeof(texts) / sizeof(uistring)) {
|
||||
textidx = 0;
|
||||
} else {
|
||||
textidx++;
|
||||
}
|
||||
|
||||
tdlast = time;
|
||||
}
|
||||
|
||||
::DrawText(
|
||||
hdc,
|
||||
texts[textidx].c_str(),
|
||||
texts[textidx].size() + 1,
|
||||
&textrect,
|
||||
DT_CENTER
|
||||
);
|
||||
}
|
||||
|
||||
// Some idle time to give other threads the chance to process
|
||||
::Sleep(1);
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
// Shutdown GDI+
|
||||
delete gp_logo; delete logo;
|
||||
Gdiplus::GdiplusShutdown(gp_tok);
|
||||
|
||||
// Delete resources
|
||||
delete[] screen; screen = NULL;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPTSTR commandLi
|
||||
// Initialize locale
|
||||
try {
|
||||
uistring appDirectory( musik::core::GetApplicationDirectory() );
|
||||
Locale::Instance()->SetLocaleDirectory(appDirectory);
|
||||
Locale::Instance()->SetLocaleDirectory(appDirectory + _T("\\locales"));
|
||||
Locale::Instance()->LoadConfig(_T("english"));
|
||||
}
|
||||
catch(...) {
|
||||
|
Loading…
Reference in New Issue
Block a user