Scale fonts by float values and filter them if texture filtering is on; Another fix for the code flow in change_res() as the check for minimal custom resolution always failed
This commit is contained in:
parent
7e1141a881
commit
cf147bcd4c
67
2d/font.c
67
2d/font.c
|
@ -37,8 +37,8 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#endif
|
||||
#include "console.h"
|
||||
|
||||
#define FONTSCALE_X(x) ((x)*(FNTScaleX))
|
||||
#define FONTSCALE_Y(x) ((x)*(FNTScaleY))
|
||||
#define FONTSCALE_X(x) ((float)(x)*(FNTScaleX))
|
||||
#define FONTSCALE_Y(x) ((float)(x)*(FNTScaleY))
|
||||
|
||||
#define BITS_TO_BYTES(x) (((x)+7)>>3)
|
||||
|
||||
|
@ -530,18 +530,18 @@ void ogl_font_choose_size(grs_font * font,int gap,int *rw,int *rh){
|
|||
Error("couldn't fit font?\n");
|
||||
}
|
||||
|
||||
void ogl_init_font(grs_font * font){
|
||||
int oglflags = OGL_FLAG_ALPHA;
|
||||
void ogl_init_font(grs_font * font)
|
||||
{
|
||||
int oglflags = OGL_FLAG_ALPHA | OGL_FLAG_MIPMAP;
|
||||
int nchars = font->ft_maxchar-font->ft_minchar+1;
|
||||
int i,w,h,tw,th,x,y,curx=0,cury=0;
|
||||
unsigned char *fp;
|
||||
// char data[32*32*4];
|
||||
ubyte *data;
|
||||
int gap=0;//having a gap just wastes ram, since we don't filter text textures at all.
|
||||
// char s[2];
|
||||
int gap=1; // x/y offset between the chars so we can filter
|
||||
|
||||
ogl_font_choose_size(font,gap,&tw,&th);
|
||||
data=d_malloc(tw*th);
|
||||
memset(data, 0, tw * th);
|
||||
memset(data, TRANSPARENCY_COLOR, tw * th); // map the whole data with transparency so we won't have borders if using gap
|
||||
gr_init_bitmap(&font->ft_parent_bitmap,BM_LINEAR,0,0,tw,th,tw,data);
|
||||
gr_set_transparent(&font->ft_parent_bitmap, 1);
|
||||
|
||||
|
@ -552,36 +552,62 @@ void ogl_init_font(grs_font * font){
|
|||
font->ft_bitmaps=(grs_bitmap*)d_malloc( nchars * sizeof(grs_bitmap));
|
||||
h=font->ft_h;
|
||||
|
||||
for(i=0;i<nchars;i++){
|
||||
for(i=0;i<nchars;i++)
|
||||
{
|
||||
if (font->ft_flags & FT_PROPORTIONAL)
|
||||
w=font->ft_widths[i];
|
||||
else
|
||||
w=font->ft_w;
|
||||
|
||||
if (w<1 || w>256){
|
||||
if (w<1 || w>256)
|
||||
continue;
|
||||
}
|
||||
if (curx+w+gap>tw){
|
||||
|
||||
if (curx+w+gap>tw)
|
||||
{
|
||||
cury+=h+gap;
|
||||
curx=0;
|
||||
}
|
||||
|
||||
if (cury+h>th)
|
||||
Error("font doesn't really fit (%i/%i)?\n",i,nchars);
|
||||
if (font->ft_flags & FT_COLOR) {
|
||||
|
||||
if (font->ft_flags & FT_COLOR)
|
||||
{
|
||||
if (font->ft_flags & FT_PROPORTIONAL)
|
||||
fp = font->ft_chars[i];
|
||||
else
|
||||
fp = font->ft_data + i * w*h;
|
||||
for (y=0;y<h;y++)
|
||||
for (x=0;x<w;x++){
|
||||
{
|
||||
for (x=0;x<w;x++)
|
||||
{
|
||||
font->ft_parent_bitmap.bm_data[curx+x+(cury+y)*tw]=fp[x+y*w];
|
||||
}
|
||||
// Let's call this a HACK:
|
||||
// If we filter the fonts, the sliders will be messed up as the border pixels will have an
|
||||
// alpha value while filtering. So the slider bitmaps will not look "connected".
|
||||
// To prevent this, duplicate the first/last pixel-row with a 1-pixel offset.
|
||||
if (gap && i >= 99 && i <= 102)
|
||||
{
|
||||
// See which bitmaps need left/right shifts:
|
||||
// 99 = SLIDER_LEFT - shift RIGHT
|
||||
// 100 = SLIDER_RIGHT - shift LEFT
|
||||
// 101 = SLIDER_MIDDLE - shift LEFT+RIGHT
|
||||
// 102 = SLIDER_MARKER - shift RIGHT
|
||||
|
||||
// gr_init_bitmap(&font->ft_bitmaps[i],BM_LINEAR,0,0,w,h,w,font->);
|
||||
}else{
|
||||
// shift left border
|
||||
if (x==0 && i != 99 && i != 102)
|
||||
font->ft_parent_bitmap.bm_data[(curx+x+(cury+y)*tw)-1]=fp[x+y*w];
|
||||
|
||||
// shift right border
|
||||
if (x==w-1 && i != 100)
|
||||
font->ft_parent_bitmap.bm_data[(curx+x+(cury+y)*tw)+1]=fp[x+y*w];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int BitMask,bits=0,white=gr_find_closest_color(63,63,63);
|
||||
// if (w*h>sizeof(data))
|
||||
// Error("ogl_init_font: toobig\n");
|
||||
if (font->ft_flags & FT_PROPORTIONAL)
|
||||
fp = font->ft_chars[i];
|
||||
else
|
||||
|
@ -604,7 +630,6 @@ void ogl_init_font(grs_font * font){
|
|||
}
|
||||
}
|
||||
gr_init_sub_bitmap(&font->ft_bitmaps[i],&font->ft_parent_bitmap,curx,cury,w,h);
|
||||
|
||||
curx+=w+gap;
|
||||
}
|
||||
ogl_loadbmtexture_f(&font->ft_parent_bitmap, oglflags);
|
||||
|
@ -655,7 +680,7 @@ int ogl_internal_string(int x, int y, char *s )
|
|||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (grd_curcanv->cv_font->ft_flags&FT_COLOR)
|
||||
ogl_ubitmapm_cs(xx,yy,FONTSCALE_X(grd_curcanv->cv_font->ft_widths[letter]),FONTSCALE_Y(grd_curcanv->cv_font->ft_h),&grd_curcanv->cv_font->ft_bitmaps[letter],-1,F1_0);
|
||||
else{
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
D1X-Rebirth Changelog
|
||||
|
||||
20081029
|
||||
--------
|
||||
2d/font.c, main/gamefont.c, main/gamefont.h, main/menu.c: Scale fonts by float values and filter them if texture filtering is on; Another fix for the code flow in change_res() as the check for minimal custom resolution always failed
|
||||
|
||||
20081028
|
||||
--------
|
||||
arch/ogl.c, include/gr.h, main/game.c, main/gauges.c, main/gauges.h, main/newmenu.c: Removed hack for Cockpit-window transparencies and added function to decode and add alpha to the bitmap directly (now works in non-OGL as well); Using sub-bitmaps for Cockpit-windows and menu backgrounds; Cleaned old bkg stuff from menu GUI
|
||||
|
|
|
@ -84,9 +84,16 @@ int Ugly_robot_texture = 0;
|
|||
|
||||
#define STANDARD_EXPL_DELAY (f1_0/4)
|
||||
|
||||
//##void collide_fireball_and_wall(object *fireball,fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt) {
|
||||
//## return;
|
||||
//##}
|
||||
int check_collision_sound_exec()
|
||||
{
|
||||
static int last_play_time=0;
|
||||
if (last_play_time + (F1_0/3) < GameTime || last_play_time > GameTime)
|
||||
{
|
||||
last_play_time = GameTime;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------
|
||||
// The only reason this routine is called (as of 10/12/94) is so Brain guys can open doors.
|
||||
|
@ -653,7 +660,7 @@ void collide_robot_and_player( object * robot, object * player, vms_vector *coll
|
|||
multi_robot_request_change(robot, player->id);
|
||||
#endif
|
||||
#endif
|
||||
if (FixedStep & EPS4)
|
||||
if (check_collision_sound_exec())
|
||||
digi_link_sound_to_pos( SOUND_ROBOT_HIT_PLAYER, player->segnum, 0, collision_point, 0, F1_0 );
|
||||
|
||||
bump_two_objects(robot, player, 1);
|
||||
|
@ -743,7 +750,7 @@ void collide_player_and_controlcen( object * controlcen, object * player, vms_ve
|
|||
ai_do_cloak_stuff(); // In case player cloaked, make control center know where he is.
|
||||
}
|
||||
|
||||
if (FixedStep & EPS4)
|
||||
if (check_collision_sound_exec())
|
||||
digi_link_sound_to_pos( SOUND_ROBOT_HIT_PLAYER, player->segnum, 0, collision_point, 0, F1_0 );
|
||||
|
||||
bump_two_objects(controlcen, player, 1);
|
||||
|
@ -1014,7 +1021,7 @@ void collide_hostage_and_player( object * hostage, object * player, vms_vector *
|
|||
//##}
|
||||
|
||||
void collide_player_and_player( object * player1, object * player2, vms_vector *collision_point ) {
|
||||
if (FixedStep & EPS4)
|
||||
if (check_collision_sound_exec())
|
||||
digi_link_sound_to_pos( SOUND_ROBOT_HIT_PLAYER, player1->segnum, 0, collision_point, 0, F1_0 );
|
||||
|
||||
bump_two_objects(player1, player2, 1);
|
||||
|
@ -1362,7 +1369,7 @@ void collide_player_and_powerup( object * player, object * powerup, vms_vector *
|
|||
//##}
|
||||
|
||||
void collide_player_and_clutter( object * player, object * clutter, vms_vector *collision_point ) {
|
||||
if (FixedStep & EPS4)
|
||||
if (check_collision_sound_exec())
|
||||
digi_link_sound_to_pos( SOUND_ROBOT_HIT_PLAYER, player->segnum, 0, collision_point, 0, F1_0 );
|
||||
|
||||
bump_two_objects(clutter, player, 1);
|
||||
|
|
|
@ -48,7 +48,7 @@ char * Gamefont_filenames_h[] = {
|
|||
grs_font *Gamefonts[MAX_FONTS];
|
||||
|
||||
int Gamefont_installed=0;
|
||||
int FNTScaleX = 1, FNTScaleY = 1;
|
||||
float FNTScaleX = 1, FNTScaleY = 1;
|
||||
|
||||
//code to allow variable GAME_FONT, added 10/7/99 Matt Mueller - updated 11/18/99 to handle all fonts, not just GFONT_SMALL
|
||||
// take scry into account? how/when?
|
||||
|
@ -113,14 +113,14 @@ void gamefont_choose_game_font(int scrx,int scry){
|
|||
#ifdef OGL
|
||||
if (!GameArg.OglFixedFont)
|
||||
{
|
||||
FNTScaleX = (float)scrx/font_conf[gf].font[m].x;
|
||||
FNTScaleY = (float)scry/font_conf[gf].font[m].y;
|
||||
if (GameArg.OglFixedFontWidth)
|
||||
{
|
||||
FNTScaleX = FNTScaleY = scry/font_conf[gf].font[m].y;
|
||||
}
|
||||
else
|
||||
{
|
||||
FNTScaleX = scrx/font_conf[gf].font[m].x;
|
||||
FNTScaleY = scry/font_conf[gf].font[m].y;
|
||||
if (FNTScaleY < FNTScaleX)
|
||||
FNTScaleX = FNTScaleY;
|
||||
else if (FNTScaleX < FNTScaleY)
|
||||
FNTScaleY = FNTScaleX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -43,12 +43,12 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
|
||||
#define MAX_FONTS 5
|
||||
|
||||
extern int FNTScaleX, FNTScaleY;
|
||||
extern float FNTScaleX, FNTScaleY;
|
||||
|
||||
// add (scaled) spacing to given font coordinate
|
||||
#define FSPACX(x) ((x)*(FNTScaleX*(GAME_FONT->ft_w/7)))
|
||||
#define FSPACY(y) ((y)*(FNTScaleY*(GAME_FONT->ft_h/5)))
|
||||
#define LINE_SPACING (FNTScaleY*(grd_curcanv->cv_font->ft_h+(GAME_FONT->ft_h/5)))
|
||||
#define FSPACX(x) ((float)(x)*(FNTScaleX*(GAME_FONT->ft_w/7)))
|
||||
#define FSPACY(y) ((float)(y)*(FNTScaleY*(GAME_FONT->ft_h/5)))
|
||||
#define LINE_SPACING ((float)FNTScaleY*(grd_curcanv->cv_font->ft_h+(GAME_FONT->ft_h/5)))
|
||||
|
||||
extern grs_font *Gamefonts[MAX_FONTS];
|
||||
|
||||
|
|
|
@ -530,12 +530,12 @@ void change_res()
|
|||
if (!strchr(customres, 'x'))
|
||||
return;
|
||||
|
||||
screen_mode = SM(atoi(customres), atoi(strchr(customres, 'x')+1));
|
||||
if (SM_W(screen_mode) < 320 || SM_H(screen_mode) < 200) // oh oh - the resolution is too small. Revert!
|
||||
{
|
||||
nm_messagebox( TXT_WARNING, 1, "OK", "Entered resolution is too small.\nReverting ..." );
|
||||
return;
|
||||
}
|
||||
screen_mode = SM(atoi(customres), atoi(strchr(customres, 'x')+1));
|
||||
if (strchr(aspect, 'x')) // we even have a custom aspect set up
|
||||
{
|
||||
aspect_mode = SM(atoi(aspect), atoi(strchr(aspect, 'x')+1));
|
||||
|
|
Loading…
Reference in a new issue