@notify: C-- version 0.7

git-svn-id: svn://kolibrios.org@4004 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2013-10-10 22:42:17 +00:00
parent 89ac0aa669
commit 23b2f8b13c
3 changed files with 95 additions and 77 deletions

View File

@ -1,5 +1,9 @@
@del lang.h--
@echo #define LANG_ENG 1 >lang.h--
..\C--\C-- notify.c
@del @notify
@rename notify.com @notify
@del warning.txt
@del lang.h--
@pause

View File

@ -0,0 +1,9 @@
@del lang.h--
@echo #define LANG_RUS 1 >lang.h--
..\C--\C-- notify.c
@del @notify
@rename notify.com @notify
@del warning.txt
@del lang.h--
@pause

View File

@ -1,62 +1,83 @@
//notify 0.52
//notify 0.7
//SoUrcerer 2010, Leency 2012-2013, GNU GPLv2
#define MEMSIZE 0x3E80
#define MEMSIZE 0x2F00
#include "..\lib\kolibri.h"
#include "..\lib\strings.h"
#include "..\lib\mem.h"
#include "..\lib\figures.h"
?define PADDING 12;
int SCREEN_SIZE_X,
SCREEN_SIZE_Y;
int WIN_Y=0,
WIN_SIZE_X=300,
int WIN_X,
WIN_Y,
WIN_SIZE_X=256,
WIN_SIZE_Y=28;
int delay = 500;
int delay = 400;
#include "lang.h--"
#ifdef LANG_RUS
?define DEFAULT_TEXT "<EFBFBD>â  ¯à®£à ¬¬  ¯®ª §ë¢ ¥â 㢥¤®¬«¥­¨ï.";
#else
?define DEFAULT_TEXT "This program shows notices. Open it with params.";
#endif
void PutText(dword x, y) {
WriteText(x,y, 0x80, 0, #param);
}
inline fastcall int GetClientTop()
{
$mov eax, 48
$mov ebx, 5
$int 0x40
$mov eax, ebx
$shr eax, 16
}
dword shadow_buf, lighter_pixel1, lighter_pixel2;
void GetBackground()
{
CopyScreen(shadow_buf, WIN_X, WIN_Y, WIN_SIZE_X, WIN_SIZE_Y);
CopyScreen(lighter_pixel1, WIN_X, WIN_Y, 1, 1);
CopyScreen(lighter_pixel2, WIN_X, WIN_Y+WIN_SIZE_Y, 1, 1);
ShadowImage(shadow_buf, WIN_SIZE_X, WIN_SIZE_Y, 6);
ShadowImage(lighter_pixel1, 1, 1, 2);
ShadowImage(lighter_pixel2, 1, 1, 2);
}
void main()
{
int TEXT_X=4,
TEXT_Y=12;
dword shadow_buf, lighter_pixel1, lighter_pixel2;
char drawn;
if (!param)
{
if (GetSystemLanguage()==4)
strcpy(#param, "<EFBFBD>â  ¯à®£à ¬¬  ¯®ª §ë¢ ¥â 㢥¤®¬«¥­¨ï.");
else
strcpy(#param, "This program shows notices. Open it with params.");
}
SCREEN_SIZE_X=GetScreenWidth()+1;
if (!param) strcpy(#param, DEFAULT_TEXT);
if (strlen(#param)*6>WIN_SIZE_X)
{
WIN_SIZE_X=strlen(#param)*6+8;
WIN_SIZE_X=strlen(#param)*6+PADDING;
delay = strlen(#param)*10;
}
TEXT_X=-6*strlen(#param)+WIN_SIZE_X/2;
TEXT_Y=WIN_SIZE_Y/2-3;
SCREEN_SIZE_X=GetScreenWidth()+1;
WIN_X = SCREEN_SIZE_X-WIN_SIZE_X-1;
WIN_Y = GetClientTop();
TEXT_X = -6*strlen(#param)+WIN_SIZE_X/2;
TEXT_Y = WIN_SIZE_Y/2-3;
//èçÿÿÿùíûé êîñòûëü, ðåàëèçóþùèé ìíîãîïîòî÷íîñòü :)
//emulate multithread :)
while (GetPixelColor(SCREEN_SIZE_X-1, SCREEN_SIZE_X, WIN_Y)==0x333333) WIN_Y+=WIN_SIZE_Y+17;
#if !defined(AUTOBUILD)
{
mem_Init();
shadow_buf = malloc(WIN_SIZE_X*WIN_SIZE_Y*3);
lighter_pixel1 = malloc(3);
lighter_pixel2 = malloc(3);
CopyScreen(shadow_buf, SCREEN_SIZE_X-WIN_SIZE_X-1, WIN_Y, WIN_SIZE_X, WIN_SIZE_Y);
CopyScreen(lighter_pixel1, SCREEN_SIZE_X-WIN_SIZE_X-1, WIN_Y, 1, 1);
CopyScreen(lighter_pixel2, SCREEN_SIZE_X-WIN_SIZE_X-1, WIN_Y+WIN_SIZE_Y, 1, 1);
ShadowImage(shadow_buf, WIN_SIZE_X, WIN_SIZE_Y, 4);
ShadowImage(lighter_pixel1, 1, 1, 1);
ShadowImage(lighter_pixel2, 1, 1, 1);
}
#endif
mem_Init();
shadow_buf = malloc(WIN_SIZE_X*WIN_SIZE_Y*3);
lighter_pixel1 = malloc(3);
lighter_pixel2 = malloc(3);
GetBackground();
loop()
{
@ -64,37 +85,37 @@ void main()
switch(EAX & 0xFF)
{
case evButton:
if (GetButtonID()==1) ExitProcess();
break;
case evKey:
ExitProcess();
break;
case evReDraw:
DefineAndDrawWindow(SCREEN_SIZE_X-WIN_SIZE_X,WIN_Y,WIN_SIZE_X, WIN_SIZE_Y-1, 0x01, 0, 0, 0x01fffFFF);
DefineButton(0,0, WIN_SIZE_X, WIN_SIZE_Y, 1+BT_HIDE+BT_NOFRAME, 0);
//draw_grid();
//PutShadow(0,0,WIN_SIZE_X,WIN_SIZE_Y, 0, 4);
#ifdef AUTOBUILD
{ draw_grid(); }
#else
DefineAndDrawWindow(WIN_X+1,WIN_Y,WIN_SIZE_X, WIN_SIZE_Y-1, 0x01, 0, 0, 0x01fffFFF);
if (drawn==1)
{
_PutImage(0,0,WIN_SIZE_X,WIN_SIZE_Y,shadow_buf);
PutPixel(0,0,ESDWORD[lighter_pixel1]);
PutPixel(0,WIN_SIZE_Y-1,ESDWORD[lighter_pixel2]);
drawn=2;
MoveSize(0,0,-1,-1);
pause(3);
GetBackground();
MoveSize(WIN_X,WIN_Y,-1,-1);
drawn=1;
}
#endif
DrawBar(WIN_SIZE_X,0, 1, WIN_SIZE_Y, 0x333333);
WriteText(TEXT_X-1,TEXT_Y, 0x80, 0,#param); //òåíü
WriteText(TEXT_X+1,TEXT_Y, 0x80, 0,#param);
WriteText(TEXT_X,TEXT_Y-1, 0x80, 0,#param);
WriteText(TEXT_X,TEXT_Y+1, 0x80, 0,#param);
WriteText(TEXT_X-1,TEXT_Y-1, 0x80, 0,#param);
WriteText(TEXT_X+1,TEXT_Y+1, 0x80, 0,#param);
WriteText(TEXT_X-1,TEXT_Y+1, 0x80, 0,#param);
WriteText(TEXT_X+1,TEXT_Y-1, 0x80, 0,#param);
DefineButton(0,0, WIN_SIZE_X, WIN_SIZE_Y, 1+BT_HIDE+BT_NOFRAME, 0);
WriteText(TEXT_X,TEXT_Y, 0x80, 0xFFFfff,#param);
_PutImage(0,0,WIN_SIZE_X,WIN_SIZE_Y,shadow_buf);
PutPixel(0,0,ESDWORD[lighter_pixel1]);
PutPixel(0,WIN_SIZE_Y-1,ESDWORD[lighter_pixel2]);
DrawBar(WIN_SIZE_X,0, 1, WIN_SIZE_Y, 0x333333);
PutText(TEXT_X-1,TEXT_Y+1);
PutText(TEXT_X-1,TEXT_Y-1);
PutText(TEXT_X-1,TEXT_Y );
PutText(TEXT_X+1,TEXT_Y-1);
PutText(TEXT_X+1,TEXT_Y );
PutText(TEXT_X+1,TEXT_Y+1);
PutText(TEXT_X, TEXT_Y+1);
PutText(TEXT_X, TEXT_Y-1);
WriteText(TEXT_X, TEXT_Y, 0x80, 0xFFFfff, #param);
if (drawn==0) drawn=1;
break;
default:
ExitProcess();
@ -103,20 +124,4 @@ void main()
}
:void draw_grid()
{
int x, y;
for (y=0; y<=WIN_SIZE_Y; y++)
{
for (x=0; x<=WIN_SIZE_X; x++)
{
if (! y&1) && (! x&1) PutPixel(x, y, 0);
if ( y&1) && ( x&1) PutPixel(x, y, 0);
}
}
}
stop: