engine.c
来自「SEAL是DOS 下的32位保护模式的GUI程序」· C语言 代码 · 共 979 行 · 第 1/2 页
C
979 行
/******************************************************************
* SEAL 2.0 *
* Copyright (c) 1999-2002 SEAL Developers. All Rights Reserved. *
* *
* Web site: http://sealsystem.sourceforge.net/ *
* E-mail (current maintainer): orudge@users.sourceforge.net *
******************************************************************/
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define NEW_ALLEGRO
#define __MAIN_INCLUDED__
#include <allegro.h>
#include <allegro/internal/aintern.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <io.h>
#include <mss.h>
#include <zlib.h> // OCR - 05/04/2002
#define new_menu_item2(name,param,hk,msg,it,enable,img,next) new_menu_item_ex(name, param, hk, msg, enable, it, 0, NULL, img, NULL, 0, next)
#define new_sub_menu2(name,menu,enable,img,next) new_sub_menu_ex(name, enable, NULL, NULL, img, NULL, 0, menu, next)
////////////////////// H ////////////////////////////////////
#include <engine.h>
l_text TXT[] = { NULL };
l_text SealApi = "SEAL";
l_text SealApiCopyright = "Copyright (c) 1999-2000 Michal Stencl, Copyright (c) 2001-2002 SEAL Developers. All Rights Reserved.";
l_int SealApiVersion = 200011; // 2.00.011
l_text SealApiTxtVersion = "2.00.11";
l_bool safe_mode = 0;
/////////////////////////////////////////////////////////////
#ifndef BUFFER_FORMAT_TEXT
#define BUFFER_FORMAT_TEXT 1024
#endif
#ifndef TEXTOUT_BUFFER_SIZE
#define TEXTOUT_BUFFER_SIZE 1024
#endif
#ifndef FIFO_BUFFER_SIZE
#define FIFO_BUFFER_SIZE 512
#endif
FILE *seal_debug_file = NULL;
l_int DEBUG_printf ( l_text text, ...)
{
l_int nc = 0;
va_list arg;
if ( !seal_debug_file ) return 0;
va_start(arg, text);
nc = vfprintf(seal_debug_file, text, arg);
va_end(arg);
fflush(seal_debug_file);
return nc;
};
/////////////////////////////////////////////////////////////
l_int (*seal_error) ( l_int errtype, l_text str, ... );
/////////////////////////////////////////////////////////////
void RunAllRegistryEntries ( l_text rootkey, void(*callbak)(l_text) );
FILE *_fopen (l_text x, l_text y) { return fopen(x,y); };
void _fclose (FILE *f) { fclose(f); };
#define fopen(x,y) SealFileOpen(x,y)
//#define fclose(x) SealFileClose(x)
l_int font_smooth = 1;
l_int translucide = 0;
#include <object.h>
#include <safmem.h> // Safe Memory functions by Michal Stencl
//#include"text.c" // Text manipulation
#include<registry.h> // Registry functions by BadSector
#include<dataini.h> // DataIni function by Michal Stencl
//#include"object\filter.c" // Data flters
#include <filter.h>
//#include"object\rect.c" // Position and origin runtimes ...
//#include"object\object.c" // Object Run times ...
#include "alleg.c" // Allegro and its expensions
//#include"grfx-f.c" // GRFX advanced grafics functions
#include "grfx-f.h"
extern PALETTE Gr_pal;
//#include"txts.c"
#include "txts.h"
//#include"colors.c"
#include "colors.h"
//#include"bmps.c"
#include "bmps.h"
//#include"skin.c"
#include "skin.h"
//#include"drivers.c"
#include "drivers.h"
#include "savescr.h"
#include "screen.h"
#define SFA_INCLUDE_STANDARD_DRIVERS
#include "sound.h"
//#include"list.c" // Lists functions by Michal Stencl
#include "list.h"
#include<view.h> // View Run times ...
//#include"lnk.c" // LNK system
#include "lnk.h"
//#include"files.c" // Files manager functions by Julien Etelain
#include "files.h"
//#include"vfile.c" // Virtual File System by Julien Etelain
#include "vfile.h"
//#include"ico.c" // ICO and CUR files loader by Julien Etelain
#include "ico.h"
//#include"stimer.c" // Safe timer functions
#include "stimer.h"
//#include"controls\grfx.c"
#include "grfx.h"
#include <button.h>
//#include"controls\window.c"
#include "window.h"
#include<stattext.h>
#include<app.h>
#include<scroller.h>
#include<menus.h>
#include<dialogs.h>
#include<iodlg.h>
#include<editor.h>
#include<treeview.h>
#include<checkbox.h>
//#include"tips.c"
//#include"xdldata.c"
#include <inputbox.h>
#include <trackbar.h>
#include <seal/tabbook.h>
#include <compat.h>
static l_text app_about_appname;
static void redraw_about_dialog(p_view v);
static BITMAP *app_about_bmp;
void seal2_app_about(l_text appname, BITMAP *icon)
{
p_appwin winAbout;
p_button btnClose;
p_view vInfo;
l_dword msg = MSG_NOTHING;
l_text title;
title = set_format_text(NULL, "About %s", appname);
app_about_appname = appname;
if (icon == NULL)
app_about_bmp = load_image("/system/bmp/app.ico,32");
else
app_about_bmp = icon;
winAbout = appwin_init(_malloc(sizeof(t_appwin)),
rect_assign(0, 0, 310, 175),
title,
NULL, NULL, NULL);
if (winAbout) VIEW(winAbout)->align |= TX_ALIGN_CENTER;
WINDOW(winAbout)->flags -= WF_SYSMENU;
OBJECT(desktop)->insert(OBJECT(desktop), OBJECT(winAbout));
btnClose = button_init(_malloc(sizeof(t_button)),
rect_assign(118, 140, 200, 165),
TXT_OK, MSG_OK, BF_NORMAL);
OBJECT(winAbout)->insert(OBJECT(winAbout), OBJECT(btnClose));
vInfo = view_init(_malloc(sizeof(t_view)),
rect_assign(0, 0, 310, 140));
VIEW(vInfo)->draw = &redraw_about_dialog;
OBJECT(winAbout)->insert(OBJECT(winAbout), OBJECT(vInfo));
msg = desktop->execute_view(desktop, VIEW(winAbout));
dispose(OBJECT(winAbout));
}
static void redraw_about_dialog(p_view v)
{
l_int x;
t_point p;
t_rect r = v->size_limits(v);
BITMAP *out = v->begin_paint(v, &p, r);
if (out)
{
if (!use_skins)
rectfill(out, p.x, p.y, p.x+310, p.y+175, color_3d_face);
masked_blit(app_about_bmp, out, 0, 0, p.x + 15, p.y + 30, 32, 32);
textout_printf(out, v->font, -1,
p.x+65, p.y+30, p.x+310, p.y+115,
TX_ALIGN_LEFT, color_3d_text, TX_NOCOLOR, 0,
"SEAL %s\n%s\n\nCopyright \xA9 1999-2002 SEAL Developers.\nAll Rights Reserved.\n\nE-mail: orudge@users.sourceforge.net\nWeb site: http://sealsystem.sourceforge.net/", SealApiTxtVersion, app_about_appname);
};
v->end_of_paint(v, r);
}
/////////////////////////////////////////////////////////////
void RunAllRegistryEntries ( l_text rootkey, void(*callbak)(l_text) ) {
l_text filedlx;
p_registry_search inf = (p_registry_search) malloc(sizeof(t_registry_search));
DEBUG_printf ( "\n - Run all registry entries from '%s'\n", rootkey );
if ( reg_find_first(rootkey, inf) ) do {
if ( callbak ) {
l_text s = (char *) malloc(2048);
l_text s2 = key_in_path(inf->name, "title");
if (key_exists(s2)) strcpy(s, get_key(s2)); else strcpy(s, get_key(inf->name));
callbak ( s );
_free(s2);
_free(s);
};
filedlx = get_key(inf->name);
DEBUG_printf (" Run :: %s\n", filedlx );
run_file(filedlx);
free(filedlx);
} while (reg_find_next(inf));
};
/////////////////////////////////////////////////////////////
void ListLoadedApp ( void ) {
DEBUG_printf("Loaded XDL list :\n");
DEBUG_printf(" XDL no[id] : [appname] ([filename]) by [manufacturer]\n");
if ( listapp && listapp->last ) {
p_item x = listapp->first(listapp);
p_item f = x;
if ( f )
do {
p_app o = ((p_app)(x->rec));
DEBUG_printf (" XDL no %d %d : %s (%s) by %s\n",o->id ,o->appname,o->filename,o->manufacturer);
x = x->next;
} while ( x != f );
};
};
/////////////////////////////////////////////////////////////
l_int txt_seal_error ( l_int errtype, l_text str, ... )
{
switch ( errtype ) {
case ERR_NONREGULAR : {
va_list argptr;
va_start(argptr, str);
printf("\nError :\n");
vprintf(str, argptr);
va_end(argptr);
return 0;
}; break;
case ERR_INFO : {
va_list argptr;
va_start(argptr, str);
printf("\nError :\n");
vprintf(str, argptr);
va_end(argptr);
return 1;
}; break;
};
return 0;
};
/////////////////////////////////////////////////////////////
#include<djc.h> // All Djgpp functions declaration
/////////////////////////////////////////////////////////////
#include"engine.exp" // Dlx export functions table
////////////////////////////////////////////////////////////////////////////////
l_big event_timer = 0;
p_object event_stop = NULL;
t_event event_main;
l_bool go_process = true;
t_data clipboard;
/* the main program object */
l_int task_tick = 20;
/* the main program object */
t_object program;
/* list of objects that use OB_OF_STILLPROCESS option flag */
t_list stillprocess_list;
/* drivers, the main object for drivers, such as keyboard, mouse, ... */
p_drivers drivers = NULL;
/* destkop, the main object of visible objects */
p_view desktop = NULL;
/* define if clock-cursor must be included */
l_int clock_including = 0;
/* contains queue of events ( if you use put_event function ) */
static t_event event_panding;
/* saves the last time of caling program_translate_event function */
static l_big event_oldtimer;
/* insert event to event queue */
void program_put_event ( t_object *o, t_event *event )
{
event_panding = (*event);
};
////////////////////////////////////////////////////////////////////////////////
/*
insert object (s) to stillprocess objects
return 1, if all is OK
return 0, on error
*/
int program_put_into_stillprocess ( p_object o, p_object s )
{
if ( stillprocess_list.insert(&stillprocess_list, s) != -1 )
return 1;
return 0;
};
////////////////////////////////////////////////////////////////////////////////
/*
clear object (s) from stillprocess objects
return 1, if everything is OK
return 0, on error
*/
int program_clear_from_stillprocess ( p_object o, p_object s )
{
p_item p = stillprocess_list.find_rec(&stillprocess_list, s);
if ( p ) {
stillprocess_list.remove_item(&stillprocess_list, p);
return 1;
};
return 0;
};
////////////////////////////////////////////////////////////////////////////////
/*
main get_event function.
- get last event from event's queue
*/
void program_get_event ( t_object *o, t_event *event )
{
STOP_PROCESS();
clear_event(event);
/* save the last time of calling */
event_oldtimer = time_get_mili();
if ( event_panding.type != EV_NOTHING ) { /* something in queue */
(*event) = event_panding; /* new event will contain last from queue */
clear_event(&event_panding); /* clear queue */
} else { /* nothing in queue */
if ( drivers ) { /* drivers exists */
/* call each object in drivers object */
((p_object)drivers)->translate_event((p_object)drivers, event);
};
};
START_PROCESS();
/* call each stillprocess object */
program_call_each_stillprocess(&stillprocess_list);
};
////////////////////////////////////////////////////////////////////////////////
l_int scr_shots = 1;
void fast_scr_shot ( void ) {
BITMAP *scr = create_bitmap(screen_width, screen_height);
if ( scr ) {
l_text file = set_format_text(NULL,"shot%d.bmp",scr_shots);
if ( file ) {
blit(screen,scr,0,0,0,0,screen_width,screen_height);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?