summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-18 17:47:21 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-18 17:47:21 +0000
commit8b88fbd2166388611430cf0036e988b3e24adbd4 (patch)
treebdc145d04d6c16ce8dbd549a7f1ae2bf0da17d00 /crawl-ref
parent1b7d49de6031caab5a0ef6210ebb3e7c6b625d5c (diff)
downloadcrawl-ref-8b88fbd2166388611430cf0036e988b3e24adbd4.tar.gz
crawl-ref-8b88fbd2166388611430cf0036e988b3e24adbd4.zip
Making mouse-over region larger on Linux.
Reformatting mouse-over messages to be consistent. More tile code cleanup and dead code removal. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3299 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/libgui.cc56
-rw-r--r--crawl-ref/source/libx11.cc115
-rw-r--r--crawl-ref/source/tile2.cc111
-rw-r--r--crawl-ref/source/tiles.h49
4 files changed, 135 insertions, 196 deletions
diff --git a/crawl-ref/source/libgui.cc b/crawl-ref/source/libgui.cc
index b8c5ab4881..6817a9db38 100644
--- a/crawl-ref/source/libgui.cc
+++ b/crawl-ref/source/libgui.cc
@@ -9,9 +9,6 @@
*
*/
-#define deblog(x) {FILE *ddfp=fopen("log.txt","a");fprintf(ddfp,x);fprintf(ddfp,"\n");fclose(ddfp);}
-#define deblog2(x,y) {FILE *ddfp=fopen("log.txt","a");fprintf(ddfp,"%s %d\n",x,y);fclose(ddfp);}
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -78,9 +75,6 @@ img_type TileImg, TileIsoImg;
img_type PlayerImg;
img_type WallImg;
-extern bool force_redraw_tile;
-extern bool force_redraw_inv;
-
// for item use gui
#define MAX_ITEMLIST 60
extern int itemlist[MAX_ITEMLIST];
@@ -620,7 +614,8 @@ void libgui_init()
}
#elif defined(USE_X11)
- region_tip = new TextRegionClass(region_stat->mx, 1, 0, 0);
+ const unsigned int region_tip_height = 3;
+ region_tip = new TextRegionClass(region_stat->mx, region_tip_height, 0, 0);
region_tip->id = REGION_TIP;
region_crt->init_font(font_name);
@@ -996,14 +991,14 @@ void edit_prefs()
if (upd_dngn)
{
region_tile -> resize_backbuf();
- force_redraw_tile = true;
+ tile_set_force_redraw_tiles(true);
TileResizeScreen(dngn_x, dngn_y);
}
if (region_item)
region_item->resize_backbuf();
if (region_item2)
region_item2->resize_backbuf();
- force_redraw_inv = true;
+ tile_set_force_redraw_inv(true);
tile_draw_inv(-1, REGION_INV1);
region_map->force_redraw = true;
@@ -1237,7 +1232,7 @@ static int handle_mouse_motion(int mouse_x, int mouse_y, bool init)
}
desc += mitm[ix].name(DESC_NOCAP_A);
if (display_actions)
- desc += EOL "[L-Click] *Pickup(g)";
+ desc += EOL "[L-Click] Pick up (g)";
}
else
{
@@ -1278,69 +1273,69 @@ static int handle_mouse_motion(int mouse_x, int mouse_y, bool init)
case OBJ_WEAPONS:
case OBJ_STAVES:
case OBJ_MISCELLANY:
- desc += "*(w)ield";
+ desc += "Wield (w)";
break;
case OBJ_WEAPONS + 18:
- desc += "unwield";
+ desc += "Unwield";
break;
case OBJ_MISCELLANY + 18:
if (you.inv[ix].sub_type >= MISC_DECK_OF_ESCAPE
&& you.inv[ix].sub_type <= MISC_DECK_OF_DEFENSE)
{
- desc += "draw a card";
+ desc += "Draw a card (E)";
break;
}
// else fall-through
case OBJ_STAVES + 18: // rods - other staves handled above
- desc += "*(E)voke";
+ desc += "Evoke (E)";
break;
case OBJ_ARMOUR:
- desc += "*(W)ear";
+ desc += "Wear (W)";
break;
case OBJ_ARMOUR + 18:
- desc += "*(T)ake off";
+ desc += "Take off (T)";
break;
case OBJ_JEWELLERY:
- desc += "*(P)ut on";
+ desc += "Put on (P)";
break;
case OBJ_JEWELLERY + 18:
- desc += "*(R)emove";
+ desc += "Remove (R)";
break;
case OBJ_MISSILES:
- desc += "*(t)hrow";
+ desc += "Throw (t)";
break;
case OBJ_WANDS:
- desc += "*(z)ap";
+ desc += "Zap (z)";
break;
case OBJ_BOOKS:
if (item_type_known(you.inv[ix])
&& you.inv[ix].sub_type != BOOK_MANUAL
&& you.inv[ix].sub_type != BOOK_DESTRUCTION)
{
- desc += "*(M)emorize";
+ desc += "Memorize (M)";
break;
}
// else fall-through
case OBJ_SCROLLS:
- desc += "*(r)ead";
+ desc += "Read (r)";
break;
case OBJ_POTIONS:
- desc += "*(q)uaff";
+ desc += "Quaff (q)";
break;
case OBJ_FOOD:
- desc += "*(e)at";
+ desc += "Eat (e)";
break;
case OBJ_CORPSES:
if (you.species == SP_VAMPIRE)
- desc += "drink blood";
+ desc += "Drink blood (e)";
break;
default:
- desc += "*Use it";
+ desc += "Use";
}
}
desc += EOL "[R-Click] Info";
- desc += EOL "[Shift-L-Click] *(d)rop";
+ desc += EOL "[Shift-L-Click] Drop (d)";
}
}
update_tip_text(desc.c_str());
@@ -1402,13 +1397,13 @@ static int handle_mouse_motion(int mouse_x, int mouse_y, bool init)
desc += get_class_abbrev(you.char_class);
desc += ")" EOL;
- desc += EOL "[L-Click] *Search 1 turn(s)";
+ desc += EOL "[L-Click] Search 1 turn";
if (grid_stair_direction( grd[gx][gy] ) != CMD_NO_CMD)
desc += EOL "[Shift-L-Click] use stairs (</>)";
// character overview
- desc += EOL "[R-Click] Overview(%)";
+ desc += EOL "[R-Click] Overview (%)";
// Religion
if (you.religion != GOD_NO_GOD)
@@ -1451,7 +1446,7 @@ static int handle_mouse_motion(int mouse_x, int mouse_y, bool init)
if (mode == REGION_STAT && mouse_mode == MOUSE_MODE_COMMAND)
{
if (oldmode != REGION_STAT)
- update_tip_text("[L-Click] Rest/Search for a while");
+ update_tip_text("[L-Click] Rest / Search for a while");
oldmode = mode;
oldcx = cx;
oldcy = cy;
@@ -1460,6 +1455,7 @@ static int handle_mouse_motion(int mouse_x, int mouse_y, bool init)
return 0;
}
+
static int handle_mouse_button(int mx, int my, int button,
bool shift, bool ctrl)
{
diff --git a/crawl-ref/source/libx11.cc b/crawl-ref/source/libx11.cc
index cf291db862..2bc75e3ac6 100644
--- a/crawl-ref/source/libx11.cc
+++ b/crawl-ref/source/libx11.cc
@@ -116,90 +116,91 @@ int my_getenv_int(const char *envname, int def)
return atoi(rstr);
}
-#if 0
-void libgui_load_prefs(struct pref_data *pref, int nprefs)
-{
- int i;
- strcpy(font_name, my_getenv("CRAWL_X11_FONT",
- "-alias-fixed-bold-r-normal--16-*"));
- strcpy(font_name, my_getenv("CRAWL_X11_FONT", "9x15"));
- *crt_x = my_getenv_int("CRAWL_X11_CRTX",80);
- *crt_y = my_getenv_int("CRAWL_X11_CRTY",25);
- *msg_x = my_getenv_int("CRAWL_X11_MSGX",80);
- *msg_y = my_getenv_int("CRAWL_X11_MSGY",8);
- *map_x = my_getenv_int("CRAWL_X11_MAPX",3);
- *map_y = my_getenv_int("CRAWL_X11_MAPY",3);
- *dngn_x = my_getenv_int("CRAWL_X11_DNGNX",17);
- *dngn_y = my_getenv_int("CRAWL_X11_DNGNY",17);
-}
-
-void libgui_save_prefs()
-{
-}
-#endif
-
extern WinClass *win_main;
extern TextRegionClass *region_tip;
+extern TextRegionClass *region_crt;
void update_tip_text(const char *tip)
{
- static char newtip[512];
- static char oldtip[512];
- char tbuf[35];
+ const unsigned int tip_size = 512;
+ static char old_tip[tip_size];
+ char new_tip[tip_size];
- strncpy(newtip, tip, 500);
- char* pc = strchr(newtip, '\n');
- if (pc)
- *pc = 0;
-
- if (strncmp(oldtip, newtip, 500)==0)
+ if (strncmp(old_tip, tip, tip_size) == 0)
return;
- strncpy(oldtip, newtip, 500);
- strncpy(tbuf,tip,34);
- tbuf[34]=0;
+ const bool is_main_screen = (win_main->active_layer == 0);
+ const unsigned int height = is_main_screen ? region_tip->my : 1;
+ const unsigned int width = is_main_screen ? region_tip->mx : region_crt->mx;
+
+ strncpy(new_tip, tip, tip_size);
+ strncpy(old_tip, new_tip, tip_size);
+
+ if (is_main_screen)
+ {
+ region_tip->clear();
+ }
- if (win_main->active_layer == 0)
+ char *next_tip = new_tip;
+ for (unsigned int i = 0; next_tip && i < height; i++)
{
- // avoid overruns...
- if ((int)strlen(newtip) > region_tip->mx)
+ char *this_tip = next_tip;
+
+ // find end of line
+ char *pc = strchr(next_tip, '\n');
+ if (pc)
+ {
+ *pc = 0;
+ next_tip = pc + 1;
+ }
+ else
+ {
+ next_tip = 0;
+ }
+
+ if (strlen(this_tip) > width)
{
// try to remove inscriptions
- char *ins = strchr(newtip, '{');
- if (ins && ins[-1] == ' ') ins--;
- if (ins && (ins - newtip <= region_tip->mx))
+ char *ins = strchr(this_tip, '{');
+ if (ins && ins[-1] == ' ')
+ ins--;
+ if (ins && (ins - this_tip <= (int)width))
{
*ins = 0;
}
else
{
// try to remove state, e.g. "(worn)"
- char *state = strchr(newtip, '(');
- if (state && state[-1] == ' ') state--;
- if (state && (state - newtip <= region_tip->mx))
+ char *state = strchr(this_tip, '(');
+ if (state && state[-1] == ' ')
+ state--;
+ if (state && (state - this_tip <= (int)width))
{
*state = 0;
}
else
{
// if nothing else...
- newtip[region_tip->mx] = 0;
- newtip[region_tip->mx-1] = '.';
- newtip[region_tip->mx-2] = '.';
+ this_tip[width] = 0;
+ this_tip[width-1] = '.';
+ this_tip[width-2] = '.';
}
}
}
- region_tip->clear();
- region_tip->gotoxy(1,1);
- region_tip->addstr(newtip);
- region_tip->make_active();
- }
- else
- {
- textattr( WHITE );
- gotoxy(1, get_number_of_lines() + 1);
- cprintf("%s", oldtip);
- clear_to_end_of_line();
+ if (is_main_screen)
+ {
+ region_tip->gotoxy(1, 1 + i);
+ region_tip->addstr(this_tip);
+ region_tip->make_active();
+ }
+ else
+ {
+ ASSERT(i == 0);
+ textattr(WHITE);
+ gotoxy(1, get_number_of_lines() + 1);
+ cprintf("%s", this_tip);
+ clear_to_end_of_line();
+ }
}
}
diff --git a/crawl-ref/source/tile2.cc b/crawl-ref/source/tile2.cc
index ac2f808421..e5b9ebd716 100644
--- a/crawl-ref/source/tile2.cc
+++ b/crawl-ref/source/tile2.cc
@@ -54,7 +54,6 @@ static img_type DollCacheImg;
static void tile_draw_grid(int kind, int xx, int yy);
static void clear_tcache();
static void init_tcache();
-static void init_tileflag();
static void register_tile_mask(int tile, int region, int *cp,
char *ms, bool smalltile = false);
static void tcache_compose_normal(int ix, int *fg, int *bg);
@@ -63,8 +62,19 @@ static void mcache_init();
//Internal variables
-bool force_redraw_tile;
-bool force_redraw_inv = false;
+static bool force_redraw_tile = false;
+static bool force_redraw_inv = false;
+
+void tile_set_force_redraw_tiles(bool redraw)
+{
+ force_redraw_tile = redraw;
+}
+
+void tile_set_force_redraw_inv(bool redraw)
+{
+ force_redraw_inv = redraw;
+}
+
static unsigned short int t1buf[TILE_DAT_XMAX+2][TILE_DAT_YMAX+2],
t2buf[TILE_DAT_XMAX+2][TILE_DAT_YMAX+2];
static short unsigned int tb_bk[TILE_DAT_YMAX*TILE_DAT_XMAX*2];
@@ -154,19 +164,6 @@ const int tcache_ox_normal[TCACHE_KIND_NORMAL] = {0};
const int tcache_oy_normal[TCACHE_KIND_NORMAL] = {0};
const int tcache_nlayer_normal[TCACHE_KIND_NORMAL] = {1};
-unsigned char tile_flag[TILE_TOTAL2];
-#define TFLAG_A 0x80
-#define TFLAG_B 0x40
-#define TFLAG_C 0x20
-#define TFLAG_D 0x10
-#define TFLAG_F 0x08
-#define TFLAG_G 0x04
-#define TFLAG_H 0x02
-#define TFLAG_I 0x01
-
-#define tile_check_blank(tile,region) \
- if( (tile_flag[tile & TILE_FLAG_MASK]&(region))==0) (tile) &= ~TILE_FLAG_MASK;
-
#define TREGION_0_NORMAL 0
const int region_sx_normal[1]={0};
const int region_sy_normal[1]={0};
@@ -176,11 +173,6 @@ const int region_wy_normal[1]={TILE_Y};
// ISO mode sink mask
static char *sink_mask;
-/* BG tile priority */
-static unsigned char tile_prio[TILE_TOTAL2];
-#define PRIO_WALL 10
-#define tile_is_wall(tile) (tile_prio[(tile)&TILE_FLAG_MASK]==PRIO_WALL)
-
/********* Image manipulation subroutines ****************/
img_type ImgLoadFileSimple(const char *name)
{
@@ -315,7 +307,6 @@ void TileInit()
sink_mask = (char *)malloc(TILE_X*TILE_Y);
- init_tileflag();
init_tcache();
DollCacheImg = ImgCreateSimple(TILE_X, TILE_Y);
@@ -323,7 +314,7 @@ void TileInit()
for(x=0;x<TILE_DAT_XMAX+2;x++){
for(y=0;y<TILE_DAT_YMAX+2;y++){
t1buf[x][y]=0;
- t2buf[x][y]=simple_iso_tile(TILE_DNGN_UNSEEN)|TILE_FLAG_UNSEEN;
+ t2buf[x][y]=TILE_DNGN_UNSEEN|TILE_FLAG_UNSEEN;
}}
force_redraw_tile = false;
@@ -362,45 +353,6 @@ void TileResizeScreen(int x0, int y0)
crawl_view.vbuf.size(crawl_view.viewsz);
}
-/*** Investigate a region of specific tile whether it contains any
- picture, or it is blank ***/
-int init_tileflag_aux(int tile, int xs, int ys, int wx, int wy){
- int x,y, sx,sy;
- img_type src=TileImg;
-
- ASSERT(tile<TILE_TOTAL2);
-
- sx = tile % TILE_PER_ROW;
- sx *= TILE_X;
- sy = tile / TILE_PER_ROW;
- sy *= TILE_Y;
-
- for(x=xs;x<xs+wx;x++){
- for(y=ys;y<ys+wy;y++){
- if(!ImgIsTransparentAt(src, sx+x, sy+y))
- return 1;
- }}
- return 0;
-}
-
-void init_tileflag(){
- int tile, flag;
-
- for(tile=0;tile<TILE_TOTAL2;tile++){
- flag = 0;
- tile_flag[tile]=flag;
- tile_prio[tile]=0;
- }
-
- for(tile=0;tile<4;tile++)
- {
- tile_prio[simple_iso_tile(TILE_DNGN_LAVA)+tile]=2;
- tile_prio[simple_iso_tile(TILE_DNGN_SHALLOW_WATER)+tile]=2;
- tile_prio[simple_iso_tile(TILE_DNGN_DEEP_WATER)+tile]=3;
- }
-
-}
-
void clear_tcache(){
int i, k, h;
@@ -707,7 +659,7 @@ void redraw_spx_tcache(int tile)
void get_bbg(int bg, int *new_bg, int *bbg)
{
int bg0 = bg & TILE_FLAG_MASK;
- *bbg=simple_iso_tile(TILE_DNGN_FLOOR);
+ *bbg=TILE_DNGN_FLOOR;
*new_bg= bg0;
if(bg0 == TILE_DNGN_UNSEEN ||
@@ -726,24 +678,13 @@ int sink_mask_tile(int bg, int fg)
{
int bg0 = bg & TILE_FLAG_MASK;
- if (fg == 0 || (fg & TILE_FLAG_FLYING)!=0) return 0;
-/*
- if ( bg0 == simple_iso_tile(TILE_DNGN_SHALLOW_WATER))
- return TILE_MASK_SHALLOW_WATER;
- if ( bg0 == simple_iso_tile(TILE_DNGN_DEEP_WATER))
- return TILE_MASK_DEEP_WATER;
- if ( bg0 >= simple_iso_tile(TILE_DNGN_LAVA) &&
- bg0 <= simple_iso_tile(TILE_DNGN_LAVA)+3)
- return TILE_MASK_LAVA;
-*/
- if ( bg0 >= simple_iso_tile(TILE_DNGN_LAVA) &&
- bg0 <= simple_iso_tile(TILE_DNGN_SHALLOW_WATER) + 3)
- {
- int result = TILE_SINK_MASK;//simple_iso_tile(TILE_SINK_MASK);
- if ((fg & TILE_FLAG_MASK) >= TILE_NORMAL)
- result = simple_iso_tile(TILE_SINK_MASK);
- //if ((fg & TILE_FLAG_MASK) >= TILE_NORMAL) result++;
- return result;
+ if (fg == 0 || (fg & TILE_FLAG_FLYING) != 0)
+ return 0;
+
+ if ( bg0 >= TILE_DNGN_LAVA &&
+ bg0 <= TILE_DNGN_SHALLOW_WATER + 3)
+ {
+ return TILE_SINK_MASK;
}
return 0;
@@ -876,7 +817,8 @@ void LoadDungeonView(short unsigned int *tileb)
void TileDrawDungeon(short unsigned int *tileb)
{
int x, y, kind;
- if(!TileImg)return;
+ if(!TileImg)
+ return;
LoadDungeonView(tileb);
@@ -2061,7 +2003,7 @@ void TilePlayerEdit()
for(x=0;x<TILE_DAT_XMAX+2;x++){
for(y=0;y<TILE_DAT_YMAX+2;y++){
t1buf[x][y]=0;
- t2buf[x][y]=simple_iso_tile(TILE_DNGN_UNSEEN)|TILE_FLAG_UNSEEN;
+ t2buf[x][y]=TILE_DNGN_UNSEEN|TILE_FLAG_UNSEEN;
}}
for(k=0;k<tcache_kind;k++)
@@ -2285,9 +2227,6 @@ void TileInitItems()
ImgCopyFromTileImg(tile1, DollCacheImg, 0, 0, 0);
ImgCopyToTileImg (tile1, DollCacheImg, 0, 0, 1);
}
-
- //Hack: call it again
- init_tileflag();
}
// Monster weapon tile
diff --git a/crawl-ref/source/tiles.h b/crawl-ref/source/tiles.h
index 0a6ffdc7ea..dc04817f69 100644
--- a/crawl-ref/source/tiles.h
+++ b/crawl-ref/source/tiles.h
@@ -17,8 +17,6 @@ int tileidx_zap(int color);
int tile_idx_unseen_terrain(int x, int y, int what);
int tile_unseen_flag(const coord_def& gc);
-#define simple_iso_tile(x) (x)
-
// Player tile related
void tilep_race_default(int race, int gender, int level, int *parts);
void tilep_job_default(int job, int gender, int *parts);
@@ -67,6 +65,9 @@ int get_floor_tile_idx();
int get_floor_special_tile_idx();
void tile_init_flavor();
+void tile_set_force_redraw_tiles(bool redraw);
+void tile_set_force_redraw_inv(bool redraw);
+
/**************************************/
/* tile2.cc image manipulation */
/**************************************/
@@ -120,7 +121,6 @@ void TileInitItems();
// load wall tiles
void TileLoadWall(bool wizard);
-//�^�C�g��
void TileDrawTitle();
// monster+weapon tile
@@ -130,26 +130,29 @@ int get_base_idx_from_mcache(int tile_idx);
int get_clean_map_idx(int tile_idx);
/* Flags for drawing routines */
-// MAY_STAB, FLAG_STAB, and FLAG_PET are mutually exclusive
-#define TILE_FLAG_MAY_STAB 0xC000 // May stab brand is always fg
-#define TILE_FLAG_STAB 0x8000 // Stab brand is always fg
-#define TILE_FLAG_PET 0x4000 //pet is always fg
-
-#define TILE_FLAG_NET 0x2000 //nets are always in fg
-#define TILE_FLAG_FLYING 0x1000 //flying object is always fg
-#define TILE_FLAG_S_UNDER 0x800 //fg
-
-#define TILE_FLAG_CURSOR 0xc000 //cursor is always bg
-#define TILE_FLAG_CURSOR1 0x8000 //cursor is always bg
-#define TILE_FLAG_CURSOR2 0x4000 //cursor is always bg
-#define TILE_FLAG_CURSOR3 0xc000 //cursor is always bg
-#define TILE_FLAG_CURSOR0 0x0000 //cursor is always bg
-
-#define TILE_FLAG_UNSEEN 0x2000 //unseen flag is set to bg
-#define TILE_FLAG_MM_UNSEEN 0x1000
-#define TILE_FLAG_RAY 0x800
-
-#define TILE_FLAG_MASK 0x07ff
+enum tile_flags
+{
+ // Foreground flags
+ TILE_FLAG_S_UNDER = 0x00000800,
+ TILE_FLAG_FLYING = 0x00001000,
+ TILE_FLAG_NET = 0x00002000,
+ TILE_FLAG_PET = 0x00004000,
+ TILE_FLAG_STAB = 0x00008000,
+ TILE_FLAG_MAY_STAB = 0x0000C000,
+
+ // Background flags
+ TILE_FLAG_RAY = 0x00000800,
+ TILE_FLAG_MM_UNSEEN = 0x00001000,
+ TILE_FLAG_UNSEEN = 0x00002000,
+ TILE_FLAG_CURSOR0 = 0x00000000,
+ TILE_FLAG_CURSOR1 = 0x00008000,
+ TILE_FLAG_CURSOR2 = 0x00004000,
+ TILE_FLAG_CURSOR3 = 0x0000C000,
+ TILE_FLAG_CURSOR = 0x0000C000,
+
+ // General
+ TILE_FLAG_MASK = 0x000007FF
+};
#define TILEI_FLAG_SELECT 0x100