Cleanup test code. Use a message and run the easter egg from MessageReceived(). USe find_directory() to find the fortune file.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39241 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -643,10 +643,8 @@ void
|
|||||||
AboutView::MouseDown(BPoint point)
|
AboutView::MouseDown(BPoint point)
|
||||||
{
|
{
|
||||||
BRect r(92, 26, 105, 31);
|
BRect r(92, 26, 105, 31);
|
||||||
if (r.Contains(point)) {
|
if (r.Contains(point))
|
||||||
printf("Easter egg\n");
|
BMessenger(this).SendMessage('eegg');
|
||||||
PickRandomHaiku();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Bounds().Contains(point)) {
|
if (Bounds().Contains(point)) {
|
||||||
fLastActionTime = system_time();
|
fLastActionTime = system_time();
|
||||||
@@ -691,6 +689,12 @@ AboutView::MessageReceived(BMessage* msg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'eegg':
|
||||||
|
{
|
||||||
|
printf("Easter egg\n");
|
||||||
|
PickRandomHaiku();
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(msg);
|
BView::MessageReceived(msg);
|
||||||
break;
|
break;
|
||||||
@@ -789,18 +793,19 @@ AboutView::AddCopyrightEntry(const char* name, const char* text,
|
|||||||
void
|
void
|
||||||
AboutView::PickRandomHaiku()
|
AboutView::PickRandomHaiku()
|
||||||
{
|
{
|
||||||
BFile fortunes(
|
BPath path;
|
||||||
#ifdef __HAIKU__
|
if (find_directory(B_SYSTEM_DATA_DIRECTORY, &path) != B_OK)
|
||||||
"/etc/fortunes/Haiku",
|
path = "/system/data";
|
||||||
#else
|
path.Append("fortunes");
|
||||||
"data/etc/fortunes/Haiku",
|
path.Append("Haiku");
|
||||||
#endif
|
|
||||||
B_READ_ONLY);
|
BFile fortunes(path.Path(), B_READ_ONLY);
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (fortunes.InitCheck() < B_OK)
|
if (fortunes.InitCheck() < B_OK)
|
||||||
return;
|
return;
|
||||||
if (fortunes.GetStat(&st) < B_OK)
|
if (fortunes.GetStat(&st) < B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char* buff = (char*)malloc((size_t)st.st_size + 1);
|
char* buff = (char*)malloc((size_t)st.st_size + 1);
|
||||||
if (!buff)
|
if (!buff)
|
||||||
return;
|
return;
|
||||||
@@ -822,6 +827,7 @@ AboutView::PickRandomHaiku()
|
|||||||
free(buff);
|
free(buff);
|
||||||
if (haikuList.CountItems() < 1)
|
if (haikuList.CountItems() < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BString* s = (BString*)haikuList.ItemAt(rand() % haikuList.CountItems());
|
BString* s = (BString*)haikuList.ItemAt(rand() % haikuList.CountItems());
|
||||||
BFont font(be_bold_font);
|
BFont font(be_bold_font);
|
||||||
font.SetSize(be_bold_font->Size());
|
font.SetSize(be_bold_font->Size());
|
||||||
|
|||||||
Reference in New Issue
Block a user